Skip to content

BoundsError in type inference when abstract-evaluating OpaqueClosure #54236

Open

Description

julia> struct Printable
            self::Any
            show::Core.OpaqueClosure{Tuple{Base.TTY, Any}, Nothing}

            Printable(self::T) where T = new(self,
                #= show =# Base.Experimental.@opaque (io::Base.TTY, @nospecialize(self::Any))->show(io, self::T)::Nothing
            )
       end

julia> Printable(1)
Internal error: during type inference of
(::Type{Main.Printable})(Int64)
Encountered unexpected error in runtime:
BoundsError(a=Array{Core.Compiler.VarState, 1}(dims=(0,), mem=Memory{Core.Compiler.VarState}(0, 0x7f2d2f80df70)[]), i=(1,))
throw_boundserror at ./essentials.jl:14
getindex at ./essentials.jl:891 [inlined]
stmt_effect_flags at ./compiler/optimize.jl:312
recompute_effects_flags at ./compiler/optimize.jl:381 [inlined]
add_inst_flag! at ./compiler/ssair/inlining.jl:1216 [inlined]
add_inst_flag! at ./compiler/ssair/inlining.jl:1213 [inlined]
process_simple! at ./compiler/ssair/inlining.jl:1243
assemble_inline_todo! at ./compiler/ssair/inlining.jl:1614
ssa_inlining_pass! at ./compiler/ssair/inlining.jl:80 [inlined]
run_passes_ipo_safe at ./compiler/optimize.jl:968
run_passes_ipo_safe at ./compiler/optimize.jl:983 [inlined]
optimize at ./compiler/optimize.jl:957
jfptr_optimize_40222.1 at /home/topolarity/dist/julia-cedar/vanilla/latest/lib/julia/sys.so (unknown line)
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
_typeinf at ./compiler/typeinfer.jl:253
typeinf at ./compiler/typeinfer.jl:215
jfptr_typeinf_37232.1 at /home/topolarity/dist/julia-cedar/vanilla/latest/lib/julia/sys.so (unknown line)
typeinf_edge at ./compiler/typeinfer.jl:863
abstract_call_method at ./compiler/abstractinterpretation.jl:655
abstract_call_opaque_closure at ./compiler/abstractinterpretation.jl:2217
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2575
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2775
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:3062
typeinf_local at ./compiler/abstractinterpretation.jl:3340
typeinf_nocycle at ./compiler/abstractinterpretation.jl:3422
_typeinf at ./compiler/typeinfer.jl:235
typeinf at ./compiler/typeinfer.jl:215
typeinf_ext at ./compiler/typeinfer.jl:1121
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1179 [inlined]
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1177
jfptr_typeinf_ext_toplevel_37476.1 at /home/topolarity/dist/julia-cedar/vanilla/latest/lib/julia/sys.so (unknown line)
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
jl_apply at /build/julia/src/julia.h:2185 [inlined]
jl_type_infer at /build/julia/src/gf.c:393
jl_compile_method_internal at /build/julia/src/gf.c:2559
_jl_invoke at /build/julia/src/gf.c:2986 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
jl_apply at /build/julia/src/julia.h:2185 [inlined]
do_call at /build/julia/src/interpreter.c:126
eval_value at /build/julia/src/interpreter.c:223
eval_stmt_value at /build/julia/src/interpreter.c:174 [inlined]
eval_body at /build/julia/src/interpreter.c:659
jl_interpret_toplevel_thunk at /build/julia/src/interpreter.c:829
top-level scope at REPL[2]:1
jl_toplevel_eval_flex at /build/julia/src/toplevel.c:953
__repl_entry_eval_expanded_with_loc at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:220
toplevel_eval_with_hooks at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:227
toplevel_eval_with_hooks at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:231
toplevel_eval_with_hooks at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:224 [inlined]
eval_user_input at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:249
repl_backend_loop at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:358
#start_repl_backend#59 at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:343
start_repl_backend at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:340
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
#run_repl#72 at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:499
run_repl at /home/topolarity/dist/julia-cedar/vanilla/latest/share/julia/stdlib/v1.12/REPL/src/REPL.jl:485
unknown function (ip: 0x7f2d4cf05cd6)
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
#1159 at ./client.jl:448
jfptr_YY.1159_16939 at /home/topolarity/.julia/compiled/v1.12/REPL/u0gqU_rt7eL.so (unknown line)
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
jl_apply at /build/julia/src/julia.h:2185 [inlined]
jl_f__call_latest at /build/julia/src/builtins.c:875
#invokelatest#2 at ./essentials.jl:1030 [inlined]
invokelatest at ./essentials.jl:1027 [inlined]
run_main_repl at ./client.jl:432
repl_main at ./client.jl:569 [inlined]
_start at ./client.jl:543
jfptr__start_69785.1 at /home/topolarity/dist/julia-cedar/vanilla/latest/lib/julia/sys.so (unknown line)
_jl_invoke at /build/julia/src/gf.c:2994 [inlined]
ijl_apply_generic at /build/julia/src/gf.c:3171
jl_apply at /build/julia/src/julia.h:2185 [inlined]
true_main at /build/julia/src/jlapi.c:900
jl_repl_entrypoint at /build/julia/src/jlapi.c:1059
main at /build/julia/cli/loader_exe.c:58
unknown function (ip: 0x7f2d5861cd8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)

Seems to occur on 1.10, 1.11, and latest nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcompiler:inferenceType inference

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions