Skip to content

Commit 1317280

Browse files
simeonschaubNHDalyJeffBezanson
authored andcommitted
fix #40258: nested string interpolation (#40261)
* fix #40258: nested string interpolation fixes #40258 * fix interpolation with varargs * add additional test case * add additional test cases Co-authored-by: Nathan Daly <NHDaly@gmail.com> * keep previous behavior, don't try to be too smart Co-authored-by: Nathan Daly <NHDaly@gmail.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com> (cherry picked from commit 637f52b)
1 parent 5d9e539 commit 1317280

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/julia-syntax.scm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,11 +2295,12 @@
22952295
'string
22962296
(lambda (e)
22972297
(expand-forms
2298-
`(call (top string) ,@(map (lambda (s)
2299-
(if (and (pair? s) (eq? (car s) 'string))
2300-
(cadr s)
2301-
s))
2302-
(cdr e)))))
2298+
`(call (top string)
2299+
,@(map (lambda (s)
2300+
(if (and (length= s 2) (eq? (car s) 'string) (string? (cadr s)))
2301+
(cadr s)
2302+
s))
2303+
(cdr e)))))
23032304

23042305
'|::|
23052306
(lambda (e)

test/syntax.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,3 +2692,11 @@ macro m_nospecialize_unnamed_hygiene()
26922692
end
26932693

26942694
@test @m_nospecialize_unnamed_hygiene()(1) === Any
2695+
2696+
# issue 40258
2697+
@test "a $("b $("c")")" == "a b c"
2698+
2699+
@test "$(([[:a, :b], [:c, :d]]...)...)" == "abcd"
2700+
2701+
@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc"
2702+
@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"

0 commit comments

Comments
 (0)