Skip to content

Commit 83ca48d

Browse files
committed
fix [;;\n] parsing
1 parent adcdcee commit 83ca48d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/components/lists.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function parse_tuple(ps::ParseState, ret::EXPR)
4646
end
4747

4848
# XXX: Avert thine eyes.
49-
function count_semicolons(ps)
49+
function count_semicolons(ps, check_newline = true)
5050
dims = 0
5151
has_newline = false
5252
old_pos = position(ps.l.io)
@@ -55,7 +55,7 @@ function count_semicolons(ps)
5555
c = readchar(ps.l.io)
5656
if c == ';'
5757
dims += 1
58-
elseif c == '\n'
58+
elseif check_newline && c == '\n'
5959
# technically, only trailing newlines are allowed; we're a bit more lenient here
6060
has_newline = true
6161
else
@@ -82,7 +82,7 @@ function parse_array(ps::ParseState, isref = false)
8282
if kindof(ps.nt) === Tokens.RSQUARE
8383
dims = 0
8484
if kindof(ps.ws) == SemiColonWS
85-
dims = count_semicolons(ps)
85+
dims = count_semicolons(ps, false)
8686
end
8787
push!(trivia, accept_rsquare(ps))
8888
if dims > 0

test/parser.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ end
496496
@testset "ncat" begin
497497
@test "[;]" |> test_expr
498498
@test "[;;]" |> test_expr
499+
@test "[;;\n]" |> test_expr
500+
@test "[\n ;; \n]" |> test_expr
499501
@test "[;;;;;;;]" |> test_expr
500502
@test "[x;;;;;]" |> test_expr
501503
@test "[x;;]" |> test_expr

0 commit comments

Comments
 (0)