Skip to content

Commit 637f52b

Browse files
simeonschaubNHDalyJeffBezanson
authored
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>
1 parent 8868d3f commit 637f52b

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
@@ -2384,11 +2384,12 @@
23842384
'string
23852385
(lambda (e)
23862386
(expand-forms
2387-
`(call (top string) ,@(map (lambda (s)
2388-
(if (and (pair? s) (eq? (car s) 'string))
2389-
(cadr s)
2390-
s))
2391-
(cdr e)))))
2387+
`(call (top string)
2388+
,@(map (lambda (s)
2389+
(if (and (length= s 2) (eq? (car s) 'string) (string? (cadr s)))
2390+
(cadr s)
2391+
s))
2392+
(cdr e)))))
23922393

23932394
'|::|
23942395
(lambda (e)

test/syntax.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,3 +2763,11 @@ macro m_begin_hygiene(a)
27632763
end
27642764

27652765
@test @m_begin_hygiene([1, 2, 3]) == 1
2766+
2767+
# issue 40258
2768+
@test "a $("b $("c")")" == "a b c"
2769+
2770+
@test "$(([[:a, :b], [:c, :d]]...)...)" == "abcd"
2771+
2772+
@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc"
2773+
@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"

0 commit comments

Comments
 (0)