Skip to content

Assertion failure with nested scoped values #53521

Closed
@simonbyrne

Description

On current master (77c0672) the following example:

const VALUE = ScopedValue{Int}(1)

x = 0
@with VALUE => 2 begin
    for r = Int[1]
        @with VALUE => 3 begin
            try
                copy(x)
            catch err
                nothing
            end
        end
    end
end

triggers an assertion failure

Internal error: during type inference of
Tuple{}
Encountered unexpected error in runtime:
MethodError(f=Base.string, args=(Expr(:call, :==, :current_mapping, :val),), world=0x0000000000001720)
jl_method_error_bare at /Users/simon/src/julia/src/gf.c:2215
jl_method_error at /Users/simon/src/julia/src/gf.c:2233
jl_lookup_generic_ at /Users/simon/src/julia/src/gf.c:3145 [inlined]
ijl_apply_generic at /Users/simon/src/julia/src/gf.c:3160
macro expansion at ./error.jl:233 [inlined]
update_scope_mapping! at ./compiler/ssair/passes.jl:1162
sroa_pass! at ./compiler/ssair/passes.jl:1230
run_passes_ipo_safe at ./compiler/optimize.jl:958
run_passes_ipo_safe at ./compiler/optimize.jl:973 [inlined]
optimize at ./compiler/optimize.jl:947
jfptr_optimize_40169 at /Users/simon/src/julia/usr/lib/julia/sys.dylib (unknown line)
_typeinf at ./compiler/typeinfer.jl:262
typeinf at ./compiler/typeinfer.jl:216
typeinf_ext at ./compiler/typeinfer.jl:1125
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1179 [inlined]
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1177
jfptr_typeinf_ext_toplevel_37409 at /Users/simon/src/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/simon/src/julia/src/./julia.h:2174 [inlined]
jl_type_infer at /Users/simon/src/julia/src/gf.c:393
jl_toplevel_eval_flex at /Users/simon/src/julia/src/toplevel.c:932
jl_toplevel_eval_flex at /Users/simon/src/julia/src/toplevel.c:886
ijl_toplevel_eval at /Users/simon/src/julia/src/toplevel.c:952 [inlined]
ijl_toplevel_eval_in at /Users/simon/src/julia/src/toplevel.c:994
eval at ./boot.jl:428 [inlined]
include_string at ./loading.jl:2486
_include at ./loading.jl:2546
include at ./Base.jl:557
jfptr_include_43902 at /Users/simon/src/julia/usr/lib/julia/sys.dylib (unknown line)
exec_options at ./client.jl:318
_start at ./client.jl:526
jfptr__start_67460 at /Users/simon/src/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/simon/src/julia/src/./julia.h:2174 [inlined]
true_main at /Users/simon/src/julia/src/jlapi.c:898
jl_repl_entrypoint at /Users/simon/src/julia/src/jlapi.c:1057

Possibly related #52819

cc: @Keno @vchuravy

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcompiler:optimizerOptimization passes (mostly in base/compiler/ssair/)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions