Julia: Broadcasting a function on an array gives an expression

Created on 26 Mar 2017  路  3Comments  路  Source: JuliaLang/julia

Maybe this should throw an error.

julia> identity.[3,4,5]
:([3, 4, 5])
bug lowering

Most helpful comment

This is not an expression that has ever meant anything. It gives various different errors in all versions of julia. We allow parsing it, so it should probably be some kind of error during lowering.

All 3 comments

FWIW I'm only seeing this with identity:

julia> sum.[1,2,3]
ERROR: MethodError: no method matching start(::Expr)
Closest candidates are:
  start(::SimpleVector) at essentials.jl:259
  start(::Base.MethodList) at reflection.jl:560
  start(::ExponentialBackOff) at error.jl:107
  ...
Stacktrace:
 [1] mapfoldl(::Base.#identity, ::Function, ::Expr) at ./reduce.jl:67
 [2] sum(::Expr) at ./reduce.jl:342
 [3] broadcast(::Function, ::Expr) at ./broadcast.jl:415

julia> identity.[1,2,3]
:([1, 2, 3])

julia> length.[1,2,3]
ERROR: MethodError: no method matching length(::Expr)
Closest candidates are:
  length(::SimpleVector) at essentials.jl:257
  length(::Base.MethodList) at reflection.jl:558
  length(::MethodTable) at reflection.jl:634
  ...
Stacktrace:
 [1] broadcast(::Function, ::Expr) at ./broadcast.jl:415

It looks like it's being lowered to broadcast(identity, :([1,2,3])).

This is not an expression that has ever meant anything. It gives various different errors in all versions of julia. We allow parsing it, so it should probably be some kind of error during lowering.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helgee picture helgee  路  3Comments

felixrehren picture felixrehren  路  3Comments

i-apellaniz picture i-apellaniz  路  3Comments

thofma picture thofma  路  3Comments

yurivish picture yurivish  路  3Comments