Skip to content

Commit

Permalink
Consistent attachment of syntax trivia to top level statements (#495)
Browse files Browse the repository at this point in the history
Fix #494
  • Loading branch information
c42f authored Aug 13, 2024
1 parent 0a0aa04 commit 87fcdf0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ function parse_toplevel(ps::ParseState)
bump_trivia(ps)
break
else
bump_trivia(ps)
parse_stmts(ps)
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
:body,
),
)

@test parseall("a\n\nx") ==
Expr(:toplevel,
LineNumberNode(1),
:a,
LineNumberNode(3),
:x
)
@test parseall("a\n\nx;y") ==
Expr(:toplevel,
LineNumberNode(1),
:a,
LineNumberNode(3),
Expr(:toplevel, :x, :y)
)
end

@testset "Function definition lines" begin
Expand Down

0 comments on commit 87fcdf0

Please sign in to comment.