fix: remove empty body error -> fall back to silence
This commit is contained in:
parent
04dcbda9a3
commit
8984055ea6
1 changed files with 1 additions and 8 deletions
|
|
@ -257,14 +257,7 @@ export function transpiler(input, options = {}) {
|
||||||
body.push(silenceExpression);
|
body.push(silenceExpression);
|
||||||
} else if (!body?.[body.length - 1]?.expression) {
|
} else if (!body?.[body.length - 1]?.expression) {
|
||||||
// Last statement is not an expression (e.g., VariableDeclaration, FunctionDeclaration)
|
// 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);
|
body.push(silenceExpression);
|
||||||
} else {
|
|
||||||
if (!prebake) {
|
|
||||||
throw new Error('unexpected ast format without body expression');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For block-based eval, add scope assignments before the return statement
|
// For block-based eval, add scope assignments before the return statement
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue