Skip to content

Commit 6b55399

Browse files
committed
Fix trivia diagnostic range in empty mulitdimensional array syntax + add tests
1 parent 880c0b9 commit 6b55399

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/parser.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2727,11 +2727,13 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
27272727
# [] ==> (vect)
27282728
return parse_vect(ps, closer)
27292729
elseif k == K";"
2730+
#v1.8: [;] ==> (ncat-1)
27302731
#v1.8: [;;] ==> (ncat-2)
27312732
#v1.8: [\n ;; \n ] ==> (ncat-2)
2733+
#v1.7: [;;] ==> (ncat-2 (error))
27322734
n_semis, _ = parse_array_separator(ps; skip_newlines=true)
2733-
bump_closing_token(ps, closer)
27342735
min_supported_version(v"1.8", ps, mark, "empty multidimensional array syntax")
2736+
bump_closing_token(ps, closer)
27352737
return (K"ncat", set_numeric_flags(n_semis))
27362738
end
27372739
parse_eq_star(ps)

test/parser.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,10 @@ tests = [
634634
((v=v"1.7",), "[x ; y ;; z ; w ;;; a ; b ;; c ; d]") =>
635635
"(ncat-3 (nrow-2 (nrow-1 x y) (nrow-1 z w)) (nrow-2 (nrow-1 a b) (nrow-1 c d)))"
636636
# Empty nd arrays
637+
((v=v"1.8",), "[;]") => "(ncat-1)"
637638
((v=v"1.8",), "[;;]") => "(ncat-2)"
638639
((v=v"1.8",), "[\n ;; \n ]") => "(ncat-2)"
640+
((v=v"1.7",), "[;;]") => "(ncat-2 (error))"
639641
],
640642
JuliaSyntax.parse_string => [
641643
"\"a \$(x + y) b\"" => "(string \"a \" (call-i x + y) \" b\")"

0 commit comments

Comments
 (0)