From 13172802afef5493afd7aebbd72021783ea0412e Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Wed, 31 Mar 2021 23:10:08 +0200 Subject: [PATCH] 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 * keep previous behavior, don't try to be too smart Co-authored-by: Nathan Daly Co-authored-by: Jeff Bezanson (cherry picked from commit 637f52b8eb836bda45bdb282ff3dd3d347bef439) --- src/julia-syntax.scm | 11 ++++++----- test/syntax.jl | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 620253de26bbc0..f2861656015f66 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2295,11 +2295,12 @@ 'string (lambda (e) (expand-forms - `(call (top string) ,@(map (lambda (s) - (if (and (pair? s) (eq? (car s) 'string)) - (cadr s) - s)) - (cdr e))))) + `(call (top string) + ,@(map (lambda (s) + (if (and (length= s 2) (eq? (car s) 'string) (string? (cadr s))) + (cadr s) + s)) + (cdr e))))) '|::| (lambda (e) diff --git a/test/syntax.jl b/test/syntax.jl index 76e15c78b27506..68f32b600b79db 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2692,3 +2692,11 @@ macro m_nospecialize_unnamed_hygiene() end @test @m_nospecialize_unnamed_hygiene()(1) === Any + +# issue 40258 +@test "a $("b $("c")")" == "a b c" + +@test "$(([[:a, :b], [:c, :d]]...)...)" == "abcd" + +@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc" +@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"