-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Improve with/else error message on invalid form #4847
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
Conversation
lib/elixir/src/elixir_with.erl
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this indentation is a bit off. Maybe we can have
Message = "expected -> clauses in else block",
elixir_errors:compile_error(Meta, ?m(E, file), Message, []).Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I'm not sure about the error message either: maybe "expected one or more -> in this with's else block" or something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the message for case missing expressions? Shouldn't it be exactly the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point @michalmuskala, the message for cases is
expected -> clauses for do in case
so maybe we can drop the "one or more" but we should say "in with's else block" or something along those lines IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback.
@whatyouhide Oh, you're right, my indentation is weird, I'll fix it with the message!
I agree with @michalmuskala, keeping the same message as case is more consistent.
The case message is
expected -> clauses for do in case
so what do you think about
expected -> clauses for else in with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message in case can be changed as well, if there's a better one, but IMHO they should match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's go with "expected -> clauses for else in with", then we can think about changing both :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated the PR 😄
ef12e5f to
a9bdfc6
Compare
|
This looks good to me, let's wait for a second thumbs up :) |
|
Second 👍 . |
|
Thanks @tuvistavie, great catch! :) |
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
When upgrading my code to Elixir 1.3, I forgot to use clauses in my
elsewhen replacingif/elsebywith/else,and got an error message difficult to parse, so I added a clause to get something more readable.
Before:
After: