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

Use of one in generator causing world age issues for ForwardDiff #316

Closed
jrevels opened this issue Oct 6, 2017 · 6 comments
Closed

Use of one in generator causing world age issues for ForwardDiff #316

jrevels opened this issue Oct 6, 2017 · 6 comments

Comments

@jrevels
Copy link

jrevels commented Oct 6, 2017

ref JuliaDiff/ForwardDiff.jl#277

MWE (expected output is an empty SVector):

julia> using ForwardDiff, StaticArrays

julia> StaticArrays.diff(SVector(ForwardDiff.Dual(1)))
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type ForwardDiff.Dual{Void,Int64,0}
The applicable method may be too new: running in world age 21813, while current world is 21817.
This may have arisen from a call to the constructor ForwardDiff.Dual{Void,Int64,0}(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] one(::Type{ForwardDiff.Dual{Void,Int64,0}}) at ./number.jl:163
 [2] _diff(...) at /Users/jarrettrevels/.julia/v0.6/StaticArrays/src/mapreduce.jl:245
 [3] diff(::SVector{1,ForwardDiff.Dual{Void,Int64,0}}) at /Users/jarrettrevels/.julia/v0.6/StaticArrays/src/mapreduce.jl:238

AFAICT this is caused by the use of one (which ForwardDiff overloads for Dual numbers) within the generator here.

@mschauer
Copy link
Collaborator

mschauer commented Oct 6, 2017

Probably you should explain how the resulting eltype T = typeof(one(eltype(a)) - one(eltype(a))) can be computed for Dual numbers.

@timholy
Copy link
Member

timholy commented Oct 6, 2017

Is there clear evidence that this line couldn't be moved into the "body" (the quoted expression)? Inference is getting better and better at static evaluation...

@c42f
Copy link
Member

c42f commented Oct 6, 2017

Yes, moving the type computation into the body should fix this up. We do the same thing elsewhere in StaticArrays.

@c42f
Copy link
Member

c42f commented Oct 6, 2017

Does #317 do it for you? I found quite a lot of other places where this same problem exists.

@mschauer mschauer reopened this Oct 7, 2017
@mschauer
Copy link
Collaborator

mschauer commented Oct 7, 2017

Addresses the MWE. Please bump if there are remaining issues.

@mschauer mschauer closed this as completed Oct 7, 2017
@jrevels
Copy link
Author

jrevels commented Oct 10, 2017

This fixes the broken ForwardDiff tests. Can you tag a new release containing #317? Thanks!

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

4 participants