From 94a8564b80dabe3e25e046886781751e117cb2b7 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 20 Nov 2018 09:51:01 +0900 Subject: [PATCH] fix #30030, assignment expr as named tuple element value (#30045) (cherry picked from commit 69fabf7aa03643cba155b3aa237fa8fdd27b7e3c) --- src/julia-syntax.scm | 4 +++- test/syntax.jl | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index a9fb4304544a4..5d9e99a9627d9 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -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"))) diff --git a/test/syntax.jl b/test/syntax.jl index f8b760e2f042f..c557028dbf317 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -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