JuliaSyntax.jl icon indicating copy to clipboard operation
JuliaSyntax.jl copied to clipboard

build_tree errors with unparsed ParseStream

Open mlechu opened this issue 6 months ago • 0 comments

Broke sometime after eceaa39. We used to get an empty K"wrapper", but I'm not sure what the best thing to do is, since it's possible the user just forgot to parse!. (Not always; JETLS was using this code to produce a type and was OK with the wrapper.)

JS.build_tree(JS.SyntaxNode, JS.ParseStream(""))

ERROR: BoundsError: attempt to access 1-element Vector{JuliaSyntax.RawGreenNode} at index [0]
Stacktrace:
  [1] throw_boundserror(A::Vector{JuliaSyntax.RawGreenNode}, I::Tuple{Int64})
    @ Base ./essentials.jl:15
  [2] checkbounds
    @ ./essentials.jl:387 [inlined]
  [3] getindex
    @ ./essentials.jl:966 [inlined]
  [4] getindex
    @ ./abstractarray.jl:1358 [inlined]
  [5] this
    @ ~/.julia/packages/JuliaSyntax/4IHpz/src/core/tree_cursors.jl:25 [inlined]
  [6] head
    @ ~/.julia/packages/JuliaSyntax/4IHpz/src/core/tree_cursors.jl:70 [inlined]
  [7] JuliaSyntax.GreenNode(cursor::JuliaSyntax.GreenTreeCursor)
    @ JuliaSyntax ~/.julia/packages/JuliaSyntax/4IHpz/src/porcelain/green_node.jl:122
  [8] build_tree(::Type{…}, stream::JuliaSyntax.ParseStream; filename::Nothing, first_line::Int64, keep_parens::Bool, kws::@Kwargs{})
    @ JuliaSyntax ~/.julia/packages/JuliaSyntax/4IHpz/src/porcelain/syntax_tree.jl:315
  [9] build_tree(::Type{SyntaxNode}, stream::JuliaSyntax.ParseStream)
    @ JuliaSyntax ~/.julia/packages/JuliaSyntax/4IHpz/src/porcelain/syntax_tree.jl:304

mlechu avatar Jul 10 '25 17:07 mlechu