Skip to content

AssertionError when inferring an OpaqueClosure w/ incorrect arguments #55627

@topolarity

Description

@topolarity

MWE:

using Base.Experimental: @opaque

some_method(x) = 2x
make_oc() = @opaque (x::Int)->some_method(x)

function foo()
    f = make_oc()
    println(Core.stdout, "Hello, world! ", f(1)) # fine
    println(Core.stdout, "Hello, world! ", f()) # errors in type-inference
end

foo()

This code leads to an AssertionError in inference:

AssertionError(msg="invalid `given_argtypes` for `mi`")
va_process_argtypes at ./compiler/inferenceresult.jl:123
InferenceState at ./compiler/inferencestate.jl:310
InferenceState at ./compiler/inferencestate.jl:546
typeinf_edge at ./compiler/typeinfer.jl:911
abstract_call_method at ./compiler/abstractinterpretation.jl:744
abstract_call_opaque_closure at ./compiler/abstractinterpretation.jl:2290
...

Occurs on nightly (but not 1.10 or 1.11):

Julia Version 1.12.0-DEV.1108
Commit 378f1920db0 (2024-08-28 15:58 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 12th Gen Intel(R) Core(TM) i7-1255U
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcompiler:inferenceType inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions