Skip to content

Commit 89efdcb

Browse files
authored
Merge pull request #362 from julia-vscode/sp/unterminated-bracket
Fix parsing of unterminated brackets
2 parents 9cc3429 + 7214ab6 commit 89efdcb

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/components/lists.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ function parse_array_outer(ps::ParseState, trivia, isref)
151151
push!(trivia, accept_comma(ps))
152152
@closesquare ps parse_comma_sep(ps, args, trivia, isref, insert_params_at = 1)
153153
return EXPR(:vect, args, trivia)
154+
elseif kindof(ps.nt) === Tokens.ENDMARKER
155+
push!(args, a)
156+
return EXPR(:vect, args, trivia)
154157
end
155158
end
156159
is_start = false

test/parser.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ end
480480
@test "[1,2,3,4,5]" |> test_expr
481481
# this is nonsensical, but iteration should still work
482482
@test traverse(CSTParser.parse(raw"""[[:alpha:]a←-]"""))
483+
# unterminated expressions may cause issues
484+
@test traverse(CSTParser.parse("bind_artifact!(\"../Artifacts.toml\",\"example\",hash,download_info=[(\"file://c:/juliaWork/tarballs/example.tar.gz\"\",tarball_hash)],force=true)\n2+2\n"))
485+
@test traverse(CSTParser.parse("[2+3+4"))
486+
@test traverse(CSTParser.parse("[2+3+4+"))
487+
@test traverse(CSTParser.parse("[\"hi\"\""))
488+
@test traverse(CSTParser.parse("[\"hi\"\"\n"))
489+
@test traverse(CSTParser.parse("[(1,2,3])"))
483490
end
484491

485492
@testset "ref" begin

0 commit comments

Comments
 (0)