Skip to content

Commit

Permalink
fix #14691, wrong value returned from a.b = c expression
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 16, 2016
1 parent a1fc070 commit b992fe6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1403,16 +1403,19 @@
;; a.b =
(let ((a (cadr (cadr e)))
(b (caddr (cadr e)))
(rhs (caddr e)))
(rhs (expand-forms (caddr e))))
(let ((aa (if (atom? a) a (make-jlgensym)))
(bb (if (or (atom? b) (quoted? b)) b (make-jlgensym))))
(bb (if (or (atom? b) (quoted? b)) b (make-jlgensym)))
(rr (if (atom? rhs) rhs (make-jlgensym))))
`(block
,.(if (eq? aa a) '() `((= ,aa ,(expand-forms a))))
,.(if (eq? bb b) '() `((= ,bb ,(expand-forms b))))
,.(if (eq? aa a) '() `((= ,aa ,(expand-forms a))))
,.(if (eq? bb b) '() `((= ,bb ,(expand-forms b))))
,.(if (eq? rr rhs) '() `((= ,rr ,rhs)))
(call (top setfield!) ,aa ,bb
(call (top convert)
(call (top fieldtype) (call (top typeof) ,aa) ,bb)
,(expand-forms rhs)))))))
,rr))
,rr))))

((tuple)
;; multiple assignment
Expand Down
4 changes: 4 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3647,3 +3647,7 @@ end

# issue #14564
@test isa(object_id(Tuple.name.cache), Integer)

# issue #14691
type T14691; a::UInt; end
@test (T14691(0).a = 0) === 0

0 comments on commit b992fe6

Please sign in to comment.