Skip to content

Commit

Permalink
codegen: fix crash with for of no left decl
Browse files Browse the repository at this point in the history
test262: 11.29% (+0.01) | πŸ§ͺ 49377 | 🀠 5573 (+3) | ❌ 1248 (+1) | πŸ’€ 8684 (+1) | 🧩 2517 | πŸ’₯ 748 (-6) | ⏰ 2 | πŸ“ 30605 (+1)
  • Loading branch information
CanadaHonk committed Feb 13, 2024
1 parent 9f8ffb2 commit dfa0583
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/codeGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,13 @@ const generateForOf = (scope, decl) => {
// setup local for left
generate(scope, decl.left);

const leftName = decl.left.declarations[0].id.name;
let leftName = decl.left.declarations?.[0]?.id?.name;
if (!leftName && decl.left.name) {
leftName = decl.left.name;

generateVar(scope, { kind: 'var', _bare: true, declarations: [ { id: { name: leftName } } ] })
}

const [ local, isGlobal ] = lookupName(scope, leftName);

depth.push('block');
Expand Down

0 comments on commit dfa0583

Please sign in to comment.