JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
266 stars 32 forks source link

Error message implies missing parenthesis, but the issue is a missing argument #398

Open KronosTheLate opened 6 months ago

KronosTheLate commented 6 months ago

When an argument is missing, the error message is not fantastic:

julia> rand(, 10)
ERROR: ParseError:
# Error @ REPL[1]:1:6
rand(, 10)
#    └──┘ ── Expected `)`
Stacktrace:
 [1] top-level scope
   @ none:1

In fact, replacing the underlined part with the "expected" ) would not even solve the problem. It is much less the root issue.

Relevant issues: https://github.com/JuliaLang/JuliaSyntax.jl/issues/348 and https://github.com/JuliaLang/JuliaSyntax.jl/issues/336

julia> versioninfo()
Julia Version 1.10.0-rc2
Commit dbb9c46795b (2023-12-03 15:25 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_PKG_PRESERVE_TIERED_INSTALLED = true
  JULIA_CONDAPKG_BACKEND = Null
pfitzseb commented 6 months ago

I think the correct syntax form implied by the error message is rand(), 10, but that's a bit of a stretch.

c42f commented 6 months ago

The error messages for this kind of thing did change recently in #397 to improve the highlighted range but... that change does rather clash with this particular type of error. Yikes :grimacing:

julia> rand(, 10)

ERROR: ParseError:
# Error @ REPL[8]:1:6
rand(, 10)
#    └ ── Expected `)` or `,`