Skip to content

Commit 40a22d8

Browse files
Dale-Blackclaude
andcommitted
Skip emission for suppressed calls (empty compile result)
When compile_call returns "" (suppressed NamedTuple/apply_type), don't emit _vN = ; which is invalid JS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0bc56d7 commit 40a22d8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/compiler/codegen.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ Emit an expression statement, assigning to local if needed.
479479
function compile_expr_stmt!(ctx, buf, idx, expr::Expr, indent::String)
480480
if expr.head === :call
481481
result = compile_call(ctx, expr)
482-
if haskey(ctx.js_locals, idx)
482+
if isempty(result)
483+
# Suppressed call (e.g., NamedTuple constructor, apply_type) — skip
484+
elseif haskey(ctx.js_locals, idx)
483485
name = ctx.js_locals[idx]
484486
print(buf, "$(indent)$(name) = $(result);\n")
485487
else
@@ -488,15 +490,19 @@ function compile_expr_stmt!(ctx, buf, idx, expr::Expr, indent::String)
488490
end
489491
elseif expr.head === :invoke
490492
result = compile_invoke(ctx, expr)
491-
if haskey(ctx.js_locals, idx)
493+
if isempty(result)
494+
# Suppressed
495+
elseif haskey(ctx.js_locals, idx)
492496
name = ctx.js_locals[idx]
493497
print(buf, "$(indent)$(name) = $(result);\n")
494498
else
495499
print(buf, "$(indent)$(result);\n")
496500
end
497501
elseif expr.head === :new
498502
result = compile_new_expr(ctx, expr)
499-
if haskey(ctx.js_locals, idx)
503+
if isempty(result)
504+
# Suppressed
505+
elseif haskey(ctx.js_locals, idx)
500506
name = ctx.js_locals[idx]
501507
print(buf, "$(indent)$(name) = $(result);\n")
502508
else

0 commit comments

Comments
 (0)