Something weird on Julia master

Sorry for the little descriptive title, I really don’t know how to summarize this stuff which is driving me crazy.

While testing Measurements.jl on Julia master I ran into an issue. This is a minimal code reproducing the issue:

using Measurements

function test(x, a)
    T = Measurements.gettype(a)
    println(T)
    println(typeof(x))
    println(T(x))
    println(typeof(T(x)))
end

a = big"3.00000001" ± big"1e-17"
b = 3 ± 0.1
test(a.val, (a, b))

The output of this script is:

BigFloat
BigFloat
3.00000001
Float64

Thus, inside the test function x is a BigFloat, T is BigFloat, but T(x) is a Float64. Does anyone have a clue of what’s going on here? No problem in Julia 0.6. Also, no problem if I replace the call to Measurements.gettype with a hard-coded BigFloat.

This looks like some sort of constructor fallback issue, possibly related to the removal of default constructors in 0.7. It might be worth seeing if you can reproduce the error with a custom type to track down the problem in the simplest case.

Seems to be an inference problem. I’ve opened an issue here (based on a simplified form): https://github.com/JuliaLang/julia/issues/27204

3 Likes