Skip to content

Commit

Permalink
Disallow space-separated semicolons in array expression (#40903)
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick authored May 21, 2021
1 parent 139aba6 commit a075e9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,8 @@
(parse-array-inner s a is-row-first semicolon-count max-level closer #f gotlinesep)))
((#\;)
(or gotnewline (take-token s))
(if (and (> semicolon-count 0) (ts:space? s)) ; disallow [a; ;b]
(error "multiple semicolons must be adjacent in an array expression"))
(let ((next (peek-token s)))
(let ((is-line-sep
(if (and (not (null? is-row-first)) is-row-first (= semicolon-count 1))
Expand Down
1 change: 1 addition & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,7 @@ end
@test Meta.parse("[1\n;]") == :([1;]) # semicolons following a linebreak are fine
@test Meta.parse("[1\n;;; 2]") == :([1;;; 2])
@test_throws ParseError Meta.parse("[1;\n;2]") # semicolons cannot straddle a line break
@test_throws ParseError Meta.parse("[1; ;2]") # semicolons cannot be separated by a space
end

# issue #25652
Expand Down

0 comments on commit a075e9f

Please sign in to comment.