Skip to content

Inferred result Nothing instead of Any for generated function with abstract signature #31590

@vchuravy

Description

@vchuravy

Bisected to #31191 I haven't had any luck narrowing this down further / creating a Cassette less reproducer.

On JuliaLabs/Cassette.jl#118

using Cassette

Cassette.@context Ctx
const ctx = Ctx()

x1 = 0
x2  = 0
f() = Cassette.overdub(ctx, Main.:*, Main.x1, Main.x2)

@assert Cassette.overdub(ctx, Main.:*, Main.x1, Main.x2) == 0
julia> @code_typed optimize=false f()
CodeInfo(
1 ─ %1 = Cassette.overdub::Core.Compiler.Const(Cassette.overdub, false)
│   %2 = Main.:*::Core.Compiler.Const(*, false)
│   %3 = Main.x1::Any
│   %4 = Main.x2::Any
│   %5 = (%1)(Main.ctx, %2, %3, %4)::Core.Compiler.Const(nothing, false)
└──      return %5
) => Nothing

Previously:

julia> @code_typed optimize=false f()
CodeInfo(
1 ─ %1 = Cassette.overdub::Core.Compiler.Const(Cassette.overdub, false)
│   %2 = Main.:*::Core.Compiler.Const(*, false)
│   %3 = Main.x1::Any
│   %4 = Main.x2::Any
│   %5 = (%1)(Main.ctx, %2, %3, %4)::Core.Compiler.Const(nothing, false)
└──      return %5
) => Nothing

determining the Core.Compiler.Const(nothing, false) seems false to me. It might be a bug in how Cassette is interacting with the base compiler after #31191, but I couldn't find anything glaringly obvious.

Metadata

Metadata

Labels

compiler:inferenceType inferenceregressionRegression in behavior compared to a previous version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions