diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index a46c6ff628d27..b350baf8f8474 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1921,7 +1921,12 @@ '.= (lambda (e) - (expand-fuse-broadcast (cadr e) (caddr e))) + `(ifvalue + ,(let ((temp (make-ssavalue))) + `(block ,(expand-forms `(= ,temp ,(caddr e))) + ,(expand-fuse-broadcast (cadr e) temp) + ,temp)) + ,(expand-fuse-broadcast (cadr e) (caddr e)))) '|<:| (lambda (e) (expand-forms `(call |<:| ,@(cdr e)))) @@ -3679,6 +3684,8 @@ f(x) = yt(x) (if value (compile (cadr e) break-labels value tail) #f)) + ((ifvalue) + (compile (if value (cadr e) (caddr e)) break-labels value tail)) ((if elseif) (let ((test `(gotoifnot ,(compile-cond (cadr e) break-labels) _)) (end-jump `(goto _)) diff --git a/test/broadcast.jl b/test/broadcast.jl index f094027160e27..f8e1b8169bf01 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -612,3 +612,15 @@ let n = 1 @test ceil.(Int, n ./ (1,)) == (1,) @test ceil.(Int, 1 ./ (1,)) == (1,) end + +# issue #25954, value of `.=` +let a = zeros(2, 3), b = zeros(4, 5) + a .= b .= 1 + @test a == ones(2, 3) + @test b == ones(4, 5) + @test (b .= 1) === 1 + c = [6, 7]; d = [8, 9] + x = (a .= c.+d) + @test a == [14 14 14; 16 16 16] + @test x == [14, 16] +end