From 1a1427325fa933331ab979c1891c55cc053479f5 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 22 Jan 2026 16:43:02 +0100 Subject: [PATCH] Fix missing and fields --- Compiler/src/typeinfer.jl | 2 ++ Compiler/test/ssair.jl | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Compiler/src/typeinfer.jl b/Compiler/src/typeinfer.jl index e3b7ee1f4926c..c97cf8b7f62a5 100644 --- a/Compiler/src/typeinfer.jl +++ b/Compiler/src/typeinfer.jl @@ -1186,6 +1186,8 @@ function codeinfo_for_const(::AbstractInterpreter, mi::MethodInstance, worlds::W tree.min_world = first(worlds) tree.max_world = last(worlds) tree.edges = edges + tree.nargs = UInt(nargs) + tree.isva = method.isva set_inlineable!(tree, true) tree.parent = mi return tree diff --git a/Compiler/test/ssair.jl b/Compiler/test/ssair.jl index 7aca2b8977a4e..f8d8a14adf9d7 100644 --- a/Compiler/test/ssair.jl +++ b/Compiler/test/ssair.jl @@ -845,3 +845,16 @@ end let ir = Base.code_ircode(_worker_task57153, (), optimize_until="CC: COMPACT_2")[1].first @test findfirst(x->x==0, ir.cfg.blocks[1].preds) !== nothing end + +# issue #59413 - codeinfo_for_const should set nargs and isva +let + _const_return_func(@nospecialize(x)) = 42 + mi = Compiler.specialize_method(only(methods(_const_return_func)), Tuple{typeof(_const_return_func), Int}, Core.svec()) + worlds = Compiler.WorldRange(Base.get_world_counter(), Base.get_world_counter()) + ci = Compiler.codeinfo_for_const(Compiler.NativeInterpreter(), mi, worlds, Core.svec(), 42) + @test ci.nargs == 2 + @test ci.isva == false + # inflate_ir! should succeed now that nargs/isva are set + ir = Compiler.inflate_ir!(ci, mi) + @test ir isa Compiler.IRCode +end