Skip to content

Commit 0fdcf9e

Browse files
authored
Merge pull request #379 from julia-vscode/sp/fix-str-macro-getfield-suffix
fix: correctly handle suffixed string macros with mod access
2 parents 027ee01 + 69a1242 commit 0fdcf9e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/utils.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,23 @@ end
659659

660660
function issuffixableliteral(ps::ParseState, x::EXPR)
661661
# prefixed string/cmd macros can be suffixed by identifiers or numeric literals
662-
(isidentifier(ps.nt) || isnumberliteral(ps.nt) || isbool(ps.nt)) && isemptyws(ps.ws) && ismacrocall(x) && (valof(x.args[1]) isa String && (endswith(valof(x.args[1]), "_str") || endswith(valof(x.args[1]), "_cmd")))
662+
return (
663+
isidentifier(ps.nt) ||
664+
isnumberliteral(ps.nt) ||
665+
isbool(ps.nt)
666+
) &&
667+
isemptyws(ps.ws) &&
668+
ismacrocall(x) &&
669+
(
670+
(
671+
valof(x.args[1]) isa String &&
672+
(endswith(valof(x.args[1]), "_str") || endswith(valof(x.args[1]), "_cmd"))
673+
) ||
674+
(
675+
is_getfield(x.args[1]) && x.args[1].args[2] isa EXPR && x.args[1].args[2].head in (:quote, :quotenode) &&
676+
(endswith(valof(x.args[1].args[2].args[1]), "_str") || endswith(valof(x.args[1].args[2].args[1]), "_cmd"))
677+
)
678+
)
663679
end
664680

665681
function loop_check(ps, prevpos)

test/parser/test_parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ end
867867
include("../shared.jl")
868868

869869
@test test_expr(raw"""test"asd"asd""")
870+
@test test_expr(raw"""Mod.test"asd"asd""")
870871
if VERSION >= v"1.6"
871872
@test test_expr(raw"""test"asd"0""")
872873
@test test_expr(raw"""test"asd"0o0""")

0 commit comments

Comments
 (0)