JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
266 stars 32 forks source link

Regression with semi-colon in comprehension before `for` #402

Open pfitzseb opened 6 months ago

pfitzseb commented 6 months ago

It's unclear to me whether the flisp behaviour is intended or desired, but JuliaSyntax does behave differently than flisp: flisp:

julia> Meta.parse("[i; for i in 1:3]")
:([i for i = 1:3])

julia> Meta.parse("[i for i in 1:3]")
:([i for i = 1:3])

JuliaSyntax#main:

julia> JuliaSyntax.parse(Expr, "[i; for i in 1:3]")
ERROR: ParseError:
# Error @ line 1:17
[i; for i in 1:3]
#               ╙ ── unexpected `]`
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/dev/JuliaSyntax/src/parser_api.jl:93
 [2] _parse (repeats 2 times)
   @ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/parser_api.jl:77 [inlined]
 [3] parsestmt(::Type{Expr}, text::String)
   @ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/parser_api.jl:140
 [4] parse(::Type, ::Vararg{Any}; kwargs::@Kwargs{})
   @ JuliaSyntax ./deprecated.jl:116
 [5] parse(::Type, ::Vararg{Any})
   @ JuliaSyntax ./deprecated.jl:113
 [6] top-level scope
   @ REPL[28]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> JuliaSyntax.parse(Expr, "[i for i in 1:3]")
:([i for i = 1:3])