-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Elixir and Erlang/OTP versions
Elixir 1.18 and main (around 1.19)
OTP 27
Operating system
Linux
Current behavior
This code:
with [] <- System.ls!() do
:ok
else
:error
end
Causes this error:
error: expected -> clauses for :else in "with"
│
1 │ with [] <- System.ls!() do
│ ^
│
└─ bla.exs:1:1
** (CompileError) bla.exs: cannot compile file (errors have been logged)
I was quite tripped up for a moment looking at where the arrow is pointing at the start of with
which is not the problem.
I took a brief look at it but fell down a dark hole and couldn't crawl out before my discretionary time ran out. So I figured I'd report it :)
Expected behavior
Ideally it would point at the else
clause or at the bad value inside of it.
rmand97
Activity
josevalim commentedon Jun 10, 2025
Unfortunately we cannot provide precise location here because of the AST structure but we can provide a better error message. Something like:
lawik commentedon Jun 10, 2025
Ah, that figures then. The information is good but it didn't make me snap to the solution. I think your suggested change makes sense.
Is the
expected -> clauses for %Key in %Kind
used for more structures than with? It seemed fairly generic in how it was written but I don't know if the error is actually only forwith
. I could PR the error if I get a chance.josevalim commentedon Jun 10, 2025
I will push something soon, no worries.
Improve error message for bad/missing clauses, closes #14569