Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broadcast() fails to infer type #15426

Closed
maxlarsen opened this issue Mar 9, 2016 · 2 comments
Closed

broadcast() fails to infer type #15426

maxlarsen opened this issue Mar 9, 2016 · 2 comments

Comments

@maxlarsen
Copy link

Not sure if this is fixed on master, but on 0.4.3:

function ff()
    gg(x,y)=1.0*(x==y)
    xx=[(i,i) for i=1:2]
    yy=xx'
    broadcast(gg,xx,yy)
end

ff()

> ERROR: LoadError: MethodError: `convert` has no method matching
> convert(::Type{Tuple{Int64,Int64}}, ::Float64)

@stevengj
Copy link
Member

stevengj commented May 5, 2016

Duplicate of #16164 (or vice versa), since the type computation in map works but in broadcast doesn't. Still a problem in master:

julia> xx=[(i,i) for i=1:2];
julia> map(x -> x[1] == x[2], xx)
2-element Array{Bool,1}:
 true
 true

julia> broadcast(x -> x[1] == x[2], xx)
ERROR: MethodError: Cannot `convert` an object of type Bool to an object of type Tuple{Int64,Int64}
This may have arisen from a call to the constructor Tuple{Int64,Int64}(...),
since type constructors fall back to convert methods.
 [inlined code] from ./REPL[3]:1
 in (::Base.Broadcast.#_F_#5)(::Array{Tuple{Int64,Int64},1}, ::Array{Tuple{Int64,Int64},1}) at ./broadcast.jl:175
 in broadcast!(::Function, ::Array{Tuple{Int64,Int64},1}, ::Array{Tuple{Int64,Int64},1}) at ./broadcast.jl:213
 [inlined code] from ./boot.jl:315
 in broadcast(::Function, ::Array{Tuple{Int64,Int64},1}) at ./broadcast.jl:220
 in eval(::Module, ::Any) at ./boot.jl:228

@stevengj stevengj closed this as completed May 5, 2016
@stevengj
Copy link
Member

stevengj commented May 5, 2016

Or rather, of #4883.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@stevengj @maxlarsen and others