fix: null alternate

This commit is contained in:
cha0s 2024-06-30 11:27:42 -05:00
parent 398dd66594
commit 00862f96bd
2 changed files with 8 additions and 1 deletions

View File

@ -294,10 +294,14 @@ export default class Sandbox {
if (test.yield) { if (test.yield) {
return test; return test;
} }
result = {
yield: YIELD_NONE,
value: undefined,
};
if (test.value) { if (test.value) {
result = this.executeSync(node.consequent, depth + 1); result = this.executeSync(node.consequent, depth + 1);
} }
else { else if (node.alternate) {
result = this.executeSync(node.alternate, depth + 1); result = this.executeSync(node.alternate, depth + 1);
} }
if (result.yield) { if (result.yield) {

View File

@ -135,6 +135,9 @@ test('evaluates conditional branches', async () => {
else { else {
bar = 2; bar = 2;
} }
if (await false) {
bar = 1;
}
`), `),
); );
await finish(sandbox); await finish(sandbox);