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>
  • Loading branch information
3 people authored Mar 31, 2021
1 parent 8868d3f commit 637f52b
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 @@ -2384,11 +2384,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 @@ -2763,3 +2763,11 @@ macro m_begin_hygiene(a)
end

@test @m_begin_hygiene([1, 2, 3]) == 1

# 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 637f52b

Please sign in to comment.