Skip to content

Commit

Permalink
codegen: fix objecthack crash
Browse files Browse the repository at this point in the history
test262: 11.17% | πŸ§ͺ 49377 | 🀠 5513 | ❌ 1256 (+4) | πŸ’€ 8656 (+49) | 🧩 2478 (+9) | πŸ’₯ 1854 (-450) | ⏰ 1 | πŸ“ 29619 (+388)
  • Loading branch information
CanadaHonk committed Feb 12, 2024
1 parent f4cee87 commit 4035760
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/codeGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2875,11 +2875,14 @@ const objectHack = node => {
// if object is not identifier or another member exp, give up
if (node.object.type !== 'Identifier' && node.object.type !== 'MemberExpression') return node;

if (!objectName) objectName = objectHack(node.object).name.slice(2);
if (!objectName) objectName = objectHack(node.object)?.name?.slice?.(2);

// if .length, give up (hack within a hack!)
if (node.property.name === 'length') return node;

// no object name, give up
if (!objectName) return node;

const name = '__' + objectName + '_' + node.property.name;
if (codeLog) log('codegen', `object hack! ${node.object.name}.${node.property.name} -> ${name}`);

Expand Down

0 comments on commit 4035760

Please sign in to comment.