Julia: `=== nothing` is not `== nothing` with `--code-coverage=user`

Created on 15 Jul 2019  ยท  9Comments  ยท  Source: JuliaLang/julia

I just have a very strange bug that cannot be reproduced locally _and_ replacing === nothing with == nothing (as below) fixes this bug.

diff --git a/examples/primes.jl b/examples/primes.jl
index 7dac9d2f..0f194e7f 100644
--- a/examples/primes.jl
+++ b/examples/primes.jl
@@ -11,7 +11,7 @@ using Transducers

 function sieve(xf, x)
     @info "sieve(xf, x=$x)"
-    if (@show mapfoldl(xf, right, (x,), init=nothing)) === nothing
+    if (@show mapfoldl(xf, right, (x,), init=nothing)) == nothing
         @info "$x is NOT prime"
         nothing, xf
     else

See: https://travis-ci.com/tkf/Transducers.jl/builds/119090143 (Ref https://github.com/tkf/Transducers.jl/pull/17)

Maybe it's relevant to #32135?

bug optimizer

Most helpful comment

This seems like it shouldnโ€™t happen.

All 9 comments

This seems like it shouldnโ€™t happen.

Seems like someone may have deleted the build log for the OP?

I can reproduce this locally if I try using Run.jl as in the travis script for that package.

Looks like the difference is the --code-coverage=user flag.

Looking at the IR, I see:

23 โ”„ %44  = ฯ† (#21 => false)::Bool
โ”‚    %45  = ฯ† (#21 => _3, #22 => nothing)::Union{Nothing, Int64}
โ””โ”€โ”€โ”€        goto #25
24 โ”€        goto #25
25 โ”„ %48  = ฯ† (#23 => %44)::Bool
โ”‚    %49  = ฯ† (#23 => %45, #24 => nothing)::Union{Nothing, Int64}
โ””โ”€โ”€โ”€        goto #26
26 โ”€ %51  = (isa)(%49, Nothing)::Bool
โ””โ”€โ”€โ”€        goto #28 if not %51
27 โ”€ %53  = ฯ€ (%49, Nothing)
โ””โ”€โ”€โ”€        goto #31
28 โ”€ %55  = (isa)(%49, Int64)::Bool
โ””โ”€โ”€โ”€        goto #30 if not %55
29 โ”€ %57  = ฯ€ (%49, Int64)
โ””โ”€โ”€โ”€        goto #31
30 โ”€        Core.throw(ErrorException("fatal error in type inference (type bound)"))::Union{}
โ””โ”€โ”€โ”€        $(Expr(:unreachable))::Union{}
31 โ”„ %61  = ฯ† (#27 => %48, #29 => %48)::Bool

which looks like an optimizer bug, probably in type lifting.

using Run.jl

Ah, I thought I've tried this... But yes, I can reproduce it with Run.test() now.

Edit: maybe the easiest way to run the script is julia --startup-file=no --project=test --code-coverage=user examples/primes.jl

Ref https://github.com/JuliaLang/julia/issues/32135#issuecomment-533975397 for another instance of this

Was this page helpful?
0 / 5 - 0 ratings