Skip to content

Commit d05d5de

Browse files
committed
fix global parsing
1 parent bfcdc77 commit d05d5de

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/components/keywords.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function parse_local_global(ps::ParseState, islocal = true)
107107
push!(args, arg)
108108
elseif arg.head === :tuple
109109
append!(args, arg.args)
110+
append!(trivia, arg.trivia)
110111
else
111112
push!(args, arg)
112113
end

test/spec.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ function check_parents(x::EXPR)
1515
end
1616
end
1717

18+
function test_iter(ex)
19+
total = 0
20+
for x in ex
21+
@test x isa EXPR
22+
test_iter(x)
23+
total += x.fullspan
24+
end
25+
if length(ex) > 0
26+
@test total == ex.fullspan
27+
end
28+
end
1829

1930
function test_expr(s, head, n, endswithtrivia = false)
2031
x = CSTParser.parse(s)
@@ -25,6 +36,7 @@ function test_expr(s, head, n, endswithtrivia = false)
2536
@test Expr(x) == jl_parse(s)
2637
@test isempty(check_span(x))
2738
check_parents(x)
39+
test_iter(x)
2840
@test endswithtrivia ? (x.fullspan-x.span) == (last(x.trivia).fullspan - last(x.trivia).span) : (x.fullspan-x.span) == (last(x.args).fullspan - last(x.args).span)
2941
end
3042

@@ -35,7 +47,7 @@ end
3547

3648
@testset ":global" begin
3749
test_expr("global a", :global, 2)
38-
test_expr("global a, b", :global, 3)
50+
test_expr("global a, b", :global, 4)
3951
test_expr("global a, b = 2", :global, 2)
4052
test_expr("global const a = 1", :const, 3)
4153
test_expr("global const a = 1, b", :const, 3)

0 commit comments

Comments
 (0)