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

make sure .= uses Base.identity, not a local identity #18122

Merged
merged 1 commit into from
Aug 19, 2016

Conversation

stevengj
Copy link
Member

As pointed out by @shashi in GiovineItalia/Gadfly.jl#864, the .= lowering was incorrectly lowering x .= y to broadcast!(identity, x, y), when in fact it should have used Base.identity. This let to a confusing error in Gadfly, which defines a local variable named identity.

@tkelman, can this be backported to 0.5.0?

@stevengj stevengj added bug Indicates an unexpected problem or unintended behavior backport pending 0.5 labels Aug 18, 2016
@vtjnash
Copy link
Member

vtjnash commented Aug 18, 2016

lgtm

@yuyichao
Copy link
Contributor

Should this be done for other builtin functions too?

julia> function f(a)
           getindex = 1
           a[1]
       end
f (generic function with 1 method)

julia> f([1])
ERROR: MethodError: objects of type Int64 are not callable
 in f(::Array{Int64,1}) at ./REPL[1]:3

@toivoh
Copy link
Contributor

toivoh commented Aug 19, 2016

I think there has been an intention that you should be able to provide your own +, getindex, etc locally.

But this case is different, the identity function is just an implementation detail of .= and not the official function one should overload to add behavior to it (like + is).

@stevengj stevengj merged commit b117e59 into JuliaLang:master Aug 19, 2016
@stevengj stevengj deleted the broadcast-identity branch August 19, 2016 18:32
tkelman pushed a commit that referenced this pull request Aug 20, 2016
mfasi pushed a commit to mfasi/julia that referenced this pull request Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants