Skip to content

Commit

Permalink
fix JuliaLang#17304: f.(args...) and splatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and mfasi committed Sep 5, 2016
1 parent 22ff2e6 commit 5e3fe36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1562,13 +1562,13 @@

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

'|<:| syntactic-op-to-call
'|>:| syntactic-op-to-call
Expand Down
5 changes: 5 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,8 @@ end
@test Base.promote_op(+, Bool) === Int
@test isa(broadcast(+, true), Array{Int,0})
@test Base.promote_op(Float64, Bool) === Float64

# issue #17304
let foo = [[1,2,3],[4,5,6],[7,8,9]]
@test max.(foo...) == broadcast(max, foo...) == [7,8,9]
end

0 comments on commit 5e3fe36

Please sign in to comment.