Skip to content

Commit

Permalink
fix #30030, assignment expr as named tuple element value (#30045)
Browse files Browse the repository at this point in the history
(cherry picked from commit 69fabf7)
  • Loading branch information
JeffBezanson authored and KristofferC committed Nov 28, 2018
1 parent 8302431 commit 8664908
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,9 @@

(define (named-tuple-expr names values)
`(call (curly (core NamedTuple) (tuple ,@names))
(tuple ,@values)))
;; NOTE: don't use `tuple` head, so an assignment expression as a value
;; doesn't turn this into another named tuple.
(call (core tuple) ,@values)))

(define (lower-named-tuple lst
(dup-error-fn (lambda (name) (string "field name \"" name "\" repeated in named tuple")))
Expand Down
6 changes: 6 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1740,3 +1740,9 @@ end
finally
end
end)), :thunk)

# issue #30030
let x = 0
@test (a=1, b=2, c=(x=3)) == (a=1, b=2, c=3)
@test x == 3
end

0 comments on commit 8664908

Please sign in to comment.