Skip to content

Commit

Permalink
codegen: fix new.target in arrows crashing
Browse files Browse the repository at this point in the history
test262: 50.91% (+0.02) | πŸ§ͺ 48625 | 🀠 24755 (+9) | ❌ 6997 (+2) | πŸ’€ 15555 (+14) | πŸ—οΈ 21 (-4) | πŸ’₯ 169 (-25) | ⏰ 134 | πŸ“ 994 (+4)
  • Loading branch information
CanadaHonk committed Dec 8, 2024
1 parent 644588f commit efefd99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
25 changes: 13 additions & 12 deletions compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,14 +1697,12 @@ const getNodeType = (scope, node) => {
}

if (node.type === 'MetaProperty') {
switch (`${node.meta.name}.${node.property.name}`) {
case 'new.target': {
return [ [ Opcodes.local_get, scope.locals['#newtarget#type'].idx ] ];
}

default:
return todo(scope, `meta property object ${node.meta.name} is not supported yet`, true);
if (scope.constr && node.meta.name === 'new' && node.property.name === 'target') {
// new.target
return [ [ Opcodes.local_get, scope.locals['#newtarget#type'].idx ] ];
}

return TYPES.undefined;
}

if (node.type === 'SequenceExpression') {
Expand Down Expand Up @@ -5295,14 +5293,17 @@ const generateEmpty = (scope, decl) => {
};

const generateMeta = (scope, decl) => {
switch (`${decl.meta.name}.${decl.property.name}`) {
case 'new.target': return [
[ Opcodes.local_get, scope.locals['#newtarget'].idx ],
if (decl.meta.name === 'new' && decl.property.name === 'target') {
// new.target
if (scope.constr) return [
[ Opcodes.local_get, scope.locals['#newtarget'].idx ]
];

default:
return todo(scope, `meta property object ${decl.meta.name} is not supported yet`, true);
// not constructor so does not exist, return undefined
return [ number(UNDEFINED) ];
}

return todo(scope, `meta property object ${decl.meta.name} is not supported yet`, true);
};

let pages = new Map();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "porffor",
"description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
"version": "0.50.22",
"version": "0.50.23",
"author": "CanadaHonk",
"license": "MIT",
"scripts": {},
Expand Down
2 changes: 1 addition & 1 deletion runner/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import fs from 'node:fs';
globalThis.version = '0.50.22';
globalThis.version = '0.50.23';

// deno compat
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion test262/history.json

Large diffs are not rendered by default.

0 comments on commit efefd99

Please sign in to comment.