-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
StackOverflow with operate!! and NonlinearExpr #3469
Comments
I think this is expected behavior. See #3106 (comment) julia> import MutableArithmetics as MA
julia> struct Foo <: MA.AbstractMutable
x::Int
end
julia> Base.copy(f::Foo) = Foo(f.x)
julia> function MA.add_mul(lhs::Foo, x::Union{Int,Foo}, y::Union{Int,Foo})
return MA.operate!!(MA.add_mul, copy(lhs), x, y)
end
julia> lhs = Foo(2)
Foo(2)
julia> x = Foo(3)
Foo(3)
julia> MA.add_mul(lhs, x, 3)
ERROR: StackOverflowError:
Stacktrace:
[1] operate_fallback!!(::MutableArithmetics.IsNotMutable, ::typeof(MutableArithmetics.add_mul), ::Foo, ::Foo, ::Int64)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:581
[2] operate!!(::typeof(MutableArithmetics.add_mul), ::Foo, ::Foo, ::Int64)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/rewrite.jl:89
[3] add_mul(lhs::Foo, x::Foo, y::Int64)
@ Main ./REPL[26]:2
[4] operate(op::typeof(MutableArithmetics.add_mul), x::Foo, y::Foo, args::Int64)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:206
[5] operate_fallback!!(::MutableArithmetics.IsNotMutable, ::typeof(MutableArithmetics.add_mul), ::Foo, ::Foo, ::Int64)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:586
--- the last 4 lines are repeated 19994 more times ---
[79982] operate!!(::typeof(MutableArithmetics.add_mul), ::Foo, ::Foo, ::Int64)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/rewrite.jl:89
[79983] add_mul(lhs::Foo, x::Foo, y::Int64)
@ Main ./REPL[26]:2 |
Oh sorry I missed that comment. It's good the PR is merged and we can now discuss on separate issue, it's going to be easier to keep track of discussions threads ^^ |
I don't understand what there is to discuss here. This is expected behavior. The definition of |
What is there to do here? |
I think it's fine, we could add a link to this issue in the comments in the code |
This should be investigated, I wouldn't expect this to cause a StackOverflow
JuMP.jl/src/mutable_arithmetics.jl
Lines 289 to 291 in a573de2
The text was updated successfully, but these errors were encountered: