Skip to content

Commit

Permalink
fix #40258: nested string interpolation (#40261)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
simeonschaub authored and KristofferC committed Apr 4, 2021
1 parent 5d9e539 commit 1317280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 1317280

Please sign in to comment.