fix: remove empty body error -> fall back to silence

This commit is contained in:
Felix Roos 2026-02-13 08:40:27 +01:00
parent 04dcbda9a3
commit 8984055ea6
No known key found for this signature in database

View file

@ -257,14 +257,7 @@ export function transpiler(input, options = {}) {
body.push(silenceExpression);
} else if (!body?.[body.length - 1]?.expression) {
// Last statement is not an expression (e.g., VariableDeclaration, FunctionDeclaration)
if (blockBased) {
// For block-based eval, add silence as the return value when block ends with declaration
body.push(silenceExpression);
} else {
if (!prebake) {
throw new Error('unexpected ast format without body expression');
}
}
body.push(silenceExpression);
}
// For block-based eval, add scope assignments before the return statement