Skip to content

Commit bcad840

Browse files
authored
allow numbers as string macro suffixes (#38336)
1 parent 7d8d768 commit bcad840

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/julia-parser.scm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,11 +1272,13 @@
12721272
(parse-raw-literal s t)))
12731273
(nxt (peek-token s))
12741274
(macname (macroify-name ex (macsuffix t))))
1275-
(if (and (symbol? nxt) (not (operator? nxt))
1275+
(if (and (or (symbol? nxt) (number? nxt) (large-number? nxt)) (not (operator? nxt))
12761276
(not (ts:space? s)))
12771277
;; string literal suffix, "s"x
12781278
(loop `(macrocall ,macname ,startloc ,macstr
1279-
,(string (take-token s))))
1279+
,(if (symbol? nxt)
1280+
(string (take-token s))
1281+
(take-token s))))
12801282
(loop `(macrocall ,macname ,startloc ,macstr))))
12811283
ex))
12821284
(else ex))))))

test/syntax.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ macro test999_str(args...); args; end
6060
a
6161
b""" == ("a\nb",)
6262

63+
# make sure a trailing integer, not just a symbol, is allowed also
64+
@test test999"foo"123 == ("foo", 123)
65+
6366
# issue #5997
6467
@test_throws ParseError Meta.parse(": x")
6568
@test_throws ParseError Meta.parse("""begin

0 commit comments

Comments
 (0)