diff --git a/src/runestone.jl b/src/runestone.jl index 23a0930..66e0d19 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -570,10 +570,6 @@ function spaces_in_listlike(ctx::Context, node::Node) elseif kind(kid′) === K"parameters" # Note that some of these are not valid Julia syntax still parse @assert kind(node) in KSet"call dotcall curly tuple vect" - @assert i === last_item_idx - @assert findnext( - !JuliaSyntax.is_whitespace, @view(kids[1:(closing_leaf_idx - 1)]), i + 1, - ) === nothing if kind(first_leaf(kid′)) === K"Whitespace" # Delete the whitespace leaf kid_ws = first_leaf(kid′) @@ -629,7 +625,10 @@ function spaces_in_listlike(ctx::Context, node::Node) push!(kids′, kid′) end end - state = :expect_closing # parameters must be the last item(?) + # K"parameter" is always the last item in valid Julia code but we need to + # handle all expression that parses and there might be multiple + # K"parameters"... + state = i == last_item_idx ? (:expect_closing) : (:expect_item) else @assert false # Unreachable? end diff --git a/test/runtests.jl b/test/runtests.jl index d402dfb..58daafe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -276,6 +276,9 @@ end "f(\n $(a);\n $(b),\n)" # vect with parameter (not valid Julia syntax, but parses) @test format_string("[$(sp)1,$(sp)2$(sp);$(sp)]") == "[1, 2]" + # Multple `;` in argument list (lowering error but parses....) + @test format_string("f($(sp)x$(sp);$(sp)y$(sp)=$(sp)$(a)$(sp);$(sp)z$(sp)=$(sp)$(b)$(sp))") == + "f(x; y = $(a); z = $(b))" end # Splatting for sp in ("", " ", " ")