Skip to content

Commit

Permalink
Something is wrong with inference of promote_op on Float16
Browse files Browse the repository at this point in the history
please revert this if you can fix it
  • Loading branch information
tkelman committed Jul 13, 2016
1 parent 6b40f86 commit 377dede
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,12 @@ let types = (Base.BitInteger_types..., BigInt, Bool,
Complex{Int}, Complex{UInt}, Complex32, Complex64, Complex128)
for S in types
for op in (+, -)
T = @inferred Base.promote_op(op, S)
if S === Float16 # type instability here?
@test_broken @inferred Base.promote_op(op, S)
T = Base.promote_op(op, S)
else
T = @inferred Base.promote_op(op, S)
end
t = @inferred op(one(S))
@test T === typeof(t)
end
Expand All @@ -2780,8 +2785,15 @@ let types = (Base.BitInteger_types..., BigInt, Bool,

for R in types, S in types
for op in (+, -, *, /, ^)
T = @inferred Base.promote_op(op, R, S)
t = @inferred op(one(R), one(S))
if R in (Float16, Complex{Float16}) || S in (Float16, Complex{Float16})
@test_broken @inferred Base.promote_op(op, R, S)
T = Base.promote_op(op, R, S)
@test_broken @inferred op(one(R), one(S))
t = op(one(R), one(S))
else
T = @inferred Base.promote_op(op, R, S)
t = @inferred op(one(R), one(S))
end
@test T === typeof(t)
end
end
Expand All @@ -2792,7 +2804,12 @@ let types = (Base.BitInteger_types..., BigInt, Bool,
Float16, Float32, Float64, BigFloat)
for S in types, T in types
for op in (<, >, <=, >=, (==))
@test @inferred(Base.promote_op(op, S, T)) === Bool
if S === Float16 || T === Float16
@test_broken @inferred(Base.promote_op(op, S, T))
@test Base.promote_op(op, S, T) === Bool
else
@test @inferred(Base.promote_op(op, S, T)) === Bool
end
end
end
end
Expand Down

0 comments on commit 377dede

Please sign in to comment.