JuliaLang / JuliaLang/JuliaSyntax.jl

`i++` could use a better error message

Open
#376 9 comments 0 reactions 0 assignees View on GitHub
parser
Dominant language
Julia
Stars
293
Forks
50
PR merge metrics
No merged PRs in 30d

Description

I'm opening this issue based on a [question on discourse](https://discourse.julialang.org/t/compiler-complains-about-unexpected-end/83037).

Consider the following code:
```julia
i = 0
for n = 1:5
i++
end
```

This will result in (at least on Julia 1.7.0)
```julia
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
```julia
ERROR: syntax: attempted to call an infix operator with just one argument - perhaps you meant "i += 1"?
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.