JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
267 stars 32 forks source link

poor handling of incomplete as a ParseError #366

Open vtjnash opened 8 months ago

vtjnash commented 8 months ago

This printing seems to expose internal details:

julia> lazy"$(join([], ", "))"
ERROR: syntax: invalid syntax (incomplete #<julia: Base.Meta.ParseError(msg="ParseError:
# Error @ REPL[1]:1:11
(join([], 
#         └ ── Expected `)`", detail=Base.JuliaSyntax.ParseError(source=Base.JuliaSyntax.SourceFile(code=Base.SubString{String}(string="$(join([], ", offset=1, ncodeunits=10), byte_offset=1, filename="REPL[1]", first_line=1, line_starts=Array{Int64, (2,)}[1, 11]), diagnostics=Array{Base.JuliaSyntax.Diagnostic, (2,)}[Base.JuliaSyntax.Diagnostic(first_byte=12, last_byte=11, level=:error, message="Expected `)`"), Base.JuliaSyntax.Diagnostic(first_byte=12, last_byte=11, level=:error, message="Expected `)`")], incomplete_tag=:other))>)
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

from https://github.com/JuliaLang/julia/issues/51654

c42f commented 8 months ago

This seems to be an issue to fix in Base (the printing here comes from Base.Meta.ParseError which, for historical reasons is not JuliaSyntax.ParseError :-( )