3 ms·
The code_warntype macro is helpful, but to prevent a future inadvertently introduced type stability, a failing test would be much better. Test.@inferred is not
by kwertzzz 5y ago
The code_warntype macro is helpful, but to prevent a future inadvertently introduced type stability, a failing test would be much better.
Test.@inferred is not quite what is needed:
function foo(x)
s = 0
# better use a zero of the same type than x
# s = zero(x)
for y in x
s += y
end
return s
end
Test.@inferred Float64 foo(12.1)
This test succeeds even if code is type-unstable