Skip to content

Commit 3a47d4e

Browse files
authored
Merge pull request #21439 from JuliaLang/jb/fix21155
fix #21155, parse `using` with leading dots and line breaks
2 parents 5d41dd5 + 109456d commit 3a47d4e

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/julia-parser.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@
14431443

14441444
(define (parse-import-dots s)
14451445
(let loop ((l '())
1446-
(t (peek-token s)))
1446+
(t (require-token s))) ;; skip newlines
14471447
(cond ((eq? t '|.|)
14481448
(begin (take-token s)
14491449
(loop (list* '|.| l) (peek-token s))))

test/parse.jl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,13 @@ f16517() = try error(); catch 0; end
574574
# issue #16671
575575
@test parse("1.") === 1.0
576576

577+
isline(x) = isa(x,Expr) && x.head === :line
578+
577579
# issue #16672
578-
let isline(x) = isa(x,Expr) && x.head === :line
579-
@test count(isline, parse("begin end").args) == 1
580-
@test count(isline, parse("begin; end").args) == 1
581-
@test count(isline, parse("begin; x+2; end").args) == 1
582-
@test count(isline, parse("begin; x+2; y+1; end").args) == 2
583-
end
580+
@test count(isline, parse("begin end").args) == 1
581+
@test count(isline, parse("begin; end").args) == 1
582+
@test count(isline, parse("begin; x+2; end").args) == 1
583+
@test count(isline, parse("begin; x+2; y+1; end").args) == 2
584584

585585
# issue #16736
586586
let
@@ -1084,3 +1084,22 @@ let prim = parse("primitive type X 8 end")
10841084
@test parse("primitive type X 8\nend") == prim
10851085
@test parse(string("primitive type X 8", "\n"^5, "end")) == prim
10861086
end
1087+
1088+
# issue #21155
1089+
@test filter(!isline,
1090+
parse("module B
1091+
using ..x,
1092+
..y
1093+
end").args[3].args)[1] ==
1094+
Expr(:toplevel,
1095+
Expr(:using, Symbol("."), Symbol("."), :x),
1096+
Expr(:using, Symbol("."), Symbol("."), :y))
1097+
1098+
@test filter(!isline,
1099+
parse("module A
1100+
using .B,
1101+
.C
1102+
end").args[3].args)[1] ==
1103+
Expr(:toplevel,
1104+
Expr(:using, Symbol("."), :B),
1105+
Expr(:using, Symbol("."), :C))

0 commit comments

Comments
 (0)