Skip to content

Commit 55da4b1

Browse files
authored
Merge pull request #17307 from stevengj/broadcast-splat
fix f.(args...) with splatting
2 parents 3704eac + a859bac commit 55da4b1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/julia-syntax.scm

+5-5
Original file line numberDiff line numberDiff line change
@@ -1562,13 +1562,13 @@
15621562

15631563
'|.|
15641564
(lambda (e) ; e = (|.| f x)
1565-
(let ((f (expand-forms (cadr e)))
1566-
(x (expand-forms (caddr e))))
1565+
(let ((f (cadr e))
1566+
(x (caddr e)))
15671567
(if (or (eq? (car x) 'quote) (eq? (car x) 'inert) (eq? (car x) '$))
1568-
`(call (core getfield) ,f ,x)
1568+
`(call (core getfield) ,(expand-forms f) ,(expand-forms x))
15691569
; otherwise, came from f.(args...) --> broadcast(f, args...),
1570-
; where x = (call (top tuple) args...) at this point:
1571-
`(call broadcast ,f ,@(cddr x)))))
1570+
; where x = (tuple args...) at this point:
1571+
(expand-forms `(call broadcast ,f ,@(cdr x))))))
15721572

15731573
'|<:| syntactic-op-to-call
15741574
'|>:| syntactic-op-to-call

test/broadcast.jl

+5
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,8 @@ end
213213
@test Base.promote_op(+, Bool) === Int
214214
@test isa(broadcast(+, true), Array{Int,0})
215215
@test Base.promote_op(Float64, Bool) === Float64
216+
217+
# issue #17304
218+
let foo = [[1,2,3],[4,5,6],[7,8,9]]
219+
@test max.(foo...) == broadcast(max, foo...) == [7,8,9]
220+
end

0 commit comments

Comments
 (0)