Browse Source

Fix a bug in do-block tree normalization

pull/53/head
Fredrik Ekre 1 year ago
parent
commit
c9e2b6c294
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 2
      src/chisels.jl
  2. 1
      test/runtests.jl

2
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 # If the tuple ends with a K"NewlineWs" node we move it into the block
block = kids[blockidx] block = kids[blockidx]
blockkids = verified_kids(block) blockkids = verified_kids(block)
if length(blockkids) > 0
@assert kind(blockkids[1]) !== K"Whitespace" @assert kind(blockkids[1]) !== K"Whitespace"
end
pushfirst!(blockkids, pop!(tuplekids)) pushfirst!(blockkids, pop!(tuplekids))
# Remake the nodes to recompute the spans # Remake the nodes to recompute the spans
kids[tupleidx] = make_node(tuple, tuplekids) kids[tupleidx] = make_node(tuple, tuplekids)

1
test/runtests.jl

@ -1033,6 +1033,7 @@ end
end end
# do-end # do-end
@test format_string("open() do\na$(d)end") == "open() do\n a\nend" @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_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" @test format_string("open() do io$(d)a end") == "open() do io\n a\nend"

Loading…
Cancel
Save