JuliaSyntax.jl
JuliaSyntax.jl copied to clipboard
Parser Failed with `@(var"which")`
Parser failed with some (admittedly weird) input. Installed Julia with curl -fsSL https://install.julialang.org | sh.
julia> macro var"@hi"() :(println("hi")) end
@@hi (macro with 1 method)
julia> @var"@hi"
hi
julia> @(var"@hi")
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│ This is not your fault. Please submit a bug report to https://github.com/JuliaLang/JuliaSyntax.jl/issues
│ exception =
│ TypeError: in typeassert, expected String, got a value of type Nothing
│ [...]
│ offset = 0
│ code = "@(var\"@hi\")"
└ @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-XG3Q6T6R70.0/build/default-honeycrisp-XG3Q6T6R70-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/hooks.jl:260
hi
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 10 × Apple M1 Max
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 10 default, 0 interactive, 5 GC (on 8 virtual cores)
Environment:
JULIA_NUM_THREADS = 10
Hm, I feel like that's a bug in the flisp parser and should be a syntax error...
Slightly simpler example:
julia> var"@which" 1+1
ERROR: ParseError:
# Error @ REPL[6]:1:12
var"@which" 1+1
# └──┘ ── extra tokens after end of expression
Stacktrace:
[1] top-level scope
@ none:1
julia> @var"which" 1+1
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
@ Base int.jl:87
julia> @(var"which") 1+1 # This line is the bug in question
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│ This is not your fault. Please submit a bug report to https://github.com/JuliaLang/JuliaSyntax.jl/issues
│ exception =
│ TypeError: in typeassert, expected String, got a value of type Nothing
│ Stacktrace:
│ [1] untokenize(head::Base.JuliaSyntax.SyntaxHead; unique::Bool, include_flag_suff::Bool)
│ @ Base.JuliaSyntax /cache/build/tester-armageddon-11/julialang/julia-release-1-dot-11/base/JuliaSyntax/src/parse_stream.jl:103
[...]
│ [28] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│ @ REPL ~/.julia/juliaup/julia-1.11.0-beta2+0.aarch64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:457
│ offset = 0
│ code = "@(var\"which\") 1+1"
└ @ Base.JuliaSyntax /cache/build/tester-armageddon-11/julialang/julia-release-1-dot-11/base/JuliaSyntax/src/hooks.jl:260
+(x::T, y::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
@ Base int.jl:87
This appears to be fixed on JuliaSyntax master - possibly by https://github.com/JuliaLang/JuliaSyntax.jl/pull/572 or maybe earlier. (Note that it won't show up in a Julia release until it's bumped there sometime in the 1.13 time frame, but it's addressed here).