Skip to content

Fix another dialyzer Kernel.with edge case #13869

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

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

sabiwara
Copy link
Contributor

Close #13868

Note: I tried to add "generated" to a bunch of places, like to the call or to all else clauses, but it didn't fix it.
This ended up being the solution.

@sabiwara sabiwara merged commit f685a76 into elixir-lang:main Sep 30, 2024
9 checks passed
@sabiwara sabiwara deleted the dialyzer-with branch September 30, 2024 08:11
@fishtreesugar
Copy link

Should it be backported to the v1.17 branch?

josevalim pushed a commit that referenced this pull request Sep 30, 2024
@josevalim
Copy link
Member

Backported, tks!

@sabiwara
Copy link
Contributor Author

Good call @fishtreesugar, sorry I meant to do it and forgot 🙇

@NobbZ
Copy link
Contributor

NobbZ commented Nov 1, 2024

Backported, tks!

Any idea when a new version with the fix will be released? We are currently blocked updating because of this (and another issue, I am trying to create a reproducer for)

@codeadict
Copy link

Was this backported to 1.17.3?

@josevalim
Copy link
Member

josevalim commented Jan 31, 2025

It was backported but no new release was made, as v1.18 was released slightly soon after.

@codeadict
Copy link

So in that case skipping 1.17 altogether and going to 1.18 would be the solution?

@sabiwara
Copy link
Contributor Author

Just mentioning for the record, but there are several options that might be available depending on your situation:

  • temporarily disabling this one (@dialyzer {:nowarn_function, {:x, 1}}) - sometimes not enough since callers might still be impacted
  • temporarily trick dialyzer to ignore this one - see example below
  • implement this refactoring suggestion (fixing the warning would just be a nice side effect)

Tricking dialyzer:
Adding an extra level of indirection is enough to lose dialyzer and consider anything as term()

  def x(arg) do
-    with {:foo, :ok} <- {:foo, foo(arg)},
+    with {:foo, :ok} <- Function.identity({:foo, foo(arg)}),
         {:bar, :ok} <- {:bar, bar(arg)} do

(you could implement your own def dialyzer_ignore(term), do: term)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Dialyzer error on with usage
5 participants