Skip to content

Commit 4de5744

Browse files
authored
Merge pull request #313 from julia-vscode/sp/fix-310
Fix nonstdid parsing and $ parsing in import
2 parents 753b3c6 + eb76616 commit 4de5744

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/components/internals.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,17 @@ function parse_importexport_item(ps, is_colon = false)
364364
pushtotrivia!(a, accept_rparen(ps))
365365
a
366366
elseif kindof(ps.nt) === Tokens.EX_OR
367-
@closer ps :comma parse_expression(ps)
367+
parse_unary(ps, INSTANCE(next(ps)))
368368
elseif !is_colon && isoperator(ps.nt)
369369
next(ps)
370370
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
371371
elseif VERSION > v"1.3.0-" && isidentifier(ps.nt) && isemptyws(ps.nws) && (kindof(ps.nnt) === Tokens.STRING || kindof(ps.nnt) === Tokens.TRIPLE_STRING)
372-
EXPR(:NONSTDIDENTIFIER, EXPR[INSTANCE(next(ps)), INSTANCE(next(ps))])
373-
#TODO fix nonstdid handling
372+
id = INSTANCE(next(ps))
373+
if valof(id) == "var"
374+
EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))])
375+
else
376+
mErrorToken(ps, EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))]), UnexpectedToken)
377+
end
374378
else
375379
INSTANCE(next(ps))
376380
end

test/parser.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,4 +1324,15 @@ end
13241324
x, ps = CSTParser.parse(CSTParser.ParseState(str), true)
13251325
@test ps.errored == false
13261326
end
1327+
1328+
@testset "#310" begin
1329+
x, ps = CSTParser.parse(CSTParser.ParseState("""import a.notvar"papa" """), true)
1330+
@test ps.errored == true
1331+
x, ps = CSTParser.parse(CSTParser.ParseState("""import notvar"papa" """), true)
1332+
@test ps.errored == true
1333+
end
1334+
1335+
@testset "#311" begin
1336+
@test test_expr(raw"import a.$b.c")
1337+
end
13271338
end

0 commit comments

Comments
 (0)