From a859bac1050e46b40576387aaafe288bf4a0fca3 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 6 Jul 2016 19:28:17 -0400 Subject: [PATCH] fix #17304: f.(args...) and splatting --- src/julia-syntax.scm | 10 +++++----- test/broadcast.jl | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index a1574692dcbed..168352c1e1f10 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -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 diff --git a/test/broadcast.jl b/test/broadcast.jl index 0b43510974ae7..23d0b1c0c4245 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -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