Skip to content

Commit cbe0d16

Browse files
BeyondMagicCopilot
andauthored
fix(codegen): save side effect expression
Co-authored-by: Copilot <[email protected]>
1 parent 1c4080c commit cbe0d16

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/codegen_lua.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ static void emit_statement(FILE *out, const AstStmt *stmt, const FunctionTable *
170170
{
171171
return; // Dead Code Elimination: remove unused locals without side effects
172172
}
173+
// Unused variable with initializer that has side effects: emit only the initializer as a statement
174+
emit_indent(out, indent);
175+
emit_expression_expected(out, stmt->data.decl.init, functions, stmt->data.decl.type);
176+
fputc('\n', out);
177+
return;
173178
}
174179

175180
if (stmt->data.decl.is_array)

0 commit comments

Comments
 (0)