Skip to content

Commit 54431fa

Browse files
Dale-Blackclaude
andcommitted
Skip Core.apply_type and NamedTuple constructors in codegen
These are compile-time type operations from kwcall dispatch. They're consumed by _extract_kwargs, not needed in JS output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 071b846 commit 54431fa

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/compiler/codegen.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,28 @@ function compile_call(ctx::JSCompilationContext, expr::Expr)
10011001
end
10021002
end
10031003

1004+
# ─── Skip type-level operations (dead code in unoptimized IR) ───
1005+
# Core.apply_type(NamedTuple, ...) and NamedTuple constructors are compile-time
1006+
# operations used for kwcall dispatch — they're consumed by _extract_kwargs
1007+
if callee isa GlobalRef && callee.name === :apply_type && callee.mod === Core
1008+
return ""
1009+
end
1010+
1011+
# NamedTuple constructor: (%apply_type_result)(%tuple) — skip if result is NamedTuple
1012+
if callee isa Core.SSAValue
1013+
ct = ctx.code_info.ssavaluetypes[callee.id]
1014+
if ct isa Core.Const && ct.val isa Type && ct.val <: NamedTuple
1015+
return ""
1016+
end
1017+
end
1018+
1019+
# Core.tuple used for kwargs assembly — skip if result feeds into NamedTuple
1020+
if (callee isa GlobalRef && callee.name === :tuple && callee.mod === Core) ||
1021+
(callee isa typeof(Core.tuple))
1022+
# Check if result type is a plain Tuple (kwargs values) — keep it if it's used elsewhere
1023+
# but suppress the line emission (it'll be inlined by compile_value)
1024+
end
1025+
10041026
# Check for Core.Intrinsics — may be referenced via Base.add_int etc.
10051027
if callee isa GlobalRef
10061028
resolved = try

0 commit comments

Comments
 (0)