JuliaSyntax.jl icon indicating copy to clipboard operation
JuliaSyntax.jl copied to clipboard

`i++` could use a better error message

Open StevenWhitaker opened this issue 2 years ago • 9 comments

I'm opening this issue based on a question on discourse.

Consider the following code:

i = 0
for n = 1:5
    i++
end

This will result in (at least on Julia 1.7.0)

ERROR: syntax: unexpected "end"

This error message could benefit from JuliaLang/julia#45791. However, I'm doing a separate issue for this special case because a new user might write i++ not knowing it is not equivalent to i += 1 (or even that ++ is parsed as an infix operator). Would it be possible to have a more specific error message? Something like

ERROR: syntax: attempted to call an infix operator with just one argument - perhaps you meant "i += 1"?

StevenWhitaker avatar Jun 23 '22 14:06 StevenWhitaker