Skip to content

Commit

Permalink
codegen: allow generators in iterable checks
Browse files Browse the repository at this point in the history
do not do anything but do not error either

test262: 49.30% (+0.50) | πŸ§ͺ 48414 | 🀠 23868 (+243) | ❌ 6812 (+204) | πŸ’€ 15476 (-439) | πŸ—οΈ 153 | πŸ’₯ 300 | ⏰ 170 (-8) | πŸ“ 1635
  • Loading branch information
CanadaHonk committed Oct 14, 2024
1 parent 69cba27 commit c447caf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
out = out.concat([
// check tmp is iterable
// array or string or bytestring
...typeIsOneOf(getType(scope, tmpName), [ TYPES.array, TYPES.string, TYPES.bytestring ]),
...typeIsOneOf(getType(scope, tmpName), [ TYPES.array, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
// typed array
...getType(scope, tmpName),
...number(TYPES.uint8array, Valtype.i32),
Expand Down Expand Up @@ -4116,7 +4116,7 @@ const generateForOf = (scope, decl) => {

// check tmp is iterable
// array or string or bytestring
...typeIsOneOf(iterType, [ TYPES.array, TYPES.set, TYPES.string, TYPES.bytestring ]),
...typeIsOneOf(iterType, [ TYPES.array, TYPES.set, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
// typed array
...iterType,
...number(TYPES.uint8array, Valtype.i32),
Expand Down Expand Up @@ -4456,6 +4456,8 @@ const generateForOf = (scope, decl) => {
]
}),

[TYPES.__porffor_generator]: () => [],

// note: should be impossible to reach?
default: internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`)
}, Blocktype.void));
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.48.0",
"version": "0.48.1",
"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.48.0';
globalThis.version = '0.48.1';

// 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 c447caf

Please sign in to comment.