"?" expression error message is not unambiguous


#1

k = x -> x > 5 ? "foo" : "bar"
works perfectly fine, but
k = x -> x > 5 ? return "foo" : return "bar"
returns
ERROR: syntax: colon expected in "?" expression

I’m running julia 0.6.2.

I just spent 10 minutes wondering if my “:” is colon or some other random character which looks just like colon. I know ? expression doesn’t allow statements, but error message could be clearer.


#2

Isn’t this just the parser being too eager? Eg

julia> true ? (return "foo") : return "bar"
"foo"