Skip to content

Commit

Permalink
fix JuliaLang#30030, assignment expr as named tuple element value (Ju…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and tkf committed Nov 21, 2018
1 parent fbca2e5 commit c755fcb
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 @@ -1691,7 +1691,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 @@ -1758,3 +1758,9 @@ end
@test Meta.isexpr(Meta.parse("1, \n"), :incomplete)
@test_throws LoadError include_string(@__MODULE__, "1,")
@test_throws LoadError include_string(@__MODULE__, "1,\n")

# 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 c755fcb

Please sign in to comment.