Closed
Description
As seen on PkgEval: https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2024-01/07/Comonicon.primary.log
Internal error: during type inference of
with_logstate(TestD.var"#1#2", Base.CoreLogging.LogState)
Encountered unexpected error in runtime:
MethodError(f=Base.string, args=(Expr(:call, :in, Expr(:ref, :scope_mapping, :bb), Expr(:tuple, :val, Expr(:call, :SSAValue, 0))),), world=0x00000000000016ae)
jl_method_error_bare at /source/src/gf.c:2216
jl_method_error at /source/src/gf.c:2234
jl_lookup_generic_ at /source/src/gf.c:3079 [inlined]
ijl_apply_generic at /source/src/gf.c:3094
macro expansion at ./error.jl:233 [inlined]
update_scope_mapping! at ./compiler/ssair/passes.jl:1150
sroa_pass! at ./compiler/ssair/passes.jl:1216
run_passes_ipo_safe at ./compiler/optimize.jl:908
run_passes_ipo_safe at ./compiler/optimize.jl:923 [inlined]
optimize at ./compiler/optimize.jl:897
The string
MethodError is a red herring; #50536.
MWE:
macro cast(ex)
return quote
Core.@__doc__ identity
$cast()
end
end
cast() = JLMD()
f() = @cast foo(a) = nothing
Base.code_ircode(Base.CoreLogging.with_logstate, Tuple{typeof(f), Base.CoreLogging.LogState})
ERROR: LoadError: AssertionError: scope_mapping[bb] in (val, SSAValue(0))
Stacktrace:
[1] update_scope_mapping!(scope_mapping::Vector{Core.SSAValue}, bb::Int64, val::Core.SSAValue)
@ Core.Compiler ./compiler/ssair/passes.jl:1150
[2] sroa_pass!(ir::Core.Compiler.IRCode, inlining::Core.Compiler.InliningState{Core.Compiler.NativeInterpreter})
@ Core.Compiler ./compiler/ssair/passes.jl:1216
[3] run_passes_ipo_safe(ci::Core.CodeInfo, sv::Core.Compiler.OptimizationState{Core.Compiler.NativeInterpreter}, caller::Core.Compiler.InferenceResult, optimize_until::Nothing)
@ Core.Compiler ./compiler/optimize.jl:908
[4] typeinf_ircode(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance, optimize_until::Nothing)
@ Core.Compiler ./compiler/typeinfer.jl:984
[5] typeinf_ircode(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance, optimize_until::Nothing)
@ Core.Compiler ./compiler/typeinfer.jl:969 [inlined]
[6] code_ircode_by_type(tt::Type; world::UInt64, interp::Core.Compiler.NativeInterpreter, optimize_until::Nothing)
@ Base ./reflection.jl:1698
[7] code_ircode_by_type
@ ./reflection.jl:1685 [inlined]
[8] code_ircode(f::Any, types::Any; kwargs::@Kwargs{})
@ Base ./reflection.jl:1676
[9] code_ircode(f::Any, types::Any)
@ Base ./reflection.jl:1671
[10] top-level scope
@ ~/Julia/tools/creduce/main.jl:9