-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Possible incorrect warning on dynamic module calls #14043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You are correct! This should be fixed on Elixir v1.19, you can track this issue: #13227 Once we understand guards, we will be able to know the second clause can only be |
What do you mean by "tag the argument"? I see this error popping up on some libraries we use and they build with --warnings-as-errors, so will fail on 1.18 builds. |
--warnings-as-errors would not fail on warnings from dependencies. (Strictly speaking it is a flag recognized by |
@wojtekmach yes, correct. I just meant there are libraries out there with this issue and adding 1.18 to the ci-runs would mean they either need to remove the flag or modify the code ( which might not be trivial )... something to keep in mind. |
@wkirschbaum make it return |
thanks, it does make more sense. quick uncomplicated solution. 👍🏼 |
This will only happen on Elixir 1.18. The solution was suggested here: elixir-lang/elixir#14043
This will only happen on Elixir 1.18. The solution was suggested here: elixir-lang/elixir#14043
Similar issue, and wondering how we can rewrite the code to make it more elixir-y (or how can we do it in a better way without triggering the warning). Details as follows: In module A
In module Provider:
Happy to clean up our code base to improve it, I tried searching, and this seemed the closest issue. The warning I am getting is:
Elixir 1.18.1 |
I think in your case the warning is correct. Otherwise how can you be sure that If it is still a false positive, there are a few options:
|
@josevalim What about using Protocols for preventing this warning. Would it be an overkill?. |
You can use protocols but we want to solve behaviours at some point too. |
So we do use behaviors and the modules implement the behaviors. We also raise an exception if there is no matching module Adding this line to the code base (for the bsp_module functions), eliminated the warning message: |> Code.ensure_loaded!() |
Elixir and Erlang/OTP versions
Elixir 1.18.0-dev (4328b09) (compiled with Erlang/OTP 27)
Operating system
Linux
Current behavior
With the following code snippet:
I get the following warning:
Expected behavior
The handles the :error case, so the warning is a false positive.
The text was updated successfully, but these errors were encountered: