diff --git a/src/chisels.jl b/src/chisels.jl index bdc5383..1d3b586 100644 --- a/src/chisels.jl +++ b/src/chisels.jl @@ -154,7 +154,9 @@ function normalize_tree!(node) # If the tuple ends with a K"NewlineWs" node we move it into the block block = kids[blockidx] blockkids = verified_kids(block) - @assert kind(blockkids[1]) !== K"Whitespace" + if length(blockkids) > 0 + @assert kind(blockkids[1]) !== K"Whitespace" + end pushfirst!(blockkids, pop!(tuplekids)) # Remake the nodes to recompute the spans kids[tupleidx] = make_node(tuple, tuplekids) diff --git a/test/runtests.jl b/test/runtests.jl index 3ac2cd4..01c454e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1033,6 +1033,7 @@ end end # do-end @test format_string("open() do\na$(d)end") == "open() do\n a\nend" + @test format_string("open() do\nend") == "open() do\nend" @test_broken format_string("open() do;a$(d)end") == "open() do\n a\nend" @test_broken format_string("open() do ;a$(d)end") == "open() do\n a\nend" @test format_string("open() do io$(d)a end") == "open() do io\n a\nend"