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

Failure with empty sums #31

Closed
blegat opened this issue Jan 10, 2020 · 0 comments · Fixed by #32
Closed

Failure with empty sums #31

blegat opened this issue Jan 10, 2020 · 0 comments · Fixed by #32

Comments

@blegat
Copy link
Member

blegat commented Jan 10, 2020

Reported by @ccoffrin in jump-dev/JuMP.jl#2120 (comment)

julia> using MutableArithmetics

julia> @rewrite(sum(1 for i in 1:0) * sum(1 for i in 1:0))
ERROR: MethodError: no method matching *(::MutableArithmetics.Zero, ::MutableArithmetics.Zero)
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:529
Stacktrace:
 [1] operate(::typeof(*), ::MutableArithmetics.Zero, ::MutableArithmetics.Zero) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:88
 [2] operate(::typeof(MutableArithmetics.add_mul), ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero) at /home/blegat/.julia/dev/MutableArithmetics/src/rewrite.jl:35
 [3] operate_fallback!(::MutableArithmetics.NotMutable, ::Function, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:275
 [4] operate!(::Function, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:271
 [5] top-level scope at /home/blegat/.julia/dev/MutableArithmetics/src/rewrite.jl:195

julia> @rewrite(sum(1 for i in 1:0) * 1^2)
ERROR: MethodError: no method matching *(::MutableArithmetics.Zero, ::Int64)
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:529
  *(::Complex{Bool}, ::Real) at complex.jl:305
  *(::Missing, ::Number) at missing.jl:115
  ...
Stacktrace:
 [1] operate(::typeof(*), ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:88
 [2] operate(::typeof(MutableArithmetics.add_mul), ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/rewrite.jl:35
 [3] operate_fallback!(::MutableArithmetics.NotMutable, ::Function, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:275
 [4] operate!(::Function, ::MutableArithmetics.Zero, ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:271
 [5] top-level scope at /home/blegat/.julia/dev/MutableArithmetics/src/rewrite.jl:195

julia> @rewrite(BigInt(1) + sum(1 for i in 1:0) * 1^2)
ERROR: MethodError: no method matching zero(::Type{MutableArithmetics.Zero})
Closest candidates are:
  zero(::Type{Missing}) at missing.jl:103
  zero(::Type{LibGit2.GitHash}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/LibGit2/src/oid.jl:220
  zero(::Type{Pkg.Resolve.VersionWeights.VersionWeight}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Pkg/src/resolve/VersionWeights.jl:19
  ...
Stacktrace:
 [1] promote_operation(::typeof(*), ::Type, ::Type) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:21
 [2] promote_operation(::typeof(MutableArithmetics.add_mul), ::Type, ::Type, ::Type) at /home/blegat/.julia/dev/MutableArithmetics/src/shortcuts.jl:53
 [3] mutability(::Type, ::Function, ::Type, ::Type, ::Type) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:132
 [4] mutability(::BigInt, ::Function, ::BigInt, ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:138
 [5] operate!(::Function, ::BigInt, ::MutableArithmetics.Zero, ::Int64) at /home/blegat/.julia/dev/MutableArithmetics/src/interface.jl:271
 [6] top-level scope at /home/blegat/.julia/dev/MutableArithmetics/src/rewrite.jl:195
This was referenced Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant