Closed c42f closed 1 year ago
Actually this can also happen with parsestmt
if there's trailing text
julia> exc = try JuliaSyntax.parsestmt(Expr, "x\nz") ; catch e ; e end
JuliaSyntax.ParseError(SourceFile("x", 0, nothing, 1, [1, 2]), JuliaSyntax.Diagnostic[JuliaSyntax.Diagnostic(3, 3, :error, "unexpected text after parsing statement")], :none)
julia> showerror(stdout, exc)
ParseError:
ERROR: BoundsError: attempt to access 1-codeunit SubString{String} at index [2]
Stacktrace:
[1] _nextind_str(s::SubString{String}, i::Int64)
@ Base ./strings/string.jl:177
[2] nextind(s::SubString{String}, i::Int64)
@ Base ./strings/substring.jl:104 [inlined]
[3] source_location(source::SourceFile, byte_index::Int64)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/source_files.jl:64
[4] show_diagnostic(io::Base.TTY, diagnostic::JuliaSyntax.Diagnostic, source::SourceFile)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/diagnostics.jl:61
[5] show_diagnostics(io::Base.TTY, diagnostics::Vector{JuliaSyntax.Diagnostic}, source::SourceFile)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/diagnostics.jl:86
[6] showerror(io::Base.TTY, err::JuliaSyntax.ParseError)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/parser_api.jl:20
[7] top-level scope
@ REPL[122]:1
Printing errors arising from
parseatom
sometimes fails, but notparsestmt
orparseall
.MWE:
Found in https://github.com/JuliaLang/julia/issues/50245