-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
ternary operator ambiguous behaviour #7252
Comments
Why not do |
what about |
Sure, but this seems inconsistent with the other parsing behaviors of
That said, this seems unambiguous to me only because #6823 hasn't yet been decided upon — there still must be a colon somewhere in the statement. Were that to change this becomes more tricky. Edit: oooh, I see. It's not 2:a that's the invalid location; it's the whole ternary expression! That does make a little more sense to me now. |
The problem is that julia> a = :(1 > 0 ? a=2 : a=3)
:(if 1 > 0
a = 2
else
a
end = 3) |
|
Expressions like
1 > 0 ? a=2 : a=3
fail with
syntax: invalid assignment location
This can be solved by
1 > 0 ? a=2 : (a=3)
but I think the expression is unambiguous enough to work without parantheses.
The text was updated successfully, but these errors were encountered: