Skip to content

Commit

Permalink
Merge branch 'master' into od/fix-mutability-size
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Mar 24, 2024
2 parents c0ad2aa + a9779ff commit 101ebc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ _instantiate(::Type{S}) where {S<:Irrational} = S()
_instantiate_zero(::Type{S}) where {S<:AbstractIrrational} = _instantiate(S)
_instantiate_oneunit(::Type{S}) where {S<:AbstractIrrational} = _instantiate(S)

# Julia v1.0.x has trouble with inference with the `Vararg` method, see
# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
function promote_operation_fallback(
::typeof(/),
op::Union{typeof(/),typeof(div)},
::Type{S},
::Type{T},
) where {S,T}
return typeof(_instantiate_zero(S) / _instantiate_oneunit(T))
return typeof(op(_instantiate_zero(S), _instantiate_oneunit(T)))
end

# Julia v1.0.x has trouble with inference with the `Vararg` method, see
# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
function promote_operation_fallback(
op::F,
::Type{S},
Expand Down
9 changes: 9 additions & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,12 @@ end
@test MA.mutability(z, *, z, z) == MA.IsNotMutable()
@test MA.mutability(z, *, z, z, y) == MA.IsNotMutable()
end

@testset "Error-free mutability (issue #240)" begin
for op in (+, -, *, /, div)
for T in
(Float64, BigFloat, Int, BigInt, Rational{Int}, Rational{BigInt})
@test_nowarn MA.mutability(T, op, T, T) # should run without error
end
end
end

0 comments on commit 101ebc2

Please sign in to comment.