-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Parser: fix a-b -c
incorrectly parsed as a - (b - c)
#9652
Parser: fix a-b -c
incorrectly parsed as a - (b - c)
#9652
Conversation
665fb7b
to
c1289a0
Compare
Assign.new("c".var, 3.int32), | ||
Call.new(Call.new("a".var, "-", "b".var), "-", "c".var), | ||
]) | ||
it_parses "a = 1; b = 2; c = 3; a-b -c", Expressions.new([ |
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 suppose you wanted to change this to +
es :)
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.
No, the difference is there's a space
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.
Ah. How about specs for +
then? :D
while current_char.ascii_whitespace? | ||
next_char_no_column_increment | ||
end | ||
comes_plus_or_minus = current_char == '+' || current_char == '-' |
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.
comes_plus_or_minus = current_char == '+' || current_char == '-' | |
comes_plus_or_minus = current_char.in?('+', '-') |
Closing because I'm not sure this is the best way to solve this. |
@asterite Perhaps it's not the best but it works, so why to throw the baby with the bathwater? |
Nope |
Feel free to open a PR with this diff, I won't babysit it. |
There should still be a bug report for this. |
I think this one should be merged before 1.0 |
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 fix seems good enough to me. I've been validating with ast_helper a couple of expressions, trying to break things, but all seems good 👍 .
Fixes https://forum.crystal-lang.org/t/results-of-a-b-c-and-a-b-c-different/2402