From f788e4188303c6ef4ecc1f38fb801b327c7e9b96 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Fri, 21 May 2021 16:17:13 -0500 Subject: [PATCH] Disallow space-separated semicolons in array expression (#40903) --- src/julia-parser.scm | 2 ++ test/syntax.jl | 1 + 2 files changed, 3 insertions(+) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 9f176f95829db..1f594ff0a1414 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -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)) diff --git a/test/syntax.jl b/test/syntax.jl index 448595ff1a8d7..d7e136f92dfcc 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -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