JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
266 stars 32 forks source link

Throw on invalid keyword arguments #416

Open LilithHafner opened 4 months ago

LilithHafner commented 4 months ago

Running parseall(SyntaxNode, "abc", ignore_error=true) should throw because "ignore_error" is not a valid keyword.

julia> parseall(SyntaxNode, "abc", ignore_error=true)
line:col│ tree                                   │ file_name
   1:1  │[toplevel]
   1:1  │  abc

julia> parseall(SyntaxNode, "abc +", ignore_error=true)
ERROR: ParseError:
# Error @ line 1:6
abc +
#    └ ── premature end of input
Stacktrace:
 [1] _parse(rule::Symbol, need_eof::Bool, ::Type{…}, text::String, index::Int64; version::VersionNumber, ignore_trivia::Bool, filename::Nothing, first_line::Int64, ignore_errors::Bool, ignore_warnings::Bool, kws::@Kwargs{…})
   @ JuliaSyntax ~/.julia/packages/JuliaSyntax/eqCSU/src/parser_api.jl:93
 [2] _parse (repeats 2 times)
   @ ~/.julia/packages/JuliaSyntax/eqCSU/src/parser_api.jl:77 [inlined]
 [3] #parseall#96
   @ ~/.julia/packages/JuliaSyntax/eqCSU/src/parser_api.jl:143 [inlined]
 [4] top-level scope
   @ REPL[306]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> parseall(SyntaxNode, "abc +", ignore_errors=true)
line:col│ tree                                   │ file_name
   1:1  │[toplevel]
   1:1  │  [call-i]
   1:1  │    abc
   1:5  │    +
   1:6  │    ✘