Skip to content

Commit

Permalink
Merge pull request #313 from julia-vscode/sp/fix-310
Browse files Browse the repository at this point in the history
Fix nonstdid parsing and $ parsing in import
  • Loading branch information
pfitzseb authored Nov 3, 2021
2 parents 753b3c6 + eb76616 commit 4de5744
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,17 @@ function parse_importexport_item(ps, is_colon = false)
pushtotrivia!(a, accept_rparen(ps))
a
elseif kindof(ps.nt) === Tokens.EX_OR
@closer ps :comma parse_expression(ps)
parse_unary(ps, INSTANCE(next(ps)))
elseif !is_colon && isoperator(ps.nt)
next(ps)
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
elseif VERSION > v"1.3.0-" && isidentifier(ps.nt) && isemptyws(ps.nws) && (kindof(ps.nnt) === Tokens.STRING || kindof(ps.nnt) === Tokens.TRIPLE_STRING)
EXPR(:NONSTDIDENTIFIER, EXPR[INSTANCE(next(ps)), INSTANCE(next(ps))])
#TODO fix nonstdid handling
id = INSTANCE(next(ps))
if valof(id) == "var"
EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))])
else
mErrorToken(ps, EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))]), UnexpectedToken)
end
else
INSTANCE(next(ps))
end
Expand Down
11 changes: 11 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,15 @@ end
x, ps = CSTParser.parse(CSTParser.ParseState(str), true)
@test ps.errored == false
end

@testset "#310" begin
x, ps = CSTParser.parse(CSTParser.ParseState("""import a.notvar"papa" """), true)
@test ps.errored == true
x, ps = CSTParser.parse(CSTParser.ParseState("""import notvar"papa" """), true)
@test ps.errored == true
end

@testset "#311" begin
@test test_expr(raw"import a.$b.c")
end
end

0 comments on commit 4de5744

Please # to comment.