From db566046bd39324a03a26c8adcf938cfe206fcdb Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 14:31:22 +0100 Subject: [PATCH 001/100] feat(codemode): add embeddable Rust port --- .oxlintrc.json | 1 + packages/codemode-rust/.gitignore | 1 + packages/codemode-rust/AGENTS.md | 23 + packages/codemode-rust/Cargo.lock | 881 ++++++ packages/codemode-rust/Cargo.toml | 11 + packages/codemode-rust/bench/Cargo.toml | 9 + packages/codemode-rust/bench/RESULTS.md | 71 + .../codemode-rust/bench/baseline/meta.txt | 5 + .../bench/baseline/reference-bench.txt | 9 + packages/codemode-rust/bench/compare.sh | 149 ++ .../codemode-rust/bench/examples/embed.rs | 21 + packages/codemode-rust/bench/ref/embed.ts | 24 + packages/codemode-rust/bench/ref/run-case.ts | 26 + packages/codemode-rust/bench/src/main.rs | 82 + .../codemode-rust/bench/tests/conformance.rs | 162 ++ .../conformance/cases/array-basic-methods.js | 7 + .../cases/array-basic-methods.json | 46 + .../cases/array-callback-methods.js | 4 + .../cases/array-callback-methods.json | 45 + .../conformance/cases/array-construct.js | 1 + .../conformance/cases/array-construct.json | 40 + .../conformance/cases/array-sort.js | 4 + .../conformance/cases/array-sort.json | 40 + .../conformance/cases/arrow-functions.js | 4 + .../conformance/cases/arrow-functions.json | 13 + .../conformance/cases/async-functions.js | 4 + .../conformance/cases/async-functions.json | 10 + .../conformance/cases/await-values.js | 4 + .../conformance/cases/await-values.json | 6 + .../cases/bench-array-callbacks.js | 5 + .../cases/bench-array-callbacks.json | 10 + .../cases/bench-closure-recursion.js | 2 + .../cases/bench-closure-recursion.json | 6 + .../cases/bench-generator-iteration.js | 4 + .../cases/bench-generator-iteration.json | 6 + .../cases/bench-json-round-trip.js | 4 + .../cases/bench-json-round-trip.json | 6 + .../conformance/cases/bench-map-set-ops.js | 8 + .../conformance/cases/bench-map-set-ops.json | 6 + .../conformance/cases/bench-numeric-loop.js | 3 + .../conformance/cases/bench-numeric-loop.json | 6 + .../cases/bench-promise-fan-out.js | 3 + .../cases/bench-promise-fan-out.json | 6 + .../cases/bench-string-building.js | 5 + .../cases/bench-string-building.json | 6 + .../conformance/cases/bench-tool-fan-out.js | 2 + .../conformance/cases/bench-tool-fan-out.json | 6 + .../conformance/cases/bindings.js | 2 + .../conformance/cases/bindings.json | 23 + .../conformance/cases/boundary-collections.js | 1 + .../cases/boundary-collections.json | 12 + .../conformance/cases/boundary-error.js | 3 + .../conformance/cases/boundary-error.json | 10 + .../conformance/cases/boundary-functions.js | 1 + .../conformance/cases/boundary-functions.json | 11 + .../conformance/cases/boundary-promise.js | 1 + .../conformance/cases/boundary-promise.json | 8 + .../conformance/cases/boundary-to-json.js | 1 + .../conformance/cases/boundary-to-json.json | 10 + .../cases/boundary-undefined-null.js | 1 + .../cases/boundary-undefined-null.json | 19 + .../conformance/cases/closure-counter.js | 4 + .../conformance/cases/closure-counter.json | 9 + .../conformance/cases/closure-iife.js | 2 + .../conformance/cases/closure-iife.json | 6 + .../conformance/cases/closure-loop-let.js | 3 + .../conformance/cases/closure-loop-let.json | 10 + .../conformance/cases/coercion.js | 1 + .../conformance/cases/coercion.json | 19 + .../conformance/cases/console-log.js | 5 + .../conformance/cases/console-log.json | 11 + .../conformance/cases/destructuring-array.js | 4 + .../cases/destructuring-array.json | 15 + .../conformance/cases/destructuring-object.js | 2 + .../cases/destructuring-object.json | 15 + .../conformance/cases/destructuring-params.js | 2 + .../cases/destructuring-params.json | 9 + .../conformance/cases/equality.js | 1 + .../conformance/cases/equality.json | 17 + .../conformance/cases/error-class.js | 2 + .../conformance/cases/error-class.json | 6 + .../conformance/cases/error-parse.js | 1 + .../conformance/cases/error-parse.json | 6 + .../conformance/cases/error-reference.js | 1 + .../conformance/cases/error-reference.json | 6 + .../conformance/cases/error-throw-error.js | 2 + .../conformance/cases/error-throw-error.json | 8 + .../conformance/cases/error-throw-value.js | 1 + .../conformance/cases/error-throw-value.json | 6 + .../cases/error-tool-call-limit-caught.js | 4 + .../cases/error-tool-call-limit-caught.json | 12 + .../cases/error-tool-call-limit.js | 3 + .../cases/error-tool-call-limit.json | 9 + .../conformance/cases/error-tool-caught.js | 1 + .../conformance/cases/error-tool-caught.json | 9 + .../conformance/cases/error-tool-uncaught.js | 2 + .../cases/error-tool-uncaught.json | 6 + .../conformance/cases/error-unknown-tool.js | 1 + .../conformance/cases/error-unknown-tool.json | 6 + .../conformance/cases/finally-overrides.js | 3 + .../conformance/cases/finally-overrides.json | 9 + .../conformance/cases/for-of-for-in.js | 7 + .../conformance/cases/for-of-for-in.json | 16 + .../conformance/cases/function-hoisting.js | 2 + .../conformance/cases/function-hoisting.json | 6 + .../cases/generator-for-of-break.js | 4 + .../cases/generator-for-of-break.json | 12 + .../conformance/cases/generator-protocol.js | 3 + .../conformance/cases/generator-protocol.json | 22 + .../conformance/cases/generator-spread.js | 2 + .../conformance/cases/generator-spread.json | 12 + .../conformance/cases/if-else-ternary.js | 2 + .../conformance/cases/if-else-ternary.json | 11 + .../conformance/cases/instanceof.js | 2 + .../conformance/cases/instanceof.json | 14 + .../conformance/cases/json-methods.js | 3 + .../conformance/cases/json-methods.json | 29 + .../conformance/cases/json-parse-error.js | 1 + .../conformance/cases/json-parse-error.json | 9 + .../codemode-rust/conformance/cases/labels.js | 10 + .../conformance/cases/labels.json | 14 + .../conformance/cases/let-const-var.js | 5 + .../conformance/cases/let-const-var.json | 10 + .../conformance/cases/logical-nullish.js | 4 + .../conformance/cases/logical-nullish.json | 19 + .../codemode-rust/conformance/cases/loops.js | 9 + .../conformance/cases/loops.json | 11 + .../conformance/cases/map-object-keys.js | 4 + .../conformance/cases/map-object-keys.json | 12 + .../conformance/cases/map-set.js | 7 + .../conformance/cases/map-set.json | 53 + .../codemode-rust/conformance/cases/math.js | 1 + .../codemode-rust/conformance/cases/math.json | 20 + .../conformance/cases/number-formatting.js | 1 + .../conformance/cases/number-formatting.json | 19 + .../conformance/cases/number-methods.js | 1 + .../conformance/cases/number-methods.json | 22 + .../conformance/cases/object-literals.js | 5 + .../conformance/cases/object-literals.json | 32 + .../conformance/cases/object-methods.js | 2 + .../conformance/cases/object-methods.json | 41 + .../conformance/cases/operators.js | 7 + .../conformance/cases/operators.json | 23 + .../cases/plugin-reducer-command.js | 4 + .../cases/plugin-reducer-command.json | 23 + .../conformance/cases/plugin-reducer-init.js | 4 + .../cases/plugin-reducer-init.json | 21 + .../cases/plugin-reducer-other-command.js | 4 + .../cases/plugin-reducer-other-command.json | 18 + .../cases/plugin-reducer-unknown-event.js | 4 + .../cases/plugin-reducer-unknown-event.json | 18 + .../conformance/cases/promise-all.js | 2 + .../conformance/cases/promise-all.json | 11 + .../conformance/cases/promise-ordering.js | 6 + .../conformance/cases/promise-ordering.json | 10 + .../conformance/cases/promise-then-chain.js | 3 + .../conformance/cases/promise-then-chain.json | 9 + .../conformance/cases/recursion.js | 4 + .../conformance/cases/recursion.json | 10 + .../conformance/cases/repl-last-expression.js | 2 + .../cases/repl-last-expression.json | 6 + .../conformance/cases/repl-no-value.js | 1 + .../conformance/cases/repl-no-value.json | 6 + .../conformance/cases/repl-undefined.js | 1 + .../conformance/cases/repl-undefined.json | 6 + .../conformance/cases/runtime-type-error.js | 5 + .../conformance/cases/runtime-type-error.json | 11 + .../conformance/cases/spread-rest.js | 4 + .../conformance/cases/spread-rest.json | 21 + .../cases/string-from-char-code.js | 3 + .../cases/string-from-char-code.json | 16 + .../conformance/cases/string-methods.js | 3 + .../conformance/cases/string-methods.json | 44 + .../codemode-rust/conformance/cases/switch.js | 12 + .../conformance/cases/switch.json | 13 + .../conformance/cases/template-literals.js | 4 + .../conformance/cases/template-literals.json | 11 + .../conformance/cases/throw-errors.js | 2 + .../conformance/cases/throw-errors.json | 31 + .../conformance/cases/throw-values.js | 3 + .../conformance/cases/throw-values.json | 13 + .../conformance/cases/tool-calls.js | 4 + .../conformance/cases/tool-calls.json | 14 + .../conformance/cases/tool-concurrent.js | 2 + .../conformance/cases/tool-concurrent.json | 10 + .../conformance/cases/tool-result-copy.js | 4 + .../conformance/cases/tool-result-copy.json | 9 + .../conformance/cases/try-catch-finally.js | 5 + .../conformance/cases/try-catch-finally.json | 15 + .../codemode-rust/conformance/cases/typeof.js | 1 + .../conformance/cases/typeof.json | 18 + .../conformance/cases/var-hoisting.js | 4 + .../conformance/cases/var-hoisting.json | 10 + .../codemode-rust/conformance/generate.ts | 70 + .../crates/psychoscript/Cargo.toml | 19 + .../crates/psychoscript/examples/run.rs | 29 + .../crates/psychoscript/src/builtins/array.rs | 736 ++++++ .../psychoscript/src/builtins/collections.rs | 438 +++ .../crates/psychoscript/src/builtins/mod.rs | 186 ++ .../psychoscript/src/builtins/object.rs | 707 +++++ .../psychoscript/src/builtins/string.rs | 915 +++++++ .../crates/psychoscript/src/bytecode.rs | 214 ++ .../crates/psychoscript/src/compiler.rs | 2353 +++++++++++++++++ .../crates/psychoscript/src/convert.rs | 756 ++++++ .../crates/psychoscript/src/lib.rs | 104 + .../crates/psychoscript/src/object.rs | 290 ++ .../crates/psychoscript/src/ops.rs | 1119 ++++++++ .../crates/psychoscript/src/promise.rs | 331 +++ .../crates/psychoscript/src/run.rs | 247 ++ .../crates/psychoscript/src/strings.rs | 189 ++ .../crates/psychoscript/src/value.rs | 501 ++++ .../crates/psychoscript/src/vm.rs | 1927 ++++++++++++++ .../crates/psychoscript/tests/api.rs | 135 + 213 files changed, 14359 insertions(+) create mode 100644 packages/codemode-rust/.gitignore create mode 100644 packages/codemode-rust/AGENTS.md create mode 100644 packages/codemode-rust/Cargo.lock create mode 100644 packages/codemode-rust/Cargo.toml create mode 100644 packages/codemode-rust/bench/Cargo.toml create mode 100644 packages/codemode-rust/bench/RESULTS.md create mode 100644 packages/codemode-rust/bench/baseline/meta.txt create mode 100644 packages/codemode-rust/bench/baseline/reference-bench.txt create mode 100644 packages/codemode-rust/bench/compare.sh create mode 100644 packages/codemode-rust/bench/examples/embed.rs create mode 100644 packages/codemode-rust/bench/ref/embed.ts create mode 100644 packages/codemode-rust/bench/ref/run-case.ts create mode 100644 packages/codemode-rust/bench/src/main.rs create mode 100644 packages/codemode-rust/bench/tests/conformance.rs create mode 100644 packages/codemode-rust/conformance/cases/array-basic-methods.js create mode 100644 packages/codemode-rust/conformance/cases/array-basic-methods.json create mode 100644 packages/codemode-rust/conformance/cases/array-callback-methods.js create mode 100644 packages/codemode-rust/conformance/cases/array-callback-methods.json create mode 100644 packages/codemode-rust/conformance/cases/array-construct.js create mode 100644 packages/codemode-rust/conformance/cases/array-construct.json create mode 100644 packages/codemode-rust/conformance/cases/array-sort.js create mode 100644 packages/codemode-rust/conformance/cases/array-sort.json create mode 100644 packages/codemode-rust/conformance/cases/arrow-functions.js create mode 100644 packages/codemode-rust/conformance/cases/arrow-functions.json create mode 100644 packages/codemode-rust/conformance/cases/async-functions.js create mode 100644 packages/codemode-rust/conformance/cases/async-functions.json create mode 100644 packages/codemode-rust/conformance/cases/await-values.js create mode 100644 packages/codemode-rust/conformance/cases/await-values.json create mode 100644 packages/codemode-rust/conformance/cases/bench-array-callbacks.js create mode 100644 packages/codemode-rust/conformance/cases/bench-array-callbacks.json create mode 100644 packages/codemode-rust/conformance/cases/bench-closure-recursion.js create mode 100644 packages/codemode-rust/conformance/cases/bench-closure-recursion.json create mode 100644 packages/codemode-rust/conformance/cases/bench-generator-iteration.js create mode 100644 packages/codemode-rust/conformance/cases/bench-generator-iteration.json create mode 100644 packages/codemode-rust/conformance/cases/bench-json-round-trip.js create mode 100644 packages/codemode-rust/conformance/cases/bench-json-round-trip.json create mode 100644 packages/codemode-rust/conformance/cases/bench-map-set-ops.js create mode 100644 packages/codemode-rust/conformance/cases/bench-map-set-ops.json create mode 100644 packages/codemode-rust/conformance/cases/bench-numeric-loop.js create mode 100644 packages/codemode-rust/conformance/cases/bench-numeric-loop.json create mode 100644 packages/codemode-rust/conformance/cases/bench-promise-fan-out.js create mode 100644 packages/codemode-rust/conformance/cases/bench-promise-fan-out.json create mode 100644 packages/codemode-rust/conformance/cases/bench-string-building.js create mode 100644 packages/codemode-rust/conformance/cases/bench-string-building.json create mode 100644 packages/codemode-rust/conformance/cases/bench-tool-fan-out.js create mode 100644 packages/codemode-rust/conformance/cases/bench-tool-fan-out.json create mode 100644 packages/codemode-rust/conformance/cases/bindings.js create mode 100644 packages/codemode-rust/conformance/cases/bindings.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-collections.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-collections.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-error.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-error.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-functions.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-functions.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-promise.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-promise.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-to-json.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-to-json.json create mode 100644 packages/codemode-rust/conformance/cases/boundary-undefined-null.js create mode 100644 packages/codemode-rust/conformance/cases/boundary-undefined-null.json create mode 100644 packages/codemode-rust/conformance/cases/closure-counter.js create mode 100644 packages/codemode-rust/conformance/cases/closure-counter.json create mode 100644 packages/codemode-rust/conformance/cases/closure-iife.js create mode 100644 packages/codemode-rust/conformance/cases/closure-iife.json create mode 100644 packages/codemode-rust/conformance/cases/closure-loop-let.js create mode 100644 packages/codemode-rust/conformance/cases/closure-loop-let.json create mode 100644 packages/codemode-rust/conformance/cases/coercion.js create mode 100644 packages/codemode-rust/conformance/cases/coercion.json create mode 100644 packages/codemode-rust/conformance/cases/console-log.js create mode 100644 packages/codemode-rust/conformance/cases/console-log.json create mode 100644 packages/codemode-rust/conformance/cases/destructuring-array.js create mode 100644 packages/codemode-rust/conformance/cases/destructuring-array.json create mode 100644 packages/codemode-rust/conformance/cases/destructuring-object.js create mode 100644 packages/codemode-rust/conformance/cases/destructuring-object.json create mode 100644 packages/codemode-rust/conformance/cases/destructuring-params.js create mode 100644 packages/codemode-rust/conformance/cases/destructuring-params.json create mode 100644 packages/codemode-rust/conformance/cases/equality.js create mode 100644 packages/codemode-rust/conformance/cases/equality.json create mode 100644 packages/codemode-rust/conformance/cases/error-class.js create mode 100644 packages/codemode-rust/conformance/cases/error-class.json create mode 100644 packages/codemode-rust/conformance/cases/error-parse.js create mode 100644 packages/codemode-rust/conformance/cases/error-parse.json create mode 100644 packages/codemode-rust/conformance/cases/error-reference.js create mode 100644 packages/codemode-rust/conformance/cases/error-reference.json create mode 100644 packages/codemode-rust/conformance/cases/error-throw-error.js create mode 100644 packages/codemode-rust/conformance/cases/error-throw-error.json create mode 100644 packages/codemode-rust/conformance/cases/error-throw-value.js create mode 100644 packages/codemode-rust/conformance/cases/error-throw-value.json create mode 100644 packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.js create mode 100644 packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.json create mode 100644 packages/codemode-rust/conformance/cases/error-tool-call-limit.js create mode 100644 packages/codemode-rust/conformance/cases/error-tool-call-limit.json create mode 100644 packages/codemode-rust/conformance/cases/error-tool-caught.js create mode 100644 packages/codemode-rust/conformance/cases/error-tool-caught.json create mode 100644 packages/codemode-rust/conformance/cases/error-tool-uncaught.js create mode 100644 packages/codemode-rust/conformance/cases/error-tool-uncaught.json create mode 100644 packages/codemode-rust/conformance/cases/error-unknown-tool.js create mode 100644 packages/codemode-rust/conformance/cases/error-unknown-tool.json create mode 100644 packages/codemode-rust/conformance/cases/finally-overrides.js create mode 100644 packages/codemode-rust/conformance/cases/finally-overrides.json create mode 100644 packages/codemode-rust/conformance/cases/for-of-for-in.js create mode 100644 packages/codemode-rust/conformance/cases/for-of-for-in.json create mode 100644 packages/codemode-rust/conformance/cases/function-hoisting.js create mode 100644 packages/codemode-rust/conformance/cases/function-hoisting.json create mode 100644 packages/codemode-rust/conformance/cases/generator-for-of-break.js create mode 100644 packages/codemode-rust/conformance/cases/generator-for-of-break.json create mode 100644 packages/codemode-rust/conformance/cases/generator-protocol.js create mode 100644 packages/codemode-rust/conformance/cases/generator-protocol.json create mode 100644 packages/codemode-rust/conformance/cases/generator-spread.js create mode 100644 packages/codemode-rust/conformance/cases/generator-spread.json create mode 100644 packages/codemode-rust/conformance/cases/if-else-ternary.js create mode 100644 packages/codemode-rust/conformance/cases/if-else-ternary.json create mode 100644 packages/codemode-rust/conformance/cases/instanceof.js create mode 100644 packages/codemode-rust/conformance/cases/instanceof.json create mode 100644 packages/codemode-rust/conformance/cases/json-methods.js create mode 100644 packages/codemode-rust/conformance/cases/json-methods.json create mode 100644 packages/codemode-rust/conformance/cases/json-parse-error.js create mode 100644 packages/codemode-rust/conformance/cases/json-parse-error.json create mode 100644 packages/codemode-rust/conformance/cases/labels.js create mode 100644 packages/codemode-rust/conformance/cases/labels.json create mode 100644 packages/codemode-rust/conformance/cases/let-const-var.js create mode 100644 packages/codemode-rust/conformance/cases/let-const-var.json create mode 100644 packages/codemode-rust/conformance/cases/logical-nullish.js create mode 100644 packages/codemode-rust/conformance/cases/logical-nullish.json create mode 100644 packages/codemode-rust/conformance/cases/loops.js create mode 100644 packages/codemode-rust/conformance/cases/loops.json create mode 100644 packages/codemode-rust/conformance/cases/map-object-keys.js create mode 100644 packages/codemode-rust/conformance/cases/map-object-keys.json create mode 100644 packages/codemode-rust/conformance/cases/map-set.js create mode 100644 packages/codemode-rust/conformance/cases/map-set.json create mode 100644 packages/codemode-rust/conformance/cases/math.js create mode 100644 packages/codemode-rust/conformance/cases/math.json create mode 100644 packages/codemode-rust/conformance/cases/number-formatting.js create mode 100644 packages/codemode-rust/conformance/cases/number-formatting.json create mode 100644 packages/codemode-rust/conformance/cases/number-methods.js create mode 100644 packages/codemode-rust/conformance/cases/number-methods.json create mode 100644 packages/codemode-rust/conformance/cases/object-literals.js create mode 100644 packages/codemode-rust/conformance/cases/object-literals.json create mode 100644 packages/codemode-rust/conformance/cases/object-methods.js create mode 100644 packages/codemode-rust/conformance/cases/object-methods.json create mode 100644 packages/codemode-rust/conformance/cases/operators.js create mode 100644 packages/codemode-rust/conformance/cases/operators.json create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-command.js create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-command.json create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-init.js create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-init.json create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-other-command.js create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-other-command.json create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.js create mode 100644 packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.json create mode 100644 packages/codemode-rust/conformance/cases/promise-all.js create mode 100644 packages/codemode-rust/conformance/cases/promise-all.json create mode 100644 packages/codemode-rust/conformance/cases/promise-ordering.js create mode 100644 packages/codemode-rust/conformance/cases/promise-ordering.json create mode 100644 packages/codemode-rust/conformance/cases/promise-then-chain.js create mode 100644 packages/codemode-rust/conformance/cases/promise-then-chain.json create mode 100644 packages/codemode-rust/conformance/cases/recursion.js create mode 100644 packages/codemode-rust/conformance/cases/recursion.json create mode 100644 packages/codemode-rust/conformance/cases/repl-last-expression.js create mode 100644 packages/codemode-rust/conformance/cases/repl-last-expression.json create mode 100644 packages/codemode-rust/conformance/cases/repl-no-value.js create mode 100644 packages/codemode-rust/conformance/cases/repl-no-value.json create mode 100644 packages/codemode-rust/conformance/cases/repl-undefined.js create mode 100644 packages/codemode-rust/conformance/cases/repl-undefined.json create mode 100644 packages/codemode-rust/conformance/cases/runtime-type-error.js create mode 100644 packages/codemode-rust/conformance/cases/runtime-type-error.json create mode 100644 packages/codemode-rust/conformance/cases/spread-rest.js create mode 100644 packages/codemode-rust/conformance/cases/spread-rest.json create mode 100644 packages/codemode-rust/conformance/cases/string-from-char-code.js create mode 100644 packages/codemode-rust/conformance/cases/string-from-char-code.json create mode 100644 packages/codemode-rust/conformance/cases/string-methods.js create mode 100644 packages/codemode-rust/conformance/cases/string-methods.json create mode 100644 packages/codemode-rust/conformance/cases/switch.js create mode 100644 packages/codemode-rust/conformance/cases/switch.json create mode 100644 packages/codemode-rust/conformance/cases/template-literals.js create mode 100644 packages/codemode-rust/conformance/cases/template-literals.json create mode 100644 packages/codemode-rust/conformance/cases/throw-errors.js create mode 100644 packages/codemode-rust/conformance/cases/throw-errors.json create mode 100644 packages/codemode-rust/conformance/cases/throw-values.js create mode 100644 packages/codemode-rust/conformance/cases/throw-values.json create mode 100644 packages/codemode-rust/conformance/cases/tool-calls.js create mode 100644 packages/codemode-rust/conformance/cases/tool-calls.json create mode 100644 packages/codemode-rust/conformance/cases/tool-concurrent.js create mode 100644 packages/codemode-rust/conformance/cases/tool-concurrent.json create mode 100644 packages/codemode-rust/conformance/cases/tool-result-copy.js create mode 100644 packages/codemode-rust/conformance/cases/tool-result-copy.json create mode 100644 packages/codemode-rust/conformance/cases/try-catch-finally.js create mode 100644 packages/codemode-rust/conformance/cases/try-catch-finally.json create mode 100644 packages/codemode-rust/conformance/cases/typeof.js create mode 100644 packages/codemode-rust/conformance/cases/typeof.json create mode 100644 packages/codemode-rust/conformance/cases/var-hoisting.js create mode 100644 packages/codemode-rust/conformance/cases/var-hoisting.json create mode 100644 packages/codemode-rust/conformance/generate.ts create mode 100644 packages/codemode-rust/crates/psychoscript/Cargo.toml create mode 100644 packages/codemode-rust/crates/psychoscript/examples/run.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/builtins/array.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/builtins/collections.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/builtins/mod.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/builtins/object.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/builtins/string.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/bytecode.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/compiler.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/convert.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/lib.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/object.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/ops.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/promise.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/run.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/strings.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/value.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/vm.rs create mode 100644 packages/codemode-rust/crates/psychoscript/tests/api.rs diff --git a/.oxlintrc.json b/.oxlintrc.json index 0ad3ae0a5cc8..f45d737de583 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -216,6 +216,7 @@ "**/*.d.ts", "**/sdk.gen.ts", "packages/plugins/figma/skills/**", + "packages/codemode-rust/conformance/cases/**", ".agent/**", ".agents/**", ".claude/**", diff --git a/packages/codemode-rust/.gitignore b/packages/codemode-rust/.gitignore new file mode 100644 index 000000000000..2f7896d1d136 --- /dev/null +++ b/packages/codemode-rust/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md new file mode 100644 index 000000000000..c798c9a08a33 --- /dev/null +++ b/packages/codemode-rust/AGENTS.md @@ -0,0 +1,23 @@ +# PsychoScript (Rust) + +A Rust port of OpenCode's Code Mode (`packages/codemode` in anomalyco/opencode, the reference implementation), embeddable in Rust programs with no Bun, Node or other JavaScript engine at build or run time. + +## Scope: minimal, targeted + +In scope: + +- The language subset needed by the nine reference benchmark programs (`conformance/cases/bench-*`), the plugin reducer example, and the other conformance cases. +- Pipeline: parse → compile to bytecode → stack VM. Values cross the host boundary as JSON copies (`serde_json::Value`), never shared. +- Host API in `crates/psychoscript/src/lib.rs`: synchronous tools at dotted paths, JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. + +Out of scope: classes (rejected, like the reference), `export`/modules/`import`, snapshots and suspend/resume, OpenAPI tools, Effect integration, extensions/globals, async host tools, `search`, RegExp, URL, Date, BigInt, Symbol beyond iterators, test262 parity. + +## Rules + +- Functional style at the API: plugins are programs over data, not objects. Do not add classes to the language. +- Unsupported syntax returns `UnsupportedSyntax` with a location; never panic on user input. +- No `unsafe` unless measured and justified in a comment. +- Dependencies: pure Rust only, and few. Justify each in the commit that adds it. +- `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` must pass. +- Benchmark claims need the command, machine and numbers in `bench/RESULTS.md`. +- Nothing in the repo mentions internal tooling, private chats, home paths, hostnames or secrets. diff --git a/packages/codemode-rust/Cargo.lock b/packages/codemode-rust/Cargo.lock new file mode 100644 index 000000000000..f8c103572786 --- /dev/null +++ b/packages/codemode-rust/Cargo.lock @@ -0,0 +1,881 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "compact_str" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79fcda08c33bb58b97008b2cdada6622500e949e060f5913361763121abd2416" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "static_assertions", + "zmij", +] + +[[package]] +name = "cow-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417bef24afe1460300965a25ff4a24b8b45ad011948302ec221e8a0a81eb2c79" + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "serde", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b195dc605f81aa181bec9b3bd14e26cc71b903e4644f6af578ca9772c7a710" +dependencies = [ + "icu_collections", + "icu_locale_fallback", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "smallvec", + "utf8_iter", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913a7d294ad056474749152107309fdee3ec17d2482d1ab70fdc61a81c64b9a3" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "nonmax" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" + +[[package]] +name = "num-bigint" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oxc_allocator" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf8c5fa53291fec5f52e179974cc58cd002e45eab0defdbdfb6b36a1809c9ef" +dependencies = [ + "allocator-api2", + "hashbrown", + "oxc_data_structures", + "rustc-hash", +] + +[[package]] +name = "oxc_ast" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac049e885e553878688ca583184cc2b8de02177914328f59616e59ffc224f" +dependencies = [ + "bitflags", + "oxc_allocator", + "oxc_ast_macros", + "oxc_data_structures", + "oxc_diagnostics", + "oxc_estree", + "oxc_regular_expression", + "oxc_span", + "oxc_str", + "oxc_syntax", +] + +[[package]] +name = "oxc_ast_macros" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb36e1df5e540ebd898865ed79ffd8d8f9e06310521dc0d8e5b9cc4567fc6739" +dependencies = [ + "phf", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "oxc_ast_visit" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a019293646229f79954cf7c5d022a13324c84e1b874e8ce030c8e7c0a56e5b0f" +dependencies = [ + "oxc_allocator", + "oxc_ast", + "oxc_span", + "oxc_syntax", +] + +[[package]] +name = "oxc_data_structures" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8932e4c5ad3c6973548bf2f7750b778315012ecd7086617721d23f17b43e5a55" + +[[package]] +name = "oxc_diagnostics" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901588f26a8f1e7a0a8f7ebab60bf311bc9a1d22935e740a1b545c33b020f29f" +dependencies = [ + "bytecount", + "cow-utils", + "itoa", + "memchr", + "oxc_span", + "percent-encoding", + "smallvec", + "textwrap", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "oxc_ecmascript" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4127c1685ec3e85c34bcbe9b4055b1ce34bc0e2614c4bf5cf56c52a5424c7fc5" +dependencies = [ + "itoa", + "memchr", + "num-bigint", + "num-traits", + "oxc_ast", + "oxc_data_structures", + "oxc_span", + "oxc_str", + "oxc_syntax", + "zmij_ecma", +] + +[[package]] +name = "oxc_estree" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c806bed591dc97e36678eeaaccb6e85ecc21766eaf6f8a77e7a261a4457a2c" + +[[package]] +name = "oxc_index" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "191884bee6c3744909a51acc7d78d4ae370d817b25875b10642f632327b6296e" +dependencies = [ + "nonmax", + "serde", +] + +[[package]] +name = "oxc_parser" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fd93cb9811da8634acfd28a864889d1bf68bce2c546a52372205afabd4a63e7" +dependencies = [ + "bitflags", + "cow-utils", + "memchr", + "num-bigint", + "num-traits", + "oxc_allocator", + "oxc_ast", + "oxc_data_structures", + "oxc_diagnostics", + "oxc_ecmascript", + "oxc_span", + "oxc_str", + "oxc_syntax", + "rustc-hash", + "seq-macro", +] + +[[package]] +name = "oxc_regular_expression" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85fe16e0f852ba1b1085f08efec7b9d611ecaba1851ca6fecb7f91b09631714" +dependencies = [ + "bitflags", + "oxc_allocator", + "oxc_ast_macros", + "oxc_data_structures", + "oxc_diagnostics", + "oxc_span", + "oxc_str", + "phf", + "rustc-hash", + "unicode-id-start", +] + +[[package]] +name = "oxc_semantic" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61b34d4fb57e1f91ed099708e09b7450960d34d3a706ee84be55f821da27021" +dependencies = [ + "itertools", + "memchr", + "oxc_allocator", + "oxc_ast", + "oxc_ast_visit", + "oxc_data_structures", + "oxc_diagnostics", + "oxc_ecmascript", + "oxc_index", + "oxc_span", + "oxc_str", + "oxc_syntax", + "rustc-hash", + "self_cell", + "smallvec", +] + +[[package]] +name = "oxc_span" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bb9aed024358d262b9daab20b7aa7ae89b42946e549b52ff92ddfef033d0e1" +dependencies = [ + "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", +] + +[[package]] +name = "oxc_str" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b51303dd938569998ad07110fff48d76da59cfe47748a39833c4652424babb4" +dependencies = [ + "compact_str", + "hashbrown", + "memchr", + "oxc_allocator", + "oxc_estree", + "oxc_span", +] + +[[package]] +name = "oxc_syntax" +version = "0.159.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f832591474dac1e451b6619d9e9d6187f08445d9d73c47b331dedc34439eb81" +dependencies = [ + "bitflags", + "cow-utils", + "nonmax", + "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", + "oxc_index", + "oxc_span", + "oxc_str", + "phf", + "unicode-id-start", + "zmij_ecma", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" +dependencies = [ + "phf_macros", + "phf_shared", + "serde", +] + +[[package]] +name = "phf_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" +dependencies = [ + "fastrand", + "phf_shared", +] + +[[package]] +name = "phf_macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" +dependencies = [ + "siphasher", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "serde_core", + "writeable", + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psychoscript" +version = "0.1.0" +dependencies = [ + "oxc_allocator", + "oxc_ast", + "oxc_ast_visit", + "oxc_diagnostics", + "oxc_parser", + "oxc_semantic", + "oxc_span", + "oxc_str", + "oxc_syntax", + "rustc-hash", + "serde_json", +] + +[[package]] +name = "psychoscript-bench" +version = "0.0.0" +dependencies = [ + "psychoscript", + "serde_json", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "foldhash", + "indexmap", + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" +dependencies = [ + "serde", +] + +[[package]] +name = "smawk" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e2fb0f499abb4d162f2bedad68f5ef91a1682b5a03596ddb67efd37768d100" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "textwrap" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ecfad6c3abc80a577f2b91c1e412ee57e7a060d430b553c1b0c940974ebcd49" +dependencies = [ + "icu_segmenter", + "smawk", + "unicode-width", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "serde_core", + "zerovec", +] + +[[package]] +name = "unicode-id-start" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0825d2e09dcae814a4273c1e1435979d414ede25b2ee235b1545da6682483765" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zmij_ecma" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458b3e7a977f14499066b6bdb63d69da30ce337d6c160f077e6c575c82a44db9" diff --git a/packages/codemode-rust/Cargo.toml b/packages/codemode-rust/Cargo.toml new file mode 100644 index 000000000000..158b6353d9aa --- /dev/null +++ b/packages/codemode-rust/Cargo.toml @@ -0,0 +1,11 @@ +[workspace] +resolver = "3" +members = ["crates/psychoscript", "bench"] + +[workspace.package] +edition = "2024" +license = "MIT" + +[profile.release] +lto = "thin" +codegen-units = 1 diff --git a/packages/codemode-rust/bench/Cargo.toml b/packages/codemode-rust/bench/Cargo.toml new file mode 100644 index 000000000000..490d4320ecc0 --- /dev/null +++ b/packages/codemode-rust/bench/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "psychoscript-bench" +version = "0.0.0" +edition.workspace = true +publish = false + +[dependencies] +psychoscript = { path = "../crates/psychoscript" } +serde_json = { version = "1", features = ["float_roundtrip"] } diff --git a/packages/codemode-rust/bench/RESULTS.md b/packages/codemode-rust/bench/RESULTS.md new file mode 100644 index 000000000000..c0d11842c63f --- /dev/null +++ b/packages/codemode-rust/bench/RESULTS.md @@ -0,0 +1,71 @@ +# Benchmark results + +Generated by `bench/compare.sh` on 2026-11-17. "n/a" means the Rust side could not run the case. + +## Environment + +- CPU: AMD EPYC 9554P 64-Core Processor, 8 cores, 31 GiB RAM, Linux 6.12.115 +- Reference: anomalyco/opencode 95b0de8aa3154c293bccd7d5b324e2b44dac4ad8, `packages/codemode` +- PsychoScript: 95b0de8aa3154c293bccd7d5b324e2b44dac4ad8 +- bun 1.4.4; rustc 1.100.0 (0ef1bc386 2026-11-09); cargo 1.100.0 (3acc79c0c 2026-11-05) + +## (a) Per-case wall time, 11 iterations after one warm-up + +| Case | Reference median ms | Reference min ms | Rust median ms | Rust min ms | Median speedup | +| -------------------------- | ------------------: | ---------------: | -------------: | ----------: | -------------: | +| numeric loop | 19.8 | 14.4 | 14.2 | 10.0 | 1.4x | +| closure recursion (fib 22) | 5.2 | 4.8 | 4.8 | 3.4 | 1.1x | +| array callbacks (50k) | 87.0 | 84.1 | 24.4 | 23.5 | 3.6x | +| promise fan-out (5k) | 11.8 | 7.5 | 2.8 | 2.8 | 4.2x | +| tool fan-out (1k) | 8.9 | 8.1 | 0.6 | 0.6 | 14.9x | +| JSON round-trip | 52.3 | 48.6 | 23.5 | 23.0 | 2.2x | +| generator iteration | 5.5 | 5.0 | 6.4 | 4.6 | 0.9x | +| string building | 18.4 | 15.8 | 11.6 | 7.3 | 1.6x | +| Map/Set ops | 15.9 | 13.8 | 13.5 | 13.2 | 1.2x | + +## (b) Cold start: process start to the result of `return 1` + +| Implementation | Median wall ms (20 runs) | +| ---------------------------------- | -----------------------: | +| Reference (bun bench/ref/embed.ts) | 165.5 | +| Rust (embed example) | 1.1 | + +## (c) Peak RSS, each case once in a fresh process + +| Case | Reference peak RSS MiB | Rust peak RSS MiB | +| -------------------------- | ---------------------: | ----------------: | +| numeric loop | 84.2 | 3.9 | +| closure recursion (fib 22) | 82.5 | 4.0 | +| array callbacks (50k) | 99.3 | 6.8 | +| promise fan-out (5k) | 94.2 | 8.6 | +| tool fan-out (1k) | 89.6 | 5.1 | +| JSON round-trip | 118.7 | 20.2 | +| generator iteration | 82.8 | 4.1 | +| string building | 108.8 | 7.1 | +| Map/Set ops | 97.3 | 8.3 | + +## (d) Binary size + +| Artifact | Bytes | MiB | +| ---------------------------------------- | --------: | -----: | +| Rust embed example, release, stripped | 2139576 | 2.04 | +| bun executable (what you ship otherwise) | 107308936 | 102.34 | + +## Commands + +```sh +bash bench/compare.sh # reference at ../codemode, or CODEMODE_REF= +cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed +# (a) +(cd ../codemode && bun run script/bench.ts --iterations 11) +target/release/psychoscript-bench --filter --iterations 11 --json +# (b) 20 timed runs each after one untimed run, wall time from bash $EPOCHREALTIME +bun bench/ref/embed.ts +target/release/examples/embed +# (c) +/usr/bin/time -v bun bench/ref/run-case.ts +/usr/bin/time -v target/release/psychoscript-bench --filter --iterations 0 +# (d) +strip -o embed target/release/examples/embed && stat -c %s embed +stat -c %s "$(readlink -f "$(command -v bun)")" +``` diff --git a/packages/codemode-rust/bench/baseline/meta.txt b/packages/codemode-rust/bench/baseline/meta.txt new file mode 100644 index 000000000000..9c7eb605628e --- /dev/null +++ b/packages/codemode-rust/bench/baseline/meta.txt @@ -0,0 +1,5 @@ +command: cd packages/codemode && bun run script/bench.ts --iterations 11 +reference: anomalyco/opencode a9a35b4b4ce35573d71207e246e770cfa26ff0e1 +bun: 1.4.4 +cpu: AMD EPYC 9554P 64-Core Processor, 8 cores +date: 2026-11-17 diff --git a/packages/codemode-rust/bench/baseline/reference-bench.txt b/packages/codemode-rust/bench/baseline/reference-bench.txt new file mode 100644 index 000000000000..fc577a8a39e1 --- /dev/null +++ b/packages/codemode-rust/bench/baseline/reference-bench.txt @@ -0,0 +1,9 @@ +numeric loop 15.2 ms (min 14.2 ms) +closure recursion (fib 22) 5.2 ms (min 4.9 ms) +array callbacks (50k) 85.0 ms (min 81.2 ms) +promise fan-out (5k) 11.1 ms (min 9.1 ms) +tool fan-out (1k) 10.7 ms (min 8.7 ms) +JSON round-trip 54.6 ms (min 48.4 ms) +generator iteration 5.2 ms (min 5.1 ms) +string building 18.5 ms (min 15.3 ms) +Map/Set ops 20.6 ms (min 14.0 ms) diff --git a/packages/codemode-rust/bench/compare.sh b/packages/codemode-rust/bench/compare.sh new file mode 100644 index 000000000000..6000e6f4d37e --- /dev/null +++ b/packages/codemode-rust/bench/compare.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +# Measures PsychoScript against the reference CodeMode and writes bench/RESULTS.md. +# Usage: bash bench/compare.sh. The reference CodeMode package is ../codemode relative to this workspace; set +# CODEMODE_REF to another package directory to override it. +# Needs bun, cargo, jq, strip and /usr/bin/time. Rust columns read "n/a" while the core cannot run a case. +set -uo pipefail +[ -n "${CODEMODE_REF:-}" ] && CODEMODE_REF=$(cd "$CODEMODE_REF" && pwd) +cd "$(dirname "$0")/.." +REF_PKG=${CODEMODE_REF:-../codemode} +[ -f "$REF_PKG/script/bench.ts" ] || { echo "reference CodeMode package not found at $REF_PKG" >&2; exit 1; } +ITERATIONS=${ITERATIONS:-11} +COLD_RUNS=${COLD_RUNS:-20} +OUT=bench/RESULTS.md +TMP=$(mktemp -d) +trap 'rm -rf "$TMP"' EXIT + +SLUGS=(numeric-loop closure-recursion array-callbacks promise-fan-out tool-fan-out json-round-trip generator-iteration string-building map-set-ops) +NAMES=("numeric loop" "closure recursion (fib 22)" "array callbacks (50k)" "promise fan-out (5k)" "tool fan-out (1k)" "JSON round-trip" "generator iteration" "string building" "Map/Set ops") +BENCH=target/release/psychoscript-bench +EMBED=target/release/examples/embed + +median() { sort -g | awk '{ v[NR] = $1 } END { print v[int(NR / 2) + 1] }'; } +fmt() { [ -n "$1" ] && printf '%.1f' "$1" || printf 'n/a'; } + +echo "building release binaries" >&2 +cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed >&2 || echo "Rust build failed" >&2 + +# (a) Per-case median and min. +echo "(a) reference bench" >&2 +(cd "$REF_PKG" && bun run script/bench.ts --iterations "$ITERATIONS") >"$TMP/ref-bench.txt" +ref_field() { # name, field (1 = median, 2 = min) + grep -F "$1 " "$TMP/ref-bench.txt" | sed -E 's/.* ([0-9.]+) ms \(min ([0-9.]+) ms\).*/\1 \2/' | cut -d' ' -f"$2" +} +TABLE_A="| Case | Reference median ms | Reference min ms | Rust median ms | Rust min ms | Median speedup | +|---|---:|---:|---:|---:|---:|" +for i in "${!SLUGS[@]}"; do + slug=${SLUGS[$i]} name=${NAMES[$i]} + echo "(a) rust $slug" >&2 + rm_med="" rm_min="" + if [ -x "$BENCH" ] && "$BENCH" --filter "$slug" --iterations "$ITERATIONS" --json >"$TMP/rust-$slug.json" 2>/dev/null; then + rm_med=$(jq '.[0].median_ms' "$TMP/rust-$slug.json") rm_min=$(jq '.[0].min_ms' "$TMP/rust-$slug.json") + fi + r_med=$(ref_field "$name" 1) r_min=$(ref_field "$name" 2) + speedup=n/a + [ -n "$rm_med" ] && speedup=$(awk -v r="$r_med" -v s="$rm_med" 'BEGIN { printf "%.1fx", r / s }') + TABLE_A+=" +| $name | $r_med | $r_min | $(fmt "$rm_med") | $(fmt "$rm_min") | $speedup |" +done + +# (b) Cold start: process start to a printed result for `return 1`, median of COLD_RUNS processes. +cold() { # command... + "$@" >/dev/null 2>&1 || return 1 + for _ in $(seq "$COLD_RUNS"); do + local start=$EPOCHREALTIME + "$@" >/dev/null 2>&1 || return 1 + awk -v a="$start" -v b="$EPOCHREALTIME" 'BEGIN { printf "%.3f\n", (b - a) * 1000 }' + done +} +echo "(b) cold start" >&2 +ref_cold=$(cold bun bench/ref/embed.ts | median) +rust_cold="" +[ -x "$EMBED" ] && rust_cold=$(cold "$EMBED" | median) +TABLE_B="| Implementation | Median wall ms ($COLD_RUNS runs) | +|---|---:| +| Reference (bun bench/ref/embed.ts) | $(fmt "$ref_cold") | +| Rust (embed example) | $(fmt "$rust_cold") |" + +# (c) Peak RSS per case, each case once in a fresh process. +rss() { # command... -> MiB + /usr/bin/time -v "$@" 2>"$TMP/time.txt" >/dev/null || return 1 + awk -F': ' '/Maximum resident set size/ { printf "%.1f\n", $2 / 1024 }' "$TMP/time.txt" +} +echo "(c) peak RSS" >&2 +TABLE_C="| Case | Reference peak RSS MiB | Rust peak RSS MiB | +|---|---:|---:|" +for i in "${!SLUGS[@]}"; do + slug=${SLUGS[$i]} + ref_rss=$(rss bun bench/ref/run-case.ts "$slug") + rust_rss="" + [ -x "$BENCH" ] && rust_rss=$(rss "$BENCH" --filter "$slug" --iterations 0) + TABLE_C+=" +| ${NAMES[$i]} | $(fmt "$ref_rss") | $(fmt "$rust_rss") |" +done + +# (d) Shipped size, once the embed example runs. +BUN_BIN=$(readlink -f "$(command -v bun)") +bun_size=$(stat -c %s "$BUN_BIN") +mib() { awk -v b="$1" 'BEGIN { printf "%.2f", b / 1048576 }'; } +embed_row="| Rust embed example, release, stripped | n/a | n/a |" +if [ -x "$EMBED" ] && "$EMBED" >/dev/null 2>&1; then + strip -o "$TMP/embed" "$EMBED" + embed_size=$(stat -c %s "$TMP/embed") + embed_row="| Rust embed example, release, stripped | $embed_size | $(mib "$embed_size") |" +fi +TABLE_D="| Artifact | Bytes | MiB | +|---|---:|---:| +$embed_row +| bun executable (what you ship otherwise) | $bun_size | $(mib "$bun_size") |" + +CPU=$(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2 | sed 's/^ //') +MEM=$(awk '/MemTotal/ { printf "%.0f GiB", $2 / 1048576 }' /proc/meminfo) +cat >"$OUT" < +cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed +# (a) +(cd ../codemode && bun run script/bench.ts --iterations $ITERATIONS) +target/release/psychoscript-bench --filter --iterations $ITERATIONS --json +# (b) $COLD_RUNS timed runs each after one untimed run, wall time from bash \$EPOCHREALTIME +bun bench/ref/embed.ts +target/release/examples/embed +# (c) +/usr/bin/time -v bun bench/ref/run-case.ts +/usr/bin/time -v target/release/psychoscript-bench --filter --iterations 0 +# (d) +strip -o embed target/release/examples/embed && stat -c %s embed +stat -c %s "\$(readlink -f "\$(command -v bun)")" +\`\`\` +EOF +echo "wrote $OUT" >&2 diff --git a/packages/codemode-rust/bench/examples/embed.rs b/packages/codemode-rust/bench/examples/embed.rs new file mode 100644 index 000000000000..b7623ff1121a --- /dev/null +++ b/packages/codemode-rust/bench/examples/embed.rs @@ -0,0 +1,21 @@ +//! Minimal embedding: one tool, one program, print the result. + +use psychoscript::Runtime; + +fn main() { + let runtime = Runtime::new().tool("echo", |input| Ok(input.clone())); + let code = std::env::args() + .nth(1) + .unwrap_or_else(|| "return 1".to_owned()); + let outcome = runtime.execute(&code, &serde_json::Map::new()); + for line in &outcome.logs { + eprintln!("{line}"); + } + match outcome.result { + Ok(value) => println!("{value}"), + Err(d) => { + eprintln!("{:?}: {}", d.kind, d.message); + std::process::exit(1); + } + } +} diff --git a/packages/codemode-rust/bench/ref/embed.ts b/packages/codemode-rust/bench/ref/embed.ts new file mode 100644 index 000000000000..d70ce34bc9ec --- /dev/null +++ b/packages/codemode-rust/bench/ref/embed.ts @@ -0,0 +1,24 @@ +// Reference counterpart of bench/examples/embed.rs. Usage: bun bench/ref/embed.ts [code] +import { resolve } from "node:path" + +// The reference CodeMode package: CODEMODE_REF, or by default ../codemode relative to this workspace. + +const pkg = + process.env.CODEMODE_REF === undefined + ? resolve(import.meta.dir, "../../../codemode") + : resolve(process.env.CODEMODE_REF) +const { Effect, Schema } = await import(Bun.resolveSync("effect", resolve(pkg, "src"))) +const { CodeMode, Tool } = await import(resolve(pkg, "src/index.ts")) + +const runtime = CodeMode.make({ + tools: { + echo: Tool.make({ description: "Echo", input: Schema.Unknown, output: Schema.Unknown, execute: Effect.succeed }), + }, +}) +const result = await Effect.runPromise(runtime.execute(process.argv[2] ?? "return 1")) +for (const line of result.logs ?? []) console.error(line) +if (!result.ok) { + console.error(`${result.error.kind}: ${result.error.message}`) + process.exit(1) +} +console.log(JSON.stringify(result.value)) diff --git a/packages/codemode-rust/bench/ref/run-case.ts b/packages/codemode-rust/bench/ref/run-case.ts new file mode 100644 index 000000000000..9b5e5af7d8b6 --- /dev/null +++ b/packages/codemode-rust/bench/ref/run-case.ts @@ -0,0 +1,26 @@ +// Runs one bench case once through the reference, for one-shot measurements such as peak RSS. +// Usage: bun bench/ref/run-case.ts +import { resolve } from "node:path" + +// The reference CodeMode package: CODEMODE_REF, or by default ../codemode relative to this workspace. + +const pkg = + process.env.CODEMODE_REF === undefined + ? resolve(import.meta.dir, "../../../codemode") + : resolve(process.env.CODEMODE_REF) +const { Effect, Schema } = await import(Bun.resolveSync("effect", resolve(pkg, "src"))) +const { CodeMode, Tool } = await import(resolve(pkg, "src/index.ts")) + +const runtime = CodeMode.make({ + tools: { + echo: Tool.make({ + description: "Echo an id", + input: Schema.Struct({ id: Schema.Number }), + output: Schema.Number, + execute: ({ id }: { id: number }) => Effect.succeed(id), + }), + }, +}) +const code = await Bun.file(resolve(import.meta.dir, `../../conformance/cases/bench-${process.argv[2]}.js`)).text() +const result = await Effect.runPromise(runtime.execute(code)) +if (!result.ok) throw new Error(`${process.argv[2]} failed: ${JSON.stringify(result)}`) diff --git a/packages/codemode-rust/bench/src/main.rs b/packages/codemode-rust/bench/src/main.rs new file mode 100644 index 000000000000..5cd9cb47cb92 --- /dev/null +++ b/packages/codemode-rust/bench/src/main.rs @@ -0,0 +1,82 @@ +//! Interpreter benchmarks, mirroring the reference `script/bench.ts`: median and fastest wall-clock milliseconds per +//! program. Each iteration calls `execute` on the source, with one warm-up run that also checks the program succeeds. +//! Usage: psychoscript-bench [--iterations N] [--filter name] [--json] [--cases DIR] +//! `--iterations 0` runs only the warm-up, for one-shot measurements such as peak RSS. + +use std::path::PathBuf; +use std::time::Instant; + +use psychoscript::{Json, Runtime}; + +/// Case files and reference names, in the reference order. +const CASES: [(&str, &str); 9] = [ + ("numeric-loop", "numeric loop"), + ("closure-recursion", "closure recursion (fib 22)"), + ("array-callbacks", "array callbacks (50k)"), + ("promise-fan-out", "promise fan-out (5k)"), + ("tool-fan-out", "tool fan-out (1k)"), + ("json-round-trip", "JSON round-trip"), + ("generator-iteration", "generator iteration"), + ("string-building", "string building"), + ("map-set-ops", "Map/Set ops"), +]; + +fn main() { + let mut iterations = 11usize; + let mut filter = String::new(); + let mut json = false; + let mut dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../conformance/cases"); + let mut args = std::env::args().skip(1); + while let Some(arg) = args.next() { + match arg.as_str() { + "--iterations" => { + iterations = args + .next() + .and_then(|n| n.parse().ok()) + .expect("--iterations N") + } + "--filter" => filter = args.next().expect("--filter name"), + "--json" => json = true, + "--cases" => dir = args.next().expect("--cases DIR").into(), + other => panic!("unknown argument {other}"), + } + } + + let runtime = Runtime::new().tool("echo", |input| { + Ok(input.get("id").cloned().unwrap_or(Json::Null)) + }); + let bindings = serde_json::Map::new(); + let mut report = Vec::new(); + for (slug, name) in CASES { + if !(slug.contains(&filter) || name.contains(&filter)) { + continue; + } + let path = dir.join(format!("bench-{slug}.js")); + let code = + std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); + if let Err(d) = runtime.execute(&code, &bindings).result { + panic!("{name} failed: {d:?}"); + } + let times: Vec = (0..iterations) + .map(|_| { + let start = Instant::now(); + let _ = runtime.execute(&code, &bindings); + start.elapsed().as_secs_f64() * 1e3 + }) + .collect(); + if times.is_empty() { + continue; + } + let mut sorted = times.clone(); + sorted.sort_by(f64::total_cmp); + let (median, min) = (sorted[sorted.len() / 2], sorted[0]); + if json { + report.push(serde_json::json!({ "slug": slug, "name": name, "median_ms": median, "min_ms": min, "times_ms": times })); + } else { + println!("{name:<28} {median:>8.1} ms (min {min:.1} ms)"); + } + } + if json { + println!("{}", Json::from(report)); + } +} diff --git a/packages/codemode-rust/bench/tests/conformance.rs b/packages/codemode-rust/bench/tests/conformance.rs new file mode 100644 index 000000000000..2bc8ad442c9b --- /dev/null +++ b/packages/codemode-rust/bench/tests/conformance.rs @@ -0,0 +1,162 @@ +//! Runs every `conformance/cases/.js` through `psychoscript::Runtime` and compares it with the reference outcome +//! in `.json`. Reports every failing case at once. `CONFORMANCE_FILTER=` narrows the run. + +use std::panic::{self, AssertUnwindSafe}; +use std::path::Path; + +use psychoscript::{DiagnosticKind, Json, Limits, Runtime}; + +fn runtime(limits: Limits) -> Runtime { + Runtime::new() + .tool("echo", |input| { + Ok(input.get("id").cloned().unwrap_or(Json::Null)) + }) + .tool("fail", |_| Err("boom".to_owned())) + .tool("git.status", |_| { + Ok(serde_json::json!({ "branch": "main", "dirty": true })) + }) + .limits(limits) +} + +fn kind_name(kind: DiagnosticKind) -> &'static str { + match kind { + DiagnosticKind::ParseError => "ParseError", + DiagnosticKind::UnsupportedSyntax => "UnsupportedSyntax", + DiagnosticKind::UnknownTool => "UnknownTool", + DiagnosticKind::InvalidDataValue => "InvalidDataValue", + DiagnosticKind::ToolCallLimitExceeded => "ToolCallLimitExceeded", + DiagnosticKind::TimeoutExceeded => "TimeoutExceeded", + DiagnosticKind::ToolFailure => "ToolFailure", + DiagnosticKind::ExecutionFailure => "ExecutionFailure", + } +} + +/// JSON equality where numbers compare by value, so `3` equals `3.0`. +fn same(a: &Json, b: &Json) -> bool { + match (a, b) { + (Json::Number(x), Json::Number(y)) => x.as_f64() == y.as_f64(), + (Json::Array(x), Json::Array(y)) => { + x.len() == y.len() && x.iter().zip(y).all(|(x, y)| same(x, y)) + } + (Json::Object(x), Json::Object(y)) => { + x.len() == y.len() + && x.iter() + .zip(y) + .all(|((kx, vx), (ky, vy))| kx == ky && same(vx, vy)) + } + _ => a == b, + } +} + +fn check(name: &str, code: &str, expected: &Json) -> Result<(), String> { + let bindings = expected["bindings"] + .as_object() + .cloned() + .unwrap_or_default(); + let limits = Limits { + max_tool_calls: expected["limits"]["max_tool_calls"].as_u64(), + timeout_ms: expected["limits"]["timeout_ms"].as_u64(), + max_output_bytes: None, + }; + let rt = runtime(limits); + let outcome = panic::catch_unwind(AssertUnwindSafe(|| rt.execute(code, &bindings))).map_err( + |payload| { + let msg = payload + .downcast_ref::() + .cloned() + .or_else(|| payload.downcast_ref::<&str>().map(|s| (*s).to_owned())) + .unwrap_or_default(); + format!("{name}: panicked: {msg}") + }, + )?; + + let mut problems = Vec::new(); + match (&outcome.result, expected["ok"].as_bool()) { + (Ok(value), Some(true)) => { + if !same(value, &expected["value"]) { + problems.push(format!( + "value\n expected: {}\n actual: {value}", + expected["value"] + )); + } + } + (Err(d), Some(false)) => { + if kind_name(d.kind) != expected["kind"] { + problems.push(format!( + "kind: expected {}, got {} ({})", + expected["kind"], + kind_name(d.kind), + d.message + )); + } + } + (Ok(value), _) => problems.push(format!( + "expected {} error, got ok: {value}", + expected["kind"] + )), + (Err(d), _) => problems.push(format!( + "expected ok {}, got {}: {}", + expected["value"], + kind_name(d.kind), + d.message + )), + } + if let Some(logs) = expected.get("logs") { + let actual = Json::from(outcome.logs.clone()); + if !same(&actual, logs) { + problems.push(format!( + "logs\n expected: {logs}\n actual: {actual}" + )); + } + } + if problems.is_empty() { + Ok(()) + } else { + Err(format!("{name}: {}", problems.join("\n "))) + } +} + +#[test] +fn conformance() { + let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../conformance/cases"); + let filter = std::env::var("CONFORMANCE_FILTER").unwrap_or_default(); + let mut names: Vec = std::fs::read_dir(&dir) + .expect("conformance/cases") + .filter_map(|e| { + e.ok()? + .file_name() + .into_string() + .ok()? + .strip_suffix(".js") + .map(str::to_owned) + }) + .filter(|n| n.contains(&filter)) + .collect(); + names.sort(); + assert!(!names.is_empty(), "no conformance cases matched"); + + let hook = panic::take_hook(); + panic::set_hook(Box::new(|_| {})); + let failures: Vec = names + .iter() + .filter_map(|name| { + let code = std::fs::read_to_string(dir.join(format!("{name}.js"))).unwrap(); + let expected: Json = serde_json::from_str( + &std::fs::read_to_string(dir.join(format!("{name}.json"))).unwrap(), + ) + .unwrap(); + check(name, &code, &expected).err() + }) + .collect(); + panic::set_hook(hook); + + if !failures.is_empty() { + panic!( + "{} of {} conformance cases failed:\n{}", + failures.len(), + names.len(), + failures.join("\n") + ); + } + println!("{} conformance cases passed", names.len()); +} diff --git a/packages/codemode-rust/conformance/cases/array-basic-methods.js b/packages/codemode-rust/conformance/cases/array-basic-methods.js new file mode 100644 index 000000000000..f5d2cec94256 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-basic-methods.js @@ -0,0 +1,7 @@ +const a = [1, 2, 3] +a.push(4, 5) +const popped = a.pop() +a.unshift(0) +const shifted = a.shift() +const spliced = a.splice(1, 1, "x", "y") +return [a, popped, shifted, spliced, a.slice(1, 3), a.slice(-2), a.concat([9], 10), a.indexOf("x"), a.includes(4), a.join("-"), [3, 1, 2].reverse(), a.length, a.at(-1)] diff --git a/packages/codemode-rust/conformance/cases/array-basic-methods.json b/packages/codemode-rust/conformance/cases/array-basic-methods.json new file mode 100644 index 000000000000..2ac0a7079fed --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-basic-methods.json @@ -0,0 +1,46 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + 1, + "x", + "y", + 3, + 4 + ], + 5, + 0, + [ + 2 + ], + [ + "x", + "y" + ], + [ + 3, + 4 + ], + [ + 1, + "x", + "y", + 3, + 4, + 9, + 10 + ], + 1, + true, + "1-x-y-3-4", + [ + 2, + 1, + 3 + ], + 5, + 4 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/array-callback-methods.js b/packages/codemode-rust/conformance/cases/array-callback-methods.js new file mode 100644 index 000000000000..0b034a379df0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-callback-methods.js @@ -0,0 +1,4 @@ +const xs = [1, 2, 3, 4, 5] +const seen = [] +xs.forEach((x, i) => seen.push(x * i)) +return [xs.map((x) => x * 2), xs.filter((x) => x % 2), xs.reduce((a, b) => a + b), xs.reduce((a, b) => a + b, 10), xs.find((x) => x > 2), xs.findIndex((x) => x > 2), xs.find((x) => x > 9), xs.some((x) => x > 4), xs.every((x) => x > 0), xs.flatMap((x) => [x, x]), seen] diff --git a/packages/codemode-rust/conformance/cases/array-callback-methods.json b/packages/codemode-rust/conformance/cases/array-callback-methods.json new file mode 100644 index 000000000000..4ce43b72f128 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-callback-methods.json @@ -0,0 +1,45 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + 2, + 4, + 6, + 8, + 10 + ], + [ + 1, + 3, + 5 + ], + 15, + 25, + 3, + 2, + null, + true, + true, + [ + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 4, + 5, + 5 + ], + [ + 0, + 2, + 6, + 12, + 20 + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/array-construct.js b/packages/codemode-rust/conformance/cases/array-construct.js new file mode 100644 index 000000000000..ff496688656f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-construct.js @@ -0,0 +1 @@ +return [Array.from({ length: 3 }, (_, i) => i * i), Array.from("abc"), Array.from(new Set([1, 1, 2])), Array.isArray([]), Array.isArray("a"), new Array(3).fill(0), [[1, [2]], [3]].flat(), [1, 2, 3].lastIndexOf(3), Array.of(7, 8)] diff --git a/packages/codemode-rust/conformance/cases/array-construct.json b/packages/codemode-rust/conformance/cases/array-construct.json new file mode 100644 index 000000000000..963cf5b5295e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-construct.json @@ -0,0 +1,40 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + 0, + 1, + 4 + ], + [ + "a", + "b", + "c" + ], + [ + 1, + 2 + ], + true, + false, + [ + 0, + 0, + 0 + ], + [ + 1, + [ + 2 + ], + 3 + ], + 2, + [ + 7, + 8 + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/array-sort.js b/packages/codemode-rust/conformance/cases/array-sort.js new file mode 100644 index 000000000000..bfdde6119394 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-sort.js @@ -0,0 +1,4 @@ +const nums = [10, 1, 5, 100, 25] +const words = ["pear", "Apple", "fig", "banana"] +const people = [{ n: "a", age: 30 }, { n: "b", age: 20 }, { n: "c", age: 30 }, { n: "d", age: 20 }] +return [[...nums].sort(), [...nums].sort((a, b) => a - b), [...nums].sort((a, b) => b - a), [...words].sort(), people.sort((x, y) => x.age - y.age).map((p) => p.n)] diff --git a/packages/codemode-rust/conformance/cases/array-sort.json b/packages/codemode-rust/conformance/cases/array-sort.json new file mode 100644 index 000000000000..41dcb213ff2b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/array-sort.json @@ -0,0 +1,40 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + 1, + 10, + 100, + 25, + 5 + ], + [ + 1, + 5, + 10, + 25, + 100 + ], + [ + 100, + 25, + 10, + 5, + 1 + ], + [ + "Apple", + "banana", + "fig", + "pear" + ], + [ + "b", + "d", + "a", + "c" + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/arrow-functions.js b/packages/codemode-rust/conformance/cases/arrow-functions.js new file mode 100644 index 000000000000..9a4a94a418f1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/arrow-functions.js @@ -0,0 +1,4 @@ +const sq = (x) => x * x +const add = (a, b = 10) => { return a + b } +const obj = () => ({ k: 1 }) +return [sq(4), add(1), add(1, 2), obj()] diff --git a/packages/codemode-rust/conformance/cases/arrow-functions.json b/packages/codemode-rust/conformance/cases/arrow-functions.json new file mode 100644 index 000000000000..6766a30f8c17 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/arrow-functions.json @@ -0,0 +1,13 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 16, + 11, + 3, + { + "k": 1 + } + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/async-functions.js b/packages/codemode-rust/conformance/cases/async-functions.js new file mode 100644 index 000000000000..bbe8e6fbc7d5 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/async-functions.js @@ -0,0 +1,4 @@ +async function inc(x) { return x + 1 } +const p = inc(1) +const arrow = async (x) => (await inc(x)) * 10 +return [typeof p.then, await p, await arrow(2)] diff --git a/packages/codemode-rust/conformance/cases/async-functions.json b/packages/codemode-rust/conformance/cases/async-functions.json new file mode 100644 index 000000000000..b4c79c33cc53 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/async-functions.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "function", + 2, + 30 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/await-values.js b/packages/codemode-rust/conformance/cases/await-values.js new file mode 100644 index 000000000000..48a86cc4568b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/await-values.js @@ -0,0 +1,4 @@ +const a = await 1 +const b = await Promise.resolve(2) +const c = await (async () => 3)() +return a + b + c diff --git a/packages/codemode-rust/conformance/cases/await-values.json b/packages/codemode-rust/conformance/cases/await-values.json new file mode 100644 index 000000000000..ee611aaf81c1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/await-values.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 6, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-array-callbacks.js b/packages/codemode-rust/conformance/cases/bench-array-callbacks.js new file mode 100644 index 000000000000..d77ab70abcf4 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-array-callbacks.js @@ -0,0 +1,5 @@ +const items = Array.from({ length: 50000 }, (_, i) => (i * 7919) % 50000) +const mapped = items.map((x) => x * 2).filter((x) => x % 3 !== 0) +const total = mapped.reduce((a, b) => a + b, 0) +const sorted = mapped.slice(0, 20000).sort((a, b) => a - b) +return [total, sorted[0], sorted[sorted.length - 1]] diff --git a/packages/codemode-rust/conformance/cases/bench-array-callbacks.json b/packages/codemode-rust/conformance/cases/bench-array-callbacks.json new file mode 100644 index 000000000000..8bbf9e22a8c9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-array-callbacks.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1666633334, + 2, + 99992 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-closure-recursion.js b/packages/codemode-rust/conformance/cases/bench-closure-recursion.js new file mode 100644 index 000000000000..197eb49dd323 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-closure-recursion.js @@ -0,0 +1,2 @@ +const fib = (n) => (n < 2 ? n : fib(n - 1) + fib(n - 2)) +return fib(22) diff --git a/packages/codemode-rust/conformance/cases/bench-closure-recursion.json b/packages/codemode-rust/conformance/cases/bench-closure-recursion.json new file mode 100644 index 000000000000..0bcf4df382a9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-closure-recursion.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 17711, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-generator-iteration.js b/packages/codemode-rust/conformance/cases/bench-generator-iteration.js new file mode 100644 index 000000000000..015d7dd73fab --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-generator-iteration.js @@ -0,0 +1,4 @@ +function* range(n) { for (let i = 0; i < n; i++) yield i } +let sum = 0 +for (const x of range(50000)) sum += x +return sum diff --git a/packages/codemode-rust/conformance/cases/bench-generator-iteration.json b/packages/codemode-rust/conformance/cases/bench-generator-iteration.json new file mode 100644 index 000000000000..17fb5c743a21 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-generator-iteration.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 1249975000, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-json-round-trip.js b/packages/codemode-rust/conformance/cases/bench-json-round-trip.js new file mode 100644 index 000000000000..ee2910ff3657 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-json-round-trip.js @@ -0,0 +1,4 @@ +const make = (depth) => depth === 0 ? { a: 1, b: "two", c: [1, 2, 3], d: null } : { left: make(depth - 1), right: make(depth - 1), list: [depth, String(depth)] } +let size = 0 +for (let i = 0; i < 20; i++) size += JSON.stringify(JSON.parse(JSON.stringify(make(9)))).length +return size diff --git a/packages/codemode-rust/conformance/cases/bench-json-round-trip.json b/packages/codemode-rust/conformance/cases/bench-json-round-trip.json new file mode 100644 index 000000000000..64c2b74518f5 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-json-round-trip.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 726380, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-map-set-ops.js b/packages/codemode-rust/conformance/cases/bench-map-set-ops.js new file mode 100644 index 000000000000..bbb9c0736b30 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-map-set-ops.js @@ -0,0 +1,8 @@ +const map = new Map() +const set = new Set() +for (let i = 0; i < 30000; i++) { map.set("k" + (i % 5000), i); set.add(i % 7000) } +let sum = 0 +for (const [k, v] of map) sum += v +for (const v of set) sum += v +for (let i = 0; i < 5000; i++) { map.delete("k" + i); set.delete(i) } +return sum + map.size + set.size diff --git a/packages/codemode-rust/conformance/cases/bench-map-set-ops.json b/packages/codemode-rust/conformance/cases/bench-map-set-ops.json new file mode 100644 index 000000000000..7a7a5ccd0064 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-map-set-ops.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 161996000, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-numeric-loop.js b/packages/codemode-rust/conformance/cases/bench-numeric-loop.js new file mode 100644 index 000000000000..b43fc3741ce6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-numeric-loop.js @@ -0,0 +1,3 @@ +let sum = 0 +for (let i = 0; i < 300000; i++) sum = (sum + i * 3) % 1000003 +return sum diff --git a/packages/codemode-rust/conformance/cases/bench-numeric-loop.json b/packages/codemode-rust/conformance/cases/bench-numeric-loop.json new file mode 100644 index 000000000000..553d77aebb2e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-numeric-loop.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 145003, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-promise-fan-out.js b/packages/codemode-rust/conformance/cases/bench-promise-fan-out.js new file mode 100644 index 000000000000..cb8f7fd5edee --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-promise-fan-out.js @@ -0,0 +1,3 @@ +const work = async (i) => { await null; return i * 2 } +const results = await Promise.all(Array.from({ length: 5000 }, (_, i) => work(i))) +return results.length diff --git a/packages/codemode-rust/conformance/cases/bench-promise-fan-out.json b/packages/codemode-rust/conformance/cases/bench-promise-fan-out.json new file mode 100644 index 000000000000..2dec322e6003 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-promise-fan-out.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 5000, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-string-building.js b/packages/codemode-rust/conformance/cases/bench-string-building.js new file mode 100644 index 000000000000..eac8db9e1d0a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-string-building.js @@ -0,0 +1,5 @@ +let out = "" +for (let i = 0; i < 50000; i++) out += String.fromCharCode(97 + (i % 26)) +const parts = [] +for (let i = 0; i < 20000; i++) parts.push(`item-${i}`) +return out.length + parts.join(",").length diff --git a/packages/codemode-rust/conformance/cases/bench-string-building.json b/packages/codemode-rust/conformance/cases/bench-string-building.json new file mode 100644 index 000000000000..c2544e96231f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-string-building.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 258889, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bench-tool-fan-out.js b/packages/codemode-rust/conformance/cases/bench-tool-fan-out.js new file mode 100644 index 000000000000..439274088055 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-tool-fan-out.js @@ -0,0 +1,2 @@ +const results = await Promise.all(Array.from({ length: 1000 }, (_, i) => tools.echo({ id: i }))) +return results.length diff --git a/packages/codemode-rust/conformance/cases/bench-tool-fan-out.json b/packages/codemode-rust/conformance/cases/bench-tool-fan-out.json new file mode 100644 index 000000000000..5421a2808825 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bench-tool-fan-out.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 1000, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/bindings.js b/packages/codemode-rust/conformance/cases/bindings.js new file mode 100644 index 000000000000..92347fec51d3 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bindings.js @@ -0,0 +1,2 @@ +// @bindings {"n": 2, "cfg": {"name": "demo", "tags": ["a", "b"]}, "flag": false, "nothing": null} +return { doubled: n * 2, name: cfg.name.toUpperCase(), tags: cfg.tags.length, flag, nothing } diff --git a/packages/codemode-rust/conformance/cases/bindings.json b/packages/codemode-rust/conformance/cases/bindings.json new file mode 100644 index 000000000000..53a3214ad484 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/bindings.json @@ -0,0 +1,23 @@ +{ + "bindings": { + "n": 2, + "cfg": { + "name": "demo", + "tags": [ + "a", + "b" + ] + }, + "flag": false, + "nothing": null + }, + "ok": true, + "value": { + "doubled": 4, + "name": "DEMO", + "tags": 2, + "flag": false, + "nothing": null + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-collections.js b/packages/codemode-rust/conformance/cases/boundary-collections.js new file mode 100644 index 000000000000..4b3f4ae454a5 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-collections.js @@ -0,0 +1 @@ +return { m: new Map([["a", 1]]), s: new Set(["x", "y"]) } diff --git a/packages/codemode-rust/conformance/cases/boundary-collections.json b/packages/codemode-rust/conformance/cases/boundary-collections.json new file mode 100644 index 000000000000..76b2a25b9e34 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-collections.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "ok": true, + "value": { + "m": {}, + "s": [ + "x", + "y" + ] + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-error.js b/packages/codemode-rust/conformance/cases/boundary-error.js new file mode 100644 index 000000000000..4bba13d330bf --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-error.js @@ -0,0 +1,3 @@ +const e = new TypeError("bad") +e.code = 7 +return e diff --git a/packages/codemode-rust/conformance/cases/boundary-error.json b/packages/codemode-rust/conformance/cases/boundary-error.json new file mode 100644 index 000000000000..9f1e8457d054 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-error.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": { + "name": "TypeError", + "message": "bad", + "code": 7 + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-functions.js b/packages/codemode-rust/conformance/cases/boundary-functions.js new file mode 100644 index 000000000000..0468709b96a7 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-functions.js @@ -0,0 +1 @@ +return { f: () => 1, list: [() => 2], keep: 1 } diff --git a/packages/codemode-rust/conformance/cases/boundary-functions.json b/packages/codemode-rust/conformance/cases/boundary-functions.json new file mode 100644 index 000000000000..fd4d9329dd0c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-functions.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": { + "list": [ + null + ], + "keep": 1 + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-promise.js b/packages/codemode-rust/conformance/cases/boundary-promise.js new file mode 100644 index 000000000000..a76f990f5816 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-promise.js @@ -0,0 +1 @@ +return Promise.resolve({ ok: 1 }) diff --git a/packages/codemode-rust/conformance/cases/boundary-promise.json b/packages/codemode-rust/conformance/cases/boundary-promise.json new file mode 100644 index 000000000000..a86d4a0a368b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-promise.json @@ -0,0 +1,8 @@ +{ + "bindings": {}, + "ok": true, + "value": { + "ok": 1 + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-to-json.js b/packages/codemode-rust/conformance/cases/boundary-to-json.js new file mode 100644 index 000000000000..813bd3278d93 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-to-json.js @@ -0,0 +1 @@ +return { inner: { toJSON() { return ["custom"] } } } diff --git a/packages/codemode-rust/conformance/cases/boundary-to-json.json b/packages/codemode-rust/conformance/cases/boundary-to-json.json new file mode 100644 index 000000000000..20a331b50f1c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-to-json.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": { + "inner": [ + "custom" + ] + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/boundary-undefined-null.js b/packages/codemode-rust/conformance/cases/boundary-undefined-null.js new file mode 100644 index 000000000000..9dcea9340d1c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-undefined-null.js @@ -0,0 +1 @@ +return [undefined, null, { a: undefined, b: null }, [undefined], NaN, Infinity, -Infinity, -0] diff --git a/packages/codemode-rust/conformance/cases/boundary-undefined-null.json b/packages/codemode-rust/conformance/cases/boundary-undefined-null.json new file mode 100644 index 000000000000..ea53634c5d5a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/boundary-undefined-null.json @@ -0,0 +1,19 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + null, + null, + { + "b": null + }, + [ + null + ], + null, + null, + null, + 0 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/closure-counter.js b/packages/codemode-rust/conformance/cases/closure-counter.js new file mode 100644 index 000000000000..10d600cfcee2 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-counter.js @@ -0,0 +1,4 @@ +const counter = () => { let n = 0; return { inc: () => ++n, get: () => n } } +const a = counter(), b = counter() +a.inc(); a.inc(); b.inc() +return [a.get(), b.get()] diff --git a/packages/codemode-rust/conformance/cases/closure-counter.json b/packages/codemode-rust/conformance/cases/closure-counter.json new file mode 100644 index 000000000000..92507cf8355f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-counter.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 2, + 1 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/closure-iife.js b/packages/codemode-rust/conformance/cases/closure-iife.js new file mode 100644 index 000000000000..45a64b0cb335 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-iife.js @@ -0,0 +1,2 @@ +const mod = (function () { const secret = 41; return { answer: () => secret + 1 } })() +return mod.answer() diff --git a/packages/codemode-rust/conformance/cases/closure-iife.json b/packages/codemode-rust/conformance/cases/closure-iife.json new file mode 100644 index 000000000000..9632746f9d3b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-iife.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 42, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/closure-loop-let.js b/packages/codemode-rust/conformance/cases/closure-loop-let.js new file mode 100644 index 000000000000..1c66baea7290 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-loop-let.js @@ -0,0 +1,3 @@ +const fns = [] +for (let i = 0; i < 3; i++) fns.push(() => i) +return fns.map((f) => f()) diff --git a/packages/codemode-rust/conformance/cases/closure-loop-let.json b/packages/codemode-rust/conformance/cases/closure-loop-let.json new file mode 100644 index 000000000000..03ba9683cafb --- /dev/null +++ b/packages/codemode-rust/conformance/cases/closure-loop-let.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 0, + 1, + 2 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/coercion.js b/packages/codemode-rust/conformance/cases/coercion.js new file mode 100644 index 000000000000..ae2f4efbe6a0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/coercion.js @@ -0,0 +1 @@ +return ["a" + 1, 1 + "2", 1 + 2 + "3", "3" * "4", [1, 2] + "", ({}) + "", true + 1, null + 1, "5" - 2, +"7", +"", Number(undefined) === Number(undefined)] diff --git a/packages/codemode-rust/conformance/cases/coercion.json b/packages/codemode-rust/conformance/cases/coercion.json new file mode 100644 index 000000000000..2855e99ba570 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/coercion.json @@ -0,0 +1,19 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "a1", + "12", + "33", + 12, + "1,2", + "[object Object]", + 2, + 1, + 3, + 7, + 0, + false + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/console-log.js b/packages/codemode-rust/conformance/cases/console-log.js new file mode 100644 index 000000000000..30b97ee28978 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/console-log.js @@ -0,0 +1,5 @@ +console.log("hello") +console.log("multi", 1, true, null, undefined) +console.log({ a: [1, "s"] }, [1, 2]) +console.log(`t${1}`) +return "done" diff --git a/packages/codemode-rust/conformance/cases/console-log.json b/packages/codemode-rust/conformance/cases/console-log.json new file mode 100644 index 000000000000..57bb2c6d04a8 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/console-log.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": "done", + "logs": [ + "hello", + "multi 1 true null undefined", + "{\"a\":[1,\"s\"]} [1,2]", + "t1" + ] +} diff --git a/packages/codemode-rust/conformance/cases/destructuring-array.js b/packages/codemode-rust/conformance/cases/destructuring-array.js new file mode 100644 index 000000000000..e7edb3174eb9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-array.js @@ -0,0 +1,4 @@ +const [first, , third = "t", ...others] = [1, 2, undefined, 4, 5] +let x = 1, y = 2 +;[x, y] = [y, x] +return [first, third, others, x, y] diff --git a/packages/codemode-rust/conformance/cases/destructuring-array.json b/packages/codemode-rust/conformance/cases/destructuring-array.json new file mode 100644 index 000000000000..ed54d1a10d08 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-array.json @@ -0,0 +1,15 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1, + "t", + [ + 4, + 5 + ], + 2, + 1 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/destructuring-object.js b/packages/codemode-rust/conformance/cases/destructuring-object.js new file mode 100644 index 000000000000..a514dfce75f7 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-object.js @@ -0,0 +1,2 @@ +const { a, b: { c, d = 4 }, e: renamed = "def", ...rest } = { a: 1, b: { c: 3 }, x: 9, y: 10 } +return [a, c, d, renamed, rest] diff --git a/packages/codemode-rust/conformance/cases/destructuring-object.json b/packages/codemode-rust/conformance/cases/destructuring-object.json new file mode 100644 index 000000000000..3b683981f6c0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-object.json @@ -0,0 +1,15 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1, + 3, + 4, + "def", + { + "x": 9, + "y": 10 + } + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/destructuring-params.js b/packages/codemode-rust/conformance/cases/destructuring-params.js new file mode 100644 index 000000000000..696922dc28c7 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-params.js @@ -0,0 +1,2 @@ +const f = ({ name, tags: [first] = [] }, [n = 1] = []) => name + ":" + first + ":" + n +return [f({ name: "a", tags: ["t"] }, [5]), f({ name: "b" })] diff --git a/packages/codemode-rust/conformance/cases/destructuring-params.json b/packages/codemode-rust/conformance/cases/destructuring-params.json new file mode 100644 index 000000000000..08ec2b7a5dfe --- /dev/null +++ b/packages/codemode-rust/conformance/cases/destructuring-params.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "a:t:5", + "b:undefined:1" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/equality.js b/packages/codemode-rust/conformance/cases/equality.js new file mode 100644 index 000000000000..17d41d091ab6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/equality.js @@ -0,0 +1 @@ +return [1 == "1", 1 === "1", null == undefined, null === undefined, NaN === NaN, 0 === -0, "a" < "b", "10" < "9", 10 < 9, [] == false] diff --git a/packages/codemode-rust/conformance/cases/equality.json b/packages/codemode-rust/conformance/cases/equality.json new file mode 100644 index 000000000000..b26cfb6e3eef --- /dev/null +++ b/packages/codemode-rust/conformance/cases/equality.json @@ -0,0 +1,17 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + true, + false, + true, + false, + false, + true, + true, + true, + false, + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-class.js b/packages/codemode-rust/conformance/cases/error-class.js new file mode 100644 index 000000000000..a0b5c31cb5a9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-class.js @@ -0,0 +1,2 @@ +class Point { constructor(x) { this.x = x } } +return new Point(1) diff --git a/packages/codemode-rust/conformance/cases/error-class.json b/packages/codemode-rust/conformance/cases/error-class.json new file mode 100644 index 000000000000..76cece9b414a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-class.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "UnsupportedSyntax", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-parse.js b/packages/codemode-rust/conformance/cases/error-parse.js new file mode 100644 index 000000000000..0c79626410a3 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-parse.js @@ -0,0 +1 @@ +const x = (1 + diff --git a/packages/codemode-rust/conformance/cases/error-parse.json b/packages/codemode-rust/conformance/cases/error-parse.json new file mode 100644 index 000000000000..56b9b4f6b000 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-parse.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ParseError", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-reference.js b/packages/codemode-rust/conformance/cases/error-reference.js new file mode 100644 index 000000000000..f4dc2ee3db24 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-reference.js @@ -0,0 +1 @@ +return notDefined + 1 diff --git a/packages/codemode-rust/conformance/cases/error-reference.json b/packages/codemode-rust/conformance/cases/error-reference.json new file mode 100644 index 000000000000..d67f74bc1c8e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-reference.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ExecutionFailure", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-throw-error.js b/packages/codemode-rust/conformance/cases/error-throw-error.js new file mode 100644 index 000000000000..a621e5f961ce --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-throw-error.js @@ -0,0 +1,2 @@ +console.log("before") +throw new RangeError("out of range") diff --git a/packages/codemode-rust/conformance/cases/error-throw-error.json b/packages/codemode-rust/conformance/cases/error-throw-error.json new file mode 100644 index 000000000000..41df740d3b77 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-throw-error.json @@ -0,0 +1,8 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ExecutionFailure", + "logs": [ + "before" + ] +} diff --git a/packages/codemode-rust/conformance/cases/error-throw-value.js b/packages/codemode-rust/conformance/cases/error-throw-value.js new file mode 100644 index 000000000000..091f9dd01445 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-throw-value.js @@ -0,0 +1 @@ +throw "plain string" diff --git a/packages/codemode-rust/conformance/cases/error-throw-value.json b/packages/codemode-rust/conformance/cases/error-throw-value.json new file mode 100644 index 000000000000..d67f74bc1c8e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-throw-value.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ExecutionFailure", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.js b/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.js new file mode 100644 index 000000000000..84be9d2cf63a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.js @@ -0,0 +1,4 @@ +// @limits {"max_tool_calls": 1} +const out = [await tools.echo({ id: 1 })] +try { await tools.echo({ id: 2 }) } catch (e) { out.push("caught") } +return out diff --git a/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.json b/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.json new file mode 100644 index 000000000000..521bba6e0842 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-call-limit-caught.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "limits": { + "max_tool_calls": 1 + }, + "ok": true, + "value": [ + 1, + "caught" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-tool-call-limit.js b/packages/codemode-rust/conformance/cases/error-tool-call-limit.js new file mode 100644 index 000000000000..66ba1ed14f9f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-call-limit.js @@ -0,0 +1,3 @@ +// @limits {"max_tool_calls": 2} +for (let i = 0; i < 3; i++) await tools.echo({ id: i }) +return "unreachable" diff --git a/packages/codemode-rust/conformance/cases/error-tool-call-limit.json b/packages/codemode-rust/conformance/cases/error-tool-call-limit.json new file mode 100644 index 000000000000..65a9c31b4a1b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-call-limit.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "limits": { + "max_tool_calls": 2 + }, + "ok": false, + "kind": "ToolCallLimitExceeded", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-tool-caught.js b/packages/codemode-rust/conformance/cases/error-tool-caught.js new file mode 100644 index 000000000000..87353a011b4e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-caught.js @@ -0,0 +1 @@ +try { await tools.fail({}) } catch (e) { return [e instanceof Error, e.message] } diff --git a/packages/codemode-rust/conformance/cases/error-tool-caught.json b/packages/codemode-rust/conformance/cases/error-tool-caught.json new file mode 100644 index 000000000000..915da17cd04f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-caught.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + true, + "boom" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-tool-uncaught.js b/packages/codemode-rust/conformance/cases/error-tool-uncaught.js new file mode 100644 index 000000000000..36fe26d5d752 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-uncaught.js @@ -0,0 +1,2 @@ +const v = await tools.fail({}) +return v diff --git a/packages/codemode-rust/conformance/cases/error-tool-uncaught.json b/packages/codemode-rust/conformance/cases/error-tool-uncaught.json new file mode 100644 index 000000000000..087434938799 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-tool-uncaught.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ToolFailure", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/error-unknown-tool.js b/packages/codemode-rust/conformance/cases/error-unknown-tool.js new file mode 100644 index 000000000000..dd77b4641272 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-unknown-tool.js @@ -0,0 +1 @@ +return await tools.nope({}) diff --git a/packages/codemode-rust/conformance/cases/error-unknown-tool.json b/packages/codemode-rust/conformance/cases/error-unknown-tool.json new file mode 100644 index 000000000000..95f92b51f8fa --- /dev/null +++ b/packages/codemode-rust/conformance/cases/error-unknown-tool.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "UnknownTool", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/finally-overrides.js b/packages/codemode-rust/conformance/cases/finally-overrides.js new file mode 100644 index 000000000000..c97dc040f40f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/finally-overrides.js @@ -0,0 +1,3 @@ +const f = () => { try { return "try" } finally { return "finally" } } +const g = () => { for (let i = 0; i < 3; i++) { try { if (i === 1) break } finally { } } return "done" } +return [f(), g()] diff --git a/packages/codemode-rust/conformance/cases/finally-overrides.json b/packages/codemode-rust/conformance/cases/finally-overrides.json new file mode 100644 index 000000000000..d509c748dae2 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/finally-overrides.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "finally", + "done" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/for-of-for-in.js b/packages/codemode-rust/conformance/cases/for-of-for-in.js new file mode 100644 index 000000000000..0defbd17be70 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/for-of-for-in.js @@ -0,0 +1,7 @@ +const out = [] +for (const x of [1, 2]) out.push(x) +for (const ch of "ab") out.push(ch) +for (const k in { p: 1, q: 2 }) out.push(k) +for (const i in ["x", "y"]) out.push(i) +for (const [k, v] of Object.entries({ m: 3 })) out.push(k + v) +return out diff --git a/packages/codemode-rust/conformance/cases/for-of-for-in.json b/packages/codemode-rust/conformance/cases/for-of-for-in.json new file mode 100644 index 000000000000..7f8f61b7157a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/for-of-for-in.json @@ -0,0 +1,16 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1, + 2, + "a", + "b", + "p", + "q", + "0", + "1", + "m3" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/function-hoisting.js b/packages/codemode-rust/conformance/cases/function-hoisting.js new file mode 100644 index 000000000000..1fa0543dddb1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/function-hoisting.js @@ -0,0 +1,2 @@ +return twice(21) +function twice(n) { return n * 2 } diff --git a/packages/codemode-rust/conformance/cases/function-hoisting.json b/packages/codemode-rust/conformance/cases/function-hoisting.json new file mode 100644 index 000000000000..9632746f9d3b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/function-hoisting.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 42, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/generator-for-of-break.js b/packages/codemode-rust/conformance/cases/generator-for-of-break.js new file mode 100644 index 000000000000..0c6e2765c0cf --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-for-of-break.js @@ -0,0 +1,4 @@ +function* naturals() { let n = 0; while (true) yield n++ } +const out = [] +for (const n of naturals()) { if (n > 4) break; out.push(n) } +return out diff --git a/packages/codemode-rust/conformance/cases/generator-for-of-break.json b/packages/codemode-rust/conformance/cases/generator-for-of-break.json new file mode 100644 index 000000000000..8bf542a7b8f4 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-for-of-break.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 0, + 1, + 2, + 3, + 4 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/generator-protocol.js b/packages/codemode-rust/conformance/cases/generator-protocol.js new file mode 100644 index 000000000000..12e64f32d43f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-protocol.js @@ -0,0 +1,3 @@ +function* g() { yield 1; yield 2; return 3 } +const it = g() +return [it.next(), it.next(), it.next(), it.next()] diff --git a/packages/codemode-rust/conformance/cases/generator-protocol.json b/packages/codemode-rust/conformance/cases/generator-protocol.json new file mode 100644 index 000000000000..44f72137607c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-protocol.json @@ -0,0 +1,22 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + { + "value": 1, + "done": false + }, + { + "value": 2, + "done": false + }, + { + "value": 3, + "done": true + }, + { + "done": true + } + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/generator-spread.js b/packages/codemode-rust/conformance/cases/generator-spread.js new file mode 100644 index 000000000000..5cd64dde33fb --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-spread.js @@ -0,0 +1,2 @@ +function* squares(n) { for (let i = 0; i < n; i++) yield i * i } +return [...squares(5)] diff --git a/packages/codemode-rust/conformance/cases/generator-spread.json b/packages/codemode-rust/conformance/cases/generator-spread.json new file mode 100644 index 000000000000..e66571d94435 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/generator-spread.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 0, + 1, + 4, + 9, + 16 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/if-else-ternary.js b/packages/codemode-rust/conformance/cases/if-else-ternary.js new file mode 100644 index 000000000000..faacf7aae718 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/if-else-ternary.js @@ -0,0 +1,2 @@ +const classify = (n) => { if (n < 0) return "neg"; else if (n === 0) return "zero"; else return n > 10 ? "big" : "small" } +return [-1, 0, 5, 50].map(classify) diff --git a/packages/codemode-rust/conformance/cases/if-else-ternary.json b/packages/codemode-rust/conformance/cases/if-else-ternary.json new file mode 100644 index 000000000000..fa43595e9d39 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/if-else-ternary.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "neg", + "zero", + "small", + "big" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/instanceof.js b/packages/codemode-rust/conformance/cases/instanceof.js new file mode 100644 index 000000000000..76fe4a146d16 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/instanceof.js @@ -0,0 +1,2 @@ +const m = new Map() +return [[] instanceof Array, [] instanceof Object, ({}) instanceof Array, m instanceof Map, new Set() instanceof Set, new Error("x") instanceof Error, new TypeError("x") instanceof Error] diff --git a/packages/codemode-rust/conformance/cases/instanceof.json b/packages/codemode-rust/conformance/cases/instanceof.json new file mode 100644 index 000000000000..11488c974218 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/instanceof.json @@ -0,0 +1,14 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + true, + true, + false, + true, + true, + true, + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/json-methods.js b/packages/codemode-rust/conformance/cases/json-methods.js new file mode 100644 index 000000000000..31a69b54fb01 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/json-methods.js @@ -0,0 +1,3 @@ +const v = { a: [1, "two", null, true], b: { c: 1.5 }, u: undefined, f: () => 1 } +const s = JSON.stringify(v) +return [s, JSON.stringify(v, null, 2), JSON.parse(s), JSON.stringify([undefined, () => 1]), JSON.stringify("q\"uote\n"), JSON.parse("[1, {\"x\": \"y\"}]"), JSON.stringify(undefined) === undefined] diff --git a/packages/codemode-rust/conformance/cases/json-methods.json b/packages/codemode-rust/conformance/cases/json-methods.json new file mode 100644 index 000000000000..1509e5f8ac3c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/json-methods.json @@ -0,0 +1,29 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "{\"a\":[1,\"two\",null,true],\"b\":{\"c\":1.5}}", + "{\n \"a\": [\n 1,\n \"two\",\n null,\n true\n ],\n \"b\": {\n \"c\": 1.5\n }\n}", + { + "a": [ + 1, + "two", + null, + true + ], + "b": { + "c": 1.5 + } + }, + "[null,null]", + "\"q\\\"uote\\n\"", + [ + 1, + { + "x": "y" + } + ], + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/json-parse-error.js b/packages/codemode-rust/conformance/cases/json-parse-error.js new file mode 100644 index 000000000000..4a106a904c06 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/json-parse-error.js @@ -0,0 +1 @@ +try { JSON.parse("{bad") } catch (e) { return [e instanceof SyntaxError, e.name] } diff --git a/packages/codemode-rust/conformance/cases/json-parse-error.json b/packages/codemode-rust/conformance/cases/json-parse-error.json new file mode 100644 index 000000000000..5e3b167e52ff --- /dev/null +++ b/packages/codemode-rust/conformance/cases/json-parse-error.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + true, + "SyntaxError" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/labels.js b/packages/codemode-rust/conformance/cases/labels.js new file mode 100644 index 000000000000..474dc83f8560 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/labels.js @@ -0,0 +1,10 @@ +const found = [] +outer: for (let i = 0; i < 4; i++) { + inner: for (let j = 0; j < 4; j++) { + if (j === 2) continue outer + if (i === 3) break outer + found.push(i + "" + j) + } +} +block: { found.push("in"); break block; found.push("never") } +return found diff --git a/packages/codemode-rust/conformance/cases/labels.json b/packages/codemode-rust/conformance/cases/labels.json new file mode 100644 index 000000000000..f38faaf86ff6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/labels.json @@ -0,0 +1,14 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "00", + "01", + "10", + "11", + "20", + "21", + "in" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/let-const-var.js b/packages/codemode-rust/conformance/cases/let-const-var.js new file mode 100644 index 000000000000..84da0124be05 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/let-const-var.js @@ -0,0 +1,5 @@ +var a = 1 +let b = 2 +const c = 3 +{ let b = 20; var a = 10; const c = 30 } +return [a, b, c] diff --git a/packages/codemode-rust/conformance/cases/let-const-var.json b/packages/codemode-rust/conformance/cases/let-const-var.json new file mode 100644 index 000000000000..a7c43536fcef --- /dev/null +++ b/packages/codemode-rust/conformance/cases/let-const-var.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 10, + 2, + 3 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/logical-nullish.js b/packages/codemode-rust/conformance/cases/logical-nullish.js new file mode 100644 index 000000000000..6b217d1eeeeb --- /dev/null +++ b/packages/codemode-rust/conformance/cases/logical-nullish.js @@ -0,0 +1,4 @@ +let a = null, b = 0, c = 1 +a ??= "set"; b ||= "falsy"; c &&= "truthy" +const o = { p: { q: 1 } } +return [a, b, c, 0 || "x", 0 ?? "x", "" && "y", o?.p?.q, o.missing?.q, o.missing?.(), null ?? undefined ?? 3, !0, !!""] diff --git a/packages/codemode-rust/conformance/cases/logical-nullish.json b/packages/codemode-rust/conformance/cases/logical-nullish.json new file mode 100644 index 000000000000..d7f58bfd3559 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/logical-nullish.json @@ -0,0 +1,19 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "set", + "falsy", + "truthy", + "x", + 0, + "", + 1, + null, + null, + 3, + true, + false + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/loops.js b/packages/codemode-rust/conformance/cases/loops.js new file mode 100644 index 000000000000..0f0533df3ee8 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/loops.js @@ -0,0 +1,9 @@ +let a = 0 +for (let i = 0; i < 5; i++) a += i +let b = 0 +while (b < 7) b += 2 +let c = 0 +do { c++ } while (c < 0) +let d = 0 +for (let i = 0; i < 10; i++) { if (i % 2) continue; if (i > 6) break; d += i } +return [a, b, c, d] diff --git a/packages/codemode-rust/conformance/cases/loops.json b/packages/codemode-rust/conformance/cases/loops.json new file mode 100644 index 000000000000..a03711ee0d79 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/loops.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 10, + 8, + 1, + 12 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/map-object-keys.js b/packages/codemode-rust/conformance/cases/map-object-keys.js new file mode 100644 index 000000000000..e81afa8fa2fc --- /dev/null +++ b/packages/codemode-rust/conformance/cases/map-object-keys.js @@ -0,0 +1,4 @@ +const k1 = { id: 1 }, k2 = { id: 1 } +const m = new Map([[k1, "one"]]) +m.set(1, "number").set("1", "string") +return [m.get(k1), m.get(k2), m.get(1), m.get("1"), m.size] diff --git a/packages/codemode-rust/conformance/cases/map-object-keys.json b/packages/codemode-rust/conformance/cases/map-object-keys.json new file mode 100644 index 000000000000..ad432320f993 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/map-object-keys.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "one", + null, + "number", + "string", + 3 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/map-set.js b/packages/codemode-rust/conformance/cases/map-set.js new file mode 100644 index 000000000000..d5d280b91326 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/map-set.js @@ -0,0 +1,7 @@ +const m = new Map([["a", 1]]) +m.set("b", 2).set("a", 3) +const s = new Set([3, 1, 3, 2]) +s.add(1).add(4) +const keys = [] +m.forEach((v, k) => keys.push(k + v)) +return [m.get("a"), m.get("zz"), m.has("b"), m.size, [...m.keys()], [...m.values()], [...m.entries()], [...m], m.delete("a"), m.delete("a"), [...s], s.has(2), s.size, keys] diff --git a/packages/codemode-rust/conformance/cases/map-set.json b/packages/codemode-rust/conformance/cases/map-set.json new file mode 100644 index 000000000000..65aca6d8cc41 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/map-set.json @@ -0,0 +1,53 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 3, + null, + true, + 2, + [ + "a", + "b" + ], + [ + 3, + 2 + ], + [ + [ + "a", + 3 + ], + [ + "b", + 2 + ] + ], + [ + [ + "a", + 3 + ], + [ + "b", + 2 + ] + ], + true, + false, + [ + 3, + 1, + 2, + 4 + ], + true, + 4, + [ + "a3", + "b2" + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/math.js b/packages/codemode-rust/conformance/cases/math.js new file mode 100644 index 000000000000..71260119e422 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/math.js @@ -0,0 +1 @@ +return [Math.floor(-1.5), Math.ceil(1.2), Math.round(2.5), Math.round(-2.5), Math.max(1, 9, 3), Math.min(), Math.abs(-3), Math.pow(2, 8), Math.sqrt(16), Math.trunc(-4.7), Math.sign(-3), Math.PI.toFixed(5), Math.max()] diff --git a/packages/codemode-rust/conformance/cases/math.json b/packages/codemode-rust/conformance/cases/math.json new file mode 100644 index 000000000000..ff385a9ef20e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/math.json @@ -0,0 +1,20 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + -2, + 2, + 3, + -2, + 9, + null, + 3, + 256, + 4, + -4, + -1, + "3.14159", + null + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/number-formatting.js b/packages/codemode-rust/conformance/cases/number-formatting.js new file mode 100644 index 000000000000..470403296cec --- /dev/null +++ b/packages/codemode-rust/conformance/cases/number-formatting.js @@ -0,0 +1 @@ +return [String(0.1 + 0.2), String(1 / 3), String(1e21), String(123456789012), String(-0), String(1.5e-7), String(100), String(2 ** 53), String(-1e-7), String(1 / 0), 0.1 * 3, 1e308 * 10] diff --git a/packages/codemode-rust/conformance/cases/number-formatting.json b/packages/codemode-rust/conformance/cases/number-formatting.json new file mode 100644 index 000000000000..02642f931f7c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/number-formatting.json @@ -0,0 +1,19 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "0.30000000000000004", + "0.3333333333333333", + "1e+21", + "123456789012", + "0", + "1.5e-7", + "100", + "9007199254740992", + "-1e-7", + "Infinity", + 0.30000000000000004, + null + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/number-methods.js b/packages/codemode-rust/conformance/cases/number-methods.js new file mode 100644 index 000000000000..bf1eb86bb44e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/number-methods.js @@ -0,0 +1 @@ +return [(3.14159).toFixed(2), (2).toFixed(1), Number("3.5"), Number("x"), Number(""), Number(true), parseInt("42px"), parseInt("ff", 16), parseFloat("2.5e1"), Number.isInteger(5), Number.isInteger(5.5), Number.isNaN(NaN), isNaN("x"), Number.isFinite(1 / 0), Number.MAX_SAFE_INTEGER] diff --git a/packages/codemode-rust/conformance/cases/number-methods.json b/packages/codemode-rust/conformance/cases/number-methods.json new file mode 100644 index 000000000000..9b8a0e1aecc1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/number-methods.json @@ -0,0 +1,22 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "3.14", + "2.0", + 3.5, + null, + 0, + 1, + 42, + 255, + 25, + true, + false, + true, + true, + false, + 9007199254740991 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/object-literals.js b/packages/codemode-rust/conformance/cases/object-literals.js new file mode 100644 index 000000000000..61408c387ecd --- /dev/null +++ b/packages/codemode-rust/conformance/cases/object-literals.js @@ -0,0 +1,5 @@ +const k = "dyn", a = 1 +const o = { a, [k + "Key"]: 2, 3: "three", "quoted-key": 4, m(x) { return x + this.a }, nested: { deep: [1, { z: true }] } } +o.added = 5 +delete o.a +return [o, o.m === undefined, "added" in o, "a" in o, Object.keys(o)] diff --git a/packages/codemode-rust/conformance/cases/object-literals.json b/packages/codemode-rust/conformance/cases/object-literals.json new file mode 100644 index 000000000000..95b2b098eb6c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/object-literals.json @@ -0,0 +1,32 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + { + "3": "three", + "dynKey": 2, + "quoted-key": 4, + "nested": { + "deep": [ + 1, + { + "z": true + } + ] + }, + "added": 5 + }, + false, + true, + false, + [ + "3", + "dynKey", + "quoted-key", + "m", + "nested", + "added" + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/object-methods.js b/packages/codemode-rust/conformance/cases/object-methods.js new file mode 100644 index 000000000000..8315b07279a0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/object-methods.js @@ -0,0 +1,2 @@ +const o = { b: 1, a: 2, 10: "ten", 2: "two" } +return [Object.keys(o), Object.values(o), Object.entries({ x: 1, y: [2] }), Object.assign({}, { a: 1 }, { b: 2 }), Object.fromEntries([["p", 1], ["q", 2]]), Object.hasOwn(o, "a"), o.hasOwnProperty("zz")] diff --git a/packages/codemode-rust/conformance/cases/object-methods.json b/packages/codemode-rust/conformance/cases/object-methods.json new file mode 100644 index 000000000000..f10751e6d3ce --- /dev/null +++ b/packages/codemode-rust/conformance/cases/object-methods.json @@ -0,0 +1,41 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + "2", + "10", + "b", + "a" + ], + [ + "two", + "ten", + 1, + 2 + ], + [ + [ + "x", + 1 + ], + [ + "y", + [ + 2 + ] + ] + ], + { + "a": 1, + "b": 2 + }, + { + "p": 1, + "q": 2 + }, + true, + false + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/operators.js b/packages/codemode-rust/conformance/cases/operators.js new file mode 100644 index 000000000000..6a13ba7f183f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/operators.js @@ -0,0 +1,7 @@ +let a = 5 +a += 2; a -= 1; a *= 3; a /= 2; a %= 5 +let b = 2 ** 10 +let i = 0 +const post = i++, pre = ++i +const bits = [5 & 3, 5 | 3, 5 ^ 3, ~5, 1 << 4, -16 >> 2, -16 >>> 28] +return [a, b, post, pre, i, bits, -7 % 3, 7 / 2] diff --git a/packages/codemode-rust/conformance/cases/operators.json b/packages/codemode-rust/conformance/cases/operators.json new file mode 100644 index 000000000000..b959af371dbf --- /dev/null +++ b/packages/codemode-rust/conformance/cases/operators.json @@ -0,0 +1,23 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 4, + 1024, + 0, + 2, + 2, + [ + 1, + 7, + 6, + -6, + 16, + -4, + 15 + ], + -1, + 3.5 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-command.js b/packages/codemode-rust/conformance/cases/plugin-reducer-command.js new file mode 100644 index 000000000000..8c0d4e2993f8 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-command.js @@ -0,0 +1,4 @@ +// @bindings {"event": {"type": "command", "name": "git.status"}, "state": {"runs": 2}} +if (event.type === "init") return { state: { runs: 0 }, commands: [{ name: "git.status", key: "ctrl+g" }] } +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-command.json b/packages/codemode-rust/conformance/cases/plugin-reducer-command.json new file mode 100644 index 000000000000..c842c00a415b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-command.json @@ -0,0 +1,23 @@ +{ + "bindings": { + "event": { + "type": "command", + "name": "git.status" + }, + "state": { + "runs": 2 + } + }, + "ok": true, + "value": { + "state": { + "runs": 3 + }, + "slots": { + "statusbar": { + "text": "main *" + } + } + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-init.js b/packages/codemode-rust/conformance/cases/plugin-reducer-init.js new file mode 100644 index 000000000000..b365668e08ab --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-init.js @@ -0,0 +1,4 @@ +// @bindings {"event": {"type": "init"}, "state": null} +if (event.type === "init") return { state: { runs: 0 }, commands: [{ name: "git.status", key: "ctrl+g" }] } +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-init.json b/packages/codemode-rust/conformance/cases/plugin-reducer-init.json new file mode 100644 index 000000000000..696896c2d714 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-init.json @@ -0,0 +1,21 @@ +{ + "bindings": { + "event": { + "type": "init" + }, + "state": null + }, + "ok": true, + "value": { + "state": { + "runs": 0 + }, + "commands": [ + { + "name": "git.status", + "key": "ctrl+g" + } + ] + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.js b/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.js new file mode 100644 index 000000000000..36a751b759ca --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.js @@ -0,0 +1,4 @@ +// @bindings {"event": {"type": "command", "name": "git.log"}, "state": {"runs": 2}} +if (event.type === "init") return { state: { runs: 0 }, commands: [{ name: "git.status", key: "ctrl+g" }] } +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.json b/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.json new file mode 100644 index 000000000000..0309306e4971 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-other-command.json @@ -0,0 +1,18 @@ +{ + "bindings": { + "event": { + "type": "command", + "name": "git.log" + }, + "state": { + "runs": 2 + } + }, + "ok": true, + "value": { + "state": { + "runs": 2 + } + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.js b/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.js new file mode 100644 index 000000000000..2de4e928ab0a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.js @@ -0,0 +1,4 @@ +// @bindings {"event": {"type": "tick", "at": 5}, "state": {"runs": 7}} +if (event.type === "init") return { state: { runs: 0 }, commands: [{ name: "git.status", key: "ctrl+g" }] } +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } diff --git a/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.json b/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.json new file mode 100644 index 000000000000..2ab410899175 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/plugin-reducer-unknown-event.json @@ -0,0 +1,18 @@ +{ + "bindings": { + "event": { + "type": "tick", + "at": 5 + }, + "state": { + "runs": 7 + } + }, + "ok": true, + "value": { + "state": { + "runs": 7 + } + }, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/promise-all.js b/packages/codemode-rust/conformance/cases/promise-all.js new file mode 100644 index 000000000000..2ff80c2678ef --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-all.js @@ -0,0 +1,2 @@ +const slow = async (x) => { await null; await null; return x } +return await Promise.all([slow(1), 2, Promise.resolve(3), slow(4)]) diff --git a/packages/codemode-rust/conformance/cases/promise-all.json b/packages/codemode-rust/conformance/cases/promise-all.json new file mode 100644 index 000000000000..d67f77c6321a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-all.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1, + 2, + 3, + 4 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/promise-ordering.js b/packages/codemode-rust/conformance/cases/promise-ordering.js new file mode 100644 index 000000000000..fca1abb47e3d --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-ordering.js @@ -0,0 +1,6 @@ +const order = [] +Promise.resolve().then(() => order.push("micro")) +order.push("sync") +await null +order.push("after") +return order diff --git a/packages/codemode-rust/conformance/cases/promise-ordering.json b/packages/codemode-rust/conformance/cases/promise-ordering.json new file mode 100644 index 000000000000..17f3a167445e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-ordering.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "sync", + "micro", + "after" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/promise-then-chain.js b/packages/codemode-rust/conformance/cases/promise-then-chain.js new file mode 100644 index 000000000000..71f122a1a92b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-then-chain.js @@ -0,0 +1,3 @@ +const v = await Promise.resolve(1).then((x) => x + 1).then((x) => x * 10) +const r = await Promise.reject(new Error("no")).catch((e) => e.message) +return [v, r] diff --git a/packages/codemode-rust/conformance/cases/promise-then-chain.json b/packages/codemode-rust/conformance/cases/promise-then-chain.json new file mode 100644 index 000000000000..02cc5f26ed49 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/promise-then-chain.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 20, + "no" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/recursion.js b/packages/codemode-rust/conformance/cases/recursion.js new file mode 100644 index 000000000000..a1dba0ee8f7a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/recursion.js @@ -0,0 +1,4 @@ +function fact(n) { return n <= 1 ? 1 : n * fact(n - 1) } +const even = (n) => (n === 0 ? true : odd(n - 1)) +const odd = (n) => (n === 0 ? false : even(n - 1)) +return [fact(10), even(10), odd(7)] diff --git a/packages/codemode-rust/conformance/cases/recursion.json b/packages/codemode-rust/conformance/cases/recursion.json new file mode 100644 index 000000000000..a4f9c370b2a6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/recursion.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 3628800, + true, + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/repl-last-expression.js b/packages/codemode-rust/conformance/cases/repl-last-expression.js new file mode 100644 index 000000000000..1540d67c1c7c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-last-expression.js @@ -0,0 +1,2 @@ +const a = 2 +a * 21 diff --git a/packages/codemode-rust/conformance/cases/repl-last-expression.json b/packages/codemode-rust/conformance/cases/repl-last-expression.json new file mode 100644 index 000000000000..9632746f9d3b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-last-expression.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": 42, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/repl-no-value.js b/packages/codemode-rust/conformance/cases/repl-no-value.js new file mode 100644 index 000000000000..0547b3d0eee9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-no-value.js @@ -0,0 +1 @@ +let x = 1 diff --git a/packages/codemode-rust/conformance/cases/repl-no-value.json b/packages/codemode-rust/conformance/cases/repl-no-value.json new file mode 100644 index 000000000000..db1daabf48a3 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-no-value.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": null, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/repl-undefined.js b/packages/codemode-rust/conformance/cases/repl-undefined.js new file mode 100644 index 000000000000..417b7b5370df --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-undefined.js @@ -0,0 +1 @@ +undefined diff --git a/packages/codemode-rust/conformance/cases/repl-undefined.json b/packages/codemode-rust/conformance/cases/repl-undefined.json new file mode 100644 index 000000000000..db1daabf48a3 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/repl-undefined.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": true, + "value": null, + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/runtime-type-error.js b/packages/codemode-rust/conformance/cases/runtime-type-error.js new file mode 100644 index 000000000000..f21a639bfad6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/runtime-type-error.js @@ -0,0 +1,5 @@ +const out = [] +try { null.x } catch (e) { out.push(e instanceof TypeError, e.name) } +try { const f = undefined; f() } catch (e) { out.push(e instanceof TypeError) } +try { const c = 1; c = 2 } catch (e) { out.push(e instanceof TypeError) } +return out diff --git a/packages/codemode-rust/conformance/cases/runtime-type-error.json b/packages/codemode-rust/conformance/cases/runtime-type-error.json new file mode 100644 index 000000000000..8d3738e773c9 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/runtime-type-error.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + true, + "TypeError", + true, + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/spread-rest.js b/packages/codemode-rust/conformance/cases/spread-rest.js new file mode 100644 index 000000000000..c5d1456d5db5 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/spread-rest.js @@ -0,0 +1,4 @@ +const sum = (...xs) => xs.reduce((a, b) => a + b, 0) +const arr = [1, 2, 3] +const merged = { ...{ a: 1, b: 2 }, b: 3, ...{ c: 4 } } +return [sum(...arr, 4), [0, ...arr, ...[9]], merged, Math.max(...arr)] diff --git a/packages/codemode-rust/conformance/cases/spread-rest.json b/packages/codemode-rust/conformance/cases/spread-rest.json new file mode 100644 index 000000000000..5e281187c480 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/spread-rest.json @@ -0,0 +1,21 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 10, + [ + 0, + 1, + 2, + 3, + 9 + ], + { + "a": 1, + "b": 3, + "c": 4 + }, + 3 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/string-from-char-code.js b/packages/codemode-rust/conformance/cases/string-from-char-code.js new file mode 100644 index 000000000000..73c6d9f23c3f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/string-from-char-code.js @@ -0,0 +1,3 @@ +let s = "" +for (let i = 0; i < 5; i++) s += String.fromCharCode(97 + i) +return [s, String.fromCharCode(72, 105), "€".length, "z".charCodeAt(0), String(123), String(null), String([1, [2, 3]]), (12).toString(), (255).toString(16)] diff --git a/packages/codemode-rust/conformance/cases/string-from-char-code.json b/packages/codemode-rust/conformance/cases/string-from-char-code.json new file mode 100644 index 000000000000..2e3fe550224d --- /dev/null +++ b/packages/codemode-rust/conformance/cases/string-from-char-code.json @@ -0,0 +1,16 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "abcde", + "Hi", + 1, + 122, + "123", + "null", + "1,2,3", + "12", + "ff" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/string-methods.js b/packages/codemode-rust/conformance/cases/string-methods.js new file mode 100644 index 000000000000..64c1659a7c24 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/string-methods.js @@ -0,0 +1,3 @@ +const s = " Hello, World " +const t = s.trim() +return [t, t.length, t.toUpperCase(), t.toLowerCase(), t.slice(0, 5), t.slice(-5), t.substring(7, 12), t.indexOf("o"), t.lastIndexOf("o"), t.includes("World"), t.startsWith("Hell"), t.endsWith("!"), t.split(", "), "a,b,,c".split(","), "abc".split(""), "7".padStart(3, "0"), "x".padEnd(3, "."), "ab".repeat(3), t.replace("o", "0"), t.replaceAll("o", "0"), t.charAt(1), t.charCodeAt(0), t.at(-1), s.trimStart(), s.trimEnd()] diff --git a/packages/codemode-rust/conformance/cases/string-methods.json b/packages/codemode-rust/conformance/cases/string-methods.json new file mode 100644 index 000000000000..6c1f966b2424 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/string-methods.json @@ -0,0 +1,44 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "Hello, World", + 12, + "HELLO, WORLD", + "hello, world", + "Hello", + "World", + "World", + 4, + 8, + true, + true, + false, + [ + "Hello", + "World" + ], + [ + "a", + "b", + "", + "c" + ], + [ + "a", + "b", + "c" + ], + "007", + "x..", + "ababab", + "Hell0, World", + "Hell0, W0rld", + "e", + 72, + "d", + "Hello, World ", + " Hello, World" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/switch.js b/packages/codemode-rust/conformance/cases/switch.js new file mode 100644 index 000000000000..308e3c09876e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/switch.js @@ -0,0 +1,12 @@ +const f = (x) => { + const out = [] + switch (x) { + case 1: out.push("one") + case 2: out.push("two"); break + case "3": out.push("string three"); break + default: out.push("default") + case 4: out.push("four") + } + return out.join(",") +} +return [f(1), f(2), f(3), f("3"), f(4), f(9)] diff --git a/packages/codemode-rust/conformance/cases/switch.json b/packages/codemode-rust/conformance/cases/switch.json new file mode 100644 index 000000000000..7ae3cd333ea1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/switch.json @@ -0,0 +1,13 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "one,two", + "two", + "default,four", + "string three", + "four", + "default,four" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/template-literals.js b/packages/codemode-rust/conformance/cases/template-literals.js new file mode 100644 index 000000000000..e82c3516c69c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/template-literals.js @@ -0,0 +1,4 @@ +const name = "world", n = 3 +const nested = `a${`b${n}`}c` +return [`hello ${name}!`, `${n} * 2 = ${n * 2}`, nested, `line1 +line2`] diff --git a/packages/codemode-rust/conformance/cases/template-literals.json b/packages/codemode-rust/conformance/cases/template-literals.json new file mode 100644 index 000000000000..c643b91e063a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/template-literals.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "hello world!", + "3 * 2 = 6", + "ab3c", + "line1\nline2" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/throw-errors.js b/packages/codemode-rust/conformance/cases/throw-errors.js new file mode 100644 index 000000000000..e29ccb4c94e5 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/throw-errors.js @@ -0,0 +1,2 @@ +const kinds = [() => { throw new Error("e") }, () => { throw new TypeError("t") }, () => { throw new RangeError("r") }] +return kinds.map((f) => { try { f() } catch (e) { return [e.name, e.message, String(e), e instanceof Error, e instanceof TypeError, e instanceof RangeError] } }) diff --git a/packages/codemode-rust/conformance/cases/throw-errors.json b/packages/codemode-rust/conformance/cases/throw-errors.json new file mode 100644 index 000000000000..9c353502ab78 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/throw-errors.json @@ -0,0 +1,31 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + "Error", + "e", + "Error: e", + true, + false, + false + ], + [ + "TypeError", + "t", + "TypeError: t", + true, + true, + false + ], + [ + "RangeError", + "r", + "RangeError: r", + true, + false, + true + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/throw-values.js b/packages/codemode-rust/conformance/cases/throw-values.js new file mode 100644 index 000000000000..c6c14b71a6c1 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/throw-values.js @@ -0,0 +1,3 @@ +const out = [] +for (const v of ["str", 42, { code: 7 }, null]) { try { throw v } catch (e) { out.push(e) } } +return out diff --git a/packages/codemode-rust/conformance/cases/throw-values.json b/packages/codemode-rust/conformance/cases/throw-values.json new file mode 100644 index 000000000000..386935607c89 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/throw-values.json @@ -0,0 +1,13 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "str", + 42, + { + "code": 7 + }, + null + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/tool-calls.js b/packages/codemode-rust/conformance/cases/tool-calls.js new file mode 100644 index 000000000000..5670e11eb207 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-calls.js @@ -0,0 +1,4 @@ +const a = await tools.echo({ id: 1 }) +const b = await tools["echo"]({ id: 2 }) +const s = await tools.git.status() +return [a, b, s, s.branch] diff --git a/packages/codemode-rust/conformance/cases/tool-calls.json b/packages/codemode-rust/conformance/cases/tool-calls.json new file mode 100644 index 000000000000..eeb7f15fc91c --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-calls.json @@ -0,0 +1,14 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 1, + 2, + { + "branch": "main", + "dirty": true + }, + "main" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/tool-concurrent.js b/packages/codemode-rust/conformance/cases/tool-concurrent.js new file mode 100644 index 000000000000..5979e827aa15 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-concurrent.js @@ -0,0 +1,2 @@ +const results = await Promise.all([3, 1, 2].map((id) => tools.echo({ id }))) +return results diff --git a/packages/codemode-rust/conformance/cases/tool-concurrent.json b/packages/codemode-rust/conformance/cases/tool-concurrent.json new file mode 100644 index 000000000000..9cad716270af --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-concurrent.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 3, + 1, + 2 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/tool-result-copy.js b/packages/codemode-rust/conformance/cases/tool-result-copy.js new file mode 100644 index 000000000000..d0a9aba077be --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-result-copy.js @@ -0,0 +1,4 @@ +const s = await tools.git.status() +s.branch = "changed" +const t = await tools.git.status() +return [s.branch, t.branch] diff --git a/packages/codemode-rust/conformance/cases/tool-result-copy.json b/packages/codemode-rust/conformance/cases/tool-result-copy.json new file mode 100644 index 000000000000..7b71552a83a2 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/tool-result-copy.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "changed", + "main" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/try-catch-finally.js b/packages/codemode-rust/conformance/cases/try-catch-finally.js new file mode 100644 index 000000000000..24f518de0d2e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/try-catch-finally.js @@ -0,0 +1,5 @@ +const log = [] +const f = () => { try { log.push("try"); throw new Error("x") } catch (e) { log.push("catch " + e.message); return "from catch" } finally { log.push("finally") } } +const r = f() +try { log.push("no throw") } catch { log.push("unreachable") } finally { log.push("finally2") } +return [r, log] diff --git a/packages/codemode-rust/conformance/cases/try-catch-finally.json b/packages/codemode-rust/conformance/cases/try-catch-finally.json new file mode 100644 index 000000000000..0f7e8126deb3 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/try-catch-finally.json @@ -0,0 +1,15 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "from catch", + [ + "try", + "catch x", + "finally", + "no throw", + "finally2" + ] + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/typeof.js b/packages/codemode-rust/conformance/cases/typeof.js new file mode 100644 index 000000000000..77d375562941 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/typeof.js @@ -0,0 +1 @@ +return [typeof 1, typeof "s", typeof true, typeof undefined, typeof null, typeof {}, typeof [], typeof (() => 1), typeof function* () {}, typeof undeclaredName, typeof tools.echo] diff --git a/packages/codemode-rust/conformance/cases/typeof.json b/packages/codemode-rust/conformance/cases/typeof.json new file mode 100644 index 000000000000..1eb7df5623ac --- /dev/null +++ b/packages/codemode-rust/conformance/cases/typeof.json @@ -0,0 +1,18 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "number", + "string", + "boolean", + "undefined", + "object", + "object", + "object", + "function", + "function", + "undefined", + "function" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/var-hoisting.js b/packages/codemode-rust/conformance/cases/var-hoisting.js new file mode 100644 index 000000000000..2119d851c2db --- /dev/null +++ b/packages/codemode-rust/conformance/cases/var-hoisting.js @@ -0,0 +1,4 @@ +const before = typeof x +var x = 5 +function f() { if (false) { var y = 1 } return y } +return [before, x, f() === undefined] diff --git a/packages/codemode-rust/conformance/cases/var-hoisting.json b/packages/codemode-rust/conformance/cases/var-hoisting.json new file mode 100644 index 000000000000..b60e751cbf25 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/var-hoisting.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "undefined", + 5, + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/generate.ts b/packages/codemode-rust/conformance/generate.ts new file mode 100644 index 000000000000..e1256fc6cdf7 --- /dev/null +++ b/packages/codemode-rust/conformance/generate.ts @@ -0,0 +1,70 @@ +#!/usr/bin/env bun + +// Regenerates conformance/cases/.json by running every .js through the reference CodeMode. +// Usage: bun conformance/generate.ts [reference] — the reference CodeMode package directory, from the argument, +// CODEMODE_REF, or by default ../codemode relative to this workspace. +// +// A case may start with header comments that set its inputs: +// // @bindings {"event": {"type": "init"}} +// // @limits {"max_tool_calls": 2} + +import { readdirSync, readFileSync, writeFileSync } from "node:fs" +import { join, resolve } from "node:path" + +const override = process.argv[2] ?? process.env.CODEMODE_REF +const pkg = override === undefined ? resolve(import.meta.dir, "../../codemode") : resolve(override) +const { Effect, Schema } = await import(Bun.resolveSync("effect", join(pkg, "src"))) +const { CodeMode, Tool, toolError } = await import(join(pkg, "src/index.ts")) + +const tools = { + echo: Tool.make({ + description: "Echo an id", + input: Schema.Struct({ id: Schema.Number }), + output: Schema.Number, + execute: ({ id }: { id: number }) => Effect.succeed(id), + }), + fail: Tool.make({ + description: "Always fails", + input: Schema.Struct({}), + output: Schema.Number, + execute: () => Effect.fail(toolError("boom")), + }), + git: { + status: Tool.make({ + description: "Working tree status", + input: Schema.Struct({}), + output: Schema.Struct({ branch: Schema.String, dirty: Schema.Boolean }), + execute: () => Effect.succeed({ branch: "main", dirty: true }), + }), + }, +} + +const header = (code: string, tag: string) => { + const line = code.split("\n").find((l) => l.startsWith(`// @${tag} `)) + return line === undefined ? undefined : JSON.parse(line.slice(`// @${tag} `.length)) +} + +const dir = join(import.meta.dir, "cases") +const names = readdirSync(dir) + .filter((f) => f.endsWith(".js")) + .map((f) => f.slice(0, -3)) + .sort() + +for (const name of names) { + const code = readFileSync(join(dir, `${name}.js`), "utf8") + const bindings = header(code, "bindings") ?? {} + const limits = header(code, "limits") + const runtime = CodeMode.make({ + tools, + ...(limits === undefined ? {} : { limits: { maxToolCalls: limits.max_tool_calls, timeoutMs: limits.timeout_ms } }), + }) + const result = await Effect.runPromise(runtime.execute(code, bindings)) + const expected = { + bindings, + ...(limits === undefined ? {} : { limits }), + ...(result.ok ? { ok: true, value: result.value } : { ok: false, kind: result.error.kind }), + logs: result.logs ?? [], + } + writeFileSync(join(dir, `${name}.json`), JSON.stringify(expected, null, 2) + "\n") + console.log(`${name.padEnd(36)} ${result.ok ? "ok" : result.error.kind}`) +} diff --git a/packages/codemode-rust/crates/psychoscript/Cargo.toml b/packages/codemode-rust/crates/psychoscript/Cargo.toml new file mode 100644 index 000000000000..f86cffdff61c --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "psychoscript" +version = "0.1.0" +edition.workspace = true +license.workspace = true +description = "Embeddable Rust port of OpenCode's Code Mode language" + +[dependencies] +oxc_allocator = "0.159" +oxc_ast = "0.159" +oxc_ast_visit = "0.159" +oxc_diagnostics = "0.159" +oxc_parser = { version = "0.159", default-features = false } +oxc_semantic = "0.159" +oxc_span = "0.159" +oxc_str = "0.159" +oxc_syntax = "0.159" +rustc-hash = "2" +serde_json = { version = "1", features = ["preserve_order"] } diff --git a/packages/codemode-rust/crates/psychoscript/examples/run.rs b/packages/codemode-rust/crates/psychoscript/examples/run.rs new file mode 100644 index 000000000000..9cedacbf2049 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/examples/run.rs @@ -0,0 +1,29 @@ +//! Runs a program file and prints its outcome: `cargo run --example run -- program.js`. + +use psychoscript::{Json, Limits, Runtime}; + +fn main() { + let path = std::env::args().nth(1).expect("usage: run "); + let code = std::fs::read_to_string(&path).expect("readable program"); + let runtime = Runtime::new() + .tool("echo", |input| { + Ok(input.get("id").cloned().unwrap_or(Json::Null)) + }) + .tool("fail", |_| Err("boom".to_owned())) + .tool("git.status", |_| { + Ok(serde_json::json!({ "branch": "main", "dirty": true })) + }) + .limits(Limits { + timeout_ms: Some(2000), + max_tool_calls: None, + max_output_bytes: None, + }); + let outcome = runtime.execute(&code, &serde_json::Map::new()); + for line in &outcome.logs { + println!("log: {line}"); + } + match outcome.result { + Ok(v) => println!("ok: {v}"), + Err(d) => println!("error: {:?}: {} {:?}", d.kind, d.message, d.location), + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/builtins/array.rs b/packages/codemode-rust/crates/psychoscript/src/builtins/array.rs new file mode 100644 index 000000000000..7a2d9e644668 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/builtins/array.rs @@ -0,0 +1,736 @@ +//! Array and Array.prototype. + +use super::{arg, to_index}; +use crate::object::*; +use crate::ops::MAX_ARRAY_LEN; +use crate::strings::StrId; +use crate::value::{Id, Value, to_integer}; +use crate::vm::{Res, Vm}; + +pub fn setup(vm: &mut Vm) { + let ap = vm.realm.array_proto; + let array = vm.ctor("Array", 1, array_ctor, ap, Value::Undef); + vm.methods( + array, + &[ + ("isArray", 1, array_is_array), + ("from", 1, array_from), + ("of", 0, array_of), + ], + ); + vm.methods( + ap, + &[ + ("push", 1, a_push), + ("pop", 0, a_pop), + ("shift", 0, a_shift), + ("unshift", 1, a_unshift), + ("slice", 2, a_slice), + ("splice", 2, a_splice), + ("toSpliced", 2, a_to_spliced), + ("concat", 1, a_concat), + ("join", 1, a_join), + ("toString", 0, a_to_string), + ("reverse", 0, a_reverse), + ("toReversed", 0, a_to_reversed), + ("indexOf", 1, a_index_of), + ("lastIndexOf", 1, a_last_index_of), + ("includes", 1, a_includes), + ("find", 1, a_find), + ("findIndex", 1, a_find_index), + ("findLast", 1, a_find_last), + ("findLastIndex", 1, a_find_last_index), + ("filter", 1, a_filter), + ("map", 1, a_map), + ("forEach", 1, a_for_each), + ("some", 1, a_some), + ("every", 1, a_every), + ("reduce", 1, a_reduce), + ("reduceRight", 1, a_reduce_right), + ("sort", 1, a_sort), + ("toSorted", 1, a_to_sorted), + ("flat", 0, a_flat), + ("flatMap", 1, a_flat_map), + ("fill", 1, a_fill), + ("at", 1, a_at), + ("with", 2, a_with), + ("keys", 0, a_keys), + ("entries", 0, a_entries), + ], + ); + let values = vm.method(ap, "values", 0, a_values); + vm.define_hidden(ap, SYM_ITERATOR, values); +} + +fn arr_id(vm: &mut Vm, this: &Value) -> Result { + if let Value::Obj(id) = this + && let Kind::Array(_) = vm.heap[*id as usize].kind + { + return Ok(*id); + } + Err(vm.type_error("Array.prototype method called on a value that is not an array")) +} + +fn items<'a>(vm: &'a Vm, id: Id) -> &'a [Value] { + match &vm.heap[id as usize].kind { + Kind::Array(items) => items, + _ => &[], + } +} + +fn len(vm: &Vm, id: Id) -> usize { + items(vm, id).len() +} + +fn item(vm: &Vm, id: Id, i: usize) -> Value { + items(vm, id).get(i).cloned().unwrap_or_default() +} + +fn items_mut<'a>(vm: &'a mut Vm, id: Id, growing: bool) -> Result<&'a mut Vec, Value> { + let flags = vm.heap[id as usize].flags; + if flags & FROZEN != 0 || (growing && flags & NON_EXTENSIBLE != 0) { + return Err(vm.type_error("Cannot modify a frozen or non-extensible array")); + } + if !matches!(vm.heap[id as usize].kind, Kind::Array(_)) { + return Err(vm.type_error("not an array")); + } + match &mut vm.heap[id as usize].kind { + Kind::Array(items) => Ok(items), + _ => unreachable!("checked above"), + } +} + +fn callback(vm: &mut Vm, args: &[Value]) -> Result { + let f = arg(args, 0); + if !vm.is_callable(&f) { + let d = vm.describe(&f); + return Err(vm.type_error(&format!("{d} is not a function"))); + } + Ok(f) +} + +fn array_ctor(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + if args.len() == 1 + && let Value::Num(n) = args[0] + { + if n < 0.0 || n.fract() != 0.0 || n > MAX_ARRAY_LEN as f64 { + return Err(vm.range_error("Invalid array length.")); + } + return Ok(vm.new_array(vec![Value::Undef; n as usize])); + } + Ok(vm.new_array(args.to_vec())) +} + +fn array_is_array(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool( + matches!(arg(args, 0), Value::Obj(id) if matches!(vm.heap[id as usize].kind, Kind::Array(_))), + )) +} + +fn array_of(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(vm.new_array(args.to_vec())) +} + +fn array_from(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let src = arg(args, 0); + if src.is_nullish() { + return Err(vm.type_error("Array.from requires an array-like or iterable object")); + } + let iterable = match &src { + Value::Str(_) => true, + Value::Obj(id) => { + !matches!(vm.heap[*id as usize].kind, Kind::Ordinary) || vm.has_key(*id, SYM_ITERATOR) + } + _ => false, + }; + let mut list = if iterable { + vm.iterate_to_vec(&src)? + } else if let Value::Obj(id) = src { + let lk = vm.names.length; + let lv = vm.get_obj(id, lk); + let n = to_integer(vm.number_of(&lv)?).max(0.0); + if n > MAX_ARRAY_LEN as f64 { + return Err(vm.range_error("Invalid array length.")); + } + let n = n as usize; + let has_indexes = vm.heap[id as usize] + .props + .items + .iter() + .any(|p| vm.atoms.index(p.key).is_some()); + if has_indexes { + let mut out = Vec::with_capacity(n); + for i in 0..n { + out.push(vm.get_elem(&src, &Value::Num(i as f64))?); + } + out + } else { + vec![Value::Undef; n] + } + } else { + Vec::new() + }; + let f = arg(args, 1); + if !matches!(f, Value::Undef) { + if !vm.is_callable(&f) { + return Err(vm.type_error("Array.from mapper is not a function")); + } + let this_arg = arg(args, 2); + for (i, v) in list.iter_mut().enumerate() { + let x = std::mem::take(v); + *v = vm.call(&f, this_arg, &[x, Value::Num(i as f64)])?; + } + } + Ok(vm.new_array(list)) +} + +fn a_push(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let items = items_mut(vm, id, true)?; + if items.len() + args.len() > MAX_ARRAY_LEN { + return Err(vm.range_error("Invalid array length.")); + } + items.extend_from_slice(args); + Ok(Value::Num(items.len() as f64)) +} + +fn a_pop(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + Ok(items_mut(vm, id, false)?.pop().unwrap_or_default()) +} + +fn a_shift(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let items = items_mut(vm, id, false)?; + if items.is_empty() { + return Ok(Value::Undef); + } + Ok(items.remove(0)) +} + +fn a_unshift(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let items = items_mut(vm, id, true)?; + items.splice(0..0, args.iter().cloned()); + Ok(Value::Num(items.len() as f64)) +} + +fn a_slice(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + let s = to_index(vm, &arg(args, 0), n, 0)?; + let e = to_index(vm, &arg(args, 1), n, n)?; + let out = if s < e { + items(vm, id)[s..e].to_vec() + } else { + Vec::new() + }; + Ok(vm.new_array(out)) +} + +fn splice_args(vm: &mut Vm, args: &[Value], n: usize) -> Result<(usize, usize), Value> { + let start = to_index(vm, &arg(args, 0), n, 0)?; + let count = match args.len() { + 0 => 0, + 1 => n - start, + _ => (to_integer(vm.number_of(&args[1])?).max(0.0) as usize).min(n - start), + }; + Ok((start, count)) +} + +fn a_splice(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + let (start, count) = splice_args(vm, args, n)?; + let insert: Vec = args.iter().skip(2).cloned().collect(); + let items = items_mut(vm, id, !insert.is_empty())?; + let removed: Vec = items.splice(start..start + count, insert).collect(); + Ok(vm.new_array(removed)) +} + +fn a_to_spliced(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + let (start, count) = splice_args(vm, args, n)?; + let mut out = items(vm, id).to_vec(); + out.splice(start..start + count, args.iter().skip(2).cloned()); + Ok(vm.new_array(out)) +} + +fn a_concat(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let mut out = items(vm, id).to_vec(); + for a in args { + match a { + Value::Obj(o) if matches!(vm.heap[*o as usize].kind, Kind::Array(_)) => { + out.extend_from_slice(items(vm, *o)); + } + v => out.push(*v), + } + if out.len() > MAX_ARRAY_LEN { + return Err(vm.range_error("Invalid array length.")); + } + } + Ok(vm.new_array(out)) +} + +pub fn join(vm: &mut Vm, id: Id, sep: &str, seen: &mut Vec) -> Result { + if seen.contains(&id) { + return Ok(String::new()); + } + seen.push(id); + let mut out = String::new(); + let n = len(vm, id); + for i in 0..n { + if i > 0 { + out.push_str(sep); + } + match item(vm, id, i) { + Value::Undef | Value::Null => {} + Value::Str(s) => out.push_str(vm.text(s)), + Value::Num(x) => crate::value::write_num(&mut out, x), + Value::Obj(o) if matches!(vm.heap[o as usize].kind, Kind::Array(_)) => { + let s = join(vm, o, ",", seen)?; + out.push_str(&s); + } + v => { + let t = vm.string_of(&v)?; + out.push_str(vm.text(t)); + } + } + if out.len() > crate::ops::MAX_STRING_LEN { + return Err(vm.range_error("Invalid string length")); + } + } + seen.pop(); + Ok(out) +} + +fn a_join(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let sep = match arg(args, 0) { + Value::Undef => ",".to_owned(), + v => { + let t = vm.string_of(&v)?; + vm.text(t).to_owned() + } + }; + let s = join(vm, id, &sep, &mut Vec::new())?; + Ok(vm.string_val(s)) +} + +fn a_to_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let s = join(vm, id, ",", &mut Vec::new())?; + Ok(vm.string_val(s)) +} + +fn a_reverse(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + items_mut(vm, id, false)?.reverse(); + Ok(this) +} + +fn a_to_reversed(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let mut out = items(vm, id).to_vec(); + out.reverse(); + Ok(vm.new_array(out)) +} + +fn a_index_of(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let x = arg(args, 0); + let n = len(vm, id); + let from = to_index(vm, &arg(args, 1), n, 0)?; + let r = items(vm, id) + .iter() + .enumerate() + .skip(from) + .find(|(_, v)| vm.strict_eq(v, &x)) + .map(|(i, _)| i as f64); + Ok(Value::Num(r.unwrap_or(-1.0))) +} + +fn a_last_index_of(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let x = arg(args, 0); + let n = len(vm, id); + if n == 0 { + return Ok(Value::Num(-1.0)); + } + let from = if args.len() > 1 { + let k = to_integer(vm.number_of(&args[1])?); + if k < 0.0 { + n as f64 + k + } else { + k.min(n as f64 - 1.0) + } + } else { + n as f64 - 1.0 + }; + if from < 0.0 { + return Ok(Value::Num(-1.0)); + } + let items = items(vm, id); + let r = (0..=from as usize) + .rev() + .find(|i| vm.strict_eq(&items[*i], &x)); + Ok(Value::Num(r.map(|i| i as f64).unwrap_or(-1.0))) +} + +fn a_includes(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let x = arg(args, 0); + let n = len(vm, id); + let from = to_index(vm, &arg(args, 1), n, 0)?; + Ok(Value::Bool( + items(vm, id) + .iter() + .skip(from) + .any(|v| vm.same_value_zero(v, &x)), + )) +} + +/// Calls `f(value, index, array)` for each index while `visit` returns `None`; returns what stopped it. +fn each( + vm: &mut Vm, + this: &Value, + args: &[Value], + reverse: bool, + mut visit: impl FnMut(&mut Vm, usize, Value, Value) -> Option, +) -> Result, Value> { + let id = arr_id(vm, this)?; + let f = callback(vm, args)?; + let this_arg = arg(args, 1); + let n = len(vm, id); + for k in 0..n { + let i = if reverse { n - 1 - k } else { k }; + let v = item(vm, id, i); + let r = vm.call(&f, this_arg, &[v, Value::Num(i as f64), *this])?; + if let Some(t) = visit(vm, i, v, r) { + return Ok(Some(t)); + } + } + Ok(None) +} + +fn a_find(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + Ok(each(vm, &this, args, false, |vm, _, v, r| { + vm.truthy(&r).then_some(v) + })? + .unwrap_or_default()) +} + +fn a_find_index(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let r = each(vm, &this, args, false, |vm, i, _, r| { + vm.truthy(&r).then_some(i) + })?; + Ok(Value::Num(r.map(|i| i as f64).unwrap_or(-1.0))) +} + +fn a_find_last(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + Ok(each(vm, &this, args, true, |vm, _, v, r| { + vm.truthy(&r).then_some(v) + })? + .unwrap_or_default()) +} + +fn a_find_last_index(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let r = each(vm, &this, args, true, |vm, i, _, r| { + vm.truthy(&r).then_some(i) + })?; + Ok(Value::Num(r.map(|i| i as f64).unwrap_or(-1.0))) +} + +fn a_some(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool( + each(vm, &this, args, false, |vm, _, _, r| { + vm.truthy(&r).then_some(()) + })? + .is_some(), + )) +} + +fn a_every(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool( + each(vm, &this, args, false, |vm, _, _, r| { + (!vm.truthy(&r)).then_some(()) + })? + .is_none(), + )) +} + +fn a_for_each(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + each(vm, &this, args, false, |_, _, _, _| None::<()>)?; + Ok(Value::Undef) +} + +fn a_filter(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let mut out = Vec::new(); + each(vm, &this, args, false, |vm, _, v, r| { + if vm.truthy(&r) { + out.push(v); + } + None::<()> + })?; + Ok(vm.new_array(out)) +} + +fn a_map(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let mut out = Vec::with_capacity(len(vm, id)); + each(vm, &this, args, false, |_, _, _, r| { + out.push(r); + None::<()> + })?; + Ok(vm.new_array(out)) +} + +fn reduce(vm: &mut Vm, this: Value, args: &[Value], reverse: bool) -> Res { + let id = arr_id(vm, &this)?; + let f = callback(vm, args)?; + let n = len(vm, id); + let mut k = 0; + let mut acc = if args.len() >= 2 { + args[1] + } else { + if n == 0 { + return Err(vm.type_error("Array.reduce of an empty array with no initial value.")); + } + k = 1; + item(vm, id, if reverse { n - 1 } else { 0 }) + }; + while k < n { + let i = if reverse { n - 1 - k } else { k }; + if i >= len(vm, id) { + break; + } + let v = item(vm, id, i); + acc = vm.call(&f, Value::Undef, &[acc, v, Value::Num(i as f64), this])?; + k += 1; + } + Ok(acc) +} + +fn a_reduce(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + reduce(vm, this, args, false) +} + +fn a_reduce_right(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + reduce(vm, this, args, true) +} + +fn sort_values(vm: &mut Vm, list: Vec, cmp: &Value) -> Result, Value> { + if !matches!(cmp, Value::Undef) && !vm.is_callable(cmp) { + return Err(vm.type_error("The comparison function must be either a function or undefined")); + } + let (mut defined, undefs): (Vec, Vec) = + list.into_iter().partition(|v| !matches!(v, Value::Undef)); + if let Value::Undef = cmp { + let mut keyed = Vec::with_capacity(defined.len()); + for v in defined { + let s = vm.string_of(&v)?; + keyed.push((s, v)); + } + let mut sorted = merge_sort( + vm, + keyed, + &mut |vm, a: &(StrId, Value), b: &(StrId, Value)| { + Ok(vm.atoms.sref(a.0).cmp16(vm.atoms.sref(b.0)).is_gt()) + }, + )?; + defined = sorted.drain(..).map(|(_, v)| v).collect(); + } else { + let f = *cmp; + defined = merge_sort(vm, defined, &mut |vm, a: &Value, b: &Value| { + let r = vm.call(&f, Value::Undef, &[*a, *b])?; + let n = match r { + Value::Num(n) => n, + v => vm.number_of(&v)?, + }; + Ok(n > 0.0) + })?; + } + defined.extend(undefs); + Ok(defined) +} + +type Greater<'a, T> = dyn FnMut(&mut Vm, &T, &T) -> Result + 'a; + +/// Stable merge sort with a fallible comparator; `greater(a, b)` means `a` sorts after `b`. +fn merge_sort( + vm: &mut Vm, + mut v: Vec, + greater: &mut Greater, +) -> Result, Value> { + let n = v.len(); + if n < 2 { + return Ok(v); + } + let run = 8; + for start in (0..n).step_by(run) { + let end = (start + run).min(n); + for i in start + 1..end { + let mut j = i; + while j > start && greater(vm, &v[j - 1], &v[j])? { + v.swap(j - 1, j); + j -= 1; + } + } + } + let mut width = run; + let mut buf: Vec = Vec::with_capacity(n); + while width < n { + buf.clear(); + let mut start = 0; + while start < n { + let mid = (start + width).min(n); + let end = (start + 2 * width).min(n); + let (mut i, mut j) = (start, mid); + while i < mid && j < end { + if greater(vm, &v[i], &v[j])? { + buf.push(v[j].clone()); + j += 1; + } else { + buf.push(v[i].clone()); + i += 1; + } + } + buf.extend_from_slice(&v[i..mid]); + buf.extend_from_slice(&v[j..end]); + start = end; + } + std::mem::swap(&mut v, &mut buf); + width *= 2; + } + Ok(v) +} + +fn a_sort(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let list = std::mem::take(items_mut(vm, id, false)?); + let sorted = sort_values(vm, list, &arg(args, 0)); + match sorted { + Ok(s) => { + if let Kind::Array(items) = &mut vm.heap[id as usize].kind { + *items = s; + } + Ok(this) + } + Err(e) => Err(e), + } +} + +fn a_to_sorted(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let list = items(vm, id).to_vec(); + let sorted = sort_values(vm, list, &arg(args, 0))?; + Ok(vm.new_array(sorted)) +} + +fn flatten(vm: &Vm, out: &mut Vec, list: &[Value], depth: f64) { + for v in list { + if depth >= 1.0 + && let Value::Obj(o) = v + && let Kind::Array(inner) = &vm.heap[*o as usize].kind + { + flatten(vm, out, inner, depth - 1.0); + continue; + } + out.push(*v); + } +} + +fn a_flat(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let depth = match arg(args, 0) { + Value::Undef => 1.0, + v => to_integer(vm.number_of(&v)?), + }; + let list = items(vm, id).to_vec(); + let mut out = Vec::new(); + flatten(vm, &mut out, &list, depth.min(64.0)); + Ok(vm.new_array(out)) +} + +fn a_flat_map(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let mut mapped = Vec::new(); + each(vm, &this, args, false, |_, _, _, r| { + mapped.push(r); + None::<()> + })?; + let mut out = Vec::new(); + flatten(vm, &mut out, &mapped, 1.0); + Ok(vm.new_array(out)) +} + +fn a_fill(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + let s = to_index(vm, &arg(args, 1), n, 0)?; + let e = to_index(vm, &arg(args, 2), n, n)?; + let v = arg(args, 0); + let items = items_mut(vm, id, false)?; + for slot in items.iter_mut().take(e).skip(s) { + *slot = v; + } + Ok(this) +} + +fn rel_index(vm: &mut Vm, v: &Value, n: usize) -> Result, Value> { + let mut i = to_integer(vm.number_of(v)?); + if i < 0.0 { + i += n as f64; + } + Ok(if i < 0.0 || i >= n as f64 { + None + } else { + Some(i as usize) + }) +} + +fn a_at(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + Ok(match rel_index(vm, &arg(args, 0), n)? { + Some(i) => item(vm, id, i), + None => Value::Undef, + }) +} + +fn a_with(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = arr_id(vm, &this)?; + let n = len(vm, id); + let Some(i) = rel_index(vm, &arg(args, 0), n)? else { + return Err(vm.range_error("Invalid index")); + }; + let mut out = items(vm, id).to_vec(); + out[i] = arg(args, 1); + Ok(vm.new_array(out)) +} + +fn array_iter(vm: &mut Vm, this: &Value, kind: IterKind) -> Res { + let id = arr_id(vm, this)?; + let proto = vm.realm.iter_proto; + Ok(Value::Obj(vm.alloc(Obj::new( + Some(proto), + Kind::ArrayIter { + target: id, + pos: 0, + kind, + }, + )))) +} + +fn a_keys(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + array_iter(vm, &this, IterKind::Keys) +} + +fn a_values(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + array_iter(vm, &this, IterKind::Values) +} + +fn a_entries(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + array_iter(vm, &this, IterKind::Entries) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/builtins/collections.rs b/packages/codemode-rust/crates/psychoscript/src/builtins/collections.rs new file mode 100644 index 000000000000..dad4711aa1e1 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/builtins/collections.rs @@ -0,0 +1,438 @@ +//! Map, Set, Promise, generators and built-in iterators. + +use super::arg; +use crate::object::*; +use crate::value::{Id, Value}; +use crate::vm::{Reaction, Res, Vm}; + +pub fn setup(vm: &mut Vm) { + let mp = vm.realm.map_proto; + vm.ctor("Map", 0, map_ctor, mp, Value::Undef); + vm.methods( + mp, + &[ + ("get", 1, map_get), + ("set", 2, map_set), + ("has", 1, map_has), + ("delete", 1, map_delete), + ("clear", 0, map_clear), + ("forEach", 1, map_for_each), + ("keys", 0, map_keys), + ("values", 0, map_values), + ], + ); + let entries = vm.method(mp, "entries", 0, map_entries); + vm.define_hidden(mp, SYM_ITERATOR, entries); + + let sp = vm.realm.set_proto; + vm.ctor("Set", 0, set_ctor, sp, Value::Undef); + vm.methods( + sp, + &[ + ("add", 1, set_add), + ("has", 1, map_has), + ("delete", 1, map_delete), + ("clear", 0, map_clear), + ("forEach", 1, map_for_each), + ("entries", 0, map_entries), + ], + ); + let values = vm.method(sp, "values", 0, map_values); + let keys = vm.atoms.intern_static("keys"); + vm.define_hidden(sp, keys, values); + vm.define_hidden(sp, SYM_ITERATOR, values); + + let pp = vm.realm.promise_proto; + let promise = vm.ctor("Promise", 1, promise_ctor, pp, Value::Undef); + vm.methods( + promise, + &[ + ("resolve", 1, promise_resolve), + ("reject", 1, promise_reject), + ("all", 1, promise_all), + ("allSettled", 1, promise_all_settled), + ("any", 1, promise_any), + ("race", 1, promise_race), + ("withResolvers", 0, promise_with_resolvers), + ("try", 1, promise_try), + ], + ); + let then = vm.method(pp, "then", 2, promise_then); + vm.realm.promise_then = then.as_obj().unwrap_or(0); + vm.methods( + pp, + &[("catch", 1, promise_catch), ("finally", 1, promise_finally)], + ); + + let ip = vm.realm.iter_proto; + vm.method(ip, "next", 0, iter_next); + let self_iter = vm.native_fn("[Symbol.iterator]", 0, iter_self, Value::Undef); + vm.define_hidden(ip, SYM_ITERATOR, self_iter); + + let gp = vm.realm.generator_proto; + vm.methods( + gp, + &[ + ("next", 1, gen_next), + ("return", 1, gen_return), + ("throw", 1, gen_throw), + ], + ); +} + +// ---------- Map and Set ---------- + +fn map_of(vm: &mut Vm, this: &Value, what: &str) -> Result { + if let Value::Obj(id) = this + && let Kind::Map(_) | Kind::Set(_) = vm.heap[*id as usize].kind + { + return Ok(*id); + } + Err(vm.type_error(&format!("Method {what} called on incompatible receiver"))) +} + +fn table<'a>(vm: &'a mut Vm<'_>, id: Id) -> &'a mut OrderedMap { + match &mut vm.heap[id as usize].kind { + Kind::Map(m) | Kind::Set(m) => m, + _ => unreachable!("checked by map_of"), + } +} + +fn map_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if !matches!(this, Value::Uninit) { + return Err(vm.type_error("Constructor Map requires 'new'")); + } + let proto = vm.realm.map_proto; + let id = vm.alloc(Obj::new(Some(proto), Kind::Map(Box::default()))); + let src = arg(args, 0); + if !src.is_nullish() { + for entry in vm.iterate_to_vec(&src)? { + if !matches!(entry, Value::Obj(_)) { + let d = vm.describe(&entry); + return Err(vm.type_error(&format!("Iterator value {d} is not an entry object"))); + } + let k = vm.get_elem(&entry, &Value::Num(0.0))?; + let v = vm.get_elem(&entry, &Value::Num(1.0))?; + let key = vm.map_key(&k); + table(vm, id).set(key, k, v); + } + } + Ok(Value::Obj(id)) +} + +fn set_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if !matches!(this, Value::Uninit) { + return Err(vm.type_error("Constructor Set requires 'new'")); + } + let proto = vm.realm.set_proto; + let id = vm.alloc(Obj::new(Some(proto), Kind::Set(Box::default()))); + let src = arg(args, 0); + if !src.is_nullish() { + for v in vm.iterate_to_vec(&src)? { + let key = vm.map_key(&v); + table(vm, id).set(key, v, Value::Undef); + } + } + Ok(Value::Obj(id)) +} + +fn map_get(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "Map.prototype.get")?; + let key = vm.map_key(&arg(args, 0)); + Ok(table(vm, id).get(key).unwrap_or_default()) +} + +fn map_set(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "Map.prototype.set")?; + let key = vm.map_key(&arg(args, 0)); + table(vm, id).set(key, arg(args, 0), arg(args, 1)); + Ok(this) +} + +fn set_add(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "Set.prototype.add")?; + let key = vm.map_key(&arg(args, 0)); + table(vm, id).set(key, arg(args, 0), Value::Undef); + Ok(this) +} + +fn map_has(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "has")?; + let key = vm.map_key(&arg(args, 0)); + Ok(Value::Bool(table(vm, id).has(key))) +} + +fn map_delete(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "delete")?; + let key = vm.map_key(&arg(args, 0)); + Ok(Value::Bool(table(vm, id).delete(key))) +} + +fn map_clear(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "clear")?; + table(vm, id).clear(); + Ok(Value::Undef) +} + +fn map_for_each(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let id = map_of(vm, &this, "forEach")?; + let f = arg(args, 0); + if !vm.is_callable(&f) { + let d = vm.describe(&f); + return Err(vm.type_error(&format!("{d} is not a function"))); + } + let is_set = matches!(vm.heap[id as usize].kind, Kind::Set(_)); + let this_arg = arg(args, 1); + let mut i = 0; + loop { + let entry = { + let m = table(vm, id); + if i >= m.entries.len() { + break; + } + m.entries[i] + }; + i += 1; + if let Some((k, v)) = entry { + let v = if is_set { k } else { v }; + vm.call(&f, this_arg, &[v, k, this])?; + } + } + Ok(Value::Undef) +} + +fn map_iter(vm: &mut Vm, this: &Value, kind: IterKind) -> Res { + let id = map_of(vm, this, "iterator")?; + let proto = vm.realm.iter_proto; + Ok(Value::Obj(vm.alloc(Obj::new( + Some(proto), + Kind::MapIter { + target: id, + pos: 0, + kind, + }, + )))) +} + +fn map_keys(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_iter(vm, &this, IterKind::Keys) +} + +fn map_values(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_iter(vm, &this, IterKind::Values) +} + +fn map_entries(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_iter(vm, &this, IterKind::Entries) +} + +// ---------- iterators and generators ---------- + +fn iter_next(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let r = vm.iter_step(&this)?; + Ok(match r { + Some(v) => vm.iter_result(v, false), + None => vm.iter_result(Value::Undef, true), + }) +} + +fn iter_self(_vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + Ok(this) +} + +fn gen_resume(vm: &mut Vm, this: &Value, mode: u8, v: Value) -> Res { + let Value::Obj(id) = this else { + return Err(vm.type_error("Generator method called on incompatible receiver")); + }; + if !matches!(vm.heap[*id as usize].kind, Kind::Generator(_)) { + return Err(vm.type_error("Generator method called on incompatible receiver")); + } + let (value, done) = vm.resume_generator(*id, mode, v)?; + Ok(vm.iter_result(value, done)) +} + +fn gen_next(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + gen_resume(vm, &this, 0, arg(args, 0)) +} + +fn gen_return(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + gen_resume(vm, &this, 1, arg(args, 0)) +} + +fn gen_throw(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + gen_resume(vm, &this, 2, arg(args, 0)) +} + +// ---------- Promise ---------- + +fn promise_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if !matches!(this, Value::Uninit) { + return Err(vm.type_error("Promise constructor cannot be invoked without 'new'")); + } + let executor = arg(args, 0); + if !vm.is_callable(&executor) { + let d = vm.describe(&executor); + return Err(vm.type_error(&format!("Promise resolver {d} is not a function"))); + } + let p = vm.new_promise(); + let (res, rej) = vm.create_resolvers(p); + if let Err(e) = vm.call(&executor, Value::Undef, &[res, rej]) { + if vm.fatal.is_some() { + return Err(e); + } + vm.call(&rej, Value::Undef, &[e])?; + } + Ok(Value::Obj(p)) +} + +fn promise_resolve(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Obj(vm.promise_resolve(arg(args, 0)))) +} + +fn promise_reject(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let p = vm.new_promise(); + vm.reject(p, arg(args, 0)); + Ok(Value::Obj(p)) +} + +fn combinator(vm: &mut Vm, args: &[Value], kind: CombKind) -> Res { + let items = vm.iterate_to_vec(&arg(args, 0))?; + let result = vm.new_promise(); + let n = items.len(); + if n == 0 { + if kind == CombKind::Any { + let proto = vm.realm.aggregate_error_proto; + let e = vm.make_error(proto, "All promises were rejected"); + let empty = vm.new_array(Vec::new()); + if let Value::Obj(eid) = e { + let ek = vm.names.errors; + vm.define_hidden(eid, ek, empty); + } + vm.reject(result, e); + } else { + let empty = vm.new_array(Vec::new()); + vm.resolve_promise(result, empty); + } + return Ok(Value::Obj(result)); + } + let proto = vm.realm.object_proto; + let comb = vm.alloc(Obj::new( + Some(proto), + Kind::Combinator(Box::new(Combinator { + kind, + promise: result, + values: vec![Value::Undef; n], + remaining: n, + })), + )); + for (i, item) in items.into_iter().enumerate() { + let p = vm.promise_resolve(item); + vm.perform_then( + p, + Reaction::Comb { + comb, + index: i as u32, + }, + ); + } + Ok(Value::Obj(result)) +} + +fn promise_all(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + combinator(vm, args, CombKind::All) +} + +fn promise_all_settled(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + combinator(vm, args, CombKind::AllSettled) +} + +fn promise_any(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + combinator(vm, args, CombKind::Any) +} + +fn promise_race(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let items = vm.iterate_to_vec(&arg(args, 0))?; + let result = vm.new_promise(); + for item in items { + let p = vm.promise_resolve(item); + vm.perform_then(p, Reaction::Resolve(result)); + } + Ok(Value::Obj(result)) +} + +fn promise_with_resolvers(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + let p = vm.new_promise(); + let (res, rej) = vm.create_resolvers(p); + let o = vm.new_object(); + let (pk, rk, jk) = ( + vm.atoms.intern_static("promise"), + vm.atoms.intern_static("resolve"), + vm.atoms.intern_static("reject"), + ); + vm.define(o, pk, Value::Obj(p)); + vm.define(o, rk, res); + vm.define(o, jk, rej); + Ok(Value::Obj(o)) +} + +fn promise_try(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let p = vm.new_promise(); + let rest = if args.is_empty() { &[][..] } else { &args[1..] }; + match vm.call(&arg(args, 0), Value::Undef, rest) { + Ok(v) => vm.resolve_promise(p, v), + Err(e) => { + if vm.fatal.is_some() { + return Err(e); + } + vm.reject(p, e); + } + } + Ok(Value::Obj(p)) +} + +fn this_promise(vm: &mut Vm, this: &Value) -> Result { + match vm.as_promise(this) { + Some(p) => Ok(p), + None => Err(vm.type_error("Promise.prototype method called on incompatible receiver")), + } +} + +fn promise_then(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let p = this_promise(vm, &this)?; + let derived = vm.new_promise(); + vm.perform_then( + p, + Reaction::Then { + on_ful: arg(args, 0), + on_rej: arg(args, 1), + derived, + }, + ); + Ok(Value::Obj(derived)) +} + +fn promise_catch(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let p = this_promise(vm, &this)?; + let derived = vm.new_promise(); + vm.perform_then( + p, + Reaction::Then { + on_ful: Value::Undef, + on_rej: arg(args, 0), + derived, + }, + ); + Ok(Value::Obj(derived)) +} + +fn promise_finally(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let p = this_promise(vm, &this)?; + let derived = vm.new_promise(); + let cleanup = arg(args, 0); + if vm.is_callable(&cleanup) { + vm.perform_then(p, Reaction::Finally { cleanup, derived }); + } else { + vm.perform_then(p, Reaction::Resolve(derived)); + } + Ok(Value::Obj(derived)) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/builtins/mod.rs b/packages/codemode-rust/crates/psychoscript/src/builtins/mod.rs new file mode 100644 index 000000000000..6455c5efb27e --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/builtins/mod.rs @@ -0,0 +1,186 @@ +//! Native built-ins: prototypes, constructors and global functions, created fresh for every run. + +mod array; +mod collections; +mod object; +mod string; + +use crate::object::*; +use crate::value::{Id, Value}; +use crate::vm::{NativeFn, Vm}; + +/// Global names a program cannot assign to. +pub const GLOBAL_NAMES: &[&str] = &[ + "Object", + "Function", + "Array", + "String", + "Number", + "Boolean", + "Symbol", + "Math", + "JSON", + "Promise", + "Map", + "Set", + "Error", + "TypeError", + "RangeError", + "SyntaxError", + "ReferenceError", + "EvalError", + "URIError", + "AggregateError", + "console", + "parseInt", + "parseFloat", + "isNaN", + "isFinite", + "NaN", + "Infinity", + "tools", + "globalThis", +]; + +#[inline] +pub fn arg(args: &[Value], i: usize) -> Value { + args.get(i).cloned().unwrap_or_default() +} + +impl<'rt> Vm<'rt> { + pub fn native_fn(&mut self, name: &'static str, length: u8, f: NativeFn, data: Value) -> Value { + let name = self.atoms.intern_static(name); + let proto = self.realm.function_proto; + Value::Obj(self.alloc(Obj::new( + Some(proto), + Kind::Native { + f, + data, + name, + length, + ctor: false, + }, + ))) + } + + pub fn method(&mut self, target: Id, name: &'static str, length: u8, f: NativeFn) -> Value { + let v = self.native_fn(name, length, f, Value::Undef); + let key = self.atoms.intern(name); + self.define_hidden(target, key, v); + v + } + + fn methods(&mut self, target: Id, list: &[(&'static str, u8, NativeFn)]) { + for (name, len, f) in list { + self.method(target, name, *len, *f); + } + } + + fn constant(&mut self, target: Id, name: &'static str, v: Value) { + let key = self.atoms.intern_static(name); + self.heap[target as usize].props.insert(key, v, 0); + } + + /// A constructor whose `prototype` is `proto`; `data` reaches the native as its callee data. + fn ctor(&mut self, name: &'static str, length: u8, f: NativeFn, proto: Id, data: Value) -> Id { + let name_atom = self.atoms.intern_static(name); + let fp = self.realm.function_proto; + let c = self.alloc(Obj::new( + Some(fp), + Kind::Native { + f, + data, + name: name_atom, + length, + ctor: true, + }, + )); + let (pk, ck) = (self.names.prototype, self.names.constructor); + self.heap[c as usize].props.insert(pk, Value::Obj(proto), 0); + self.define_hidden(proto, ck, Value::Obj(c)); + self.global(name, Value::Obj(c)); + c + } + + fn global(&mut self, name: &'static str, v: Value) { + let a = self.atoms.intern_static(name); + self.global_map.insert(a, v); + } + + fn plain(&mut self, proto: Id) -> Id { + self.alloc(Obj::new(Some(proto), Kind::Ordinary)) + } + + pub fn native_data(&self, callee: Id) -> Value { + match &self.heap[callee as usize].kind { + Kind::Native { data, .. } => *data, + _ => Value::Undef, + } + } + + /// An iterator result `{ value, done }`. + pub fn iter_result(&mut self, value: Value, done: bool) -> Value { + let id = self.new_object(); + let (vk, dk) = (self.names.value, self.names.done); + let props = &mut self.heap[id as usize].props; + props.push_new(vk, value, DEFAULT_FLAGS); + props.push_new(dk, Value::Bool(done), DEFAULT_FLAGS); + Value::Obj(id) + } + + pub fn setup(&mut self) { + let object_proto = self.alloc(Obj::new(None, Kind::Ordinary)); + self.realm.object_proto = object_proto; + let function_proto = self.plain(object_proto); + self.realm.function_proto = function_proto; + self.realm.array_proto = self.plain(object_proto); + self.realm.string_proto = self.plain(object_proto); + self.realm.number_proto = self.plain(object_proto); + self.realm.boolean_proto = self.plain(object_proto); + self.realm.symbol_proto = self.plain(object_proto); + self.realm.error_proto = self.plain(object_proto); + let ep = self.realm.error_proto; + self.realm.type_error_proto = self.plain(ep); + self.realm.range_error_proto = self.plain(ep); + self.realm.syntax_error_proto = self.plain(ep); + self.realm.reference_error_proto = self.plain(ep); + self.realm.aggregate_error_proto = self.plain(ep); + self.realm.promise_proto = self.plain(object_proto); + self.realm.map_proto = self.plain(object_proto); + self.realm.set_proto = self.plain(object_proto); + self.realm.iter_proto = self.plain(object_proto); + let ip = self.realm.iter_proto; + self.realm.generator_proto = self.plain(ip); + + object::setup(self); + array::setup(self); + string::setup(self); + collections::setup(self); + + let tools = self.tool_ref(""); + self.realm.tools = tools.as_obj().unwrap_or(0); + self.global("tools", tools); + self.global("NaN", Value::Num(f64::NAN)); + self.global("Infinity", Value::Num(f64::INFINITY)); + self.global("undefined", Value::Undef); + } +} + +pub fn this_obj(vm: &mut Vm, this: &Value, what: &str) -> Result { + match this { + Value::Obj(id) => Ok(*id), + _ => Err(vm.type_error(&format!("{what} called on a non-object"))), + } +} + +pub fn to_index(vm: &mut Vm, v: &Value, len: usize, default: usize) -> Result { + if let Value::Undef = v { + return Ok(default); + } + let n = crate::value::to_integer(vm.number_of(v)?); + Ok(if n < 0.0 { + (len as f64 + n).max(0.0) as usize + } else { + n.min(len as f64) as usize + }) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/builtins/object.rs b/packages/codemode-rust/crates/psychoscript/src/builtins/object.rs new file mode 100644 index 000000000000..7b1a64783576 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/builtins/object.rs @@ -0,0 +1,707 @@ +//! Object, Function, Error, Boolean, Symbol, JSON, console and the global functions. + +use super::{arg, this_obj}; +use crate::convert; +use crate::object::*; +use crate::value::{Id, Value, parse_float_prefix, to_int32}; +use crate::vm::{Res, Vm}; + +pub fn setup(vm: &mut Vm) { + let op = vm.realm.object_proto; + let object = vm.ctor("Object", 1, object_ctor, op, Value::Undef); + vm.methods( + object, + &[ + ("keys", 1, object_keys), + ("values", 1, object_values), + ("entries", 1, object_entries), + ("assign", 2, object_assign), + ("fromEntries", 1, object_from_entries), + ("hasOwn", 2, object_has_own), + ("freeze", 1, object_freeze), + ("isFrozen", 1, object_is_frozen), + ("seal", 1, object_seal), + ("isSealed", 1, object_is_sealed), + ("preventExtensions", 1, object_prevent_extensions), + ("isExtensible", 1, object_is_extensible), + ("create", 2, object_create), + ("getPrototypeOf", 1, object_get_prototype_of), + ("is", 2, object_is), + ], + ); + vm.methods( + op, + &[ + ("hasOwnProperty", 1, proto_has_own_property), + ("toString", 0, proto_to_string), + ("toLocaleString", 0, proto_to_string), + ("valueOf", 0, proto_value_of), + ("isPrototypeOf", 1, proto_is_prototype_of), + ("propertyIsEnumerable", 1, proto_property_is_enumerable), + ], + ); + + let fp = vm.realm.function_proto; + vm.ctor("Function", 1, function_ctor, fp, Value::Undef); + vm.methods( + fp, + &[ + ("call", 1, function_call), + ("apply", 2, function_apply), + ("bind", 1, function_bind), + ], + ); + + let errors = [ + ("Error", vm.realm.error_proto), + ("TypeError", vm.realm.type_error_proto), + ("RangeError", vm.realm.range_error_proto), + ("SyntaxError", vm.realm.syntax_error_proto), + ("ReferenceError", vm.realm.reference_error_proto), + ("AggregateError", vm.realm.aggregate_error_proto), + ]; + let (nk, mk) = (vm.names.name, vm.names.message); + let mut error_ctor_id = 0; + for (name, proto) in errors { + let f: crate::vm::NativeFn = if name == "AggregateError" { + aggregate_error_ctor + } else { + error_ctor + }; + let c = vm.ctor(name, 1, f, proto, Value::Obj(proto)); + if name == "Error" { + error_ctor_id = c; + vm.method(c, "isError", 1, error_is_error); + } else { + vm.heap[c as usize].proto = Some(error_ctor_id); + } + let (n, m) = (vm.static_str(name), vm.static_str("")); + vm.define_hidden(proto, nk, n); + vm.define_hidden(proto, mk, m); + } + for name in ["EvalError", "URIError"] { + let ep = vm.realm.error_proto; + let proto = vm.plain(ep); + let c = vm.ctor(name, 1, error_ctor, proto, Value::Obj(proto)); + vm.heap[c as usize].proto = Some(error_ctor_id); + let (n, m) = (vm.static_str(name), vm.static_str("")); + vm.define_hidden(proto, nk, n); + vm.define_hidden(proto, mk, m); + } + let ep = vm.realm.error_proto; + vm.method(ep, "toString", 0, error_to_string); + + let bp = vm.realm.boolean_proto; + vm.ctor("Boolean", 1, boolean_ctor, bp, Value::Undef); + vm.methods( + bp, + &[ + ("toString", 0, boolean_to_string), + ("valueOf", 0, boolean_value_of), + ], + ); + + let sp = vm.realm.symbol_proto; + let symbol = vm.ctor("Symbol", 0, symbol_ctor, sp, Value::Undef); + vm.constant(symbol, "iterator", Value::Sym(0)); + vm.methods(sp, &[("toString", 0, symbol_to_string)]); + + let json = vm.new_object(); + vm.methods( + json, + &[("parse", 2, json_parse), ("stringify", 3, json_stringify)], + ); + vm.global("JSON", Value::Obj(json)); + + let console = vm.new_object(); + vm.methods( + console, + &[ + ("log", 0, console_log), + ("info", 0, console_log), + ("debug", 0, console_debug), + ("warn", 0, console_warn), + ("error", 0, console_error), + ("dir", 0, console_dir), + ], + ); + vm.global("console", Value::Obj(console)); + + let parse_int = vm.native_fn("parseInt", 2, global_parse_int, Value::Undef); + let parse_float = vm.native_fn("parseFloat", 1, global_parse_float, Value::Undef); + vm.global("parseInt", parse_int); + vm.global("parseFloat", parse_float); + let is_nan = vm.native_fn("isNaN", 1, global_is_nan, Value::Undef); + let is_finite = vm.native_fn("isFinite", 1, global_is_finite, Value::Undef); + vm.global("isNaN", is_nan); + vm.global("isFinite", is_finite); +} + +// ---------- Object ---------- + +fn object_ctor(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + match arg(args, 0) { + Value::Undef | Value::Null => Ok(Value::Obj(vm.new_object())), + v @ Value::Obj(_) => Ok(v), + _ => Err(vm.type_error("Object() of a primitive value is not supported")), + } +} + +fn require_object_coercible(vm: &mut Vm, v: &Value) -> Result<(), Value> { + if v.is_nullish() { + return Err(vm.type_error("Cannot convert undefined or null to object")); + } + Ok(()) +} + +fn entries_of(vm: &mut Vm, v: &Value) -> Result, Value> { + require_object_coercible(vm, v)?; + Ok(match v { + Value::Obj(id) => { + let id = *id; + vm.own_entries(id) + .into_iter() + .map(|(k, v)| (Value::Str(vm.atoms.atom_str(k)), v)) + .collect() + } + Value::Str(s) => { + let units = vm.atoms.sref(*s).utf16(); + units + .iter() + .enumerate() + .map(|(i, c)| (vm.string_val(i.to_string()), vm.char_str(*c))) + .collect() + } + _ => Vec::new(), + }) +} + +fn object_keys(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let v = arg(args, 0); + if let Value::Obj(id) = v { + require_object_coercible(vm, &v)?; + let keys = vm.own_keys(id); + let items = keys + .into_iter() + .map(|k| Value::Str(vm.atoms.atom_str(k))) + .collect(); + return Ok(vm.new_array(items)); + } + let items = entries_of(vm, &v)?.into_iter().map(|(k, _)| k).collect(); + Ok(vm.new_array(items)) +} + +fn object_values(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let items = entries_of(vm, &arg(args, 0))? + .into_iter() + .map(|(_, v)| v) + .collect(); + Ok(vm.new_array(items)) +} + +fn object_entries(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let pairs = entries_of(vm, &arg(args, 0))?; + let items = pairs + .into_iter() + .map(|(k, v)| vm.new_array(vec![k, v])) + .collect(); + Ok(vm.new_array(items)) +} + +fn object_assign(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let target = arg(args, 0); + let Value::Obj(t) = target else { + return Err(vm.type_error("Object.assign target must be an object")); + }; + for src in args.iter().skip(1) { + if let Value::Obj(s) = src { + for (k, v) in vm.own_entries(*s) { + vm.set_obj(t, k, v)?; + } + } else { + vm.copy_props(t, src, &[])?; + } + } + Ok(target) +} + +fn object_from_entries(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let items = vm.iterate_to_vec(&arg(args, 0))?; + let id = vm.new_object(); + for item in items { + let k = vm.get_elem(&item, &Value::Num(0.0))?; + let v = vm.get_elem(&item, &Value::Num(1.0))?; + let a = vm.key_of(&k)?; + vm.define(id, a, v); + } + Ok(Value::Obj(id)) +} + +fn object_has_own(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let o = arg(args, 0); + require_object_coercible(vm, &o)?; + let k = vm.key_of(&arg(args, 1))?; + Ok(Value::Bool(match o { + Value::Obj(id) => vm.has_own(id, k), + Value::Str(s) => vm + .atoms + .index(k) + .is_some_and(|i| (i as usize) < vm.atoms.sref(s).len16()), + _ => false, + })) +} + +fn set_flags(vm: &mut Vm, args: &[Value], flags: u8) -> Res { + let v = arg(args, 0); + if let Value::Obj(id) = v { + vm.heap[id as usize].flags |= flags; + } + Ok(v) +} + +fn has_flags(vm: &mut Vm, args: &[Value], flags: u8, primitive: bool) -> Res { + Ok(Value::Bool(match arg(args, 0) { + Value::Obj(id) => { + let o = &vm.heap[id as usize]; + let empty = + o.props.len() == 0 && !matches!(&o.kind, Kind::Array(items) if !items.is_empty()); + o.flags & flags == flags + || (flags != NON_EXTENSIBLE && empty && o.flags & NON_EXTENSIBLE != 0) + } + _ => primitive, + })) +} + +fn object_freeze(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + set_flags(vm, args, FROZEN | SEALED | NON_EXTENSIBLE) +} +fn object_is_frozen(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + has_flags(vm, args, FROZEN, true) +} +fn object_seal(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + set_flags(vm, args, SEALED | NON_EXTENSIBLE) +} +fn object_is_sealed(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + has_flags(vm, args, SEALED, true) +} +fn object_prevent_extensions(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + set_flags(vm, args, NON_EXTENSIBLE) +} +fn object_is_extensible(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(match arg(args, 0) { + Value::Obj(id) => vm.heap[id as usize].flags & NON_EXTENSIBLE == 0, + _ => false, + })) +} + +fn object_create(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let proto = match arg(args, 0) { + Value::Obj(p) => Some(p), + Value::Null => None, + _ => return Err(vm.type_error("Object prototype may only be an Object or null")), + }; + if !matches!(arg(args, 1), Value::Undef) { + return Err(vm.type_error("Property descriptors are not supported")); + } + Ok(Value::Obj(vm.alloc(Obj::new(proto, Kind::Ordinary)))) +} + +fn object_get_prototype_of(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(match arg(args, 0) { + Value::Obj(id) => vm.heap[id as usize] + .proto + .map(Value::Obj) + .unwrap_or(Value::Null), + Value::Str(_) => Value::Obj(vm.realm.string_proto), + Value::Num(_) => Value::Obj(vm.realm.number_proto), + Value::Bool(_) => Value::Obj(vm.realm.boolean_proto), + _ => return Err(vm.type_error("Cannot convert undefined or null to object")), + }) +} + +fn object_is(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let (a, b) = (arg(args, 0), arg(args, 1)); + Ok(Value::Bool(match (&a, &b) { + (Value::Num(x), Value::Num(y)) => { + (x.is_nan() && y.is_nan()) || (x == y && x.is_sign_negative() == y.is_sign_negative()) + } + _ => vm.strict_eq(&a, &b), + })) +} + +fn proto_has_own_property(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let k = vm.key_of(&arg(args, 0))?; + Ok(Value::Bool(match this { + Value::Obj(id) => vm.has_own(id, k), + Value::Str(s) => { + vm.atoms + .index(k) + .is_some_and(|i| (i as usize) < vm.atoms.sref(s).len16()) + || k == vm.names.length + } + _ => false, + })) +} + +pub fn tag_of(vm: &Vm, v: &Value) -> &'static str { + match v { + Value::Undef | Value::Uninit => "Undefined", + Value::Null => "Null", + Value::Num(_) => "Number", + Value::Str(_) => "String", + Value::Bool(_) => "Boolean", + Value::Sym(_) => "Symbol", + Value::Obj(id) => match &vm.heap[*id as usize].kind { + Kind::Array(_) => "Array", + Kind::Arguments(_) => "Arguments", + Kind::Closure(_) | Kind::Native { .. } | Kind::Bound(_) | Kind::ToolRef(_) => { + "Function" + } + Kind::Error(_) => "Error", + Kind::Promise(_) => "Promise", + Kind::Map(_) => "Map", + Kind::Set(_) => "Set", + Kind::Generator(_) => "Generator", + Kind::ArrayIter { .. } => "Array Iterator", + Kind::MapIter { .. } => "Map Iterator", + Kind::StrIter { .. } => "String Iterator", + _ => "Object", + }, + } +} + +fn proto_to_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + if let Value::Obj(id) = this + && let Kind::Error(_) = vm.heap[id as usize].kind + { + return Ok(vm.static_str("[object Error]")); + } + let t = format!("[object {}]", tag_of(vm, &this)); + Ok(vm.static_str(&t)) +} + +fn proto_value_of(_vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + Ok(this) +} + +fn proto_is_prototype_of(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let (Value::Obj(p), Value::Obj(mut cur)) = (this, arg(args, 0)) else { + return Ok(Value::Bool(false)); + }; + while let Some(next) = vm.heap[cur as usize].proto { + if next == p { + return Ok(Value::Bool(true)); + } + cur = next; + } + Ok(Value::Bool(false)) +} + +fn proto_property_is_enumerable(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let k = vm.key_of(&arg(args, 0))?; + let Value::Obj(id) = this else { + return Ok(Value::Bool(false)); + }; + let o = &vm.heap[id as usize]; + if let Kind::Array(items) = &o.kind + && let Some(i) = vm.atoms.index(k) + { + return Ok(Value::Bool((i as usize) < items.len())); + } + Ok(Value::Bool( + o.props + .find(k) + .is_some_and(|i| o.props.items[i].flags & ENUMERABLE != 0), + )) +} + +// ---------- Function ---------- + +fn function_ctor(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + Err(vm.type_error("Function() is not supported; write a function expression instead")) +} + +fn function_call(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let rest = if args.is_empty() { &[][..] } else { &args[1..] }; + vm.call(&this, arg(args, 0), rest) +} + +fn function_apply(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let list = match arg(args, 1) { + Value::Undef | Value::Null => Vec::new(), + v @ Value::Obj(_) => array_like(vm, &v)?, + _ => return Err(vm.type_error("CreateListFromArrayLike called on non-object")), + }; + vm.call(&this, arg(args, 0), &list) +} + +pub fn array_like(vm: &mut Vm, v: &Value) -> Result, Value> { + let Value::Obj(id) = v else { + return Ok(Vec::new()); + }; + if let Kind::Array(items) | Kind::Arguments(items) = &vm.heap[*id as usize].kind { + return Ok(items.clone()); + } + let lk = vm.names.length; + let len = vm.get_obj(*id, lk); + let n = crate::value::to_integer(vm.number_of(&len)?) + .clamp(0.0, crate::ops::MAX_ARRAY_LEN as f64) as usize; + let mut out = Vec::with_capacity(n); + for i in 0..n { + out.push(vm.get_elem(v, &Value::Num(i as f64))?); + } + Ok(out) +} + +fn function_bind(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if !vm.is_callable(&this) { + return Err(vm.type_error("Bind must be called on a function")); + } + let rest = args.iter().skip(1).cloned().collect(); + let fp = vm.realm.function_proto; + Ok(Value::Obj(vm.alloc(Obj::new( + Some(fp), + Kind::Bound(Box::new((this, arg(args, 0), rest))), + )))) +} + +// ---------- Error ---------- + +fn make_error_from(vm: &mut Vm, proto: Id, message: &Value, options: &Value) -> Res { + let id = vm.alloc(Obj::new(Some(proto), Kind::Error(None))); + if !matches!(message, Value::Undef) { + let m = vm.string_of(message)?; + let mk = vm.names.message; + vm.define_hidden(id, mk, Value::Str(m)); + } + if let Value::Obj(o) = options { + let ck = vm.names.cause; + if vm.has_key(*o, ck) { + let c = vm.get_obj(*o, ck); + vm.define_hidden(id, ck, c); + } + } + Ok(Value::Obj(id)) +} + +fn error_ctor(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let proto = vm + .native_data(callee) + .as_obj() + .unwrap_or(vm.realm.error_proto); + make_error_from(vm, proto, &arg(args, 0), &arg(args, 1)) +} + +fn aggregate_error_ctor(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let proto = vm + .native_data(callee) + .as_obj() + .unwrap_or(vm.realm.aggregate_error_proto); + let e = make_error_from(vm, proto, &arg(args, 1), &arg(args, 2))?; + let errors = vm.iterate_to_vec(&arg(args, 0))?; + let arr = vm.new_array(errors); + if let Value::Obj(id) = e { + let ek = vm.names.errors; + vm.define_hidden(id, ek, arr); + } + Ok(e) +} + +fn error_is_error(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool( + matches!(arg(args, 0), Value::Obj(id) if matches!(vm.heap[id as usize].kind, Kind::Error(_))), + )) +} + +fn error_to_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let id = this_obj(vm, &this, "Error.prototype.toString")?; + let s = convert::error_to_string(vm, id); + Ok(vm.string_val(s)) +} + +// ---------- Boolean and Symbol ---------- + +fn boolean_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if let Value::Uninit = this { + return Err( + vm.type_error("Boolean wrapper objects are not supported; call Boolean(value) instead") + ); + } + Ok(Value::Bool(vm.truthy(&arg(args, 0)))) +} + +fn this_bool(vm: &mut Vm, this: &Value) -> Result { + match this { + Value::Bool(b) => Ok(*b), + _ => Err(vm.type_error("Boolean.prototype method called on an incompatible receiver")), + } +} + +fn boolean_to_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let b = this_bool(vm, &this)?; + Ok(vm.static_str(if b { "true" } else { "false" })) +} + +fn boolean_value_of(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + Ok(Value::Bool(this_bool(vm, &this)?)) +} + +fn symbol_ctor(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + Err(vm.type_error("Custom symbols are not supported")) +} + +fn symbol_to_string(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + Ok(vm.static_str("Symbol(Symbol.iterator)")) +} + +// ---------- JSON ---------- + +fn json_parse(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let text = vm.string_of(&arg(args, 0))?; + let text = vm.text(text).to_owned(); + let v = convert::parse(vm, &text)?; + let reviver = arg(args, 1); + if !vm.is_callable(&reviver) { + return Ok(v); + } + let holder = vm.new_object(); + let empty = vm.atoms.intern_static(""); + vm.define(holder, empty, v); + revive(vm, &reviver, Value::Obj(holder), empty) +} + +fn revive(vm: &mut Vm, reviver: &Value, holder: Value, key: Atom) -> Res { + let val = vm.get(&holder, key)?; + if let Value::Obj(id) = val { + let keys: Vec = vm.own_keys(id); + for k in keys { + let nv = revive(vm, reviver, val, k)?; + if let Value::Undef = nv { + vm.delete(&val, k)?; + } else { + vm.set_obj(id, k, nv)?; + } + } + } + let kv = Value::Str(vm.atoms.atom_str(key)); + vm.call(reviver, holder, &[kv, val]) +} + +fn json_stringify(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let replacer = arg(args, 1); + let mut opts = convert::Stringify { + indent: String::new(), + replacer_fn: None, + allow: None, + }; + if vm.is_callable(&replacer) { + opts.replacer_fn = Some(replacer); + } else if let Value::Obj(id) = replacer + && let Kind::Array(items) = &vm.heap[id as usize].kind + { + let items = items.clone(); + let mut allow = Vec::new(); + for i in items { + if matches!(i, Value::Str(_) | Value::Num(_)) { + let a = vm.key_of(&i)?; + if !allow.contains(&a) { + allow.push(a); + } + } + } + opts.allow = Some(allow); + } + match arg(args, 2) { + Value::Num(n) => opts.indent = " ".repeat(n.clamp(0.0, 10.0) as usize), + Value::Str(s) => opts.indent = vm.text(s).chars().take(10).collect(), + _ => {} + } + Ok(match convert::stringify(vm, &arg(args, 0), &opts)? { + Some(s) => vm.string_val(s), + None => Value::Undef, + }) +} + +// ---------- console ---------- + +fn log_line(vm: &mut Vm, prefix: &str, args: &[Value]) -> Res { + let mut line = String::from(prefix); + for (i, a) in args.iter().enumerate() { + if i > 0 { + line.push(' '); + } + line.push_str(&convert::format_value(vm, a)); + } + vm.logs.push(line); + Ok(Value::Undef) +} + +fn console_log(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + log_line(vm, "", args) +} +fn console_debug(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + log_line(vm, "[debug] ", args) +} +fn console_warn(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + log_line(vm, "[warn] ", args) +} +fn console_error(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + log_line(vm, "[error] ", args) +} +fn console_dir(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + log_line(vm, "", &args[..args.len().min(1)]) +} + +// ---------- global functions ---------- + +pub fn global_parse_int(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let s = vm.string_of(&arg(args, 0))?; + let mut radix = to_int32(vm.number_of(&arg(args, 1))?); + let owned = vm.text(s).to_owned(); + let t = owned.trim_start_matches(crate::value::is_js_whitespace); + let (neg, mut t) = match t.as_bytes().first() { + Some(b'-') => (true, &t[1..]), + Some(b'+') => (false, &t[1..]), + _ => (false, t), + }; + if radix == 0 { + radix = 10; + if t.starts_with("0x") || t.starts_with("0X") { + radix = 16; + t = &t[2..]; + } + } else if radix == 16 && (t.starts_with("0x") || t.starts_with("0X")) { + t = &t[2..]; + } + if !(2..=36).contains(&radix) { + return Ok(Value::Num(f64::NAN)); + } + let mut v = 0.0f64; + let mut any = false; + for c in t.chars() { + match c.to_digit(radix as u32) { + Some(d) => { + v = v * radix as f64 + d as f64; + any = true; + } + None => break, + } + } + if !any { + return Ok(Value::Num(f64::NAN)); + } + Ok(Value::Num(if neg { -v } else { v })) +} + +pub fn global_parse_float(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let s = vm.string_of(&arg(args, 0))?; + Ok(Value::Num(parse_float_prefix(vm.text(s)))) +} + +fn global_is_nan(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(vm.number_of(&arg(args, 0))?.is_nan())) +} + +fn global_is_finite(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(vm.number_of(&arg(args, 0))?.is_finite())) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/builtins/string.rs b/packages/codemode-rust/crates/psychoscript/src/builtins/string.rs new file mode 100644 index 000000000000..b00e10ce80c8 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/builtins/string.rs @@ -0,0 +1,915 @@ +//! String, Number and Math. + +use super::{arg, to_index}; +use crate::object::*; +use crate::ops::MAX_STRING_LEN; +use crate::strings::{StrId, StrRef}; +use crate::value::{ + Id, Value, is_js_whitespace, num_to_fixed, num_to_radix, num_to_string, to_integer, to_uint32, +}; +use crate::vm::{Res, Vm}; + +pub fn setup(vm: &mut Vm) { + let sp = vm.realm.string_proto; + let string = vm.ctor("String", 1, string_ctor, sp, Value::Undef); + vm.methods( + string, + &[ + ("fromCharCode", 1, string_from_char_code), + ("fromCodePoint", 1, string_from_code_point), + ], + ); + vm.methods( + sp, + &[ + ("charAt", 1, s_char_at), + ("charCodeAt", 1, s_char_code_at), + ("codePointAt", 1, s_code_point_at), + ("at", 1, s_at), + ("indexOf", 1, s_index_of), + ("lastIndexOf", 1, s_last_index_of), + ("includes", 1, s_includes), + ("startsWith", 1, s_starts_with), + ("endsWith", 1, s_ends_with), + ("slice", 2, s_slice), + ("substring", 2, s_substring), + ("substr", 2, s_substr), + ("toUpperCase", 0, s_to_upper), + ("toLowerCase", 0, s_to_lower), + ("toLocaleUpperCase", 0, s_to_upper), + ("toLocaleLowerCase", 0, s_to_lower), + ("trim", 0, s_trim), + ("trimStart", 0, s_trim_start), + ("trimEnd", 0, s_trim_end), + ("trimLeft", 0, s_trim_start), + ("trimRight", 0, s_trim_end), + ("padStart", 2, s_pad_start), + ("padEnd", 2, s_pad_end), + ("repeat", 1, s_repeat), + ("split", 2, s_split), + ("replace", 2, s_replace), + ("replaceAll", 2, s_replace_all), + ("concat", 1, s_concat), + ("toString", 0, s_to_string), + ("valueOf", 0, s_to_string), + ("localeCompare", 1, s_locale_compare), + ("normalize", 0, s_to_string), + ], + ); + let iter = vm.native_fn("[Symbol.iterator]", 0, s_iterator, Value::Undef); + vm.define_hidden(sp, SYM_ITERATOR, iter); + + let np = vm.realm.number_proto; + let number = vm.ctor("Number", 1, number_ctor, np, Value::Undef); + vm.methods( + number, + &[ + ("isInteger", 1, n_is_integer), + ("isSafeInteger", 1, n_is_safe_integer), + ("isFinite", 1, n_is_finite), + ("isNaN", 1, n_is_nan), + ("parseFloat", 1, super::object::global_parse_float), + ("parseInt", 2, super::object::global_parse_int), + ], + ); + for (name, v) in [ + ("MAX_SAFE_INTEGER", 9007199254740991.0), + ("MIN_SAFE_INTEGER", -9007199254740991.0), + ("MAX_VALUE", f64::MAX), + ("MIN_VALUE", 5e-324), + ("EPSILON", f64::EPSILON), + ("POSITIVE_INFINITY", f64::INFINITY), + ("NEGATIVE_INFINITY", f64::NEG_INFINITY), + ("NaN", f64::NAN), + ] { + vm.constant(number, name, Value::Num(v)); + } + vm.methods( + np, + &[ + ("toFixed", 1, n_to_fixed), + ("toString", 1, n_to_string), + ("toPrecision", 1, n_to_precision), + ("valueOf", 0, n_value_of), + ("toLocaleString", 0, n_to_locale_string), + ], + ); + + let math = vm.new_object(); + for (name, v) in [ + ("PI", std::f64::consts::PI), + ("E", std::f64::consts::E), + ("LN2", std::f64::consts::LN_2), + ("LN10", std::f64::consts::LN_10), + ("LOG2E", std::f64::consts::LOG2_E), + ("LOG10E", std::f64::consts::LOG10_E), + ("SQRT2", std::f64::consts::SQRT_2), + ("SQRT1_2", std::f64::consts::FRAC_1_SQRT_2), + ] { + vm.constant(math, name, Value::Num(v)); + } + vm.methods( + math, + &[ + ("floor", 1, m_floor), + ("ceil", 1, m_ceil), + ("round", 1, m_round), + ("trunc", 1, m_trunc), + ("sign", 1, m_sign), + ("abs", 1, m_abs), + ("sqrt", 1, m_sqrt), + ("cbrt", 1, m_cbrt), + ("exp", 1, m_exp), + ("expm1", 1, m_expm1), + ("log", 1, m_log), + ("log2", 1, m_log2), + ("log10", 1, m_log10), + ("log1p", 1, m_log1p), + ("sin", 1, m_sin), + ("cos", 1, m_cos), + ("tan", 1, m_tan), + ("asin", 1, m_asin), + ("acos", 1, m_acos), + ("atan", 1, m_atan), + ("sinh", 1, m_sinh), + ("cosh", 1, m_cosh), + ("tanh", 1, m_tanh), + ("asinh", 1, m_asinh), + ("acosh", 1, m_acosh), + ("atanh", 1, m_atanh), + ("fround", 1, m_fround), + ("clz32", 1, m_clz32), + ("atan2", 2, m_atan2), + ("pow", 2, m_pow), + ("imul", 2, m_imul), + ("max", 2, m_max), + ("min", 2, m_min), + ("hypot", 2, m_hypot), + ("random", 0, m_random), + ], + ); + vm.global("Math", Value::Obj(math)); +} + +fn this_str(vm: &mut Vm, this: &Value) -> Result { + match this { + Value::Str(s) => Ok(*s), + Value::Undef | Value::Null => { + Err(vm.type_error("String.prototype method called on null or undefined")) + } + v => vm.string_of(v), + } +} + +fn arg_str(vm: &mut Vm, args: &[Value], i: usize) -> Result { + let v = arg(args, i); + vm.string_of(&v) +} + +fn string_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if let Value::Uninit = this { + return Err( + vm.type_error("String wrapper objects are not supported; call String(value) instead") + ); + } + if args.is_empty() { + return Ok(vm.static_str("")); + } + match &args[0] { + Value::Sym(_) => Ok(vm.static_str("Symbol(Symbol.iterator)")), + v => Ok(Value::Str(vm.string_of(v)?)), + } +} + +fn string_from_char_code(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + if args.len() == 1 + && let Value::Num(n) = args[0] + { + let c = (to_uint32(n) & 0xffff) as u16; + return Ok(vm.char_str(c)); + } + let mut units = Vec::with_capacity(args.len()); + for a in args { + units.push((to_uint32(vm.number_of(a)?) & 0xffff) as u16); + } + Ok(vm.string_val(String::from_utf16_lossy(&units))) +} + +fn string_from_code_point(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let mut out = String::new(); + for a in args { + let n = vm.number_of(a)?; + match char::from_u32(n as u32) { + Some(c) if n.fract() == 0.0 && n >= 0.0 => out.push(c), + _ => return Err(vm.range_error(&format!("Invalid code point {}", num_to_string(n)))), + } + } + Ok(vm.string_val(out)) +} + +fn pos_arg(vm: &mut Vm, args: &[Value], i: usize) -> Result { + Ok(to_integer(vm.number_of(&arg(args, i))?)) +} + +fn s_char_at(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let i = pos_arg(vm, args, 0)?; + let c = if i < 0.0 { + None + } else { + vm.atoms.sref(s).code_unit(i as usize) + }; + Ok(match c { + Some(c) => vm.char_str(c), + None => vm.static_str(""), + }) +} + +fn s_char_code_at(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let i = pos_arg(vm, args, 0)?; + if i < 0.0 { + return Ok(Value::Num(f64::NAN)); + } + Ok(Value::Num( + vm.atoms + .sref(s) + .code_unit(i as usize) + .map(|c| c as f64) + .unwrap_or(f64::NAN), + )) +} + +fn s_code_point_at(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let i = pos_arg(vm, args, 0)?; + let units = vm.atoms.sref(s).utf16(); + if i < 0.0 || i as usize >= units.len() { + return Ok(Value::Undef); + } + let i = i as usize; + let a = units[i]; + if (0xd800..0xdc00).contains(&a) + && let Some(&b) = units.get(i + 1) + && (0xdc00..0xe000).contains(&b) + { + return Ok(Value::Num( + (((a as u32 - 0xd800) << 10) + (b as u32 - 0xdc00) + 0x10000) as f64, + )); + } + Ok(Value::Num(a as f64)) +} + +fn s_at(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let len = vm.atoms.sref(s).len16() as f64; + let mut i = pos_arg(vm, args, 0)?; + if i < 0.0 { + i += len; + } + if i < 0.0 || i >= len { + return Ok(Value::Undef); + } + Ok(match vm.atoms.sref(s).code_unit(i as usize) { + Some(c) => vm.char_str(c), + None => Value::Undef, + }) +} + +/// Finds `needle` in `hay` at or after code unit `from`, in code units. +fn find16(hay: StrRef, needle: StrRef, from: usize) -> Option { + if hay.ascii && needle.ascii { + if from > hay.s.len() { + return None; + } + return hay.s[from..].find(needle.s).map(|i| i + from); + } + let h = hay.utf16(); + let n = needle.utf16(); + if n.is_empty() { + return if from <= h.len() { Some(from) } else { None }; + } + if n.len() > h.len() { + return None; + } + (from..=h.len() - n.len()).find(|&i| h[i..i + n.len()] == n[..]) +} + +fn rfind16(hay: StrRef, needle: StrRef, from: usize) -> Option { + let h = hay.utf16(); + let n = needle.utf16(); + if n.len() > h.len() { + return None; + } + let start = from.min(h.len() - n.len()); + (0..=start).rev().find(|&i| h[i..i + n.len()] == n[..]) +} + +fn s_index_of(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = arg_str(vm, args, 0)?; + let len = vm.atoms.sref(s).len16() as f64; + let from = pos_arg(vm, args, 1)?.clamp(0.0, len) as usize; + let r = find16(vm.atoms.sref(s), vm.atoms.sref(n), from); + Ok(Value::Num(r.map(|i| i as f64).unwrap_or(-1.0))) +} + +fn s_last_index_of(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = arg_str(vm, args, 0)?; + let pos = vm.number_of(&arg(args, 1))?; + let from = if pos.is_nan() { + usize::MAX + } else { + to_integer(pos).max(0.0) as usize + }; + let r = rfind16(vm.atoms.sref(s), vm.atoms.sref(n), from); + Ok(Value::Num(r.map(|i| i as f64).unwrap_or(-1.0))) +} + +fn s_includes(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = arg_str(vm, args, 0)?; + let len = vm.atoms.sref(s).len16() as f64; + let from = pos_arg(vm, args, 1)?.clamp(0.0, len) as usize; + Ok(Value::Bool( + find16(vm.atoms.sref(s), vm.atoms.sref(n), from).is_some(), + )) +} + +fn s_starts_with(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = arg_str(vm, args, 0)?; + let len = vm.atoms.sref(s).len16() as f64; + let from = pos_arg(vm, args, 1)?.clamp(0.0, len) as usize; + let (h, n) = (vm.atoms.sref(s), vm.atoms.sref(n)); + if h.ascii && n.ascii { + return Ok(Value::Bool(h.s[from..].starts_with(n.s))); + } + let (h, n) = (h.utf16(), n.utf16()); + Ok(Value::Bool( + h.len() >= from + n.len() && h[from..from + n.len()] == n[..], + )) +} + +fn s_ends_with(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = arg_str(vm, args, 0)?; + let len = vm.atoms.sref(s).len16(); + let end = match arg(args, 1) { + Value::Undef => len, + v => to_integer(vm.number_of(&v)?).clamp(0.0, len as f64) as usize, + }; + let h = vm.atoms.sref(s).utf16(); + let n = vm.atoms.sref(n).utf16(); + Ok(Value::Bool( + end >= n.len() && h[end - n.len()..end] == n[..], + )) +} + +fn s_slice(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let len = vm.atoms.sref(s).len16(); + let start = to_index(vm, &arg(args, 0), len, 0)?; + let end = to_index(vm, &arg(args, 1), len, len)?; + if start == 0 && end >= len { + return Ok(Value::Str(s)); + } + let out = vm.atoms.sref(s).slice16(start, end); + Ok(vm.string_val(out)) +} + +fn s_substring(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let len = vm.atoms.sref(s).len16() as f64; + let a = pos_arg(vm, args, 0)?.clamp(0.0, len) as usize; + let b = match arg(args, 1) { + Value::Undef => len as usize, + v => to_integer(vm.number_of(&v)?).clamp(0.0, len) as usize, + }; + let out = vm.atoms.sref(s).slice16(a.min(b), a.max(b)); + Ok(vm.string_val(out)) +} + +fn s_substr(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let len = vm.atoms.sref(s).len16(); + let start = to_index(vm, &arg(args, 0), len, 0)?; + let count = match arg(args, 1) { + Value::Undef => len, + v => to_integer(vm.number_of(&v)?).max(0.0) as usize, + }; + let out = vm.atoms.sref(s).slice16(start, start.saturating_add(count)); + Ok(vm.string_val(out)) +} + +fn map_text(vm: &mut Vm, this: &Value, f: fn(&str) -> String) -> Res { + let s = this_str(vm, this)?; + let out = f(vm.text(s)); + Ok(vm.string_val(out)) +} + +fn s_to_upper(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_text(vm, &this, str::to_uppercase) +} + +fn s_to_lower(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_text(vm, &this, str::to_lowercase) +} + +fn s_trim(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_text(vm, &this, |s| s.trim_matches(is_js_whitespace).to_owned()) +} + +fn s_trim_start(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_text(vm, &this, |s| { + s.trim_start_matches(is_js_whitespace).to_owned() + }) +} + +fn s_trim_end(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + map_text(vm, &this, |s| { + s.trim_end_matches(is_js_whitespace).to_owned() + }) +} + +fn pad(vm: &mut Vm, this: Value, args: &[Value], at_start: bool) -> Res { + let s = this_str(vm, &this)?; + let target = to_integer(vm.number_of(&arg(args, 0))?); + let fill = match arg(args, 1) { + Value::Undef => " ".to_owned(), + v => { + let f = vm.string_of(&v)?; + vm.text(f).to_owned() + } + }; + let len = vm.atoms.sref(s).len16(); + if target <= len as f64 || fill.is_empty() { + return Ok(Value::Str(s)); + } + if target > MAX_STRING_LEN as f64 { + return Err(vm.range_error("Invalid string length")); + } + let need = target as usize - len; + let padding: Vec = fill.encode_utf16().cycle().take(need).collect(); + let padding = String::from_utf16_lossy(&padding); + let out = if at_start { + padding + vm.text(s) + } else { + vm.text(s).to_owned() + &padding + }; + Ok(vm.string_val(out)) +} + +fn s_pad_start(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + pad(vm, this, args, true) +} + +fn s_pad_end(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + pad(vm, this, args, false) +} + +fn s_repeat(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let n = to_integer(vm.number_of(&arg(args, 0))?); + if n < 0.0 || n.is_infinite() { + return Err(vm.range_error(&format!("Invalid count value: {}", num_to_string(n)))); + } + if vm.text(s).len() as f64 * n > MAX_STRING_LEN as f64 { + return Err(vm.range_error("Invalid string length")); + } + let out = vm.text(s).repeat(n as usize); + Ok(vm.string_val(out)) +} + +fn s_split(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let limit = match arg(args, 1) { + Value::Undef => u32::MAX as usize, + v => to_uint32(vm.number_of(&v)?) as usize, + }; + let sep = arg(args, 0); + let parts: Vec = match sep { + Value::Undef => vec![Value::Str(s)], + _ => { + let sep = vm.string_of(&sep)?; + if vm.text(sep).is_empty() { + let units = vm.atoms.sref(s).utf16(); + units.iter().take(limit).map(|c| vm.char_str(*c)).collect() + } else { + let pieces: Vec = vm + .text(s) + .split(vm.text(sep)) + .take(limit) + .map(str::to_owned) + .collect(); + pieces.into_iter().map(|p| vm.string_val(p)).collect() + } + } + }; + Ok(vm.new_array(parts)) +} + +fn expand_replacement(template: &str, matched: &str, pos: usize, subject: &str) -> String { + let mut out = String::new(); + let mut chars = template.chars().peekable(); + while let Some(c) = chars.next() { + if c != '$' { + out.push(c); + continue; + } + match chars.peek() { + Some('$') => { + chars.next(); + out.push('$'); + } + Some('&') => { + chars.next(); + out.push_str(matched); + } + Some('`') => { + chars.next(); + out.push_str(&subject[..pos]); + } + Some('\'') => { + chars.next(); + out.push_str(&subject[pos + matched.len()..]); + } + _ => out.push('$'), + } + } + out +} + +fn replace(vm: &mut Vm, this: Value, args: &[Value], all: bool) -> Res { + let s = this_str(vm, &this)?; + let pat = arg_str(vm, args, 0)?; + let rep = arg(args, 1); + let callable = vm.is_callable(&rep); + let template = if callable { + None + } else { + let t = vm.string_of(&rep)?; + Some(vm.text(t).to_owned()) + }; + let subject = vm.text(s).to_owned(); + let needle = vm.text(pat).to_owned(); + let mut positions = Vec::new(); + if needle.is_empty() { + if all { + positions.extend(subject.char_indices().map(|(i, _)| i)); + positions.push(subject.len()); + } else { + positions.push(0); + } + } else { + let mut from = 0; + while let Some(i) = subject[from..].find(&needle) { + positions.push(from + i); + from += i + needle.len(); + if !all { + break; + } + } + } + if positions.is_empty() { + return Ok(Value::Str(s)); + } + let mut out = String::new(); + let mut last = 0; + for pos in positions { + out.push_str(&subject[last..pos]); + match &template { + Some(t) => out.push_str(&expand_replacement(t, &needle, pos, &subject)), + None => { + let offset = subject[..pos].encode_utf16().count() as f64; + let r = vm.call( + &rep, + Value::Undef, + &[Value::Str(pat), Value::Num(offset), Value::Str(s)], + )?; + let r = vm.string_of(&r)?; + out.push_str(vm.text(r)); + } + } + last = pos + needle.len(); + } + out.push_str(&subject[last..]); + Ok(vm.string_val(out)) +} + +fn s_replace(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + replace(vm, this, args, false) +} + +fn s_replace_all(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + replace(vm, this, args, true) +} + +fn s_concat(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let mut out = vm.text(s).to_owned(); + for a in args { + let t = vm.string_of(a)?; + out.push_str(vm.text(t)); + } + Ok(vm.string_val(out)) +} + +fn s_to_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + match this { + Value::Str(s) => Ok(Value::Str(s)), + _ => Err(vm.type_error("String.prototype.toString requires that 'this' be a String")), + } +} + +fn s_locale_compare(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + let o = arg_str(vm, args, 0)?; + let (a, b) = (vm.text(s), vm.text(o)); + // Case-insensitive first, then lowercase before uppercase, like the default collation for plain text. + let order = a.to_lowercase().cmp(&b.to_lowercase()).then_with(|| { + a.chars() + .zip(b.chars()) + .find(|(x, y)| x != y) + .map(|(x, y)| y.is_lowercase().cmp(&x.is_lowercase())) + .unwrap_or(a.len().cmp(&b.len())) + }); + Ok(Value::Num(match order { + std::cmp::Ordering::Less => -1.0, + std::cmp::Ordering::Equal => 0.0, + std::cmp::Ordering::Greater => 1.0, + })) +} + +fn s_iterator(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let s = this_str(vm, &this)?; + vm.get_iterator(&Value::Str(s)) +} + +// ---------- Number ---------- + +fn number_ctor(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + if let Value::Uninit = this { + return Err( + vm.type_error("Number wrapper objects are not supported; call Number(value) instead") + ); + } + if args.is_empty() { + return Ok(Value::Num(0.0)); + } + Ok(Value::Num(vm.number_of(&args[0])?)) +} + +fn num_arg(args: &[Value]) -> Option { + match args.first() { + Some(Value::Num(n)) => Some(*n), + _ => None, + } +} + +fn n_is_integer(_vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool( + num_arg(args).is_some_and(|n| n.is_finite() && n.fract() == 0.0), + )) +} + +fn n_is_safe_integer(_vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(num_arg(args).is_some_and(|n| { + n.fract() == 0.0 && n.abs() <= 9007199254740991.0 + }))) +} + +fn n_is_finite(_vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(num_arg(args).is_some_and(f64::is_finite))) +} + +fn n_is_nan(_vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(num_arg(args).is_some_and(f64::is_nan))) +} + +fn this_num(vm: &mut Vm, this: &Value) -> Result { + match this { + Value::Num(n) => Ok(*n), + _ => Err(vm.type_error("Number.prototype method called on an incompatible receiver")), + } +} + +fn n_to_fixed(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let x = this_num(vm, &this)?; + let d = to_integer(vm.number_of(&arg(args, 0))?); + if !(0.0..=100.0).contains(&d) { + return Err(vm.range_error("toFixed() digits argument must be between 0 and 100")); + } + if x.abs() >= 1e21 { + return Ok(vm.string_val(num_to_string(x))); + } + Ok(vm.string_val(num_to_fixed(x, d as usize))) +} + +fn n_to_string(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let x = this_num(vm, &this)?; + let radix = match arg(args, 0) { + Value::Undef => 10.0, + v => to_integer(vm.number_of(&v)?), + }; + if !(2.0..=36.0).contains(&radix) { + return Err(vm.range_error("toString() radix must be between 2 and 36")); + } + Ok(vm.string_val(if radix == 10.0 { + num_to_string(x) + } else { + num_to_radix(x, radix as u32) + })) +} + +fn n_to_precision(vm: &mut Vm, this: Value, args: &[Value], _: Id) -> Res { + let x = this_num(vm, &this)?; + if let Value::Undef = arg(args, 0) { + return Ok(vm.string_val(num_to_string(x))); + } + let p = to_integer(vm.number_of(&arg(args, 0))?); + if !(1.0..=100.0).contains(&p) { + return Err(vm.range_error("toPrecision() argument must be between 1 and 100")); + } + if !x.is_finite() || x == 0.0 { + return Ok(vm.string_val(if x == 0.0 { + num_to_fixed(0.0, p as usize - 1) + } else { + num_to_string(x) + })); + } + let e = x.abs().log10().floor() as i32; + let p = p as i32; + if e < -6 || e >= p { + let s = format!("{:.*e}", (p - 1) as usize, x); + let (m, ex) = s.split_once('e').unwrap_or((&s, "0")); + let ex: i32 = ex.parse().unwrap_or(0); + return Ok(vm.string_val(format!( + "{m}e{}{}", + if ex < 0 { "-" } else { "+" }, + ex.abs() + ))); + } + Ok(vm.string_val(num_to_fixed(x, (p - 1 - e).max(0) as usize))) +} + +fn n_value_of(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + Ok(Value::Num(this_num(vm, &this)?)) +} + +fn n_to_locale_string(vm: &mut Vm, this: Value, _args: &[Value], _: Id) -> Res { + let x = this_num(vm, &this)?; + if !x.is_finite() { + return Ok(vm.string_val(num_to_string(x))); + } + let fixed = num_to_fixed(x, 3); + let fixed = fixed.trim_end_matches('0').trim_end_matches('.'); + let (int, frac) = fixed.split_once('.').unwrap_or((fixed, "")); + let (sign, digits) = int.strip_prefix('-').map(|d| ("-", d)).unwrap_or(("", int)); + let mut grouped = String::new(); + for (i, c) in digits.chars().enumerate() { + if i > 0 && (digits.len() - i) % 3 == 0 { + grouped.push(','); + } + grouped.push(c); + } + let out = if frac.is_empty() { + format!("{sign}{grouped}") + } else { + format!("{sign}{grouped}.{frac}") + }; + Ok(vm.string_val(out)) +} + +// ---------- Math ---------- + +fn n0(vm: &mut Vm, args: &[Value]) -> Result { + match args.first() { + Some(Value::Num(n)) => Ok(*n), + Some(v) => vm.number_of(v), + None => Ok(f64::NAN), + } +} + +fn n1(vm: &mut Vm, args: &[Value]) -> Result { + match args.get(1) { + Some(Value::Num(n)) => Ok(*n), + Some(v) => vm.number_of(v), + None => Ok(f64::NAN), + } +} + +macro_rules! math1 { + ($name:ident, $f:expr) => { + fn $name(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let x = n0(vm, args)?; + let f: fn(f64) -> f64 = $f; + Ok(Value::Num(f(x))) + } + }; +} + +math1!(m_floor, f64::floor); +math1!(m_ceil, f64::ceil); +math1!(m_trunc, f64::trunc); +math1!(m_abs, f64::abs); +math1!(m_sqrt, f64::sqrt); +math1!(m_cbrt, f64::cbrt); +math1!(m_exp, f64::exp); +math1!(m_expm1, f64::exp_m1); +math1!(m_log, f64::ln); +math1!(m_log2, f64::log2); +math1!(m_log10, f64::log10); +math1!(m_log1p, f64::ln_1p); +math1!(m_sin, f64::sin); +math1!(m_cos, f64::cos); +math1!(m_tan, f64::tan); +math1!(m_asin, f64::asin); +math1!(m_acos, f64::acos); +math1!(m_atan, f64::atan); +math1!(m_sinh, f64::sinh); +math1!(m_cosh, f64::cosh); +math1!(m_tanh, f64::tanh); +math1!(m_asinh, f64::asinh); +math1!(m_acosh, f64::acosh); +math1!(m_atanh, f64::atanh); +math1!(m_fround, |x| x as f32 as f64); +math1!(m_clz32, |x| to_uint32(x).leading_zeros() as f64); +math1!(m_sign, |x| if x.is_nan() || x == 0.0 { + x +} else { + x.signum() +}); +math1!(m_round, |x| { + if !x.is_finite() || x == 0.0 { + return x; + } + let r = x.floor(); + let v = if x - r >= 0.5 { r + 1.0 } else { r }; + if v == 0.0 && x < 0.0 { -0.0 } else { v } +}); + +fn m_atan2(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let (y, x) = (n0(vm, args)?, n1(vm, args)?); + Ok(Value::Num(y.atan2(x))) +} + +fn m_pow(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let (x, y) = (n0(vm, args)?, n1(vm, args)?); + Ok(Value::Num(crate::vm::js_pow(x, y))) +} + +fn m_imul(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let (x, y) = (n0(vm, args)?, n1(vm, args)?); + Ok(Value::Num( + (to_uint32(x) as i32).wrapping_mul(to_uint32(y) as i32) as f64, + )) +} + +fn m_max(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let mut r = f64::NEG_INFINITY; + for a in args { + let x = vm.number_of(a)?; + if x.is_nan() || r.is_nan() { + r = f64::NAN; + } else if x > r || (x == 0.0 && r == 0.0 && !x.is_sign_negative()) { + r = x; + } + } + Ok(Value::Num(r)) +} + +fn m_min(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let mut r = f64::INFINITY; + for a in args { + let x = vm.number_of(a)?; + if x.is_nan() || r.is_nan() { + r = f64::NAN; + } else if x < r || (x == 0.0 && r == 0.0 && x.is_sign_negative()) { + r = x; + } + } + Ok(Value::Num(r)) +} + +fn m_hypot(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let mut sum = 0.0; + for a in args { + let x = vm.number_of(a)?; + if x.is_infinite() { + return Ok(Value::Num(f64::INFINITY)); + } + sum += x * x; + } + Ok(Value::Num(sum.sqrt())) +} + +fn m_random(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + let mut x = vm.rng; + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + vm.rng = x; + Ok(Value::Num((x >> 11) as f64 / (1u64 << 53) as f64)) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/bytecode.rs b/packages/codemode-rust/crates/psychoscript/src/bytecode.rs new file mode 100644 index 000000000000..6106df44b1ed --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/bytecode.rs @@ -0,0 +1,214 @@ +//! Bytecode: a compact stack-machine instruction set and compiled function prototypes. + +use std::rc::Rc; + +use crate::object::Atom; + +/// One instruction. Operands are slot, constant, atom or jump-target indexes. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Op { + Nop, + Pop, + Dup, + /// `a b` -> `a b a b` + Dup2, + /// `a b` -> `b a` + Swap, + /// `a b c` -> `c a b` + Rot3, + /// `a b c` -> `b c a` + Rot3Back, + Undef, + Null, + True, + False, + Uninit, + Int(i32), + Const(u32), + + GetLocal(u32), + /// Two `GetLocal`s. + GetLocal2(u32, u32), + SetLocal(u32), + /// Reads a local that may be in its temporal dead zone; the second operand is the name's atom. + GetLocalChk(u32, Atom), + NewCell(u32), + GetCell(u32), + GetCellChk(u32, Atom), + SetCell(u32), + GetUpval(u32), + GetUpvalChk(u32, Atom), + SetUpval(u32), + GetGlobal(u32), + TypeofGlobal(u32), + ThrowConst(Atom), + ThrowRef(Atom), + /// Throws a `TypeError` with a constant message, for syntax that is only rejected when it runs. + ThrowType(u32), + This, + Callee, + Arguments, + Rest(u32), + + GetProp(Atom), + SetProp(Atom), + GetElem, + SetElem, + /// `obj` -> `f obj` + GetMethod(Atom), + DelProp(Atom), + DelElem, + In, + InstanceOf, + DefineField(Atom), + DefineElem, + NewObject, + NewArray(u32), + ArrayPush, + ArraySpread, + ObjectSpread, + /// `src k1..kn` -> `rest` + ObjRest(u32), + RequireCoercible, + + Add, + Sub, + Mul, + Div, + Mod, + Pow, + BitAnd, + BitOr, + BitXor, + Shl, + Shr, + UShr, + Eq, + Ne, + StrictEq, + StrictNe, + Lt, + Le, + Gt, + Ge, + /// A binary operator whose right operand is an integer immediate. + ArithI(Arith, i32), + Neg, + ToNumber, + ToNumeric, + Not, + BitNot, + Typeof, + Inc, + Dec, + ToStr, + Concat(u32), + /// `local += pop()` in statement position, appending in place to a string only this local holds. + AddLocal(u32), + /// `local++` on a plain local in statement position. + IncLocal(u32), + + Jump(u32), + JumpIfFalse(u32), + JumpIfTrue(u32), + JumpIfFalseKeep(u32), + JumpIfTrueKeep(u32), + JumpIfNotNullishKeep(u32), + JumpIfNotUndef(u32), + /// If the top is nullish, replace it with `undefined` and jump. + OptChain(u32), + /// If the callee under the receiver is nullish, replace both with `undefined` and jump. + OptCall(u32), + + Closure(u32), + Call(u32), + CallSpread, + New(u32), + NewSpread, + Return, + GeneratorStart, + Await, + Yield, + + Throw, + PushCatch(u32), + PushFinally(u32), + PopTry, + + GetIter(u32), + IterNext(u32, u32), + /// Like `IterNext`, but pushes the iterator's completion value before jumping, for `yield*`. + DelegateNext(u32, u32), + IterStep(u32), + IterRest(u32), + IterClose(u32), + IterCloseQuiet(u32), + ForIn(u32), +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Arith { + Add, + Sub, + Mul, + Div, + Mod, + Lt, + Le, + Gt, + Ge, + StrictEq, + StrictNe, +} + +impl Arith { + pub fn of(op: Op) -> Option { + Some(match op { + Op::Add => Arith::Add, + Op::Sub => Arith::Sub, + Op::Mul => Arith::Mul, + Op::Div => Arith::Div, + Op::Mod => Arith::Mod, + Op::Lt => Arith::Lt, + Op::Le => Arith::Le, + Op::Gt => Arith::Gt, + Op::Ge => Arith::Ge, + Op::StrictEq => Arith::StrictEq, + Op::StrictNe => Arith::StrictNe, + _ => return None, + }) + } +} + +#[derive(Clone, Copy, Debug)] +pub enum Capture { + /// A cell of the enclosing frame. + Cell(u32), + /// An upvalue of the enclosing closure. + Upval(u32), +} + +#[derive(Debug)] +pub struct FuncProto { + pub name: Atom, + pub code: Vec, + /// Source offset of each instruction, for diagnostics. + pub pos: Vec, + pub nparams: u32, + pub length: u32, + pub nlocals: u32, + pub ncells: u32, + pub captures: Vec, + pub is_async: bool, + pub is_arrow: bool, + pub is_program: bool, + /// Keeps arguments beyond `nparams` for rest parameters and `arguments`. + pub needs_extra: bool, +} + +pub struct Program { + pub protos: Vec>, + pub consts: Vec, + /// Global names referenced by `GetGlobal`, by slot. + pub globals: Vec, +} diff --git a/packages/codemode-rust/crates/psychoscript/src/compiler.rs b/packages/codemode-rust/crates/psychoscript/src/compiler.rs new file mode 100644 index 000000000000..0abe011bee34 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/compiler.rs @@ -0,0 +1,2353 @@ +//! Parses with oxc, resolves bindings with oxc_semantic, rejects syntax outside the subset, and emits bytecode. + +use std::rc::Rc; + +use oxc_allocator::Allocator; +use oxc_ast::ast::*; +use oxc_ast_visit::{Visit, walk}; +use oxc_parser::{ParseOptions, Parser}; +use oxc_semantic::{AstNodes, Scoping, SemanticBuilder}; +use oxc_span::{GetSpan, SourceType}; +use oxc_syntax::operator::{ + AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, +}; +use oxc_syntax::scope::ScopeId; +use oxc_syntax::symbol::{SymbolFlags, SymbolId}; +use rustc_hash::{FxHashMap, FxHashSet}; + +use crate::DiagnosticKind; +use crate::bytecode::{Arith, Capture, FuncProto, Op, Program}; +use crate::strings::{Atom, Strings}; +use crate::value::{Value, num_to_string}; + +pub struct CompileError { + pub kind: DiagnosticKind, + pub message: String, + pub offset: Option, +} + +type R = Result; + +/// Deepest syntactic nesting a program may have; it bounds the recursion of analysis and compilation. +const MAX_NESTING: u32 = 2_000; +/// Largest program accepted, which bounds the parser's own recursion. +const MAX_SOURCE_BYTES: usize = 256 * 1024; + +pub fn compile(source: &str, atoms: &mut Strings) -> R { + if source.len() > MAX_SOURCE_BYTES { + return Err(CompileError { + kind: DiagnosticKind::ParseError, + message: format!("Program is larger than {MAX_SOURCE_BYTES} bytes."), + offset: None, + }); + } + if source.trim().is_empty() { + return Err(CompileError { + kind: DiagnosticKind::ParseError, + message: "Source is empty.".into(), + offset: None, + }); + } + let allocator = Allocator::default(); + let options = ParseOptions { + allow_return_outside_function: true, + preserve_parens: false, + ..ParseOptions::default() + }; + let parsed = Parser::new(&allocator, source, SourceType::mjs()) + .with_options(options) + .parse(); + if let Some(d) = parsed.diagnostics.errors().next() { + return Err(parse_error(d)); + } + if parsed.fatal_error { + return Err(CompileError { + kind: DiagnosticKind::ParseError, + message: "Unexpected token.".into(), + offset: None, + }); + } + let program = &parsed.program; + let mut depth = DepthCheck { + depth: 0, + deepest: None, + }; + depth.visit_program(program); + if let Some(offset) = depth.deepest { + return Err(CompileError { + kind: DiagnosticKind::ParseError, + message: format!("SyntaxError: Program is nested more than {MAX_NESTING} levels deep."), + offset: Some(offset), + }); + } + let semantic = SemanticBuilder::new() + .with_check_syntax_error(true) + .with_build_nodes(true) + .build(program); + if let Some(d) = semantic.diagnostics.errors().next() { + return Err(parse_error(d)); + } + let scoping = semantic.semantic.scoping(); + let mut c = Compiler::new(scoping, semantic.semantic.nodes(), atoms); + c.compute_captured(); + c.compile_program(program)?; + Ok(Program { + protos: c.protos.into_iter().map(Rc::new).collect(), + consts: c.consts, + globals: c.globals, + }) +} + +/// Measures nesting without recursing past the limit. +struct DepthCheck { + depth: u32, + deepest: Option, +} + +impl DepthCheck { + fn enter(&mut self, offset: u32) -> bool { + self.depth += 1; + if self.depth > MAX_NESTING { + self.deepest.get_or_insert(offset); + return false; + } + true + } +} + +impl<'a> Visit<'a> for DepthCheck { + fn visit_expression(&mut self, it: &Expression<'a>) { + if self.enter(it.span().start) { + walk::walk_expression(self, it); + } + self.depth -= 1; + } + + fn visit_statement(&mut self, it: &Statement<'a>) { + if self.enter(it.span().start) { + walk::walk_statement(self, it); + } + self.depth -= 1; + } + + fn visit_binding_pattern(&mut self, it: &BindingPattern<'a>) { + if self.enter(it.span().start) { + walk::walk_binding_pattern(self, it); + } + self.depth -= 1; + } + + fn visit_assignment_target(&mut self, it: &AssignmentTarget<'a>) { + if self.enter(it.span().start) { + walk::walk_assignment_target(self, it); + } + self.depth -= 1; + } +} + +fn parse_error(d: &oxc_diagnostics::OxcDiagnostic) -> CompileError { + CompileError { + kind: DiagnosticKind::ParseError, + message: format!("SyntaxError: {}", d.message), + offset: d.labels.first().map(|l| l.offset()), + } +} + +fn unsupported(what: &str, span: oxc_span::Span) -> CompileError { + CompileError { + kind: DiagnosticKind::UnsupportedSyntax, + message: format!( + "{what} is not supported. This is a restricted JavaScript-like language: use plain functions and data objects instead." + ), + offset: Some(span.start), + } +} + +#[derive(Clone, Copy)] +enum Store { + Local(u32), + Cell(u32), +} + +#[derive(Clone, Copy)] +struct SymInfo { + depth: usize, + store: Store, + tdz: bool, + is_const: bool, + decl_end: u32, + switch_scoped: bool, + name: Atom, +} + +enum Control<'a> { + Loop { + labels: Vec<&'a str>, + breaks: Vec, + continues: Vec, + iter: Option, + }, + Label { + label: &'a str, + breaks: Vec, + }, + Switch { + labels: Vec<&'a str>, + breaks: Vec, + }, + Try, + Finally { + body: &'a BlockStatement<'a>, + }, +} + +struct FnState<'a> { + code: Vec, + pos: Vec, + nlocals: u32, + ncells: u32, + captures: Vec, + upval_of: FxHashMap, + controls: Vec>, + is_arrow: bool, + needs_extra: bool, + /// The instruction index a jump may land on; no instruction fuses across it. + barrier: usize, +} + +struct Compiler<'a, 's> { + scoping: &'s Scoping, + nodes: &'s AstNodes<'a>, + atoms: &'s mut Strings, + fns: Vec>, + syms: FxHashMap, + captured: FxHashSet, + protos: Vec, + consts: Vec, + str_consts: FxHashMap, + num_consts: FxHashMap, + globals: Vec, + global_of: FxHashMap, + pos: u32, + chains: Vec>, + switch_scopes: FxHashSet, +} + +#[derive(Clone, Copy, PartialEq)] +enum BindMode { + /// A declaration's initialization: no TDZ check, `const` allowed. + Init, + /// A plain assignment. + Assign, +} + +impl<'a, 's> Compiler<'a, 's> { + fn new(scoping: &'s Scoping, nodes: &'s AstNodes<'a>, atoms: &'s mut Strings) -> Self { + Compiler { + scoping, + nodes, + atoms, + fns: Vec::new(), + syms: FxHashMap::default(), + captured: FxHashSet::default(), + protos: Vec::new(), + consts: Vec::new(), + str_consts: FxHashMap::default(), + num_consts: FxHashMap::default(), + globals: Vec::new(), + global_of: FxHashMap::default(), + pos: 0, + chains: Vec::new(), + switch_scopes: FxHashSet::default(), + } + } + + fn fn_scope_of(&self, mut scope: ScopeId) -> ScopeId { + loop { + let flags = self.scoping.scope_flags(scope); + if flags.is_function() || flags.is_top() { + return scope; + } + match self.scoping.scope_parent_id(scope) { + Some(p) => scope = p, + None => return scope, + } + } + } + + /// A binding is captured when any reference to it sits in a different function than its declaration. + fn compute_captured(&mut self) { + let mut memo: FxHashMap = FxHashMap::default(); + for sym in self.scoping.symbol_ids() { + let decl_scope = self.scoping.symbol_scope_id(sym); + let decl_fn = *memo + .entry(decl_scope) + .or_insert_with(|| self.fn_scope_of(decl_scope)); + for rid in self.scoping.get_resolved_reference_ids(sym) { + let rs = self.scoping.get_reference(*rid).scope_id(); + let ref_fn = match memo.get(&rs) { + Some(f) => *f, + None => { + let f = self.fn_scope_of(rs); + memo.insert(rs, f); + f + } + }; + if ref_fn != decl_fn { + self.captured.insert(sym); + break; + } + } + } + } + + // ---------- emission helpers ---------- + + fn f(&mut self) -> &mut FnState<'a> { + self.fns.last_mut().expect("function state") + } + + fn emit(&mut self, op: Op) -> usize { + let pos = self.pos; + let f = self.f(); + // Peephole fusion with the previous instruction, unless a jump lands between the two. + if f.barrier != f.code.len() + && let Some(prev) = f.code.last_mut() + { + let fused = match (*prev, op) { + (Op::Int(k), op) => Arith::of(op).map(|a| Op::ArithI(a, k)), + (Op::GetLocal(a), Op::GetLocal(b)) => Some(Op::GetLocal2(a, b)), + _ => None, + }; + if let Some(fused) = fused { + *prev = fused; + return f.code.len() - 1; + } + } + f.code.push(op); + f.pos.push(pos); + f.code.len() - 1 + } + + fn here(&mut self) -> u32 { + let f = self.f(); + f.barrier = f.code.len(); + f.code.len() as u32 + } + + fn patch(&mut self, at: usize) { + let target = self.here(); + let op = &mut self.f().code[at]; + *op = match *op { + Op::Jump(_) => Op::Jump(target), + Op::JumpIfFalse(_) => Op::JumpIfFalse(target), + Op::JumpIfTrue(_) => Op::JumpIfTrue(target), + Op::JumpIfFalseKeep(_) => Op::JumpIfFalseKeep(target), + Op::JumpIfTrueKeep(_) => Op::JumpIfTrueKeep(target), + Op::JumpIfNotNullishKeep(_) => Op::JumpIfNotNullishKeep(target), + Op::JumpIfNotUndef(_) => Op::JumpIfNotUndef(target), + Op::OptChain(_) => Op::OptChain(target), + Op::OptCall(_) => Op::OptCall(target), + Op::PushCatch(_) => Op::PushCatch(target), + Op::PushFinally(_) => Op::PushFinally(target), + Op::IterNext(s, _) => Op::IterNext(s, target), + Op::DelegateNext(s, _) => Op::DelegateNext(s, target), + other => other, + }; + } + + fn new_local(&mut self) -> u32 { + let f = self.f(); + f.nlocals += 1; + f.nlocals - 1 + } + + fn new_cell(&mut self) -> u32 { + let f = self.f(); + f.ncells += 1; + f.ncells - 1 + } + + fn atom(&mut self, s: &str) -> Atom { + self.atoms.intern(s) + } + + fn str_const(&mut self, s: &str) -> u32 { + if let Some(i) = self.str_consts.get(s) { + return *i; + } + let i = self.consts.len() as u32; + let id = self.atoms.alloc(s.to_owned()); + self.consts.push(Value::Str(id)); + self.str_consts.insert(s.to_owned(), i); + i + } + + fn push_num(&mut self, n: f64) { + if n.fract() == 0.0 && n.abs() <= i32::MAX as f64 && !(n == 0.0 && n.is_sign_negative()) { + self.emit(Op::Int(n as i32)); + return; + } + let bits = n.to_bits(); + let i = match self.num_consts.get(&bits) { + Some(i) => *i, + None => { + let i = self.consts.len() as u32; + self.consts.push(Value::Num(n)); + self.num_consts.insert(bits, i); + i + } + }; + self.emit(Op::Const(i)); + } + + fn push_str(&mut self, s: &str) { + let i = self.str_const(s); + self.emit(Op::Const(i)); + } + + fn global_slot(&mut self, name: &str) -> u32 { + let a = self.atom(name); + if let Some(s) = self.global_of.get(&a) { + return *s; + } + let s = self.globals.len() as u32; + self.globals.push(a); + self.global_of.insert(a, s); + s + } + + fn depth(&self) -> usize { + self.fns.len() - 1 + } + + // ---------- scopes and bindings ---------- + + /// Allocates storage for a scope's bindings and returns them in declaration order. + fn declare_scope(&mut self, scope: ScopeId) -> Vec { + let mut syms: Vec = self.scoping.get_bindings(scope).values().copied().collect(); + syms.sort(); + let switch_scoped = self.switch_scopes.contains(&scope); + for s in &syms { + if self.syms.contains_key(s) { + continue; + } + self.declare_symbol(*s, None, switch_scoped); + } + syms + } + + fn declare_symbol(&mut self, s: SymbolId, param_slot: Option, switch_scoped: bool) { + let flags = self.scoping.symbol_flags(s); + let store = if self.captured.contains(&s) { + Store::Cell(self.new_cell()) + } else { + Store::Local(param_slot.unwrap_or_else(|| self.new_local())) + }; + let tdz = flags.intersects(SymbolFlags::BlockScopedVariable | SymbolFlags::ConstVariable) + && !flags.contains(SymbolFlags::Function); + let decl_end = self.decl_end(s); + let name = self.atoms.intern(self.scoping.symbol_name(s)); + self.syms.insert( + s, + SymInfo { + depth: self.depth(), + store, + tdz, + is_const: flags.contains(SymbolFlags::ConstVariable), + decl_end, + switch_scoped, + name, + }, + ); + } + + fn decl_end(&self, s: SymbolId) -> u32 { + // The end of the whole declaration, so references from inside the initializer stay checked. + self.nodes + .kind(self.scoping.symbol_declaration(s)) + .span() + .end + } + + /// Emits a scope's entry: fresh cells, TDZ markers, `var` initial values. + fn init_scope(&mut self, syms: &[SymbolId]) { + for s in syms { + let Some(info) = self.syms.get(s).copied() else { + continue; + }; + if info.depth != self.depth() { + continue; + } + let flags = self.scoping.symbol_flags(*s); + if flags.contains(SymbolFlags::CatchVariable) { + continue; + } + match info.store { + Store::Cell(c) => { + self.emit(Op::NewCell(c)); + if !info.tdz && !flags.contains(SymbolFlags::Function) { + self.emit(Op::Undef); + self.emit(Op::SetCell(c)); + } + } + Store::Local(l) => { + if info.tdz { + self.emit(Op::Uninit); + self.emit(Op::SetLocal(l)); + } + } + } + } + } + + fn hoist_functions(&mut self, stmts: &'a [Statement<'a>]) -> R<()> { + for st in stmts { + if let Statement::FunctionDeclaration(f) = st { + self.closure_for_function(f, None)?; + let id = f.id.as_ref().and_then(|id| id.symbol_id.get()); + match id { + Some(s) => self.store_symbol(s, BindMode::Init, f.span.start)?, + None => { + self.emit(Op::Pop); + } + } + } + } + Ok(()) + } + + fn needs_check(&self, info: &SymInfo, ref_pos: u32) -> bool { + info.tdz && (info.depth != self.depth() || info.switch_scoped || ref_pos < info.decl_end) + } + + fn resolve_upval(&mut self, depth: usize, s: SymbolId) -> R { + if let Some(i) = self.fns[depth].upval_of.get(&s) { + return Ok(*i); + } + let info = self.syms[&s]; + let cap = if depth - 1 == info.depth { + match info.store { + Store::Cell(c) => Capture::Cell(c), + Store::Local(_) => { + return Err(CompileError { + kind: DiagnosticKind::ExecutionFailure, + message: "internal: captured binding has no cell".into(), + offset: Some(self.pos), + }); + } + } + } else { + Capture::Upval(self.resolve_upval(depth - 1, s)?) + }; + let f = &mut self.fns[depth]; + f.captures.push(cap); + let i = f.captures.len() as u32 - 1; + f.upval_of.insert(s, i); + Ok(i) + } + + fn symbol_info(&self, s: SymbolId) -> R { + self.syms.get(&s).copied().ok_or_else(|| CompileError { + kind: DiagnosticKind::UnsupportedSyntax, + message: format!( + "'{}' is used before its scope is entered.", + self.scoping.symbol_name(s) + ), + offset: Some(self.pos), + }) + } + + fn load_symbol(&mut self, s: SymbolId, ref_pos: u32) -> R<()> { + let info = self.symbol_info(s)?; + let chk = self.needs_check(&info, ref_pos); + if info.depth == self.depth() { + match (info.store, chk) { + (Store::Local(l), false) => self.emit(Op::GetLocal(l)), + (Store::Local(l), true) => self.emit(Op::GetLocalChk(l, info.name)), + (Store::Cell(c), false) => self.emit(Op::GetCell(c)), + (Store::Cell(c), true) => self.emit(Op::GetCellChk(c, info.name)), + }; + } else { + let u = self.resolve_upval(self.depth(), s)?; + self.emit(if chk { + Op::GetUpvalChk(u, info.name) + } else { + Op::GetUpval(u) + }); + } + Ok(()) + } + + /// Pops the top of the stack into the binding. + fn store_symbol(&mut self, s: SymbolId, mode: BindMode, ref_pos: u32) -> R<()> { + let info = self.symbol_info(s)?; + if mode == BindMode::Assign { + if info.is_const { + self.emit(Op::Pop); + self.emit(Op::ThrowConst(info.name)); + return Ok(()); + } + if self.needs_check(&info, ref_pos) { + self.load_symbol(s, ref_pos)?; + self.emit(Op::Pop); + } + } + if info.depth == self.depth() { + match info.store { + Store::Local(l) => self.emit(Op::SetLocal(l)), + Store::Cell(c) => self.emit(Op::SetCell(c)), + }; + } else { + let u = self.resolve_upval(self.depth(), s)?; + self.emit(Op::SetUpval(u)); + } + Ok(()) + } + + fn ident_symbol(&self, id: &IdentifierReference) -> Option { + id.reference_id + .get() + .and_then(|r| self.scoping.get_reference(r).symbol_id()) + } + + fn load_ident(&mut self, id: &IdentifierReference) -> R<()> { + if let Some(s) = self.ident_symbol(id) { + return self.load_symbol(s, id.span.start); + } + match id.name.as_str() { + "undefined" => { + self.emit(Op::Undef); + } + "arguments" if !self.f().is_arrow && self.fns.len() > 1 => { + self.f().needs_extra = true; + self.emit(Op::Arguments); + } + name => { + let g = self.global_slot(name); + self.emit(Op::GetGlobal(g)); + } + } + Ok(()) + } + + fn store_ident(&mut self, id: &IdentifierReference) -> R<()> { + match self.ident_symbol(id) { + Some(s) => self.store_symbol(s, BindMode::Assign, id.span.start), + None => { + let a = self.atom(id.name.as_str()); + self.emit(Op::Pop); + if self.global_of.contains_key(&a) || is_builtin_global(id.name.as_str()) { + self.emit(Op::ThrowConst(a)); + } else { + self.emit(Op::ThrowRef(a)); + } + Ok(()) + } + } + } + + /// A plain, initialized-for-sure local of the current function, for fused instructions. + fn plain_local(&self, id: &IdentifierReference) -> Option { + let s = self.ident_symbol(id)?; + let info = self.syms.get(&s)?; + if info.depth != self.depth() || info.is_const || self.needs_check(info, id.span.start) { + return None; + } + match info.store { + Store::Local(l) => Some(l), + Store::Cell(_) => None, + } + } + + // ---------- functions ---------- + + fn compile_program(&mut self, program: &'a oxc_ast::ast::Program<'a>) -> R<()> { + self.fns.push(FnState::new(false)); + let name = self.atom(""); + let syms = match program.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.init_scope(&syms); + self.hoist_functions(&program.body)?; + if program.body.is_empty() + && let Some(d) = program.directives.last() + { + let text = js_str(&d.expression.value); + self.push_str(&text); + self.emit(Op::Return); + } + let n = program.body.len(); + for (i, st) in program.body.iter().enumerate() { + if i + 1 == n + && let Statement::ExpressionStatement(e) = st + { + self.pos = e.span.start; + self.expr(&e.expression)?; + self.emit(Op::Return); + break; + } + self.stmt(st)?; + } + self.emit(Op::Undef); + self.emit(Op::Return); + let f = self.fns.pop().expect("program state"); + self.protos.insert( + 0, + FuncProto { + name, + code: f.code, + pos: f.pos, + nparams: 0, + length: 0, + nlocals: f.nlocals, + ncells: f.ncells, + captures: Vec::new(), + is_async: true, + is_arrow: false, + is_program: true, + needs_extra: false, + }, + ); + // Closure instructions index `protos` assuming the program is not in the list; shift them. + for p in self.protos.iter_mut() { + for op in p.code.iter_mut() { + if let Op::Closure(i) = op { + *i += 1; + } + } + } + Ok(()) + } + + fn closure_for_function(&mut self, f: &'a Function<'a>, name: Option<&str>) -> R<()> { + if f.r#async && f.generator { + return Err(unsupported("Async generator functions", f.span)); + } + let Some(body) = &f.body else { + return Err(unsupported("Function declarations without a body", f.span)); + }; + let own_name = + f.id.as_ref() + .map(|id| id.name.as_str()) + .or(name) + .unwrap_or(""); + let self_sym = match f.r#type { + FunctionType::FunctionExpression => f.id.as_ref().and_then(|id| id.symbol_id.get()), + _ => None, + }; + let idx = self.compile_function(FnSpec { + name: own_name, + params: &f.params, + body: FnBody::Block(body), + scope: f.scope_id.get(), + is_async: f.r#async, + is_generator: f.generator, + is_arrow: false, + self_sym, + })?; + self.emit(Op::Closure(idx)); + Ok(()) + } + + fn closure_for_arrow( + &mut self, + f: &'a ArrowFunctionExpression<'a>, + name: Option<&str>, + ) -> R<()> { + let body = match &f.body { + ArrowFunctionBody::FunctionBody(b) => FnBody::Block(b), + other => match other.as_expression() { + Some(e) => FnBody::Expr(e), + None => return Err(unsupported("This arrow function body", f.span)), + }, + }; + let idx = self.compile_function(FnSpec { + name: name.unwrap_or(""), + params: &f.params, + body, + scope: f.scope_id.get(), + is_async: f.r#async, + is_generator: false, + is_arrow: true, + self_sym: None, + })?; + self.emit(Op::Closure(idx)); + Ok(()) + } + + fn compile_function(&mut self, spec: FnSpec<'a, '_>) -> R { + let saved_pos = self.pos; + let saved_chains = std::mem::take(&mut self.chains); + self.fns.push(FnState::new(spec.is_arrow)); + let params = spec.params; + let nparams = params.items.len() as u32; + self.f().nlocals = nparams; + let length = params + .items + .iter() + .take_while(|p| p.initializer.is_none()) + .count() as u32; + if params.rest.is_some() { + self.f().needs_extra = true; + } + // Simple parameters bind straight to their argument slot. + for (i, p) in params.items.iter().enumerate() { + if p.initializer.is_none() + && let BindingPattern::BindingIdentifier(id) = &p.pattern + && let Some(s) = id.symbol_id.get() + { + self.declare_symbol(s, Some(i as u32), false); + } + } + let syms = match spec.scope { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.init_scope(&syms); + for (i, p) in params.items.iter().enumerate() { + if p.initializer.is_none() + && let BindingPattern::BindingIdentifier(id) = &p.pattern + && let Some(s) = id.symbol_id.get() + { + if let Some(Store::Cell(c)) = self.syms.get(&s).map(|i| i.store) { + self.emit(Op::GetLocal(i as u32)); + self.emit(Op::SetCell(c)); + } + continue; + } + self.pos = p.span.start; + self.emit(Op::GetLocal(i as u32)); + if let Some(init) = &p.initializer { + let j = self.emit(Op::JumpIfNotUndef(0)); + self.emit(Op::Pop); + let hint = pattern_name(&p.pattern); + self.expr_named(init, hint)?; + self.patch(j); + } + self.bind_pattern(&p.pattern, BindMode::Init)?; + } + if let Some(rest) = ¶ms.rest { + self.emit(Op::Rest(nparams)); + self.bind_pattern(&rest.rest.argument, BindMode::Init)?; + } + if let Some(s) = spec.self_sym + && self.syms.get(&s).is_some_and(|i| i.depth == self.depth()) + { + self.emit(Op::Callee); + self.store_symbol(s, BindMode::Init, 0)?; + } + if spec.is_generator { + self.emit(Op::GeneratorStart); + } + match spec.body { + FnBody::Block(b) => { + self.hoist_functions(&b.statements)?; + for st in &b.statements { + self.stmt(st)?; + } + self.emit(Op::Undef); + self.emit(Op::Return); + } + FnBody::Expr(e) => { + self.expr(e)?; + self.emit(Op::Return); + } + } + let f = self.fns.pop().expect("function state"); + self.chains = saved_chains; + self.pos = saved_pos; + let name = self.atom(spec.name); + self.protos.push(FuncProto { + name, + code: f.code, + pos: f.pos, + nparams, + length, + nlocals: f.nlocals, + ncells: f.ncells, + captures: f.captures, + is_async: spec.is_async, + is_arrow: spec.is_arrow, + is_program: false, + needs_extra: f.needs_extra, + }); + Ok(self.protos.len() as u32 - 1) + } + + // ---------- statements ---------- + + fn stmts(&mut self, stmts: &'a [Statement<'a>]) -> R<()> { + for s in stmts { + self.stmt(s)?; + } + Ok(()) + } + + fn block(&mut self, b: &'a BlockStatement<'a>) -> R<()> { + let syms = match b.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.init_scope(&syms); + self.hoist_functions(&b.body)?; + self.stmts(&b.body) + } + + fn stmt(&mut self, st: &'a Statement<'a>) -> R<()> { + self.pos = st.span().start; + match st { + Statement::BlockStatement(b) => self.block(b), + Statement::EmptyStatement(_) | Statement::DebuggerStatement(_) => Ok(()), + Statement::ExpressionStatement(e) => self.expr_stmt(&e.expression), + Statement::VariableDeclaration(d) => self.var_decl(d), + Statement::FunctionDeclaration(_) => Ok(()), + Statement::IfStatement(s) => { + self.expr(&s.test)?; + let j = self.emit(Op::JumpIfFalse(0)); + self.stmt(&s.consequent)?; + match &s.alternate { + Some(alt) => { + let end = self.emit(Op::Jump(0)); + self.patch(j); + self.stmt(alt)?; + self.patch(end); + } + None => self.patch(j), + } + Ok(()) + } + Statement::ReturnStatement(r) => { + match &r.argument { + Some(a) => self.expr(a)?, + None => { + self.emit(Op::Undef); + } + } + self.emit_return() + } + Statement::ThrowStatement(t) => { + self.expr(&t.argument)?; + self.emit(Op::Throw); + Ok(()) + } + Statement::WhileStatement(w) => self.while_loop(w, Vec::new()), + Statement::DoWhileStatement(w) => self.do_while(w, Vec::new()), + Statement::ForStatement(f) => self.for_loop(f, Vec::new()), + Statement::ForOfStatement(f) => self.for_of(f, Vec::new()), + Statement::ForInStatement(f) => self.for_in(f, Vec::new()), + Statement::BreakStatement(b) => { + self.jump_out(true, b.label.as_ref().map(|l| l.name.as_str())) + } + Statement::ContinueStatement(c) => { + self.jump_out(false, c.label.as_ref().map(|l| l.name.as_str())) + } + Statement::LabeledStatement(l) => self.labeled(l), + Statement::SwitchStatement(s) => self.switch(s, Vec::new()), + Statement::TryStatement(t) => self.try_stmt(t), + Statement::ClassDeclaration(c) => Err(unsupported("Classes", c.span)), + Statement::WithStatement(w) => Err(unsupported("`with`", w.span)), + Statement::ImportDeclaration(d) => Err(unsupported("`import`", d.span)), + Statement::ExportAllDeclaration(d) => Err(unsupported("`export`", d.span)), + Statement::ExportDefaultDeclaration(d) => Err(unsupported("`export`", d.span)), + Statement::ExportNamedDeclaration(d) => Err(unsupported("`export`", d.span)), + Statement::ExportDeclaration(d) => Err(unsupported("`export`", d.span)), + Statement::ExportFromDeclaration(d) => Err(unsupported("`export`", d.span)), + other => Err(unsupported("TypeScript syntax", other.span())), + } + } + + fn expr_stmt(&mut self, e: &'a Expression<'a>) -> R<()> { + if let Expression::UpdateExpression(u) = e + && u.operator == UpdateOperator::Increment + && let SimpleAssignmentTarget::AssignmentTargetIdentifier(id) = &u.argument + && let Some(l) = self.plain_local(id) + { + self.pos = u.span.start; + self.emit(Op::IncLocal(l)); + return Ok(()); + } + if let Expression::AssignmentExpression(a) = e + && a.operator == AssignmentOperator::Assign + && let AssignmentTarget::AssignmentTargetIdentifier(id) = &a.left + { + self.pos = a.span.start; + self.expr_named(&a.right, Some(id.name.as_str()))?; + return self.store_ident(id); + } + if let Expression::AssignmentExpression(a) = e + && a.operator == AssignmentOperator::Addition + && let AssignmentTarget::AssignmentTargetIdentifier(id) = &a.left + && let Some(l) = self.plain_local(id) + { + self.pos = a.span.start; + self.expr(&a.right)?; + self.emit(Op::AddLocal(l)); + return Ok(()); + } + self.expr(e)?; + self.emit(Op::Pop); + Ok(()) + } + + fn var_decl(&mut self, d: &'a VariableDeclaration<'a>) -> R<()> { + match d.kind { + VariableDeclarationKind::Var + | VariableDeclarationKind::Let + | VariableDeclarationKind::Const => {} + _ => return Err(unsupported("`using` declarations", d.span)), + } + for decl in &d.declarations { + self.pos = decl.span.start; + match &decl.init { + Some(init) => { + self.expr_named(init, pattern_name(&decl.id))?; + self.bind_pattern(&decl.id, BindMode::Init)?; + } + None => { + if d.kind != VariableDeclarationKind::Var { + self.emit(Op::Undef); + self.bind_pattern(&decl.id, BindMode::Init)?; + } + } + } + } + Ok(()) + } + + fn emit_return(&mut self) -> R<()> { + let unwinding = self.f().controls.iter().any(|c| { + matches!( + c, + Control::Try | Control::Finally { .. } | Control::Loop { iter: Some(_), .. } + ) + }); + if !unwinding { + self.emit(Op::Return); + return Ok(()); + } + let tmp = self.new_local(); + self.emit(Op::SetLocal(tmp)); + let n = self.f().controls.len(); + self.unwind_to(0, n)?; + self.emit(Op::GetLocal(tmp)); + self.emit(Op::Return); + Ok(()) + } + + /// Emits the cleanup for leaving controls `from..to` (innermost first). + fn unwind_to(&mut self, from: usize, to: usize) -> R<()> { + for i in (from..to).rev() { + match &self.f().controls[i] { + Control::Try => { + self.emit(Op::PopTry); + } + Control::Loop { + iter: Some(slot), .. + } => { + let slot = *slot; + self.emit(Op::PopTry); + self.emit(Op::IterClose(slot)); + } + Control::Finally { body } => { + let body: &'a BlockStatement<'a> = body; + self.emit(Op::PopTry); + let tail = self.f().controls.split_off(i); + let r = self.block(body); + self.f().controls.extend(tail); + r?; + } + _ => {} + } + } + Ok(()) + } + + fn jump_out(&mut self, is_break: bool, label: Option<&str>) -> R<()> { + let controls = &self.f().controls; + let mut target = None; + for (i, c) in controls.iter().enumerate().rev() { + let hit = match (c, label) { + (Control::Loop { .. }, None) => true, + (Control::Switch { .. }, None) => is_break, + (Control::Loop { labels, .. }, Some(l)) => labels.contains(&l), + (Control::Switch { labels, .. }, Some(l)) => is_break && labels.contains(&l), + (Control::Label { label: x, .. }, Some(l)) => is_break && *x == l, + _ => false, + }; + if hit { + target = Some(i); + break; + } + } + let Some(t) = target else { + return Err(CompileError { + kind: DiagnosticKind::ParseError, + message: "SyntaxError: Illegal break or continue statement".into(), + offset: Some(self.pos), + }); + }; + let n = self.f().controls.len(); + self.unwind_to(t + 1, n)?; + if is_break + && let Control::Loop { + iter: Some(slot), .. + } = self.f().controls[t] + { + self.emit(Op::PopTry); + self.emit(Op::IterClose(slot)); + } + let j = self.emit(Op::Jump(0)); + match &mut self.f().controls[t] { + Control::Loop { + breaks, continues, .. + } => { + if is_break { + breaks.push(j) + } else { + continues.push(j) + } + } + Control::Switch { breaks, .. } | Control::Label { breaks, .. } => breaks.push(j), + _ => {} + } + Ok(()) + } + + fn push_loop(&mut self, labels: Vec<&'a str>, iter: Option) { + self.f().controls.push(Control::Loop { + labels, + breaks: Vec::new(), + continues: Vec::new(), + iter, + }); + } + + /// Pops the loop control, patching continues to `cont` and breaks to here. + fn pop_loop_continues(&mut self, cont: u32) -> Vec { + let Some(Control::Loop { + breaks, continues, .. + }) = self.f().controls.pop() + else { + return Vec::new(); + }; + for c in continues { + if let Op::Jump(_) = self.f().code[c] { + self.f().code[c] = Op::Jump(cont); + } + } + breaks + } + + fn while_loop(&mut self, w: &'a WhileStatement<'a>, labels: Vec<&'a str>) -> R<()> { + let top = self.here(); + self.expr(&w.test)?; + let exit = self.emit(Op::JumpIfFalse(0)); + self.push_loop(labels, None); + self.stmt(&w.body)?; + self.emit(Op::Jump(top)); + let breaks = self.pop_loop_continues(top); + self.patch(exit); + for b in breaks { + self.patch(b); + } + Ok(()) + } + + fn do_while(&mut self, w: &'a DoWhileStatement<'a>, labels: Vec<&'a str>) -> R<()> { + let top = self.here(); + self.push_loop(labels, None); + self.stmt(&w.body)?; + let cont = self.here(); + let breaks = self.pop_loop_continues(cont); + self.expr(&w.test)?; + self.emit(Op::JumpIfTrue(top)); + for b in breaks { + self.patch(b); + } + Ok(()) + } + + fn for_loop(&mut self, f: &'a ForStatement<'a>, labels: Vec<&'a str>) -> R<()> { + let syms = match f.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.init_scope(&syms); + match &f.init { + Some(ForStatementInit::VariableDeclaration(d)) => self.var_decl(d)?, + Some(other) => { + if let Some(e) = other.as_expression() { + self.expr(e)?; + self.emit(Op::Pop); + } + } + None => {} + } + let per_iteration: Vec = syms + .iter() + .filter_map(|s| match self.syms.get(s) { + Some(SymInfo { + store: Store::Cell(c), + depth, + .. + }) if *depth == self.depth() => Some(*c), + _ => None, + }) + .collect(); + let top = self.here(); + let exit = match &f.test { + Some(t) => { + self.expr(t)?; + Some(self.emit(Op::JumpIfFalse(0))) + } + None => None, + }; + self.push_loop(labels, None); + self.stmt(&f.body)?; + let cont = self.here(); + let breaks = self.pop_loop_continues(cont); + for c in &per_iteration { + self.emit(Op::GetCell(*c)); + self.emit(Op::NewCell(*c)); + self.emit(Op::SetCell(*c)); + } + if let Some(u) = &f.update { + self.expr_stmt(u)?; + } + self.emit(Op::Jump(top)); + if let Some(e) = exit { + self.patch(e); + } + for b in breaks { + self.patch(b); + } + Ok(()) + } + + /// Binds the loop variable of a `for...of`/`for...in` head from the value on the stack. + fn bind_for_left(&mut self, left: &'a ForStatementLeft<'a>, syms: &[SymbolId]) -> R<()> { + self.init_scope(syms); + match left { + ForStatementLeft::VariableDeclaration(d) => { + let Some(decl) = d.declarations.first() else { + return Ok(()); + }; + self.bind_pattern(&decl.id, BindMode::Init) + } + other => match other.as_assignment_target() { + Some(t) => self.assign_target(t), + None => Err(unsupported("This loop head", other.span())), + }, + } + } + + fn for_of(&mut self, f: &'a ForOfStatement<'a>, labels: Vec<&'a str>) -> R<()> { + if f.r#await { + return Err(unsupported("`for await`", f.span)); + } + let syms = match f.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.expr(&f.right)?; + let slot = self.new_local(); + self.emit(Op::GetIter(slot)); + let handler = self.emit(Op::PushFinally(0)); + let top = self.here(); + let exit = self.emit(Op::IterNext(slot, 0)); + self.push_loop(labels, Some(slot)); + self.bind_for_left(&f.left, &syms)?; + self.stmt(&f.body)?; + self.emit(Op::Jump(top)); + let breaks = self.pop_loop_continues(top); + self.patch(exit); + self.emit(Op::PopTry); + let end = self.emit(Op::Jump(0)); + self.patch(handler); + let exc = self.new_local(); + self.emit(Op::SetLocal(exc)); + self.emit(Op::IterCloseQuiet(slot)); + self.emit(Op::GetLocal(exc)); + self.emit(Op::Throw); + self.patch(end); + for b in breaks { + self.patch(b); + } + Ok(()) + } + + fn for_in(&mut self, f: &'a ForInStatement<'a>, labels: Vec<&'a str>) -> R<()> { + let syms = match f.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + self.expr(&f.right)?; + let slot = self.new_local(); + self.emit(Op::ForIn(slot)); + let top = self.here(); + let exit = self.emit(Op::IterNext(slot, 0)); + self.push_loop(labels, None); + self.bind_for_left(&f.left, &syms)?; + self.stmt(&f.body)?; + self.emit(Op::Jump(top)); + let breaks = self.pop_loop_continues(top); + self.patch(exit); + for b in breaks { + self.patch(b); + } + Ok(()) + } + + fn labeled(&mut self, l: &'a LabeledStatement<'a>) -> R<()> { + let mut labels = vec![l.label.name.as_str()]; + let mut body = &l.body; + while let Statement::LabeledStatement(inner) = body { + labels.push(inner.label.name.as_str()); + body = &inner.body; + } + match body { + Statement::WhileStatement(w) => self.while_loop(w, labels), + Statement::DoWhileStatement(w) => self.do_while(w, labels), + Statement::ForStatement(f) => self.for_loop(f, labels), + Statement::ForOfStatement(f) => self.for_of(f, labels), + Statement::ForInStatement(f) => self.for_in(f, labels), + Statement::SwitchStatement(s) => self.switch(s, labels), + other => { + for label in &labels { + self.f().controls.push(Control::Label { + label, + breaks: Vec::new(), + }); + } + self.stmt(other)?; + for _ in &labels { + if let Some(Control::Label { breaks, .. }) = self.f().controls.pop() { + for b in breaks { + self.patch(b); + } + } + } + Ok(()) + } + } + } + + fn switch(&mut self, s: &'a SwitchStatement<'a>, labels: Vec<&'a str>) -> R<()> { + self.expr(&s.discriminant)?; + let tmp = self.new_local(); + self.emit(Op::SetLocal(tmp)); + let syms = match s.scope_id.get() { + Some(scope) => { + self.switch_scopes.insert(scope); + self.declare_scope(scope) + } + None => Vec::new(), + }; + self.init_scope(&syms); + for case in &s.cases { + self.hoist_functions(&case.consequent)?; + } + let mut jumps = Vec::new(); + for case in &s.cases { + if let Some(t) = &case.test { + self.emit(Op::GetLocal(tmp)); + self.expr(t)?; + self.emit(Op::StrictEq); + jumps.push(Some(self.emit(Op::JumpIfTrue(0)))); + } else { + jumps.push(None); + } + } + let to_default = self.emit(Op::Jump(0)); + self.f().controls.push(Control::Switch { + labels, + breaks: Vec::new(), + }); + let mut default_at = None; + for (case, j) in s.cases.iter().zip(jumps) { + match j { + Some(j) => self.patch(j), + None => default_at = Some(self.here()), + } + self.stmts(&case.consequent)?; + } + let Some(Control::Switch { breaks, .. }) = self.f().controls.pop() else { + return Ok(()); + }; + match default_at { + Some(d) => self.f().code[to_default] = Op::Jump(d), + None => self.patch(to_default), + } + for b in breaks { + self.patch(b); + } + Ok(()) + } + + fn try_stmt(&mut self, t: &'a TryStatement<'a>) -> R<()> { + let fin = if let Some(fb) = &t.finalizer { + let h = self.emit(Op::PushFinally(0)); + self.f().controls.push(Control::Finally { body: fb }); + Some((h, fb)) + } else { + None + }; + match &t.handler { + Some(h) => { + let catch_at = self.emit(Op::PushCatch(0)); + self.f().controls.push(Control::Try); + self.block(&t.block)?; + self.f().controls.pop(); + self.emit(Op::PopTry); + let after = self.emit(Op::Jump(0)); + self.patch(catch_at); + let mut syms = match h.scope_id.get() { + Some(scope) => self.declare_scope(scope), + None => Vec::new(), + }; + if let Some(scope) = h.body.scope_id.get() { + syms.extend(self.declare_scope(scope)); + } + self.init_scope(&syms); + for s in &syms { + if self + .scoping + .symbol_flags(*s) + .contains(SymbolFlags::CatchVariable) + && let Some(SymInfo { + store: Store::Cell(c), + .. + }) = self.syms.get(s) + { + let c = *c; + self.emit(Op::NewCell(c)); + } + } + match &h.param { + Some(p) => self.bind_pattern(&p.pattern, BindMode::Init)?, + None => { + self.emit(Op::Pop); + } + } + self.block(&h.body)?; + self.patch(after); + } + None => self.block(&t.block)?, + } + if let Some((h, fb)) = fin { + self.f().controls.pop(); + self.emit(Op::PopTry); + self.block(fb)?; + let end = self.emit(Op::Jump(0)); + self.patch(h); + let exc = self.new_local(); + self.emit(Op::SetLocal(exc)); + self.block(fb)?; + self.emit(Op::GetLocal(exc)); + self.emit(Op::Throw); + self.patch(end); + } + Ok(()) + } + + // ---------- patterns ---------- + + /// Binds a declaration pattern from the value on the stack, consuming it. + fn bind_pattern(&mut self, p: &'a BindingPattern<'a>, mode: BindMode) -> R<()> { + match p { + BindingPattern::BindingIdentifier(id) => match id.symbol_id.get() { + Some(s) => self.store_symbol(s, mode, id.span.start), + None => { + self.emit(Op::Pop); + Ok(()) + } + }, + BindingPattern::AssignmentPattern(a) => { + let j = self.emit(Op::JumpIfNotUndef(0)); + self.emit(Op::Pop); + self.expr_named(&a.right, pattern_name(&a.left))?; + self.patch(j); + self.bind_pattern(&a.left, mode) + } + BindingPattern::ObjectPattern(o) => { + self.emit(Op::RequireCoercible); + let mut saved_keys = Vec::new(); + for prop in &o.properties { + self.emit(Op::Dup); + match static_key(&prop.key, prop.computed) { + Some(k) => { + let a = self.atom(&k); + self.emit(Op::GetProp(a)); + saved_keys.push(KeyRef::Static(k)); + } + None => { + let Some(e) = prop.key.as_expression() else { + return Err(unsupported("Private names", prop.span)); + }; + self.expr(e)?; + if o.rest.is_some() { + let t = self.new_local(); + self.emit(Op::Dup); + self.emit(Op::SetLocal(t)); + saved_keys.push(KeyRef::Local(t)); + } + self.emit(Op::GetElem); + } + } + self.bind_pattern(&prop.value, mode)?; + } + match &o.rest { + Some(rest) => { + self.push_keys(&saved_keys); + self.emit(Op::ObjRest(saved_keys.len() as u32)); + self.bind_pattern(&rest.argument, mode) + } + None => { + self.emit(Op::Pop); + Ok(()) + } + } + } + BindingPattern::ArrayPattern(a) => { + let slot = self.new_local(); + self.emit(Op::GetIter(slot)); + for el in &a.elements { + self.emit(Op::IterStep(slot)); + match el { + Some(p) => self.bind_pattern(p, mode)?, + None => { + self.emit(Op::Pop); + } + } + } + if let Some(rest) = &a.rest { + self.emit(Op::IterRest(slot)); + self.bind_pattern(&rest.argument, mode)?; + } + self.emit(Op::IterClose(slot)); + Ok(()) + } + } + } + + fn push_keys(&mut self, keys: &[KeyRef]) { + for k in keys { + match k { + KeyRef::Static(s) => self.push_str(s), + KeyRef::Local(l) => { + self.emit(Op::GetLocal(*l)); + } + } + } + } + + /// Assigns the value on the stack to an assignment target, consuming it. + fn assign_target(&mut self, t: &'a AssignmentTarget<'a>) -> R<()> { + match t { + AssignmentTarget::ArrayAssignmentTarget(a) => { + let slot = self.new_local(); + self.emit(Op::GetIter(slot)); + for el in &a.elements { + self.emit(Op::IterStep(slot)); + match el { + Some(m) => self.assign_maybe_default(m)?, + None => { + self.emit(Op::Pop); + } + } + } + if let Some(rest) = &a.rest { + self.emit(Op::IterRest(slot)); + self.assign_target(&rest.target)?; + } + self.emit(Op::IterClose(slot)); + Ok(()) + } + AssignmentTarget::ObjectAssignmentTarget(o) => { + self.emit(Op::RequireCoercible); + let mut saved_keys = Vec::new(); + for prop in &o.properties { + self.emit(Op::Dup); + match prop { + AssignmentTargetProperty::AssignmentTargetPropertyIdentifier(p) => { + let name = p.binding.name.as_str(); + let a = self.atom(name); + self.emit(Op::GetProp(a)); + saved_keys.push(KeyRef::Static(name.to_owned())); + if let Some(init) = &p.init { + let j = self.emit(Op::JumpIfNotUndef(0)); + self.emit(Op::Pop); + self.expr_named(init, Some(name))?; + self.patch(j); + } + self.store_ident(&p.binding)?; + } + AssignmentTargetProperty::AssignmentTargetPropertyProperty(p) => { + match static_key(&p.name, p.computed) { + Some(k) => { + let a = self.atom(&k); + self.emit(Op::GetProp(a)); + saved_keys.push(KeyRef::Static(k)); + } + None => { + let Some(e) = p.name.as_expression() else { + return Err(unsupported("Private names", p.span)); + }; + self.expr(e)?; + if o.rest.is_some() { + let t = self.new_local(); + self.emit(Op::Dup); + self.emit(Op::SetLocal(t)); + saved_keys.push(KeyRef::Local(t)); + } + self.emit(Op::GetElem); + } + } + self.assign_maybe_default(&p.binding)?; + } + } + } + match &o.rest { + Some(rest) => { + self.push_keys(&saved_keys); + self.emit(Op::ObjRest(saved_keys.len() as u32)); + self.assign_target(&rest.target) + } + None => { + self.emit(Op::Pop); + Ok(()) + } + } + } + other => match other.as_simple_assignment_target() { + Some(s) => self.assign_simple(s), + None => Err(unsupported("This assignment target", other.span())), + }, + } + } + + fn assign_maybe_default(&mut self, m: &'a AssignmentTargetMaybeDefault<'a>) -> R<()> { + match m { + AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(d) => { + let j = self.emit(Op::JumpIfNotUndef(0)); + self.emit(Op::Pop); + self.expr(&d.init)?; + self.patch(j); + self.assign_target(&d.binding) + } + other => match other.as_assignment_target() { + Some(t) => self.assign_target(t), + None => Err(unsupported("This assignment target", other.span())), + }, + } + } + + fn assign_simple(&mut self, s: &'a SimpleAssignmentTarget<'a>) -> R<()> { + match s { + SimpleAssignmentTarget::AssignmentTargetIdentifier(id) => self.store_ident(id), + SimpleAssignmentTarget::StaticMemberExpression(m) => { + self.expr(&m.object)?; + self.emit(Op::Swap); + let a = self.atom(m.property.name.as_str()); + self.emit(Op::SetProp(a)); + self.emit(Op::Pop); + Ok(()) + } + SimpleAssignmentTarget::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&m.expression)?; + self.emit(Op::Rot3Back); + self.emit(Op::SetElem); + self.emit(Op::Pop); + Ok(()) + } + other => Err(unsupported("This assignment target", other.span())), + } + } + + // ---------- expressions ---------- + + fn expr_named(&mut self, e: &'a Expression<'a>, name: Option<&str>) -> R<()> { + match e { + Expression::ArrowFunctionExpression(a) => { + self.pos = a.span.start; + self.closure_for_arrow(a, name) + } + Expression::FunctionExpression(f) if f.id.is_none() => { + self.pos = f.span.start; + self.closure_for_function(f, name) + } + _ => self.expr(e), + } + } + + fn expr(&mut self, e: &'a Expression<'a>) -> R<()> { + let saved = self.pos; + self.pos = e.span().start; + let r = self.expr_inner(e); + self.pos = saved; + r + } + + fn expr_inner(&mut self, e: &'a Expression<'a>) -> R<()> { + match e { + Expression::BooleanLiteral(b) => { + self.emit(if b.value { Op::True } else { Op::False }); + } + Expression::NullLiteral(_) => { + self.emit(Op::Null); + } + Expression::NumericLiteral(n) => self.push_num(n.value), + Expression::StringLiteral(s) => { + let text = js_str(&s.value); + self.push_str(&text); + } + Expression::TemplateLiteral(t) => self.template(t)?, + Expression::Identifier(id) => self.load_ident(id)?, + Expression::ThisExpression(_) => { + self.emit(Op::This); + } + Expression::ArrayExpression(a) => self.array_lit(a)?, + Expression::ObjectExpression(o) => self.object_lit(o)?, + Expression::ArrowFunctionExpression(a) => self.closure_for_arrow(a, None)?, + Expression::FunctionExpression(f) => self.closure_for_function(f, None)?, + Expression::UnaryExpression(u) => self.unary(u)?, + Expression::BinaryExpression(b) => { + self.expr(&b.left)?; + self.expr(&b.right)?; + self.emit(binary_op(b.operator)); + } + Expression::LogicalExpression(l) => { + self.expr(&l.left)?; + let j = self.emit(match l.operator { + LogicalOperator::And => Op::JumpIfFalseKeep(0), + LogicalOperator::Or => Op::JumpIfTrueKeep(0), + LogicalOperator::Coalesce => Op::JumpIfNotNullishKeep(0), + }); + self.expr(&l.right)?; + self.patch(j); + } + Expression::ConditionalExpression(c) => { + self.expr(&c.test)?; + let j = self.emit(Op::JumpIfFalse(0)); + self.expr(&c.consequent)?; + let end = self.emit(Op::Jump(0)); + self.patch(j); + self.expr(&c.alternate)?; + self.patch(end); + } + Expression::AssignmentExpression(a) => self.assignment(a)?, + Expression::UpdateExpression(u) => self.update(u)?, + Expression::SequenceExpression(s) => { + let n = s.expressions.len(); + for (i, x) in s.expressions.iter().enumerate() { + self.expr(x)?; + if i + 1 < n { + self.emit(Op::Pop); + } + } + } + Expression::ParenthesizedExpression(p) => self.expr(&p.expression)?, + Expression::CallExpression(c) => self.call(c)?, + Expression::NewExpression(n) => { + self.expr(&n.callee)?; + self.emit(Op::Undef); + match self.args(&n.arguments)? { + Some(argc) => self.emit(Op::New(argc)), + None => self.emit(Op::NewSpread), + }; + } + Expression::StaticMemberExpression(m) => { + self.expr(&m.object)?; + if m.optional { + self.opt_chain(); + } + let a = self.atom(m.property.name.as_str()); + self.emit(Op::GetProp(a)); + } + Expression::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + if m.optional { + self.opt_chain(); + } + self.elem_key(&m.expression)?; + } + Expression::ChainExpression(c) => { + self.chains.push(Vec::new()); + match &c.expression { + ChainElement::CallExpression(call) => self.call(call)?, + other => match other.as_member_expression() { + Some(m) => self.expr(m_as_expr(m))?, + None => return Err(unsupported("TypeScript syntax", other.span())), + }, + } + let patches = self.chains.pop().unwrap_or_default(); + for p in patches { + self.patch(p); + } + } + Expression::AwaitExpression(a) => { + self.expr(&a.argument)?; + self.emit(Op::Await); + } + Expression::YieldExpression(y) => { + match &y.argument { + Some(a) => self.expr(a)?, + None => { + self.emit(Op::Undef); + } + } + if y.delegate { + let slot = self.new_local(); + self.emit(Op::GetIter(slot)); + let top = self.here(); + let exit = self.emit(Op::DelegateNext(slot, 0)); + self.emit(Op::Yield); + self.emit(Op::Pop); + self.emit(Op::Jump(top)); + self.patch(exit); + } else { + self.emit(Op::Yield); + } + } + Expression::ClassExpression(c) => return Err(unsupported("Classes", c.span)), + Expression::RegExpLiteral(r) => return Err(unsupported("Regular expressions", r.span)), + Expression::BigIntLiteral(_) => { + let msg = self.str_const("BigInt literals are not supported."); + self.emit(Op::ThrowType(msg)); + } + Expression::TaggedTemplateExpression(t) => { + return Err(unsupported("Tagged templates", t.span)); + } + Expression::Super(s) => return Err(unsupported("`super`", s.span)), + Expression::ImportExpression(i) => return Err(unsupported("`import()`", i.span)), + Expression::ImportMeta(m) => return Err(unsupported("`import.meta`", m.span)), + Expression::NewTarget(m) => return Err(unsupported("`new.target`", m.span)), + Expression::PrivateFieldExpression(p) => { + return Err(unsupported("Private fields", p.span)); + } + Expression::PrivateInExpression(p) => { + return Err(unsupported("Private fields", p.span)); + } + other => return Err(unsupported("This syntax", other.span())), + } + Ok(()) + } + + fn opt_chain(&mut self) { + let j = self.emit(Op::OptChain(0)); + if let Some(c) = self.chains.last_mut() { + c.push(j); + } + } + + fn elem_key(&mut self, key: &'a Expression<'a>) -> R<()> { + if let Expression::StringLiteral(s) = key { + let a = self.atom(&js_str(&s.value)); + if self.atoms.index(a).is_none() { + self.emit(Op::GetProp(a)); + return Ok(()); + } + } + self.expr(key)?; + self.emit(Op::GetElem); + Ok(()) + } + + fn template(&mut self, t: &'a TemplateLiteral<'a>) -> R<()> { + let mut parts = 0u32; + for (i, q) in t.quasis.iter().enumerate() { + let cooked = q + .value + .cooked + .as_ref() + .map(js_str) + .unwrap_or_else(|| q.value.raw.as_str().to_owned()); + if !cooked.is_empty() || (t.expressions.is_empty() && i == 0) { + self.push_str(&cooked); + parts += 1; + } + if let Some(e) = t.expressions.get(i) { + self.expr(e)?; + self.emit(Op::ToStr); + parts += 1; + } + } + if parts != 1 { + self.emit(Op::Concat(parts)); + } + Ok(()) + } + + fn array_lit(&mut self, a: &'a ArrayExpression<'a>) -> R<()> { + let simple = a.elements.iter().all(|e| e.as_expression().is_some()); + if simple { + for el in &a.elements { + if let Some(e) = el.as_expression() { + self.expr(e)?; + } + } + self.emit(Op::NewArray(a.elements.len() as u32)); + return Ok(()); + } + self.emit(Op::NewArray(0)); + for el in &a.elements { + match el { + ArrayExpressionElement::SpreadElement(s) => { + self.expr(&s.argument)?; + self.emit(Op::ArraySpread); + } + ArrayExpressionElement::Elision(_) => { + self.emit(Op::Undef); + self.emit(Op::ArrayPush); + } + other => { + if let Some(e) = other.as_expression() { + self.expr(e)?; + self.emit(Op::ArrayPush); + } + } + } + } + Ok(()) + } + + fn object_lit(&mut self, o: &'a ObjectExpression<'a>) -> R<()> { + self.emit(Op::NewObject); + for p in &o.properties { + match p { + ObjectPropertyKind::SpreadProperty(s) => { + self.expr(&s.argument)?; + self.emit(Op::ObjectSpread); + } + ObjectPropertyKind::ObjectProperty(p) => { + if p.kind != PropertyKind::Init { + return Err(unsupported("Getters and setters", p.span)); + } + self.pos = p.span.start; + match static_key(&p.key, p.computed) { + Some(k) => { + self.expr_named(&p.value, Some(&k))?; + let a = self.atom(&k); + self.emit(Op::DefineField(a)); + } + None => { + let Some(e) = p.key.as_expression() else { + return Err(unsupported("Private names", p.span)); + }; + self.expr(e)?; + self.expr(&p.value)?; + self.emit(Op::DefineElem); + } + } + } + } + } + Ok(()) + } + + /// Pushes call arguments; returns the count, or `None` after building one array for spread arguments. + fn args(&mut self, args: &'a [Argument<'a>]) -> R> { + if args.iter().all(|a| a.as_expression().is_some()) { + for a in args { + if let Some(e) = a.as_expression() { + self.expr(e)?; + } + } + return Ok(Some(args.len() as u32)); + } + self.emit(Op::NewArray(0)); + for a in args { + match a { + Argument::SpreadElement(s) => { + self.expr(&s.argument)?; + self.emit(Op::ArraySpread); + } + other => { + if let Some(e) = other.as_expression() { + self.expr(e)?; + self.emit(Op::ArrayPush); + } + } + } + } + Ok(None) + } + + fn call(&mut self, c: &'a CallExpression<'a>) -> R<()> { + match &c.callee { + Expression::StaticMemberExpression(m) => { + self.expr(&m.object)?; + if m.optional { + self.opt_chain(); + } + let a = self.atom(m.property.name.as_str()); + self.emit(Op::GetMethod(a)); + } + Expression::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + if m.optional { + self.opt_chain(); + } + self.emit(Op::Dup); + self.elem_key(&m.expression)?; + self.emit(Op::Swap); + } + Expression::Super(s) => return Err(unsupported("`super`", s.span)), + callee => { + self.expr(callee)?; + self.emit(Op::Undef); + } + } + if c.optional { + let j = self.emit(Op::OptCall(0)); + if let Some(ch) = self.chains.last_mut() { + ch.push(j); + } + } + self.pos = c.span.start; + match self.args(&c.arguments)? { + Some(argc) => self.emit(Op::Call(argc)), + None => self.emit(Op::CallSpread), + }; + Ok(()) + } + + fn unary(&mut self, u: &'a UnaryExpression<'a>) -> R<()> { + match u.operator { + UnaryOperator::Typeof => { + if let Expression::Identifier(id) = &u.argument + && self.ident_symbol(id).is_none() + && id.name.as_str() != "undefined" + && id.name.as_str() != "arguments" + { + let g = self.global_slot(id.name.as_str()); + self.emit(Op::TypeofGlobal(g)); + return Ok(()); + } + self.expr(&u.argument)?; + self.emit(Op::Typeof); + } + UnaryOperator::Delete => match &u.argument { + Expression::StaticMemberExpression(m) => { + self.expr(&m.object)?; + let a = self.atom(m.property.name.as_str()); + self.emit(Op::DelProp(a)); + } + Expression::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&m.expression)?; + self.emit(Op::DelElem); + } + Expression::ChainExpression(c) => { + return Err(unsupported("Optional delete", c.span)); + } + other => { + self.expr(other)?; + self.emit(Op::Pop); + self.emit(Op::True); + } + }, + UnaryOperator::Void => { + self.expr(&u.argument)?; + self.emit(Op::Pop); + self.emit(Op::Undef); + } + op => { + if let (UnaryOperator::UnaryNegation, Expression::NumericLiteral(n)) = + (op, &u.argument) + { + self.push_num(-n.value); + return Ok(()); + } + self.expr(&u.argument)?; + self.emit(match op { + UnaryOperator::UnaryPlus => Op::ToNumber, + UnaryOperator::UnaryNegation => Op::Neg, + UnaryOperator::LogicalNot => Op::Not, + _ => Op::BitNot, + }); + } + } + Ok(()) + } + + fn assignment(&mut self, a: &'a AssignmentExpression<'a>) -> R<()> { + let op = a.operator; + if op == AssignmentOperator::Assign { + match &a.left { + AssignmentTarget::AssignmentTargetIdentifier(id) => { + self.expr_named(&a.right, Some(id.name.as_str()))?; + self.emit(Op::Dup); + return self.store_ident(id); + } + AssignmentTarget::StaticMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&a.right)?; + let at = self.atom(m.property.name.as_str()); + self.emit(Op::SetProp(at)); + return Ok(()); + } + AssignmentTarget::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&m.expression)?; + self.expr(&a.right)?; + self.emit(Op::SetElem); + return Ok(()); + } + AssignmentTarget::ArrayAssignmentTarget(_) + | AssignmentTarget::ObjectAssignmentTarget(_) => { + self.expr(&a.right)?; + self.emit(Op::Dup); + return self.assign_target(&a.left); + } + other => return Err(unsupported("This assignment target", other.span())), + } + } + let logical = match op { + AssignmentOperator::LogicalAnd => Some(Op::JumpIfFalseKeep(0)), + AssignmentOperator::LogicalOr => Some(Op::JumpIfTrueKeep(0)), + AssignmentOperator::LogicalNullish => Some(Op::JumpIfNotNullishKeep(0)), + _ => None, + }; + match &a.left { + AssignmentTarget::AssignmentTargetIdentifier(id) => { + if let Some(jop) = logical { + self.load_ident(id)?; + let j = self.emit(jop); + self.expr_named(&a.right, Some(id.name.as_str()))?; + self.emit(Op::Dup); + self.store_ident(id)?; + self.patch(j); + return Ok(()); + } + self.load_ident(id)?; + self.expr(&a.right)?; + self.emit(compound_op(op)); + self.emit(Op::Dup); + self.store_ident(id) + } + AssignmentTarget::StaticMemberExpression(m) => { + let at = self.atom(m.property.name.as_str()); + self.expr(&m.object)?; + self.emit(Op::Dup); + self.emit(Op::GetProp(at)); + if let Some(jop) = logical { + let j = self.emit(jop); + self.expr(&a.right)?; + self.emit(Op::SetProp(at)); + let end = self.emit(Op::Jump(0)); + self.patch(j); + self.emit(Op::Swap); + self.emit(Op::Pop); + self.patch(end); + return Ok(()); + } + self.expr(&a.right)?; + self.emit(compound_op(op)); + self.emit(Op::SetProp(at)); + Ok(()) + } + AssignmentTarget::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&m.expression)?; + self.emit(Op::Dup2); + self.emit(Op::GetElem); + if let Some(jop) = logical { + let j = self.emit(jop); + self.expr(&a.right)?; + self.emit(Op::SetElem); + let end = self.emit(Op::Jump(0)); + self.patch(j); + self.emit(Op::Rot3); + self.emit(Op::Pop); + self.emit(Op::Pop); + self.patch(end); + return Ok(()); + } + self.expr(&a.right)?; + self.emit(compound_op(op)); + self.emit(Op::SetElem); + Ok(()) + } + other => Err(unsupported("This assignment target", other.span())), + } + } + + fn update(&mut self, u: &'a UpdateExpression<'a>) -> R<()> { + let step = if u.operator == UpdateOperator::Increment { + Op::Inc + } else { + Op::Dec + }; + match &u.argument { + SimpleAssignmentTarget::AssignmentTargetIdentifier(id) => { + self.load_ident(id)?; + if u.prefix { + self.emit(step); + self.emit(Op::Dup); + } else { + self.emit(Op::ToNumeric); + self.emit(Op::Dup); + self.emit(step); + } + self.store_ident(id) + } + SimpleAssignmentTarget::StaticMemberExpression(m) => { + let at = self.atom(m.property.name.as_str()); + self.expr(&m.object)?; + self.emit(Op::Dup); + self.emit(Op::GetProp(at)); + if u.prefix { + self.emit(step); + self.emit(Op::SetProp(at)); + } else { + self.emit(Op::ToNumeric); + self.emit(Op::Dup); + self.emit(Op::Rot3); + self.emit(step); + self.emit(Op::SetProp(at)); + self.emit(Op::Pop); + } + Ok(()) + } + SimpleAssignmentTarget::ComputedMemberExpression(m) => { + self.expr(&m.object)?; + self.expr(&m.expression)?; + self.emit(Op::Dup2); + self.emit(Op::GetElem); + if u.prefix { + self.emit(step); + self.emit(Op::SetElem); + } else { + let t = self.new_local(); + self.emit(Op::ToNumeric); + self.emit(Op::Dup); + self.emit(Op::SetLocal(t)); + self.emit(step); + self.emit(Op::SetElem); + self.emit(Op::Pop); + self.emit(Op::GetLocal(t)); + } + Ok(()) + } + other => Err(unsupported("This update target", other.span())), + } + } +} + +enum KeyRef { + Static(String), + Local(u32), +} + +enum FnBody<'a> { + Block(&'a FunctionBody<'a>), + Expr(&'a Expression<'a>), +} + +struct FnSpec<'a, 'n> { + name: &'n str, + params: &'a FormalParameters<'a>, + body: FnBody<'a>, + scope: Option, + is_async: bool, + is_generator: bool, + is_arrow: bool, + self_sym: Option, +} + +impl<'a> FnState<'a> { + fn new(is_arrow: bool) -> Self { + FnState { + code: Vec::new(), + pos: Vec::new(), + nlocals: 0, + ncells: 0, + captures: Vec::new(), + upval_of: FxHashMap::default(), + controls: Vec::new(), + is_arrow, + needs_extra: false, + barrier: 0, + } + } +} + +fn m_as_expr<'x, 'a>(m: &'x MemberExpression<'a>) -> &'x Expression<'a> { + m.as_expression() +} + +fn js_str(s: &oxc_str::JSStr) -> String { + match s.as_str() { + Some(t) => t.to_owned(), + None => String::from_utf16_lossy(&s.encode_utf16().collect::>()), + } +} + +fn static_key(key: &PropertyKey, computed: bool) -> Option { + match key { + PropertyKey::StaticIdentifier(id) if !computed => Some(id.name.as_str().to_owned()), + PropertyKey::StringLiteral(s) => Some(js_str(&s.value)), + PropertyKey::NumericLiteral(n) => Some(num_to_string(n.value)), + _ => None, + } +} + +fn pattern_name<'x>(p: &'x BindingPattern) -> Option<&'x str> { + match p { + BindingPattern::BindingIdentifier(id) => Some(id.name.as_str()), + _ => None, + } +} + +fn is_builtin_global(name: &str) -> bool { + crate::builtins::GLOBAL_NAMES.contains(&name) +} + +fn binary_op(op: BinaryOperator) -> Op { + match op { + BinaryOperator::Equality => Op::Eq, + BinaryOperator::Inequality => Op::Ne, + BinaryOperator::StrictEquality => Op::StrictEq, + BinaryOperator::StrictInequality => Op::StrictNe, + BinaryOperator::LessThan => Op::Lt, + BinaryOperator::LessEqualThan => Op::Le, + BinaryOperator::GreaterThan => Op::Gt, + BinaryOperator::GreaterEqualThan => Op::Ge, + BinaryOperator::Addition => Op::Add, + BinaryOperator::Subtraction => Op::Sub, + BinaryOperator::Multiplication => Op::Mul, + BinaryOperator::Division => Op::Div, + BinaryOperator::Remainder => Op::Mod, + BinaryOperator::Exponential => Op::Pow, + BinaryOperator::ShiftLeft => Op::Shl, + BinaryOperator::ShiftRight => Op::Shr, + BinaryOperator::ShiftRightZeroFill => Op::UShr, + BinaryOperator::BitwiseOR => Op::BitOr, + BinaryOperator::BitwiseXOR => Op::BitXor, + BinaryOperator::BitwiseAnd => Op::BitAnd, + BinaryOperator::In => Op::In, + BinaryOperator::Instanceof => Op::InstanceOf, + } +} + +fn compound_op(op: AssignmentOperator) -> Op { + match op { + AssignmentOperator::Addition => Op::Add, + AssignmentOperator::Subtraction => Op::Sub, + AssignmentOperator::Multiplication => Op::Mul, + AssignmentOperator::Division => Op::Div, + AssignmentOperator::Remainder => Op::Mod, + AssignmentOperator::Exponential => Op::Pow, + AssignmentOperator::ShiftLeft => Op::Shl, + AssignmentOperator::ShiftRight => Op::Shr, + AssignmentOperator::ShiftRightZeroFill => Op::UShr, + AssignmentOperator::BitwiseOR => Op::BitOr, + AssignmentOperator::BitwiseXOR => Op::BitXor, + AssignmentOperator::BitwiseAnd => Op::BitAnd, + _ => Op::Nop, + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/convert.rs b/packages/codemode-rust/crates/psychoscript/src/convert.rs new file mode 100644 index 000000000000..97561658117d --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/convert.rs @@ -0,0 +1,756 @@ +//! Crossing the host boundary as JSON copies, `JSON.stringify`/`JSON.parse`, and console formatting. + +use std::fmt::Write as _; + +use crate::object::*; +use crate::value::{Id, Value, write_num}; +use crate::vm::{Res, Vm}; +use crate::{DiagnosticKind, Json}; + +pub const MAX_VALUE_DEPTH: usize = 32; + +/// Host JSON as a fresh program value. +pub fn from_json(vm: &mut Vm, j: &Json) -> Value { + match j { + Json::Null => Value::Null, + Json::Bool(b) => Value::Bool(*b), + Json::Number(n) => Value::Num(n.as_f64().unwrap_or(f64::NAN)), + Json::String(s) => vm.str_val(s), + Json::Array(items) => { + let vals = items.iter().map(|i| from_json(vm, i)).collect(); + vm.new_array(vals) + } + Json::Object(map) => { + let id = vm.new_object(); + for (k, v) in map { + let val = from_json(vm, v); + let a = vm.atoms.intern(k); + vm.define(id, a, val); + } + Value::Obj(id) + } + } +} + +fn json_number(n: f64) -> Json { + if n.fract() == 0.0 && n.abs() < 9.2e18 { + return Json::from(n as i64); + } + serde_json::Number::from_f64(n) + .map(Json::Number) + .unwrap_or(Json::Null) +} + +/// A program value as the host sees it: what `JSON.stringify` would serialize, plus the boundary table. +pub fn to_json(vm: &mut Vm, v: &Value) -> Result { + let mut stack = Vec::new(); + Ok(to_json_inner(vm, v, Key::Empty, &mut stack)?.unwrap_or(Json::Null)) +} + +fn to_json_inner( + vm: &mut Vm, + v: &Value, + key: Key, + stack: &mut Vec, +) -> Result, Value> { + let v = apply_to_json(vm, v, key)?; + Ok(Some(match &v { + Value::Null => Json::Null, + Value::Bool(b) => Json::Bool(*b), + Value::Num(n) => json_number(*n), + Value::Str(s) => Json::String(vm.text(*s).to_owned()), + Value::Undef | Value::Uninit | Value::Sym(_) => return Ok(None), + Value::Obj(id) => { + let id = *id; + if vm.heap[id as usize].is_callable() { + return Ok(None); + } + if stack.contains(&id) { + return Err(vm.type_error("Converting circular structure to JSON")); + } + if stack.len() >= MAX_VALUE_DEPTH { + return Err(invalid_data(vm, "Data is nested more than 32 levels deep.")); + } + stack.push(id); + let out = match &vm.heap[id as usize].kind { + Kind::Array(items) => { + let items = items.clone(); + let mut out = Vec::with_capacity(items.len()); + for (i, item) in items.iter().enumerate() { + out.push( + to_json_inner(vm, item, Key::Index(i), stack)?.unwrap_or(Json::Null), + ); + } + Json::Array(out) + } + Kind::Set(m) => { + let items: Vec = m.entries.iter().flatten().map(|(k, _)| *k).collect(); + let mut out = Vec::with_capacity(items.len()); + for (i, item) in items.iter().enumerate() { + out.push( + to_json_inner(vm, item, Key::Index(i), stack)?.unwrap_or(Json::Null), + ); + } + Json::Array(out) + } + Kind::Error(_) => { + let mut map = serde_json::Map::new(); + let (name, message) = error_parts(vm, id); + map.insert("name".into(), Json::String(name)); + map.insert("message".into(), Json::String(message)); + for (k, val) in vm.own_entries(id) { + let ks = vm.atoms.text(k).to_owned(); + if ks == "__proto__" || ks == "name" || ks == "message" { + continue; + } + if let Some(j) = to_json_inner(vm, &val, Key::Atom(k), stack)? { + map.insert(ks, j); + } + } + Json::Object(map) + } + Kind::Ordinary | Kind::Arguments(_) => { + let mut map = serde_json::Map::new(); + for (k, val) in vm.own_entries(id) { + if vm.atoms.text(k) == "__proto__" { + continue; + } + if let Some(j) = to_json_inner(vm, &val, Key::Atom(k), stack)? { + map.insert(vm.atoms.text(k).to_owned(), j); + } + } + Json::Object(map) + } + _ => Json::Object(serde_json::Map::new()), + }; + stack.pop(); + out + } + })) +} + +fn invalid_data(vm: &mut Vm, msg: &str) -> Value { + let p = vm.realm.type_error_proto; + vm.failure(p, msg, DiagnosticKind::InvalidDataValue) +} + +/// The key a value is serialized under, materialized only when a `toJSON` or replacer needs it. +#[derive(Clone, Copy)] +pub enum Key { + Empty, + Index(usize), + Atom(Atom), +} + +fn key_value(vm: &mut Vm, key: Key) -> Value { + match key { + Key::Empty => vm.static_str(""), + Key::Index(i) => vm.string_val(i.to_string()), + Key::Atom(a) => vm.atom_val(a), + } +} + +fn apply_to_json(vm: &mut Vm, v: &Value, key: Key) -> Res { + if let Value::Obj(id) = v + && matches!(vm.heap[*id as usize].kind, Kind::Ordinary | Kind::Array(_)) + { + let k = vm.names.to_json; + let f = vm.get_obj(*id, k); + if vm.is_callable(&f) { + let kv = key_value(vm, key); + return vm.call(&f, *v, &[kv]); + } + } + Ok(*v) +} + +pub fn error_parts(vm: &mut Vm, id: Id) -> (String, String) { + let (nk, mk) = (vm.names.name, vm.names.message); + let name = match vm.get_obj(id, nk) { + Value::Undef => "Error".to_owned(), + v => vm + .string_of(&v) + .map(|s| vm.text(s).to_owned()) + .unwrap_or_default(), + }; + let message = match vm.get_obj(id, mk) { + Value::Undef => String::new(), + v => vm + .string_of(&v) + .map(|s| vm.text(s).to_owned()) + .unwrap_or_default(), + }; + (name, message) +} + +/// `Error.prototype.toString`. +pub fn error_to_string(vm: &mut Vm, id: Id) -> String { + let (name, message) = error_parts(vm, id); + if message.is_empty() { + return name; + } + if name.is_empty() { + return message; + } + format!("{name}: {message}") +} + +// ---------- JSON.stringify ---------- + +pub struct Stringify { + pub indent: String, + pub replacer_fn: Option, + pub allow: Option>, +} + +pub fn stringify(vm: &mut Vm, v: &Value, opts: &Stringify) -> Result, Value> { + let mut out = String::new(); + let mut stack = Vec::new(); + let holder = vm.new_object(); + let empty = vm.atoms.intern_static(""); + vm.define(holder, empty, *v); + let ok = write_json( + vm, + &mut out, + Value::Obj(holder), + Key::Empty, + *v, + opts, + &mut stack, + "", + )?; + Ok(if ok { Some(out) } else { None }) +} + +#[allow(clippy::too_many_arguments)] +fn write_json( + vm: &mut Vm, + out: &mut String, + holder: Value, + key: Key, + v: Value, + opts: &Stringify, + stack: &mut Vec, + gap: &str, +) -> Result { + let mut v = apply_to_json(vm, &v, key)?; + if let Some(f) = &opts.replacer_fn { + let kv = key_value(vm, key); + v = vm.call(f, holder, &[kv, v])?; + } + match &v { + Value::Null => out.push_str("null"), + Value::Bool(b) => out.push_str(if *b { "true" } else { "false" }), + Value::Num(n) => { + if n.is_finite() { + write_num(out, *n); + } else { + out.push_str("null"); + } + } + Value::Str(s) => quote(out, vm.text(*s)), + Value::Undef | Value::Uninit | Value::Sym(_) => return Ok(false), + Value::Obj(id) => { + let id = *id; + if vm.heap[id as usize].is_callable() { + return Ok(false); + } + if matches!(vm.heap[id as usize].kind, Kind::Promise(_)) { + return Err(vm.type_error("Cannot serialize a promise; await it first")); + } + if stack.contains(&id) { + return Err(vm.type_error("Converting circular structure to JSON")); + } + if stack.len() > 512 { + return Err(vm.range_error("Maximum call stack size exceeded")); + } + stack.push(id); + let inner = format!("{gap}{}", opts.indent); + let is_array = matches!(vm.heap[id as usize].kind, Kind::Array(_)); + if is_array { + let len = match &vm.heap[id as usize].kind { + Kind::Array(items) => items.len(), + _ => 0, + }; + if len == 0 { + out.push_str("[]"); + } else { + out.push('['); + for i in 0..len { + if i > 0 { + out.push(','); + } + if !opts.indent.is_empty() { + out.push('\n'); + out.push_str(&inner); + } + let item = match &vm.heap[id as usize].kind { + Kind::Array(items) => items.get(i).cloned().unwrap_or_default(), + _ => Value::Undef, + }; + if !write_json( + vm, + out, + Value::Obj(id), + Key::Index(i), + item, + opts, + stack, + &inner, + )? { + out.push_str("null"); + } + } + if !opts.indent.is_empty() { + out.push('\n'); + out.push_str(gap); + } + out.push(']'); + } + } else { + let entries: Vec<(Atom, Value)> = match &vm.heap[id as usize].kind { + Kind::Error(_) => { + let (name, message) = error_parts(vm, id); + let (nk, mk) = (vm.names.name, vm.names.message); + let (name, message) = (vm.string_val(name), vm.string_val(message)); + let mut e = vec![(nk, name), (mk, message)]; + e.extend( + vm.own_entries(id) + .into_iter() + .filter(|(k, _)| *k != nk && *k != mk), + ); + e + } + Kind::Ordinary | Kind::Arguments(_) => vm.own_entries(id), + _ => Vec::new(), + }; + let entries: Vec<(Atom, Value)> = match &opts.allow { + Some(allow) => allow + .iter() + .filter_map(|k| entries.iter().find(|(e, _)| e == k).cloned()) + .collect(), + None => entries, + }; + out.push('{'); + let mut first = true; + for (k, val) in entries { + let mark = out.len(); + if !first { + out.push(','); + } + if !opts.indent.is_empty() { + out.push('\n'); + out.push_str(&inner); + } + quote(out, vm.atoms.text(k)); + out.push(':'); + if !opts.indent.is_empty() { + out.push(' '); + } + if write_json( + vm, + out, + Value::Obj(id), + Key::Atom(k), + val, + opts, + stack, + &inner, + )? { + first = false; + } else { + out.truncate(mark); + } + } + if !first && !opts.indent.is_empty() { + out.push('\n'); + out.push_str(gap); + } + out.push('}'); + } + stack.pop(); + } + } + if out.len() > crate::ops::MAX_STRING_LEN { + return Err(vm.range_error("Invalid string length")); + } + Ok(true) +} + +pub fn quote(out: &mut String, s: &str) { + out.push('"'); + let bytes = s.as_bytes(); + let mut start = 0; + for (i, &b) in bytes.iter().enumerate() { + let esc = match b { + b'"' => "\\\"", + b'\\' => "\\\\", + b'\n' => "\\n", + b'\r' => "\\r", + b'\t' => "\\t", + 0x08 => "\\b", + 0x0c => "\\f", + 0..=0x1f => "", + _ => continue, + }; + out.push_str(&s[start..i]); + if esc.is_empty() { + let _ = write!(out, "\\u{:04x}", b); + } else { + out.push_str(esc); + } + start = i + 1; + } + out.push_str(&s[start..]); + out.push('"'); +} + +// ---------- JSON.parse ---------- + +struct Parser<'s> { + s: &'s [u8], + text: &'s str, + i: usize, + depth: usize, +} + +pub fn parse(vm: &mut Vm, text: &str) -> Res { + let mut p = Parser { + s: text.as_bytes(), + text, + i: 0, + depth: 0, + }; + p.ws(); + let v = p.value(vm)?; + p.ws(); + if p.i < p.s.len() { + return Err(p.error(vm)); + } + Ok(v) +} + +impl<'s> Parser<'s> { + fn ws(&mut self) { + while self.i < self.s.len() && matches!(self.s[self.i], b' ' | b'\t' | b'\n' | b'\r') { + self.i += 1; + } + } + + fn error(&self, vm: &mut Vm) -> Value { + let msg = if self.i >= self.s.len() { + "Unexpected end of JSON input".to_owned() + } else { + let c = self.text[self.i..].chars().next().unwrap_or(' '); + format!( + "Unexpected token '{c}', \"{}\" is not valid JSON", + truncate(self.text, 30) + ) + }; + vm.syntax_error(&msg) + } + + fn value(&mut self, vm: &mut Vm) -> Res { + let Some(&c) = self.s.get(self.i) else { + return Err(self.error(vm)); + }; + match c { + b'{' => { + self.depth += 1; + if self.depth > 512 { + return Err(vm.range_error("Maximum call stack size exceeded")); + } + self.i += 1; + let id = vm.new_object(); + self.ws(); + if self.s.get(self.i) == Some(&b'}') { + self.i += 1; + self.depth -= 1; + return Ok(Value::Obj(id)); + } + loop { + self.ws(); + if self.s.get(self.i) != Some(&b'"') { + return Err(self.error(vm)); + } + let k = self.string(vm)?; + self.ws(); + if self.s.get(self.i) != Some(&b':') { + return Err(self.error(vm)); + } + self.i += 1; + self.ws(); + let v = self.value(vm)?; + let a = vm.atoms.intern(&k); + vm.define(id, a, v); + self.ws(); + match self.s.get(self.i) { + Some(b',') => self.i += 1, + Some(b'}') => { + self.i += 1; + self.depth -= 1; + return Ok(Value::Obj(id)); + } + _ => return Err(self.error(vm)), + } + } + } + b'[' => { + self.depth += 1; + if self.depth > 512 { + return Err(vm.range_error("Maximum call stack size exceeded")); + } + self.i += 1; + let mut items = Vec::new(); + self.ws(); + if self.s.get(self.i) == Some(&b']') { + self.i += 1; + self.depth -= 1; + return Ok(vm.new_array(items)); + } + loop { + self.ws(); + items.push(self.value(vm)?); + self.ws(); + match self.s.get(self.i) { + Some(b',') => self.i += 1, + Some(b']') => { + self.i += 1; + self.depth -= 1; + return Ok(vm.new_array(items)); + } + _ => return Err(self.error(vm)), + } + } + } + b'"' => { + let s = self.string(vm)?; + Ok(vm.string_val(s)) + } + b't' if self.s[self.i..].starts_with(b"true") => { + self.i += 4; + Ok(Value::Bool(true)) + } + b'f' if self.s[self.i..].starts_with(b"false") => { + self.i += 5; + Ok(Value::Bool(false)) + } + b'n' if self.s[self.i..].starts_with(b"null") => { + self.i += 4; + Ok(Value::Null) + } + b'-' | b'0'..=b'9' => { + let start = self.i; + if self.s[self.i] == b'-' { + self.i += 1; + } + let int_start = self.i; + while self.i < self.s.len() && self.s[self.i].is_ascii_digit() { + self.i += 1; + } + if self.i == int_start || (self.s[int_start] == b'0' && self.i - int_start > 1) { + return Err(self.error(vm)); + } + if self.s.get(self.i) == Some(&b'.') { + self.i += 1; + let f = self.i; + while self.i < self.s.len() && self.s[self.i].is_ascii_digit() { + self.i += 1; + } + if self.i == f { + return Err(self.error(vm)); + } + } + if matches!(self.s.get(self.i), Some(b'e' | b'E')) { + self.i += 1; + if matches!(self.s.get(self.i), Some(b'+' | b'-')) { + self.i += 1; + } + let e = self.i; + while self.i < self.s.len() && self.s[self.i].is_ascii_digit() { + self.i += 1; + } + if self.i == e { + return Err(self.error(vm)); + } + } + Ok(Value::Num( + self.text[start..self.i].parse().unwrap_or(f64::NAN), + )) + } + _ => Err(self.error(vm)), + } + } + + fn string(&mut self, vm: &mut Vm) -> Result { + self.i += 1; + let mut out = String::new(); + let mut start = self.i; + loop { + let Some(&c) = self.s.get(self.i) else { + return Err(self.error(vm)); + }; + match c { + b'"' => { + out.push_str(&self.text[start..self.i]); + self.i += 1; + return Ok(out); + } + b'\\' => { + out.push_str(&self.text[start..self.i]); + self.i += 1; + let Some(&e) = self.s.get(self.i) else { + return Err(self.error(vm)); + }; + self.i += 1; + match e { + b'"' => out.push('"'), + b'\\' => out.push('\\'), + b'/' => out.push('/'), + b'b' => out.push('\u{8}'), + b'f' => out.push('\u{c}'), + b'n' => out.push('\n'), + b'r' => out.push('\r'), + b't' => out.push('\t'), + b'u' => { + let mut units = vec![self.hex4(vm)?]; + while (0xd800..0xdc00).contains(units.last().unwrap_or(&0)) + && self.s.get(self.i) == Some(&b'\\') + && self.s.get(self.i + 1) == Some(&b'u') + { + self.i += 2; + units.push(self.hex4(vm)?); + } + out.push_str(&String::from_utf16_lossy(&units)); + } + _ => { + self.i -= 1; + return Err(self.error(vm)); + } + } + start = self.i; + } + 0..=0x1f => return Err(self.error(vm)), + _ => self.i += 1, + } + } + } + + fn hex4(&mut self, vm: &mut Vm) -> Result { + let h = self + .text + .get(self.i..self.i + 4) + .and_then(|h| u16::from_str_radix(h, 16).ok()); + match h { + Some(v) => { + self.i += 4; + Ok(v) + } + None => Err(self.error(vm)), + } + } +} + +fn truncate(s: &str, n: usize) -> String { + if s.chars().count() <= n { + s.to_owned() + } else { + format!("{}...", s.chars().take(n).collect::()) + } +} + +// ---------- console ---------- + +/// One value as `console.log` shows it. +pub fn format_value(vm: &mut Vm, v: &Value) -> String { + match v { + Value::Undef | Value::Uninit => "undefined".into(), + Value::Str(s) => vm.text(*s).to_owned(), + _ => { + let mut out = String::new(); + let mut seen = Vec::new(); + format_inner(vm, &mut out, v, &mut seen); + out + } + } +} + +fn format_inner(vm: &mut Vm, out: &mut String, v: &Value, seen: &mut Vec) { + match v { + Value::Undef | Value::Uninit | Value::Null => out.push_str("null"), + Value::Str(s) => quote(out, vm.text(*s)), + Value::Num(n) => write_num(out, *n), + Value::Bool(b) => out.push_str(if *b { "true" } else { "false" }), + Value::Sym(_) => out.push_str("Symbol(Symbol.iterator)"), + Value::Obj(id) => { + let id = *id; + if seen.len() > MAX_VALUE_DEPTH { + out.push_str("..."); + return; + } + if seen.contains(&id) { + out.push_str("[Circular]"); + return; + } + seen.push(id); + match &vm.heap[id as usize].kind { + Kind::Array(items) => { + let items = items.clone(); + out.push('['); + for (i, item) in items.iter().enumerate() { + if i > 0 { + out.push(','); + } + format_inner(vm, out, item, seen); + } + out.push(']'); + } + Kind::Ordinary | Kind::Arguments(_) => { + out.push('{'); + for (i, (k, val)) in vm.own_entries(id).into_iter().enumerate() { + if i > 0 { + out.push(','); + } + quote(out, vm.atoms.text(k)); + out.push(':'); + format_inner(vm, out, &val, seen); + } + out.push('}'); + } + Kind::Error(_) => { + let s = error_to_string(vm, id); + out.push_str(&s); + } + Kind::Map(m) | Kind::Set(m) => { + let is_set = matches!(vm.heap[id as usize].kind, Kind::Set(_)); + let entries: Vec<(Value, Value)> = + m.entries.iter().flatten().cloned().collect(); + let _ = write!( + out, + "{}({}) [", + if is_set { "Set" } else { "Map" }, + entries.len() + ); + for (i, (k, val)) in entries.iter().enumerate() { + if i > 0 { + out.push(','); + } + if is_set { + format_inner(vm, out, k, seen); + } else { + out.push('['); + format_inner(vm, out, k, seen); + out.push(','); + format_inner(vm, out, val, seen); + out.push(']'); + } + } + out.push(']'); + } + Kind::Promise(_) => out.push_str("[Promise (await it to get its value)]"), + _ => out.push_str("[opaque reference]"), + } + seen.pop(); + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/lib.rs b/packages/codemode-rust/crates/psychoscript/src/lib.rs new file mode 100644 index 000000000000..c15f88b3ef61 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/lib.rs @@ -0,0 +1,104 @@ +//! PsychoScript: a confined, JavaScript-like language for calling host tools, embeddable in Rust. +//! +//! The public API below is shared with the benchmark and conformance harnesses, so change it only together with them. + +use std::collections::BTreeMap; + +mod builtins; +mod bytecode; +mod compiler; +mod convert; +mod object; +mod ops; +mod promise; +mod run; +mod strings; +mod value; +mod vm; + +pub use serde_json::Value as Json; + +/// A host tool: plain data in, plain data out. A failure is thrown into the program as an error. +pub type ToolFn = Box Result + Send + Sync>; + +#[derive(Clone, Copy, Debug, Default)] +pub struct Limits { + pub timeout_ms: Option, + pub max_tool_calls: Option, + pub max_output_bytes: Option, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum DiagnosticKind { + ParseError, + UnsupportedSyntax, + UnknownTool, + InvalidDataValue, + ToolCallLimitExceeded, + TimeoutExceeded, + ToolFailure, + ExecutionFailure, +} + +#[derive(Clone, Debug)] +pub struct Diagnostic { + pub kind: DiagnosticKind, + pub message: String, + /// 1-based line and column in the program source, when known. + pub location: Option<(u32, u32)>, +} + +#[derive(Clone, Debug)] +pub struct ToolCall { + pub path: String, + pub input: Json, +} + +#[derive(Clone, Debug)] +pub struct Outcome { + /// `Ok(value)` is JSON-safe; `undefined` becomes `null`. + pub result: Result, + pub logs: Vec, + pub tool_calls: Vec, +} + +/// Reusable runtime: tools and limits are fixed, each `execute` is an independent run. +pub struct Runtime { + tools: BTreeMap, + limits: Limits, +} + +impl Runtime { + pub fn new() -> Self { + Self { + tools: BTreeMap::new(), + limits: Limits::default(), + } + } + + /// Registers a tool at a dotted path, callable as `tools.(input)`; `"git.status"` is `tools.git.status`. + pub fn tool( + mut self, + path: &str, + f: impl Fn(&Json) -> Result + Send + Sync + 'static, + ) -> Self { + self.tools.insert(path.to_owned(), Box::new(f)); + self + } + + pub fn limits(mut self, limits: Limits) -> Self { + self.limits = limits; + self + } + + /// Parses, compiles and runs `code`. `bindings` become top-level constants. + pub fn execute(&self, code: &str, bindings: &serde_json::Map) -> Outcome { + run::execute(self, code, bindings) + } +} + +impl Default for Runtime { + fn default() -> Self { + Self::new() + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/object.rs b/packages/codemode-rust/crates/psychoscript/src/object.rs new file mode 100644 index 000000000000..c325e094dd25 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/object.rs @@ -0,0 +1,290 @@ +//! Heap objects, property storage and the atom interner. + +use std::rc::Rc; + +use rustc_hash::FxHashMap; + +use crate::DiagnosticKind; +use crate::bytecode::FuncProto; +pub use crate::strings::{Atom, SYM_ITERATOR}; +use crate::value::{Id, Value}; +use crate::vm::{NativeFn, SavedFrame}; + +pub const ENUMERABLE: u8 = 1; +pub const WRITABLE: u8 = 2; +pub const DEFAULT_FLAGS: u8 = ENUMERABLE | WRITABLE; +pub const HIDDEN: u8 = WRITABLE; + +#[derive(Clone)] +pub struct Prop { + pub key: Atom, + pub value: Value, + pub flags: u8, +} + +/// Insertion-ordered properties; small objects scan linearly, larger ones keep a hash index. +#[derive(Default, Clone)] +pub struct Props { + pub items: Vec, + index: Option>>, +} + +const INDEX_THRESHOLD: usize = 12; + +impl Props { + #[inline] + pub fn find(&self, key: Atom) -> Option { + if let Some(idx) = &self.index { + return idx.get(&key).map(|i| *i as usize); + } + self.items.iter().position(|p| p.key == key) + } + + #[inline] + pub fn get(&self, key: Atom) -> Option<&Value> { + self.find(key).map(|i| &self.items[i].value) + } + + pub fn insert(&mut self, key: Atom, value: Value, flags: u8) { + if let Some(i) = self.find(key) { + self.items[i].value = value; + return; + } + self.push_new(key, value, flags); + } + + /// Appends a key known to be absent. + pub fn push_new(&mut self, key: Atom, value: Value, flags: u8) { + let i = self.items.len(); + self.items.push(Prop { key, value, flags }); + if let Some(idx) = &mut self.index { + idx.insert(key, i as u32); + } else if self.items.len() > INDEX_THRESHOLD { + let map = self + .items + .iter() + .enumerate() + .map(|(i, p)| (p.key, i as u32)) + .collect(); + self.index = Some(Box::new(map)); + } + } + + pub fn remove(&mut self, key: Atom) -> bool { + let Some(i) = self.find(key) else { + return false; + }; + self.items.remove(i); + if self.index.is_some() { + let map = self + .items + .iter() + .enumerate() + .map(|(i, p)| (p.key, i as u32)) + .collect(); + self.index = Some(Box::new(map)); + } + true + } + + pub fn len(&self) -> usize { + self.items.len() + } +} + +/// A failure the interpreter or host raised, kept on the error object so a rethrow reports the same diagnostic. +#[derive(Clone, Debug)] +pub struct Failure { + pub kind: DiagnosticKind, + pub message: String, + /// Source offset of the instruction that raised it, filled in when first thrown. + pub offset: Option, +} + +pub struct Closure { + pub proto: Rc, + pub upvals: Rc<[u32]>, + pub this: Value, +} + +pub enum PromiseState { + Pending, + Fulfilled(Value), + Rejected(Value), +} + +pub struct PromiseData { + pub state: PromiseState, + pub reactions: Vec, +} + +/// Key for Map and Set under SameValueZero; strings compare by their interned atom. +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub enum MapKey { + Undef, + Null, + Bool(bool), + Num(u64), + Str(Atom), + Obj(Id), + Sym(u32), +} + +/// Insertion-ordered hash map with tombstones, so iterators stay valid across deletes. +#[derive(Default)] +pub struct OrderedMap { + pub entries: Vec>, + index: FxHashMap, + pub live: usize, +} + +impl OrderedMap { + pub fn get(&self, key: MapKey) -> Option { + let i = *self.index.get(&key)?; + self.entries[i as usize].as_ref().map(|e| e.1) + } + + pub fn has(&self, key: MapKey) -> bool { + self.index.contains_key(&key) + } + + pub fn set(&mut self, key: MapKey, k: Value, v: Value) { + if let Some(i) = self.index.get(&key) { + if let Some(e) = &mut self.entries[*i as usize] { + e.1 = v; + } + return; + } + let k = if let Value::Num(n) = k { + Value::Num(if n == 0.0 { 0.0 } else { n }) + } else { + k + }; + self.index.insert(key, self.entries.len() as u32); + self.entries.push(Some((k, v))); + self.live += 1; + } + + pub fn delete(&mut self, key: MapKey) -> bool { + match self.index.remove(&key) { + Some(i) => { + self.entries[i as usize] = None; + self.live -= 1; + true + } + None => false, + } + } + + pub fn clear(&mut self) { + self.entries.fill(None); + self.index.clear(); + self.live = 0; + } +} + +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum IterKind { + Keys, + Values, + Entries, +} + +pub enum GenState { + Suspended(Box), + /// Running, holding the emptied box its frame came from. + Running(Option>), + Done, +} + +pub enum Kind { + Ordinary, + Array(Vec), + Arguments(Vec), + Closure(Box), + Native { + f: NativeFn, + data: Value, + name: Atom, + length: u8, + ctor: bool, + }, + Bound(Box<(Value, Value, Vec)>), + Error(Option>), + Promise(Box), + Map(Box), + Set(Box), + Generator(GenState), + ArrayIter { + target: Id, + pos: u32, + kind: IterKind, + }, + MapIter { + target: Id, + pos: u32, + kind: IterKind, + }, + StrIter { + s: crate::strings::StrId, + pos: u32, + }, + ListIter { + items: Rc<[Value]>, + pos: u32, + }, + ToolRef(Rc), + /// Shared state of a promise's resolve/reject pair: the promise, and whether either already ran. + Resolvers { + promise: Id, + done: bool, + }, + /// Shared state of a `Promise.all`-family combinator. + Combinator(Box), + /// A generator `return()` travelling through `finally` blocks. + ReturnSignal(Value), +} + +pub struct Combinator { + pub kind: CombKind, + pub promise: Id, + pub values: Vec, + pub remaining: usize, +} + +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum CombKind { + All, + AllSettled, + Any, +} + +pub const NON_EXTENSIBLE: u8 = 1; +pub const FROZEN: u8 = 2; +pub const SEALED: u8 = 4; + +pub struct Obj { + pub proto: Option, + pub props: Props, + pub kind: Kind, + pub flags: u8, +} + +impl Obj { + pub fn new(proto: Option, kind: Kind) -> Obj { + Obj { + proto, + props: Props::default(), + kind, + flags: 0, + } + } + + pub fn is_callable(&self) -> bool { + match &self.kind { + Kind::Closure(_) | Kind::Native { .. } | Kind::Bound(_) => true, + Kind::ToolRef(p) => !p.is_empty(), + _ => false, + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/ops.rs b/packages/codemode-rust/crates/psychoscript/src/ops.rs new file mode 100644 index 000000000000..fcb606a0b908 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/ops.rs @@ -0,0 +1,1119 @@ +//! Property access, conversions, operators and iteration on program values. + +use crate::object::*; +use crate::strings::StrId; +use crate::value::{Id, Value, num_to_string, str_to_num}; +use crate::vm::{Res, Vm}; + +pub const MAX_STRING_LEN: usize = 1 << 24; +pub const MAX_ARRAY_LEN: usize = 10_000_000; + +#[derive(Clone, Copy, PartialEq)] +pub enum Hint { + Default, + Number, + String, +} + +impl<'rt> Vm<'rt> { + // ---------- property reads ---------- + + #[inline(never)] + pub fn get(&mut self, v: &Value, key: Atom) -> Res { + match v { + Value::Obj(id) => Ok(self.get_obj(*id, key)), + Value::Str(s) => { + let s = *s; + if key == self.names.length { + return Ok(Value::Num(self.atoms.sref(s).len16() as f64)); + } + if let Some(i) = self.atoms.index(key) { + return Ok(match self.atoms.sref(s).code_unit(i as usize) { + Some(c) => self.char_str(c), + None => Value::Undef, + }); + } + let p = self.realm.string_proto; + Ok(self.get_obj(p, key)) + } + Value::Num(_) => { + let p = self.realm.number_proto; + Ok(self.get_obj(p, key)) + } + Value::Bool(_) => { + let p = self.realm.boolean_proto; + Ok(self.get_obj(p, key)) + } + Value::Sym(_) => { + let p = self.realm.symbol_proto; + Ok(self.get_obj(p, key)) + } + Value::Undef | Value::Null | Value::Uninit => { + let k = self.key_text(key); + let t = if let Value::Null = v { + "null" + } else { + "undefined" + }; + Err(self.type_error(&format!("Cannot read properties of {t} (reading '{k}')."))) + } + } + } + + pub fn key_text(&self, key: Atom) -> String { + self.atoms.text(key).to_owned() + } + + #[inline(never)] + pub fn get_obj(&mut self, id: Id, key: Atom) -> Value { + let mut cur = id; + loop { + let o = &self.heap[cur as usize]; + match &o.kind { + Kind::Array(items) | Kind::Arguments(items) => { + if let Some(i) = self.atoms.index(key) { + return items.get(i as usize).cloned().unwrap_or_default(); + } + if key == self.names.length { + return Value::Num(items.len() as f64); + } + } + Kind::Closure(c) if o.props.find(key).is_none() => { + if key == self.names.name { + return Value::Str(self.atoms.atom_str(c.proto.name)); + } + if key == self.names.length { + return Value::Num(c.proto.length as f64); + } + } + Kind::Native { name, length, .. } if o.props.find(key).is_none() => { + if key == self.names.name { + return Value::Str(self.atoms.atom_str(*name)); + } + if key == self.names.length { + return Value::Num(*length as f64); + } + } + Kind::Map(m) | Kind::Set(m) if cur == id && key == self.names.size => { + return Value::Num(m.live as f64); + } + Kind::ToolRef(path) if cur == id => { + if key == self.names.then || key == SYM_ITERATOR { + return Value::Undef; + } + let k = self.atoms.text(key); + let child = if path.is_empty() { + k.to_owned() + } else { + format!("{path}.{k}") + }; + return self.tool_ref(&child); + } + _ => {} + } + let o = &self.heap[cur as usize]; + if let Some(v) = o.props.get(key) { + return *v; + } + match o.proto { + Some(p) => cur = p, + None => return Value::Undef, + } + } + } + + #[inline(never)] + pub fn get_elem(&mut self, v: &Value, k: &Value) -> Res { + match (v, k) { + (Value::Obj(id), Value::Num(n)) => { + if let Kind::Array(items) = &self.heap[*id as usize].kind { + let i = *n as usize; + if i as f64 == *n { + return Ok(items.get(i).cloned().unwrap_or_default()); + } + } + } + (Value::Str(s), Value::Num(n)) => { + let i = *n as usize; + if i as f64 == *n { + return Ok(match self.atoms.sref(*s).code_unit(i) { + Some(c) => self.char_str(c), + None => Value::Undef, + }); + } + } + (Value::Undef | Value::Null, _) => { + let k = self + .string_of(k) + .map(|s| self.text(s).to_owned()) + .unwrap_or_default(); + let t = if let Value::Null = v { + "null" + } else { + "undefined" + }; + return Err( + self.type_error(&format!("Cannot read properties of {t} (reading '{k}').")) + ); + } + _ => {} + } + let a = self.key_of(k)?; + self.get(v, a) + } + + #[inline(never)] + pub fn key_of(&mut self, k: &Value) -> Result { + Ok(match k { + Value::Str(s) => self.atoms.intern_id(*s), + Value::Num(n) => { + let s = num_to_string(*n); + self.atoms.intern(&s) + } + Value::Sym(_) => SYM_ITERATOR, + Value::Obj(_) => { + let p = self.primitive_of(k, Hint::String)?; + return self.key_of(&p); + } + Value::Bool(b) => self.atoms.intern(if *b { "true" } else { "false" }), + Value::Null => self.atoms.intern_static("null"), + Value::Undef | Value::Uninit => self.atoms.intern_static("undefined"), + }) + } + + // ---------- property writes ---------- + + #[inline(never)] + pub fn set(&mut self, v: &Value, key: Atom, val: Value) -> Result<(), Value> { + match v { + Value::Obj(id) => self.set_obj(*id, key, val), + Value::Undef | Value::Null | Value::Uninit => { + let k = self.key_text(key); + let t = if let Value::Null = v { + "null" + } else { + "undefined" + }; + Err(self.type_error(&format!("Cannot set properties of {t} (setting '{k}')."))) + } + _ => { + let k = self.key_text(key); + let t = self.type_of(v); + Err(self.type_error(&format!("Cannot create property '{k}' on {t}"))) + } + } + } + + #[inline(never)] + pub fn set_obj(&mut self, id: Id, key: Atom, val: Value) -> Result<(), Value> { + let flags = self.heap[id as usize].flags; + let length = self.names.length; + let index = self.atoms.index(key); + let is_name_or_length = key == length || key == self.names.name; + match &mut self.heap[id as usize].kind { + Kind::Array(items) => { + if let Some(i) = index { + let i = i as usize; + if flags & FROZEN != 0 { + return Err(self.read_only(key)); + } + if i < items.len() { + items[i] = val; + return Ok(()); + } + if flags & NON_EXTENSIBLE != 0 { + return Err(self.not_extensible(key)); + } + if i >= MAX_ARRAY_LEN { + return Err(self.range_error("Invalid array length.")); + } + items.resize(i, Value::Undef); + items.push(val); + return Ok(()); + } + if key == length { + if flags & FROZEN != 0 { + return Err(self.read_only(key)); + } + let n = match val { + Value::Num(n) => n, + _ => self.number_of(&val)?, + }; + if n < 0.0 || n.fract() != 0.0 || n as usize > MAX_ARRAY_LEN { + return Err(self.range_error("Invalid array length.")); + } + if let Kind::Array(items) = &mut self.heap[id as usize].kind { + items.resize(n as usize, Value::Undef); + } + return Ok(()); + } + } + Kind::Arguments(items) => { + if let Some(i) = index + && (i as usize) < items.len() + { + items[i as usize] = val; + return Ok(()); + } + } + Kind::Closure(_) | Kind::Native { .. } | Kind::Bound(_) if is_name_or_length => { + return Err(self.read_only(key)); + } + Kind::ToolRef(_) => return Err(self.type_error("Cannot assign to a tool reference")), + _ => {} + } + let o = &mut self.heap[id as usize]; + match o.props.find(key) { + Some(i) => { + if flags & FROZEN != 0 || o.props.items[i].flags & WRITABLE == 0 { + return Err(self.read_only(key)); + } + o.props.items[i].value = val; + } + None => { + if flags & NON_EXTENSIBLE != 0 { + return Err(self.not_extensible(key)); + } + o.props.push_new(key, val, DEFAULT_FLAGS); + } + } + Ok(()) + } + + fn read_only(&mut self, key: Atom) -> Value { + let k = self.key_text(key); + self.type_error(&format!( + "Cannot assign to read only property '{k}' of object" + )) + } + + fn not_extensible(&mut self, key: Atom) -> Value { + let k = self.key_text(key); + self.type_error(&format!( + "Cannot add property {k}, object is not extensible" + )) + } + + #[inline(never)] + pub fn set_elem(&mut self, v: &Value, k: &Value, val: Value) -> Result<(), Value> { + if let (Value::Obj(id), Value::Num(n)) = (v, k) { + let o = &mut self.heap[*id as usize]; + if o.flags == 0 + && let Kind::Array(items) = &mut o.kind + { + let i = *n as usize; + if i as f64 == *n && i < items.len() { + items[i] = val; + return Ok(()); + } + if i as f64 == *n && i == items.len() { + items.push(val); + return Ok(()); + } + } + } + if v.is_nullish() { + let k = self + .string_of(k) + .map(|s| self.text(s).to_owned()) + .unwrap_or_default(); + let t = if let Value::Null = v { + "null" + } else { + "undefined" + }; + return Err(self.type_error(&format!("Cannot set properties of {t} (setting '{k}')."))); + } + let a = self.key_of(k)?; + self.set(v, a, val) + } + + /// Defines an own enumerable data property, as object literals do. + #[inline(never)] + pub fn define(&mut self, id: Id, key: Atom, val: Value) { + let index = self.atoms.index(key); + let o = &mut self.heap[id as usize]; + if let (Kind::Array(items), Some(i)) = (&mut o.kind, index) { + let i = i as usize; + if i < items.len() { + items[i] = val; + } else if i < MAX_ARRAY_LEN { + items.resize(i, Value::Undef); + items.push(val); + } + return; + } + match o.props.find(key) { + Some(i) => { + o.props.items[i].value = val; + o.props.items[i].flags = DEFAULT_FLAGS; + } + None => o.props.push_new(key, val, DEFAULT_FLAGS), + } + } + + pub fn define_hidden(&mut self, id: Id, key: Atom, val: Value) { + self.heap[id as usize].props.insert(key, val, HIDDEN); + } + + #[inline(never)] + pub fn delete(&mut self, v: &Value, key: Atom) -> Result { + let Value::Obj(id) = v else { + if v.is_nullish() { + let k = self.key_text(key); + return Err(self.type_error(&format!( + "Cannot convert undefined or null to object (deleting '{k}')" + ))); + } + return Ok(true); + }; + let id = *id; + let flags = self.heap[id as usize].flags; + let index = self.atoms.index(key); + if let Kind::Array(items) = &mut self.heap[id as usize].kind { + if key == self.names.length { + return Err(self.type_error("Cannot delete property 'length' of [object Array]")); + } + if let Some(i) = index { + if flags & (FROZEN | SEALED) != 0 { + let k = self.key_text(key); + return Err(self.type_error(&format!("Cannot delete property '{k}'"))); + } + if let Some(slot) = items.get_mut(i as usize) { + *slot = Value::Undef; + } + return Ok(true); + } + } + if self.heap[id as usize].props.find(key).is_some() && flags & (FROZEN | SEALED) != 0 { + let k = self.key_text(key); + return Err(self.type_error(&format!("Cannot delete property '{k}'"))); + } + self.heap[id as usize].props.remove(key); + Ok(true) + } + + #[inline(never)] + pub fn has_property(&mut self, o: &Value, k: &Value) -> Result { + let Value::Obj(id) = o else { + let ks = self.string_of(k)?; + let ks = self.text(ks).to_owned(); + let d = self.describe(o); + return Err(self.type_error(&format!( + "Cannot use 'in' operator to search for '{ks}' in {d}" + ))); + }; + let key = self.key_of(k)?; + Ok(self.has_key(*id, key)) + } + + pub fn has_key(&self, id: Id, key: Atom) -> bool { + let mut cur = id; + loop { + let o = &self.heap[cur as usize]; + match &o.kind { + Kind::Array(items) | Kind::Arguments(items) => { + if let Some(i) = self.atoms.index(key) { + if (i as usize) < items.len() { + return true; + } + } else if key == self.names.length { + return true; + } + } + Kind::Closure(_) | Kind::Native { .. } + if key == self.names.name || key == self.names.length => + { + return true; + } + _ => {} + } + if o.props.find(key).is_some() { + return true; + } + match o.proto { + Some(p) => cur = p, + None => return false, + } + } + } + + pub fn has_own(&self, id: Id, key: Atom) -> bool { + let o = &self.heap[id as usize]; + match &o.kind { + Kind::Array(items) | Kind::Arguments(items) => { + if let Some(i) = self.atoms.index(key) { + return (i as usize) < items.len(); + } + if key == self.names.length { + return true; + } + } + Kind::Closure(_) | Kind::Native { .. } + if key == self.names.name || key == self.names.length => + { + return true; + } + _ => {} + } + o.props.find(key).is_some() + } + + #[inline(never)] + pub fn instance_of(&mut self, v: &Value, c: &Value) -> Result { + if !self.is_callable(c) { + return Err(self.type_error("Right-hand side of 'instanceof' is not callable")); + } + let Value::Obj(cid) = c else { return Ok(false) }; + let pk = self.names.prototype; + let Value::Obj(proto) = self.get_obj(*cid, pk) else { + return Err(self.type_error("Function has non-object prototype in instanceof check")); + }; + let Value::Obj(cur) = v else { return Ok(false) }; + let mut cur = *cur; + while let Some(p) = self.heap[cur as usize].proto { + if p == proto { + return Ok(true); + } + cur = p; + } + Ok(false) + } + + /// Own enumerable string keys in JavaScript order: integer keys ascending, then insertion order. + pub fn own_keys(&mut self, id: Id) -> Vec { + let mut out = Vec::new(); + let len = match &self.heap[id as usize].kind { + Kind::Array(items) | Kind::Arguments(items) => items.len(), + _ => 0, + }; + for i in 0..len { + out.push(self.atoms.intern(&i.to_string())); + } + let props = &self.heap[id as usize].props; + let mut ints = Vec::new(); + let mut strs = Vec::new(); + for p in &props.items { + if p.flags & ENUMERABLE == 0 || p.key == SYM_ITERATOR { + continue; + } + match self.atoms.index(p.key) { + Some(i) => ints.push((i, p.key)), + None => strs.push(p.key), + } + } + if !ints.is_empty() { + ints.sort_unstable_by_key(|(i, _)| *i); + out.extend(ints.into_iter().map(|(_, k)| k)); + } + out.extend(strs); + out + } + + /// Own enumerable entries of an object in key order. + pub fn own_entries(&mut self, id: Id) -> Vec<(Atom, Value)> { + if let Kind::Ordinary | Kind::Error(_) = self.heap[id as usize].kind { + let props = &self.heap[id as usize].props; + let simple = props + .items + .iter() + .all(|p| self.atoms.index(p.key).is_none()); + if simple { + return props + .items + .iter() + .filter(|p| p.flags & ENUMERABLE != 0 && p.key != SYM_ITERATOR) + .map(|p| (p.key, p.value)) + .collect(); + } + } + let keys = self.own_keys(id); + keys.into_iter().map(|k| (k, self.get_obj(id, k))).collect() + } + + #[inline(never)] + pub fn copy_props(&mut self, target: Id, src: &Value, excluded: &[Atom]) -> Result<(), Value> { + match src { + Value::Obj(id) => { + if let Kind::Map(_) | Kind::Set(_) | Kind::Closure(_) | Kind::Native { .. } = + self.heap[*id as usize].kind + && self.heap[*id as usize].props.len() == 0 + { + return Ok(()); + } + for (k, v) in self.own_entries(*id) { + if !excluded.contains(&k) { + self.define(target, k, v); + } + } + } + Value::Str(s) => { + let units = self.atoms.sref(*s).utf16(); + for (i, c) in units.iter().enumerate() { + let k = self.atoms.intern(&i.to_string()); + if !excluded.contains(&k) { + let v = self.char_str(*c); + self.define(target, k, v); + } + } + } + _ => {} + } + Ok(()) + } + + #[inline(never)] + pub fn for_in_keys(&mut self, v: &Value) -> Vec { + match v { + Value::Obj(id) => { + let mut seen: Vec = self.own_keys(*id); + let mut cur = self.heap[*id as usize].proto; + while let Some(p) = cur { + for k in self.own_keys(p) { + if !seen.contains(&k) { + seen.push(k); + } + } + cur = self.heap[p as usize].proto; + } + seen.into_iter() + .map(|k| Value::Str(self.atoms.atom_str(k))) + .collect() + } + Value::Str(s) => { + let n = self.atoms.sref(*s).len16(); + (0..n).map(|i| self.string_val(i.to_string())).collect() + } + _ => Vec::new(), + } + } + + // ---------- conversions ---------- + + pub fn truthy(&self, v: &Value) -> bool { + match v { + Value::Bool(b) => *b, + Value::Num(n) => *n != 0.0 && !n.is_nan(), + Value::Str(s) => !self.atoms.get(*s).is_empty(), + Value::Obj(_) | Value::Sym(_) => true, + Value::Undef | Value::Null | Value::Uninit => false, + } + } + + pub fn is_callable(&self, v: &Value) -> bool { + match v { + Value::Obj(id) => self.heap[*id as usize].is_callable(), + _ => false, + } + } + + pub fn type_of(&self, v: &Value) -> &'static str { + match v { + Value::Undef | Value::Uninit => "undefined", + Value::Null => "object", + Value::Bool(_) => "boolean", + Value::Num(_) => "number", + Value::Str(_) => "string", + Value::Sym(_) => "symbol", + Value::Obj(_) => { + if self.is_callable(v) { + "function" + } else { + "object" + } + } + } + } + + pub fn describe(&self, v: &Value) -> String { + match v { + Value::Str(s) => format!("\"{}\"", self.atoms.get(*s)), + Value::Num(n) => num_to_string(*n), + Value::Bool(b) => b.to_string(), + Value::Null => "null".into(), + Value::Undef | Value::Uninit => "undefined".into(), + Value::Sym(_) => "Symbol(Symbol.iterator)".into(), + Value::Obj(id) => match &self.heap[*id as usize].kind { + Kind::Array(_) => "array".into(), + Kind::Closure(c) => { + let n = self.atoms.text(c.proto.name); + if n.is_empty() { + "function".into() + } else { + format!("function {n}") + } + } + Kind::ToolRef(p) => format!("tools.{p}"), + _ => "object".into(), + }, + } + } + + #[inline(never)] + pub fn number_of(&mut self, v: &Value) -> Result { + Ok(match v { + Value::Num(n) => *n, + Value::Str(s) => str_to_num(self.atoms.get(*s)), + Value::Bool(b) => *b as u8 as f64, + Value::Null => 0.0, + Value::Undef | Value::Uninit => f64::NAN, + Value::Sym(_) => { + return Err(self.type_error("Cannot convert a Symbol value to a number")); + } + Value::Obj(_) => { + let p = self.primitive_of(v, Hint::Number)?; + return self.number_of(&p); + } + }) + } + + #[inline(never)] + pub fn string_of(&mut self, v: &Value) -> Result { + Ok(match v { + Value::Str(s) => *s, + Value::Num(n) => { + if *n >= 0.0 && *n < 10.0 && n.fract() == 0.0 { + return Ok(self.char_strs[b'0' as usize + *n as usize]); + } + match self.string_val(num_to_string(*n)) { + Value::Str(id) => id, + _ => 0, + } + } + Value::Bool(b) => return Ok(self.static_id(if *b { "true" } else { "false" })), + Value::Null => return Ok(self.static_id("null")), + Value::Undef | Value::Uninit => return Ok(self.static_id("undefined")), + Value::Sym(_) => { + return Err(self.type_error("Cannot convert a Symbol value to a string")); + } + Value::Obj(_) => { + let p = self.primitive_of(v, Hint::String)?; + return self.string_of(&p); + } + }) + } + + pub fn map_key(&mut self, v: &Value) -> MapKey { + match v { + Value::Undef | Value::Uninit => MapKey::Undef, + Value::Null => MapKey::Null, + Value::Bool(b) => MapKey::Bool(*b), + Value::Num(n) => { + let n = if *n == 0.0 { 0.0 } else { *n }; + MapKey::Num(if n.is_nan() { + f64::NAN.to_bits() + } else { + n.to_bits() + }) + } + Value::Str(s) => MapKey::Str(self.atoms.intern_id(*s)), + Value::Obj(id) => MapKey::Obj(*id), + Value::Sym(s) => MapKey::Sym(*s), + } + } + + pub fn static_id(&mut self, s: &str) -> StrId { + let a = self.atoms.intern(s); + self.atoms.atom_str(a) + } + + pub fn primitive_of(&mut self, v: &Value, hint: Hint) -> Res { + let Value::Obj(id) = v else { + return Ok(*v); + }; + let order = if hint == Hint::String { + [self.names.to_string, self.names.value_of] + } else { + [self.names.value_of, self.names.to_string] + }; + for name in order { + let f = self.get_obj(*id, name); + if self.is_callable(&f) { + let r = self.call(&f, *v, &[])?; + if !matches!(r, Value::Obj(_)) { + return Ok(r); + } + } + } + Err(self.type_error("Cannot convert object to primitive value")) + } + + fn concat(&mut self, x: &str, y: &str) -> Res { + if x.len() + y.len() > MAX_STRING_LEN { + return Err(self.range_error("Invalid string length")); + } + let mut s = String::with_capacity(x.len() + y.len()); + s.push_str(x); + s.push_str(y); + Ok(self.string_val(s)) + } + + fn concat_ids(&mut self, x: StrId, y: StrId) -> Res { + let (a, b) = (self.atoms.get(x), self.atoms.get(y)); + if a.len() + b.len() > MAX_STRING_LEN { + return Err(self.range_error("Invalid string length")); + } + let mut s = String::with_capacity(a.len() + b.len()); + s.push_str(a); + s.push_str(b); + Ok(self.string_val(s)) + } + + #[inline(never)] + pub fn add(&mut self, a: Value, b: Value) -> Res { + match (&a, &b) { + (Value::Num(x), Value::Num(y)) => return Ok(Value::Num(x + y)), + (Value::Str(x), Value::Str(y)) => return self.concat_ids(*x, *y), + (Value::Str(x), Value::Num(y)) => { + let y = num_to_string(*y); + let x = self.atoms.get(*x).to_owned(); + return self.concat(&x, &y); + } + (Value::Num(x), Value::Str(y)) => { + let x = num_to_string(*x); + let y = self.atoms.get(*y).to_owned(); + return self.concat(&x, &y); + } + _ => {} + } + let pa = self.primitive_of(&a, Hint::Default)?; + let pb = self.primitive_of(&b, Hint::Default)?; + if matches!(pa, Value::Str(_)) || matches!(pb, Value::Str(_)) { + let x = self.string_of(&pa)?; + let y = self.string_of(&pb)?; + return self.concat_ids(x, y); + } + Ok(Value::Num(self.number_of(&pa)? + self.number_of(&pb)?)) + } + + /// The generic form of an operator fused with an immediate operand. + #[inline(never)] + pub fn arith(&mut self, op: crate::bytecode::Arith, a: Value, b: Value) -> Res { + use crate::bytecode::Arith as A; + Ok(match op { + A::Add => return self.add(a, b), + A::Sub | A::Mul | A::Div | A::Mod => { + let (x, y) = (self.number_of(&a)?, self.number_of(&b)?); + Value::Num(match op { + A::Sub => x - y, + A::Mul => x * y, + A::Div => x / y, + _ => crate::vm::js_rem(x, y), + }) + } + A::Lt => Value::Bool(self.less_than(&a, &b, true)?.unwrap_or(false)), + A::Gt => Value::Bool(self.less_than(&b, &a, false)?.unwrap_or(false)), + A::Le => Value::Bool(self.less_than(&b, &a, false)?.is_some_and(|v| !v)), + A::Ge => Value::Bool(self.less_than(&a, &b, true)?.is_some_and(|v| !v)), + A::StrictEq => Value::Bool(self.strict_eq(&a, &b)), + A::StrictNe => Value::Bool(!self.strict_eq(&a, &b)), + }) + } + + /// IsLessThan: `None` when either side is NaN. + #[inline(never)] + pub fn less_than( + &mut self, + a: &Value, + b: &Value, + left_first: bool, + ) -> Result, Value> { + let (pa, pb) = if left_first { + let pa = self.primitive_of(a, Hint::Number)?; + (pa, self.primitive_of(b, Hint::Number)?) + } else { + let pb = self.primitive_of(b, Hint::Number)?; + (self.primitive_of(a, Hint::Number)?, pb) + }; + if let (Value::Str(x), Value::Str(y)) = (&pa, &pb) { + return Ok(Some(self.atoms.sref(*x).cmp16(self.atoms.sref(*y)).is_lt())); + } + let x = self.number_of(&pa)?; + let y = self.number_of(&pb)?; + if x.is_nan() || y.is_nan() { + return Ok(None); + } + Ok(Some(x < y)) + } + + #[inline(never)] + pub fn loose_eq(&mut self, a: &Value, b: &Value) -> Result { + Ok(match (a, b) { + (Value::Undef | Value::Null, Value::Undef | Value::Null) => true, + (Value::Undef | Value::Null, _) | (_, Value::Undef | Value::Null) => false, + (Value::Num(x), Value::Str(s)) | (Value::Str(s), Value::Num(x)) => { + *x == str_to_num(self.atoms.get(*s)) + } + (Value::Str(x), Value::Str(y)) => self.atoms.get(*x) == self.atoms.get(*y), + (Value::Bool(x), _) => { + let n = Value::Num(*x as u8 as f64); + return self.loose_eq(&n, b); + } + (_, Value::Bool(y)) => { + let n = Value::Num(*y as u8 as f64); + return self.loose_eq(a, &n); + } + (Value::Obj(_), Value::Num(_) | Value::Str(_) | Value::Sym(_)) => { + let p = self.primitive_of(a, Hint::Default)?; + return self.loose_eq(&p, b); + } + (Value::Num(_) | Value::Str(_) | Value::Sym(_), Value::Obj(_)) => { + let p = self.primitive_of(b, Hint::Default)?; + return self.loose_eq(a, &p); + } + _ => self.strict_eq(a, b), + }) + } + + pub fn error_text(&mut self, e: &Value) -> String { + if let Value::Obj(id) = e + && let Kind::Error(_) = self.heap[*id as usize].kind + { + let m = self.names.message; + if let Value::Str(s) = self.get_obj(*id, m) { + return self.text(s).to_owned(); + } + } + crate::convert::format_value(self, e) + } + + // ---------- iteration ---------- + + #[inline(never)] + pub fn iterate_to_vec(&mut self, v: &Value) -> Result, Value> { + if let Value::Obj(id) = v { + match &self.heap[*id as usize].kind { + Kind::Array(items) => return Ok(items.clone()), + Kind::Set(m) => { + return Ok(m.entries.iter().flatten().map(|(k, _)| *k).collect()); + } + _ => {} + } + } + if let Value::Str(s) = v { + let chars: Vec = self.atoms.get(*s).chars().collect(); + return Ok(chars + .into_iter() + .map(|c| { + if (c as u32) < 128 { + Value::Str(self.char_strs[c as usize]) + } else { + self.string_val(c.to_string()) + } + }) + .collect()); + } + let it = self.get_iterator(v)?; + let mut out = Vec::new(); + while let Some(x) = self.iter_step(&it)? { + if out.len() >= MAX_ARRAY_LEN { + return Err(self.range_error("Invalid array length.")); + } + out.push(x); + } + Ok(out) + } + + #[inline(never)] + pub fn get_iterator(&mut self, v: &Value) -> Res { + let proto = self.realm.iter_proto; + match v { + Value::Obj(id) => { + let kind = match &self.heap[*id as usize].kind { + Kind::Array(_) | Kind::Arguments(_) => Some(Kind::ArrayIter { + target: *id, + pos: 0, + kind: IterKind::Values, + }), + Kind::Map(_) => Some(Kind::MapIter { + target: *id, + pos: 0, + kind: IterKind::Entries, + }), + Kind::Set(_) => Some(Kind::MapIter { + target: *id, + pos: 0, + kind: IterKind::Values, + }), + Kind::Generator(_) + | Kind::ArrayIter { .. } + | Kind::MapIter { .. } + | Kind::StrIter { .. } + | Kind::ListIter { .. } => return Ok(*v), + _ => None, + }; + if let Some(k) = kind { + return Ok(Value::Obj(self.alloc(Obj::new(Some(proto), k)))); + } + let f = self.get_obj(*id, SYM_ITERATOR); + if self.is_callable(&f) { + let it = self.call(&f, *v, &[])?; + if !matches!(it, Value::Obj(_)) { + return Err(self + .type_error("Result of the Symbol.iterator method is not an object")); + } + return Ok(it); + } + } + Value::Str(s) => { + return Ok(Value::Obj( + self.alloc(Obj::new(Some(proto), Kind::StrIter { s: *s, pos: 0 })), + )); + } + _ => {} + } + let d = self.describe(v); + Err(self.type_error(&format!("{d} is not iterable"))) + } + + /// One step of `yield*`: the next value, or the delegate's completion value once it is done. + #[inline(never)] + pub fn delegate_step(&mut self, it: &Value) -> Result<(Value, bool), Value> { + if let Value::Obj(id) = it { + let id = *id; + match &self.heap[id as usize].kind { + Kind::Generator(_) => return self.resume_generator(id, 0, Value::Undef), + Kind::ArrayIter { .. } + | Kind::MapIter { .. } + | Kind::StrIter { .. } + | Kind::ListIter { .. } => {} + _ => { + let next = self.names.next; + let f = self.get_obj(id, next); + let r = self.call(&f, *it, &[])?; + let Value::Obj(rid) = r else { + return Err(self.type_error("Iterator result is not an object")); + }; + let (dk, vk) = (self.names.done, self.names.value); + let d = self.get_obj(rid, dk); + return Ok((self.get_obj(rid, vk), self.truthy(&d))); + } + } + } + Ok(match self.iter_step(it)? { + Some(v) => (v, false), + None => (Value::Undef, true), + }) + } + + #[inline(never)] + pub fn iter_step(&mut self, it: &Value) -> Result, Value> { + let Value::Obj(id) = it else { return Ok(None) }; + let id = *id; + match &self.heap[id as usize].kind { + Kind::ArrayIter { target, pos, kind } => { + let (target, pos, kind) = (*target, *pos as usize, *kind); + let item = match &self.heap[target as usize].kind { + Kind::Array(items) | Kind::Arguments(items) => items.get(pos).cloned(), + _ => None, + }; + let Some(v) = item else { return Ok(None) }; + if let Kind::ArrayIter { pos: p, .. } = &mut self.heap[id as usize].kind { + *p += 1; + } + Ok(Some(match kind { + IterKind::Values => v, + IterKind::Keys => Value::Num(pos as f64), + IterKind::Entries => self.new_array(vec![Value::Num(pos as f64), v]), + })) + } + Kind::MapIter { target, pos, kind } => { + let (target, mut pos, kind) = (*target, *pos as usize, *kind); + let (entry, is_set) = match &self.heap[target as usize].kind { + Kind::Map(m) | Kind::Set(m) => { + while pos < m.entries.len() && m.entries[pos].is_none() { + pos += 1; + } + ( + m.entries.get(pos).cloned().flatten(), + matches!(self.heap[target as usize].kind, Kind::Set(_)), + ) + } + _ => (None, false), + }; + if let Kind::MapIter { pos: p, .. } = &mut self.heap[id as usize].kind { + *p = (pos + 1) as u32; + } + let Some((k, v)) = entry else { return Ok(None) }; + let v = if is_set { k } else { v }; + Ok(Some(match kind { + IterKind::Keys => k, + IterKind::Values => v, + IterKind::Entries => self.new_array(vec![k, v]), + })) + } + Kind::StrIter { s, pos } => { + let p = *pos as usize; + let Some(c) = self.atoms.get(*s)[p..].chars().next() else { + return Ok(None); + }; + let v = if (c as u32) < 128 { + self.char_str(c as u16) + } else { + self.string_val(c.to_string()) + }; + if let Kind::StrIter { pos, .. } = &mut self.heap[id as usize].kind { + *pos += c.len_utf8() as u32; + } + Ok(Some(v)) + } + Kind::ListIter { items, pos } => { + let v = items.get(*pos as usize).cloned(); + if v.is_some() + && let Kind::ListIter { pos, .. } = &mut self.heap[id as usize].kind + { + *pos += 1; + } + Ok(v) + } + Kind::Generator(_) => { + let (v, done) = self.resume_generator(id, 0, Value::Undef)?; + Ok(if done { None } else { Some(v) }) + } + _ => { + let next = self.names.next; + let f = self.get_obj(id, next); + let r = self.call(&f, *it, &[])?; + let Value::Obj(rid) = r else { + let d = self.describe(&r); + return Err(self.type_error(&format!("Iterator result {d} is not an object"))); + }; + let done = self.names.done; + let d = self.get_obj(rid, done); + if self.truthy(&d) { + return Ok(None); + } + let value = self.names.value; + Ok(Some(self.get_obj(rid, value))) + } + } + } + + #[inline(never)] + pub fn iter_close(&mut self, it: &Value) -> Result<(), Value> { + let Value::Obj(id) = it else { return Ok(()) }; + let id = *id; + match &self.heap[id as usize].kind { + Kind::Generator(GenState::Suspended(_)) => { + self.resume_generator(id, 1, Value::Undef)?; + Ok(()) + } + Kind::Generator(_) + | Kind::ArrayIter { .. } + | Kind::MapIter { .. } + | Kind::StrIter { .. } + | Kind::ListIter { .. } => Ok(()), + _ => { + let ret = self.names.return_; + let f = self.get_obj(id, ret); + if self.is_callable(&f) { + let r = self.call(&f, *it, &[])?; + if !matches!(r, Value::Obj(_)) { + return Err(self.type_error("Iterator result is not an object")); + } + } + Ok(()) + } + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/promise.rs b/packages/codemode-rust/crates/psychoscript/src/promise.rs new file mode 100644 index 000000000000..03235c41c654 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/promise.rs @@ -0,0 +1,331 @@ +//! Promises and the job queue, following the ECMAScript reaction and thenable-job ordering. + +use crate::object::*; +use crate::value::{Id, Value}; +use crate::vm::{Job, Reaction, Vm}; + +impl<'rt> Vm<'rt> { + pub fn new_promise(&mut self) -> Id { + let proto = self.realm.promise_proto; + self.alloc(Obj::new( + Some(proto), + Kind::Promise(Box::new(PromiseData { + state: PromiseState::Pending, + reactions: Vec::new(), + })), + )) + } + + pub fn as_promise(&self, v: &Value) -> Option { + match v { + Value::Obj(id) if matches!(self.heap[*id as usize].kind, Kind::Promise(_)) => Some(*id), + _ => None, + } + } + + pub fn is_pending(&self, p: Id) -> bool { + matches!(&self.heap[p as usize].kind, Kind::Promise(d) if matches!(d.state, PromiseState::Pending)) + } + + pub fn settle(&mut self, p: Id, outcome: Result) { + let Kind::Promise(d) = &mut self.heap[p as usize].kind else { + return; + }; + if !matches!(d.state, PromiseState::Pending) { + return; + } + d.state = match &outcome { + Ok(v) => PromiseState::Fulfilled(*v), + Err(e) => PromiseState::Rejected(*e), + }; + let reactions = std::mem::take(&mut d.reactions); + for r in reactions { + self.jobs.push_back(Job::Reaction(r, outcome)); + } + } + + pub fn fulfill(&mut self, p: Id, v: Value) { + self.settle(p, Ok(v)); + } + + pub fn reject(&mut self, p: Id, e: Value) { + self.settle(p, Err(e)); + } + + pub fn perform_then(&mut self, p: Id, reaction: Reaction) { + let Kind::Promise(d) = &mut self.heap[p as usize].kind else { + return; + }; + let outcome = match &d.state { + PromiseState::Pending => { + d.reactions.push(reaction); + return; + } + PromiseState::Fulfilled(v) => Ok(*v), + PromiseState::Rejected(e) => Err(*e), + }; + self.jobs.push_back(Job::Reaction(reaction, outcome)); + } + + /// A promise's resolve function: adopts thenables through a job, fulfills with anything else. + pub fn resolve_promise(&mut self, p: Id, v: Value) { + if !self.is_pending(p) { + return; + } + if let Value::Obj(id) = v { + if id == p { + let e = self.type_error("Chaining cycle detected for promise #"); + self.reject(p, e); + return; + } + let then_key = self.names.then; + let then = self.get_obj(id, then_key); + if self.is_callable(&then) { + self.jobs.push_back(Job::Thenable { + promise: p, + thenable: v, + then, + }); + return; + } + } + self.fulfill(p, v); + } + + /// `Promise.resolve`: a promise passes through, anything else is wrapped. + pub fn promise_resolve(&mut self, v: Value) -> Id { + if let Some(p) = self.as_promise(&v) { + return p; + } + let p = self.new_promise(); + self.resolve_promise(p, v); + p + } + + pub fn await_value(&mut self, v: Value, c: u32) { + let p = self.promise_resolve(v); + self.perform_then(p, Reaction::Await(c)); + } + + pub fn create_resolvers(&mut self, p: Id) -> (Value, Value) { + let proto = self.realm.object_proto; + let state = self.alloc(Obj::new( + Some(proto), + Kind::Resolvers { + promise: p, + done: false, + }, + )); + let resolve = self.native_fn("", 1, resolver_resolve, Value::Obj(state)); + let reject = self.native_fn("", 1, resolver_reject, Value::Obj(state)); + (resolve, reject) + } + + /// Marks a resolver pair used; returns its promise if this is the first use. + fn take_resolver(&mut self, callee: Id) -> Option { + let Kind::Native { + data: Value::Obj(state), + .. + } = &self.heap[callee as usize].kind + else { + return None; + }; + let state = *state; + match &mut self.heap[state as usize].kind { + Kind::Resolvers { promise, done } if !*done => { + *done = true; + Some(*promise) + } + _ => None, + } + } + + pub fn run_job(&mut self, job: Job) -> Result<(), Value> { + match job { + Job::Thenable { + promise, + thenable, + then, + } => { + let intrinsic = matches!(then, Value::Obj(t) if t == self.realm.promise_then); + if intrinsic && let Some(q) = self.as_promise(&thenable) { + self.perform_then(q, Reaction::Resolve(promise)); + return Ok(()); + } + let (res, rej) = self.create_resolvers(promise); + if let Err(e) = self.call(&then, thenable, &[res, rej]) { + if self.fatal.is_some() { + return Err(e); + } + if let Value::Obj(r) = res + && let Some(p) = self.take_resolver(r) + { + self.reject(p, e); + } + } + Ok(()) + } + Job::Reaction(reaction, outcome) => self.run_reaction(reaction, outcome), + } + } + + fn run_reaction( + &mut self, + reaction: Reaction, + outcome: Result, + ) -> Result<(), Value> { + match reaction { + Reaction::Then { + on_ful, + on_rej, + derived, + } => { + let (handler, arg, ok) = match outcome { + Ok(v) => (on_ful, v, true), + Err(e) => (on_rej, e, false), + }; + if self.is_callable(&handler) { + match self.call(&handler, Value::Undef, &[arg]) { + Ok(r) => self.resolve_promise(derived, r), + Err(e) => { + if self.fatal.is_some() { + return Err(e); + } + self.reject(derived, e); + } + } + } else if ok { + self.fulfill(derived, arg); + } else { + self.reject(derived, arg); + } + Ok(()) + } + Reaction::Await(c) => self.resume_coroutine(c, outcome), + Reaction::Resolve(target) => { + self.settle(target, outcome); + Ok(()) + } + Reaction::Comb { comb, index } => { + self.combinator_step(comb, index as usize, outcome); + Ok(()) + } + Reaction::Finally { cleanup, derived } => { + match self.call(&cleanup, Value::Undef, &[]) { + Ok(r) => { + let p = self.promise_resolve(r); + self.perform_then(p, Reaction::Restore { derived, outcome }); + } + Err(e) => { + if self.fatal.is_some() { + return Err(e); + } + self.reject(derived, e); + } + } + Ok(()) + } + Reaction::Restore { + derived, + outcome: original, + } => { + match outcome { + Ok(_) => self.settle(derived, original), + Err(e) => self.reject(derived, e), + } + Ok(()) + } + Reaction::Program => { + if self.outcome.is_none() { + self.outcome = Some(outcome); + } + Ok(()) + } + } + } + + fn combinator_step(&mut self, comb: Id, index: usize, outcome: Result) { + let status = self.names.status; + let value_key = self.names.value; + let reason = self.names.reason; + let record = match (&self.heap[comb as usize].kind, &outcome) { + (Kind::Combinator(c), _) if c.kind == CombKind::AllSettled => { + let o = self.new_object(); + match &outcome { + Ok(v) => { + let t = self.static_str("fulfilled"); + self.define(o, status, t); + self.define(o, value_key, *v); + } + Err(e) => { + let t = self.static_str("rejected"); + self.define(o, status, t); + self.define(o, reason, *e); + } + } + Some(Value::Obj(o)) + } + _ => None, + }; + let Kind::Combinator(c) = &mut self.heap[comb as usize].kind else { + return; + }; + let promise = c.promise; + let finished = match (c.kind, outcome) { + (CombKind::All, Ok(v)) => { + c.values[index] = v; + c.remaining -= 1; + c.remaining == 0 + } + (CombKind::All, Err(e)) => { + self.reject(promise, e); + return; + } + (CombKind::AllSettled, _) => { + c.values[index] = record.unwrap_or_default(); + c.remaining -= 1; + c.remaining == 0 + } + (CombKind::Any, Ok(v)) => { + self.resolve_promise(promise, v); + return; + } + (CombKind::Any, Err(e)) => { + c.values[index] = e; + c.remaining -= 1; + c.remaining == 0 + } + }; + if !finished { + return; + } + let kind = c.kind; + let values = std::mem::take(&mut c.values); + let arr = self.new_array(values); + if kind == CombKind::Any { + let proto = self.realm.aggregate_error_proto; + let e = self.make_error(proto, "All promises were rejected"); + if let Value::Obj(eid) = e { + let errors = self.names.errors; + self.define_hidden(eid, errors, arr); + } + self.reject(promise, e); + } else { + self.resolve_promise(promise, arr); + } + } +} + +fn resolver_resolve(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Result { + if let Some(p) = vm.take_resolver(callee) { + vm.resolve_promise(p, args.first().cloned().unwrap_or_default()); + } + Ok(Value::Undef) +} + +fn resolver_reject(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Result { + if let Some(p) = vm.take_resolver(callee) { + vm.reject(p, args.first().cloned().unwrap_or_default()); + } + Ok(Value::Undef) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/run.rs b/packages/codemode-rust/crates/psychoscript/src/run.rs new file mode 100644 index 000000000000..a62f44eaa90b --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/run.rs @@ -0,0 +1,247 @@ +//! One `execute`: compile, set up a fresh heap and built-ins, run to an outcome, and copy it out. + +use std::panic::AssertUnwindSafe; +use std::rc::Rc; + +use crate::compiler; +use crate::convert; +use crate::object::{Closure, Kind, Obj}; +use crate::strings::Strings; +use crate::value::Value; +use crate::vm::Vm; +use crate::{Diagnostic, DiagnosticKind, Json, Outcome, Runtime}; + +/// Small programs run on the caller's thread with a modest native-stack budget. Larger ones, whose parse can +/// recurse deeper, run on their own thread with a large stack; the reservation is virtual, only touched pages are +/// committed. +const INLINE_SOURCE_BYTES: usize = 2048; +const INLINE_BRACKET_DEPTH: usize = 64; +const INLINE_STACK_BUDGET: usize = 512 << 10; +const STACK_SIZE: usize = 256 << 20; +const THREAD_STACK_BUDGET: usize = 64 << 20; + +pub fn execute(rt: &Runtime, code: &str, bindings: &serde_json::Map) -> Outcome { + if code.len() <= INLINE_SOURCE_BYTES && bracket_depth(code) <= INLINE_BRACKET_DEPTH { + let run = AssertUnwindSafe(|| execute_here(rt, code, bindings, INLINE_STACK_BUDGET)); + return std::panic::catch_unwind(run).unwrap_or_else(|_| internal_error()); + } + std::thread::scope(|s| { + let spawned = std::thread::Builder::new() + .stack_size(STACK_SIZE) + .spawn_scoped(s, || execute_here(rt, code, bindings, THREAD_STACK_BUDGET)); + match spawned { + Ok(handle) => handle.join().unwrap_or_else(|_| internal_error()), + Err(_) => execute_here(rt, code, bindings, INLINE_STACK_BUDGET), + } + }) +} + +/// The deepest bracket nesting in the source text, a cheap bound on how deep parsing recurses. +fn bracket_depth(code: &str) -> usize { + let (mut depth, mut max) = (0usize, 0usize); + for b in code.bytes() { + match b { + b'(' | b'[' | b'{' => { + depth += 1; + max = max.max(depth); + } + b')' | b']' | b'}' => depth = depth.saturating_sub(1), + _ => {} + } + } + max +} + +/// A defect in the interpreter, reported instead of unwinding into the host. +fn internal_error() -> Outcome { + Outcome { + result: Err(Diagnostic { + kind: DiagnosticKind::ExecutionFailure, + message: "Internal interpreter error.".into(), + location: None, + }), + logs: Vec::new(), + tool_calls: Vec::new(), + } +} + +fn execute_here( + rt: &Runtime, + code: &str, + bindings: &serde_json::Map, + budget: usize, +) -> Outcome { + let probe = 0u8; + let mut atoms = Strings::new(); + let program = match compiler::compile(code, &mut atoms) { + Ok(p) => p, + Err(e) => { + let location = e.offset.map(|o| line_col(code, o)); + let message = format!("{}{}", e.message, suffix(location)); + return Outcome { + result: Err(Diagnostic { + kind: e.kind, + message, + location, + }), + logs: Vec::new(), + tool_calls: Vec::new(), + }; + } + }; + let mut vm = Vm::new(&rt.tools, rt.limits, atoms); + vm.stack_base = &probe as *const u8 as usize; + vm.stack_budget = budget; + vm.setup(); + for (k, v) in bindings { + let val = convert::from_json(&mut vm, v); + let a = vm.atoms.intern(k); + vm.global_map.insert(a, val); + } + vm.load(program); + let proto = vm.protos[0].clone(); + let fp = vm.realm.function_proto; + let main = Value::Obj(vm.alloc(Obj::new( + Some(fp), + Kind::Closure(Box::new(Closure { + proto, + upvals: Rc::from(Vec::new()), + this: Value::Undef, + })), + ))); + match vm.call(&main, Value::Undef, &[]) { + Ok(_) => { + let _ = vm.drive(); + } + Err(e) => { + if vm.outcome.is_none() { + vm.outcome = Some(Err(e)); + } + } + } + let result = match (vm.fatal.clone(), vm.outcome.take()) { + (Some((kind, message)), _) => Err(Diagnostic { + kind, + message, + location: None, + }), + (None, Some(Ok(v))) => match convert::to_json(&mut vm, &v) { + Ok(j) => Ok(j), + Err(e) => Err(diagnose(&mut vm, &e, code)), + }, + (None, Some(Err(e))) => Err(diagnose(&mut vm, &e, code)), + (None, None) => Err(Diagnostic { + kind: DiagnosticKind::ExecutionFailure, + message: "The program did not finish.".into(), + location: None, + }), + }; + let result = match (vm.fatal.clone(), result) { + (Some((kind, message)), Ok(_)) => Err(Diagnostic { + kind, + message, + location: None, + }), + (_, r) => r, + }; + let logs = std::mem::take(&mut vm.logs); + let tool_calls = std::mem::take(&mut vm.tool_calls); + bound_output( + Outcome { + result, + logs, + tool_calls, + }, + rt.limits.max_output_bytes, + ) +} + +fn diagnose(vm: &mut Vm, e: &Value, code: &str) -> Diagnostic { + if let Value::Obj(id) = e + && let Kind::Error(failure) = &vm.heap[*id as usize].kind + { + let id = *id; + if let Some(f) = failure.clone() { + let location = f.offset.map(|o| line_col(code, o)); + let message = match f.kind { + DiagnosticKind::ExecutionFailure | DiagnosticKind::InvalidDataValue => { + let (name, _) = convert::error_parts(vm, id); + format!("{name}: {}{}", f.message, suffix(location)) + } + _ => f.message.clone(), + }; + return Diagnostic { + kind: f.kind, + message, + location, + }; + } + let message = convert::error_to_string(vm, id); + return Diagnostic { + kind: DiagnosticKind::ExecutionFailure, + message, + location: None, + }; + } + let text = convert::format_value(vm, e); + Diagnostic { + kind: DiagnosticKind::ExecutionFailure, + message: format!("Uncaught: {text}"), + location: None, + } +} + +fn suffix(location: Option<(u32, u32)>) -> String { + match location { + Some((line, col)) => format!(" (line {line}, col {col})"), + None => String::new(), + } +} + +/// 1-based line and column (in UTF-16 units) of a byte offset. +fn line_col(code: &str, offset: u32) -> (u32, u32) { + let offset = (offset as usize).min(code.len()); + let before = code.get(..offset).unwrap_or(code); + let line = before.matches('\n').count() as u32 + 1; + let line_start = before.rfind('\n').map(|i| i + 1).unwrap_or(0); + let col = before[line_start..].encode_utf16().count() as u32 + 1; + (line, col) +} + +/// Keeps the result and logs within `max_output_bytes`, the way the reference does. +fn bound_output(mut outcome: Outcome, max: Option) -> Outcome { + let Some(max) = max else { return outcome }; + let mut value_bytes = 0; + if let Ok(v) = &outcome.result { + let text = v.to_string(); + value_bytes = text.len(); + if value_bytes > max { + let mut cut = max; + while !text.is_char_boundary(cut) { + cut -= 1; + } + outcome.result = Ok(Json::String(format!( + "{} [result truncated: {value_bytes} bytes exceeds the {max}-byte output limit; return a smaller value]", + &text[..cut] + ))); + } + } + let budget = max.saturating_sub(value_bytes.min(max)); + let mut used = 0; + let mut kept = 0; + for line in &outcome.logs { + used += line.len() + 1; + if used > budget { + break; + } + kept += 1; + } + if kept < outcome.logs.len() { + let total = outcome.logs.len(); + outcome.logs.truncate(kept); + outcome + .logs + .push(format!("[logs truncated: showing {kept} of {total} lines]")); + } + outcome +} diff --git a/packages/codemode-rust/crates/psychoscript/src/strings.rs b/packages/codemode-rust/crates/psychoscript/src/strings.rs new file mode 100644 index 000000000000..6bb957ffaa73 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/strings.rs @@ -0,0 +1,189 @@ +//! The per-run string arena and the property-key interner. +//! +//! Strings live for the whole run, like objects, so `Value` can be `Copy`. They are immutable, except that a string +//! built by `local += x` is held only by that local until the local is read, and grows in place meanwhile. + +use std::borrow::Cow; + +use rustc_hash::FxHashMap; + +use crate::value::index_of_key; + +pub type StrId = u32; +/// An interned property key. +pub type Atom = u32; + +/// The atom of `Symbol.iterator`, unreachable from strings. +pub const SYM_ITERATOR: Atom = 0; + +pub struct StrBuf { + /// Built-in names borrow their static text, so setting up a run allocates little. + pub s: Cow<'static, str>, + pub ascii: bool, + /// Only one local slot holds this string, so `+=` may append in place. + pub builder: bool, +} + +pub struct Strings { + pub bufs: Vec, + map: FxHashMap, Atom>, + atom_str: Vec, + atom_index: Vec, +} + +/// A borrowed string with its ASCII flag, for code-unit arithmetic. +#[derive(Clone, Copy)] +pub struct StrRef<'a> { + pub s: &'a str, + pub ascii: bool, +} + +impl Strings { + pub fn new() -> Self { + let mut s = Strings { + bufs: Vec::new(), + map: FxHashMap::default(), + atom_str: Vec::new(), + atom_index: Vec::new(), + }; + let id = s.alloc("Symbol(Symbol.iterator)".to_owned()); + s.atom_str.push(id); + s.atom_index.push(u32::MAX); + s + } + + #[inline] + pub fn alloc(&mut self, s: String) -> StrId { + let ascii = s.is_ascii(); + self.bufs.push(StrBuf { + s: Cow::Owned(s), + ascii, + builder: false, + }); + (self.bufs.len() - 1) as StrId + } + + pub fn alloc_static(&mut self, s: &'static str) -> StrId { + self.bufs.push(StrBuf { + s: Cow::Borrowed(s), + ascii: s.is_ascii(), + builder: false, + }); + (self.bufs.len() - 1) as StrId + } + + #[inline] + pub fn get(&self, id: StrId) -> &str { + &self.bufs[id as usize].s + } + + #[inline] + pub fn sref(&self, id: StrId) -> StrRef<'_> { + let b = &self.bufs[id as usize]; + StrRef { + s: &b.s, + ascii: b.ascii, + } + } + + pub fn intern(&mut self, s: &str) -> Atom { + if let Some(a) = self.map.get(s) { + return *a; + } + let id = self.alloc(s.to_owned()); + self.insert_atom(Cow::Owned(s.to_owned()), id) + } + + pub fn intern_static(&mut self, s: &'static str) -> Atom { + if let Some(a) = self.map.get(s) { + return *a; + } + let id = self.alloc_static(s); + self.insert_atom(Cow::Borrowed(s), id) + } + + pub fn intern_id(&mut self, id: StrId) -> Atom { + if let Some(a) = self.map.get(&*self.bufs[id as usize].s) { + return *a; + } + let text = self.bufs[id as usize].s.clone(); + self.insert_atom(text, id) + } + + fn insert_atom(&mut self, s: Cow<'static, str>, id: StrId) -> Atom { + let a = self.atom_str.len() as Atom; + self.atom_str.push(id); + self.atom_index.push(index_of_key(&s).unwrap_or(u32::MAX)); + self.map.insert(s, a); + a + } + + /// The string value of an atom. + #[inline] + pub fn atom_str(&self, a: Atom) -> StrId { + self.atom_str[a as usize] + } + + #[inline] + pub fn text(&self, a: Atom) -> &str { + self.get(self.atom_str[a as usize]) + } + + /// The array index an atom names, if it is canonical. + #[inline] + pub fn index(&self, a: Atom) -> Option { + let i = self.atom_index[a as usize]; + if i == u32::MAX { None } else { Some(i) } + } +} + +impl<'a> StrRef<'a> { + /// Length in UTF-16 code units, as JavaScript counts it. + pub fn len16(self) -> usize { + if self.ascii { + self.s.len() + } else { + self.s.encode_utf16().count() + } + } + + pub fn utf16(self) -> Vec { + self.s.encode_utf16().collect() + } + + pub fn code_unit(self, i: usize) -> Option { + if self.ascii { + self.s.as_bytes().get(i).map(|b| *b as u16) + } else { + self.s.encode_utf16().nth(i) + } + } + + /// The code units `start..end` (clamped). + pub fn slice16(self, start: usize, end: usize) -> String { + if self.ascii { + let len = self.s.len(); + let (s, e) = (start.min(len), end.min(len)); + return if s >= e { + String::new() + } else { + self.s[s..e].to_owned() + }; + } + let units = self.utf16(); + let (s, e) = (start.min(units.len()), end.min(units.len())); + if s >= e { + String::new() + } else { + String::from_utf16_lossy(&units[s..e]) + } + } + + /// Compares by UTF-16 code units, as JavaScript orders strings. + pub fn cmp16(self, other: StrRef) -> std::cmp::Ordering { + if self.ascii && other.ascii { + return self.s.cmp(other.s); + } + self.s.encode_utf16().cmp(other.s.encode_utf16()) + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/value.rs b/packages/codemode-rust/crates/psychoscript/src/value.rs new file mode 100644 index 000000000000..06db1ba73acf --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/value.rs @@ -0,0 +1,501 @@ +//! Program values, strings and number formatting. + +use std::fmt::Write as _; + +use crate::strings::StrId; + +/// Index of an object in the run's heap. +pub type Id = u32; + +/// A program value. `Uninit` marks a binding in its temporal dead zone and never escapes to programs. +#[derive(Clone, Copy, Debug, Default)] +#[repr(C, u64)] +pub enum Value { + #[default] + Undef, + Null, + Bool(bool), + Num(f64), + Str(StrId), + Obj(Id), + /// A well-known symbol; only `Symbol.iterator` exists. + Sym(u32), + Uninit, +} + +impl Value { + #[inline] + pub fn is_nullish(&self) -> bool { + matches!(self, Value::Undef | Value::Null) + } + + pub fn as_obj(&self) -> Option { + match self { + Value::Obj(id) => Some(*id), + _ => None, + } + } +} + +/// `Number.prototype.toString()` with radix 10. +pub fn num_to_string(x: f64) -> String { + let mut out = String::new(); + write_num(&mut out, x); + out +} + +pub fn write_num(out: &mut String, x: f64) { + if x.is_nan() { + out.push_str("NaN"); + return; + } + if x == 0.0 { + out.push('0'); + return; + } + if x.is_infinite() { + out.push_str(if x > 0.0 { "Infinity" } else { "-Infinity" }); + return; + } + if x.fract() == 0.0 && x.abs() < 1e21 { + if x.abs() < 9.0e18 { + let _ = write!(out, "{}", x as i64); + return; + } + let _ = write!(out, "{x}"); + return; + } + if x < 0.0 { + out.push('-'); + } + let e = format!("{:e}", x.abs()); + let (mantissa, exp) = e.split_once('e').unwrap_or((&e, "0")); + let exp: i32 = exp.parse().unwrap_or(0); + let digits: String = mantissa.chars().filter(|c| *c != '.').collect(); + let k = digits.len() as i32; + let n = exp + 1; + if k <= n && n <= 21 { + out.push_str(&digits); + for _ in 0..(n - k) { + out.push('0'); + } + } else if 0 < n && n <= 21 { + out.push_str(&digits[..n as usize]); + out.push('.'); + out.push_str(&digits[n as usize..]); + } else if -6 < n && n <= 0 { + out.push_str("0."); + for _ in 0..(-n) { + out.push('0'); + } + out.push_str(&digits); + } else { + let e = n - 1; + out.push_str(&digits[..1]); + if k > 1 { + out.push('.'); + out.push_str(&digits[1..]); + } + out.push('e'); + out.push(if e < 0 { '-' } else { '+' }); + let _ = write!(out, "{}", e.abs()); + } +} + +/// `Number.prototype.toString(radix)` for radix other than 10. +pub fn num_to_radix(x: f64, radix: u32) -> String { + if x.is_nan() { + return "NaN".into(); + } + if x.is_infinite() { + return if x > 0.0 { + "Infinity".into() + } else { + "-Infinity".into() + }; + } + let neg = x < 0.0; + let x = x.abs(); + let mut int = x.trunc(); + let mut frac = x - int; + let mut digits = Vec::new(); + if int == 0.0 { + digits.push(b'0'); + } + while int >= 1.0 { + let d = (int % radix as f64) as u32; + digits.push(std::char::from_digit(d, radix).unwrap_or('0') as u8); + int = (int / radix as f64).trunc(); + } + digits.reverse(); + let mut s = String::from_utf8(digits).unwrap_or_default(); + if frac > 0.0 { + s.push('.'); + let mut n = 0; + while frac > 0.0 && n < 52 { + frac *= radix as f64; + let d = frac.trunc() as u32; + s.push(std::char::from_digit(d, radix).unwrap_or('0')); + frac -= d as f64; + n += 1; + } + } + if neg { format!("-{s}") } else { s } +} + +/// `Number.prototype.toFixed`, rounding the exact binary value half away from zero like JavaScript. +pub fn num_to_fixed(x: f64, digits: usize) -> String { + if !x.is_finite() { + return num_to_string(x); + } + let exact = format!("{:.1100}", x.abs()); + let (int, frac) = exact.split_once('.').unwrap_or((&exact, "")); + let mut buf: Vec = int.bytes().chain(frac.bytes().take(digits)).collect(); + let round_up = frac.as_bytes().get(digits).is_some_and(|d| *d >= b'5'); + if round_up { + let mut i = buf.len(); + loop { + if i == 0 { + buf.insert(0, b'1'); + break; + } + i -= 1; + if buf[i] == b'9' { + buf[i] = b'0'; + } else { + buf[i] += 1; + break; + } + } + } + let split = buf.len() - digits; + let mut out = String::new(); + let negative = x < 0.0 && buf.iter().any(|b| *b != b'0'); + if negative { + out.push('-'); + } + out.push_str(std::str::from_utf8(&buf[..split]).unwrap_or("0")); + if digits > 0 { + out.push('.'); + out.push_str(std::str::from_utf8(&buf[split..]).unwrap_or("")); + } + out +} + +pub fn is_js_whitespace(c: char) -> bool { + matches!( + c, + '\u{9}' | '\u{a}' | '\u{b}' | '\u{c}' | '\u{d}' | ' ' | '\u{a0}' | '\u{1680}' | '\u{2000}' + ..='\u{200a}' + | '\u{2028}' + | '\u{2029}' + | '\u{202f}' + | '\u{205f}' + | '\u{3000}' + | '\u{feff}' + ) +} + +/// ToNumber applied to a string. +pub fn str_to_num(s: &str) -> f64 { + let t = s.trim_matches(is_js_whitespace); + if t.is_empty() { + return 0.0; + } + let (sign, body) = match t.as_bytes()[0] { + b'+' => (1.0, &t[1..]), + b'-' => (-1.0, &t[1..]), + _ => (1.0, t), + }; + if body == "Infinity" { + return sign * f64::INFINITY; + } + if t.len() > 2 && body.len() == t.len() { + let radix = match &t[..2] { + "0x" | "0X" => 16, + "0o" | "0O" => 8, + "0b" | "0B" => 2, + _ => 0, + }; + if radix != 0 { + let mut v = 0.0f64; + for c in t[2..].chars() { + match c.to_digit(radix) { + Some(d) => v = v * radix as f64 + d as f64, + None => return f64::NAN, + } + } + return v; + } + } + if !is_decimal_literal(body) { + return f64::NAN; + } + body.parse::().map(|v| sign * v).unwrap_or(f64::NAN) +} + +fn is_decimal_literal(s: &str) -> bool { + let b = s.as_bytes(); + let mut i = 0; + let int_start = i; + while i < b.len() && b[i].is_ascii_digit() { + i += 1; + } + let mut digits = i > int_start; + if i < b.len() && b[i] == b'.' { + i += 1; + let f = i; + while i < b.len() && b[i].is_ascii_digit() { + i += 1; + } + digits |= i > f; + } + if !digits { + return false; + } + if i < b.len() && (b[i] == b'e' || b[i] == b'E') { + i += 1; + if i < b.len() && (b[i] == b'+' || b[i] == b'-') { + i += 1; + } + let e = i; + while i < b.len() && b[i].is_ascii_digit() { + i += 1; + } + if i == e { + return false; + } + } + i == b.len() +} + +/// The longest decimal prefix `parseFloat` accepts. +pub fn parse_float_prefix(s: &str) -> f64 { + let t = s.trim_start_matches(is_js_whitespace); + let b = t.as_bytes(); + let mut i = 0; + if i < b.len() && (b[i] == b'+' || b[i] == b'-') { + i += 1; + } + if t[i..].starts_with("Infinity") { + return if b.first() == Some(&b'-') { + f64::NEG_INFINITY + } else { + f64::INFINITY + }; + } + let start = i; + while i < b.len() && b[i].is_ascii_digit() { + i += 1; + } + if i < b.len() && b[i] == b'.' { + i += 1; + while i < b.len() && b[i].is_ascii_digit() { + i += 1; + } + } + if i == start || &t[start..i] == "." { + return f64::NAN; + } + let mantissa_end = i; + if i < b.len() && (b[i] == b'e' || b[i] == b'E') { + let mut j = i + 1; + if j < b.len() && (b[j] == b'+' || b[j] == b'-') { + j += 1; + } + let d = j; + while j < b.len() && b[j].is_ascii_digit() { + j += 1; + } + if j > d { + i = j; + } + } + let end = if i > mantissa_end { i } else { mantissa_end }; + t[..end].parse::().unwrap_or(f64::NAN) +} + +pub fn to_int32(x: f64) -> i32 { + if x.is_finite() && x.abs() < 2147483648.0 { + return x as i32; + } + if !x.is_finite() { + return 0; + } + let m = x.trunc().rem_euclid(4294967296.0); + m as u32 as i32 +} + +pub fn to_uint32(x: f64) -> u32 { + to_int32(x) as u32 +} + +/// ToIntegerOrInfinity. +pub fn to_integer(x: f64) -> f64 { + if x.is_nan() { 0.0 } else { x.trunc() + 0.0 } +} + +/// If `s` is a canonical array index ("0", "17", not "01"), returns it. +pub fn index_of_key(s: &str) -> Option { + let b = s.as_bytes(); + if b.is_empty() || b.len() > 10 || (b.len() > 1 && b[0] == b'0') { + return None; + } + let mut v: u64 = 0; + for c in b { + if !c.is_ascii_digit() { + return None; + } + v = v * 10 + (c - b'0') as u64; + } + if v < u32::MAX as u64 { + Some(v as u32) + } else { + None + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn number_formatting() { + assert_eq!(num_to_string(0.1 + 0.2), "0.30000000000000004"); + assert_eq!(num_to_string(1e21), "1e+21"); + assert_eq!(num_to_string(1.5e-7), "1.5e-7"); + assert_eq!(num_to_string(123456789012.0), "123456789012"); + assert_eq!(num_to_string(-1e-7), "-1e-7"); + assert_eq!(num_to_string(0.000001), "0.000001"); + assert_eq!(num_to_fixed(1.23456, 2), "1.23"); + assert_eq!(num_to_fixed(2.5, 0), "3"); + assert_eq!(num_to_fixed(1.005, 2), "1.00"); + assert_eq!(num_to_radix(255.0, 16), "ff"); + } + + #[test] + fn string_to_number() { + assert_eq!(str_to_num(" 3.5 "), 3.5); + assert!(str_to_num("x").is_nan()); + assert!(str_to_num("inf").is_nan()); + assert_eq!(str_to_num(""), 0.0); + assert_eq!(str_to_num("0x1f"), 31.0); + assert_eq!(parse_float_prefix("2.5e1x"), 25.0); + } +} + +const QNAN: u64 = 0x7ff8_0000_0000_0000; +const TAGGED: u64 = 0xfff9_0000_0000_0000; +const T_UNDEF: u64 = 0xfff9; +const T_NULL: u64 = 0xfffa; +const T_BOOL: u64 = 0xfffb; +const T_STR: u64 = 0xfffc; +const T_OBJ: u64 = 0xfffd; +const T_SYM: u64 = 0xfffe; +const T_UNINIT: u64 = 0xffff; + +/// A value packed into one word (NaN-boxing), for the VM stack and closure cells. Numbers are their own bits, with +/// every NaN canonicalized; other values live in the negative quiet-NaN space with a 32-bit payload. +#[derive(Clone, Copy, PartialEq, Eq)] +pub struct Slot(pub u64); + +impl Default for Slot { + fn default() -> Self { + Slot::UNDEF + } +} + +impl Slot { + pub const UNDEF: Slot = Slot(T_UNDEF << 48); + pub const UNINIT: Slot = Slot(T_UNINIT << 48); + + #[inline(always)] + pub fn num(f: f64) -> Slot { + if f.is_nan() { + Slot(QNAN) + } else { + Slot(f.to_bits()) + } + } + + #[inline(always)] + pub fn is_num(self) -> bool { + self.0 < TAGGED + } + + #[inline(always)] + pub fn f(self) -> f64 { + f64::from_bits(self.0) + } + + #[inline(always)] + pub fn is_str(self) -> bool { + self.0 >> 48 == T_STR + } + + #[inline(always)] + pub fn payload(self) -> u32 { + self.0 as u32 + } + + #[inline(always)] + pub fn pack(v: Value) -> Slot { + match v { + Value::Num(f) => Slot::num(f), + Value::Undef => Slot::UNDEF, + Value::Null => Slot(T_NULL << 48), + Value::Bool(b) => Slot(T_BOOL << 48 | b as u64), + Value::Str(s) => Slot(T_STR << 48 | s as u64), + Value::Obj(o) => Slot(T_OBJ << 48 | o as u64), + Value::Sym(s) => Slot(T_SYM << 48 | s as u64), + Value::Uninit => Slot::UNINIT, + } + } + + #[inline(always)] + pub fn get(self) -> Value { + if self.0 < TAGGED { + return Value::Num(f64::from_bits(self.0)); + } + let p = self.0 as u32; + match self.0 >> 48 { + T_UNDEF => Value::Undef, + T_NULL => Value::Null, + T_BOOL => Value::Bool(p != 0), + T_STR => Value::Str(p), + T_OBJ => Value::Obj(p), + T_SYM => Value::Sym(p), + _ => Value::Uninit, + } + } +} + +#[cfg(test)] +mod slot_tests { + use super::*; + + #[test] + fn packing_round_trips() { + for v in [ + Value::Num(-0.0), + Value::Num(f64::NEG_INFINITY), + Value::Num(1.5), + Value::Str(7), + Value::Obj(u32::MAX), + ] { + assert_eq!(format!("{:?}", Slot::pack(v).get()), format!("{v:?}")); + } + assert!(Slot::pack(Value::Num(f64::from_bits(0xffff_0000_0000_0001))).get_num_is_nan()); + assert!(matches!( + Slot::pack(Value::Bool(true)).get(), + Value::Bool(true) + )); + assert!(matches!(Slot::UNINIT.get(), Value::Uninit)); + } + + impl Slot { + fn get_num_is_nan(self) -> bool { + matches!(self.get(), Value::Num(n) if n.is_nan()) + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/vm.rs b/packages/codemode-rust/crates/psychoscript/src/vm.rs new file mode 100644 index 000000000000..486578d12a9a --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/vm.rs @@ -0,0 +1,1927 @@ +//! The stack machine: frames, calls, exceptions, suspension and the run loop. + +use std::collections::{BTreeMap, VecDeque}; +use std::rc::Rc; +use std::time::Instant; + +use rustc_hash::FxHashMap; + +use crate::bytecode::{Arith, Capture, FuncProto, Op, Program}; +use crate::object::*; +use crate::strings::{StrId, Strings}; +use crate::value::{Id, Slot, Value}; +use crate::{DiagnosticKind, Json, Limits, ToolCall, ToolFn}; + +pub type Res = Result; +/// A tool call's result as it waits to settle its promise. +pub type ToolOutcome = Result; +pub type NativeFn = fn(&mut Vm, Value, &[Value], Id) -> Res; + +pub const MAX_DEPTH: usize = 10_000; +const MAX_OBJECTS: usize = 2_000_000; +const MAX_STRINGS: usize = 4_000_000; +const MAX_NATIVE_DEPTH: usize = 400; +const FUEL: u32 = 20_000; + +#[derive(Clone, Copy)] +pub struct Handler { + pc: u32, + sp: u32, + finally: bool, +} + +#[derive(Clone, Copy, PartialEq)] +pub enum FrameKind { + Normal, + Async(u32), + Generator(Id), +} + +pub struct Frame { + pub func: Rc, + pub pc: usize, + pub base: usize, + pub cells: Vec, + pub upvals: Rc<[u32]>, + pub handlers: Vec, + pub extra: Vec, + pub argc: u32, + pub kind: FrameKind, + pub is_base: bool, +} + +/// A suspended frame and its stack segment. The box is kept while the frame runs, so suspending again allocates +/// nothing. +pub struct SavedFrame { + pub frame: Option, + pub stack: Vec, + pub started: bool, +} + +pub enum Exit { + Return(Value), + Yield(Value), +} + +pub struct Coroutine { + pub saved: Option>, + pub promise: Option, +} + +pub enum Reaction { + Then { + on_ful: Value, + on_rej: Value, + derived: Id, + }, + Await(u32), + /// Settle the target the same way, if it is still pending. + Resolve(Id), + Comb { + comb: Id, + index: u32, + }, + Finally { + cleanup: Value, + derived: Id, + }, + Restore { + derived: Id, + outcome: Result, + }, + Program, +} + +pub enum Job { + Reaction(Reaction, Result), + Thenable { + promise: Id, + thenable: Value, + then: Value, + }, +} + +pub struct Names { + pub length: Atom, + pub name: Atom, + pub prototype: Atom, + pub constructor: Atom, + pub message: Atom, + pub next: Atom, + pub done: Atom, + pub value: Atom, + pub then: Atom, + pub to_string: Atom, + pub value_of: Atom, + pub to_json: Atom, + pub size: Atom, + pub return_: Atom, + pub cause: Atom, + pub status: Atom, + pub reason: Atom, + pub errors: Atom, +} + +#[derive(Default)] +pub struct Realm { + pub object_proto: Id, + pub function_proto: Id, + pub array_proto: Id, + pub string_proto: Id, + pub number_proto: Id, + pub boolean_proto: Id, + pub symbol_proto: Id, + pub error_proto: Id, + pub type_error_proto: Id, + pub range_error_proto: Id, + pub syntax_error_proto: Id, + pub reference_error_proto: Id, + pub aggregate_error_proto: Id, + pub promise_proto: Id, + pub promise_then: Id, + pub map_proto: Id, + pub set_proto: Id, + pub generator_proto: Id, + pub iter_proto: Id, + pub tools: Id, +} + +pub struct Vm<'rt> { + pub heap: Vec, + pub cells: Vec, + pub atoms: Strings, + pub stack: Vec, + pub frames: Vec, + spare_frames: Vec, + pub realm: Realm, + pub names: Names, + pub globals: Vec, + pub global_names: Vec, + pub global_map: FxHashMap, + pub consts: Vec, + pub protos: Vec>, + pub jobs: VecDeque, + pub inbox: VecDeque<(Id, ToolOutcome)>, + pub coroutines: Vec, + pub logs: Vec, + pub tool_calls: Vec, + pub tools: &'rt BTreeMap, + pub tool_refs: FxHashMap, Id>, + pub limits: Limits, + pub start: Instant, + fuel: u32, + pub fatal: Option<(DiagnosticKind, String)>, + pub outcome: Option>, + native_depth: usize, + /// Address near the bottom of the native stack this run started on, and how much of it calls may use. + pub stack_base: usize, + pub stack_budget: usize, + arg_pool: Vec>, + pub char_strs: Vec, + pub rng: u64, +} + +impl<'rt> Vm<'rt> { + pub fn new(tools: &'rt BTreeMap, limits: Limits, atoms: Strings) -> Self { + let mut atoms = atoms; + let names = Names { + length: atoms.intern_static("length"), + name: atoms.intern_static("name"), + prototype: atoms.intern_static("prototype"), + constructor: atoms.intern_static("constructor"), + message: atoms.intern_static("message"), + next: atoms.intern_static("next"), + done: atoms.intern_static("done"), + value: atoms.intern_static("value"), + then: atoms.intern_static("then"), + to_string: atoms.intern_static("toString"), + value_of: atoms.intern_static("valueOf"), + to_json: atoms.intern_static("toJSON"), + size: atoms.intern_static("size"), + return_: atoms.intern_static("return"), + cause: atoms.intern_static("cause"), + status: atoms.intern_static("status"), + reason: atoms.intern_static("reason"), + errors: atoms.intern_static("errors"), + }; + let char_strs = (0u8..128) + .map(|c| atoms.alloc((c as char).to_string())) + .collect(); + let seed = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_nanos() as u64) + .unwrap_or(0x9e3779b97f4a7c15); + Vm { + heap: Vec::with_capacity(1024), + cells: Vec::new(), + atoms, + stack: Vec::with_capacity(1024), + frames: Vec::with_capacity(64), + spare_frames: Vec::new(), + realm: Realm::default(), + names, + globals: Vec::new(), + global_names: Vec::new(), + global_map: FxHashMap::default(), + consts: Vec::new(), + protos: Vec::new(), + jobs: VecDeque::new(), + inbox: VecDeque::new(), + coroutines: Vec::new(), + logs: Vec::new(), + tool_calls: Vec::new(), + tools, + tool_refs: FxHashMap::default(), + limits, + start: Instant::now(), + fuel: FUEL, + fatal: None, + outcome: None, + native_depth: 0, + stack_base: 0, + stack_budget: usize::MAX, + arg_pool: Vec::new(), + char_strs, + rng: seed | 1, + } + } + + pub fn load(&mut self, program: Program) { + self.consts = program.consts; + self.protos = program.protos; + self.globals = program + .globals + .iter() + .map(|a| self.global_map.get(a).cloned().unwrap_or(Value::Uninit)) + .collect(); + self.global_names = program.globals; + } + + // ---------- allocation ---------- + + #[inline] + pub fn alloc(&mut self, obj: Obj) -> Id { + if self.heap.len() >= MAX_OBJECTS { + self.out_of_memory(); + } + self.heap.push(obj); + (self.heap.len() - 1) as Id + } + + /// Runs keep everything they allocate until they end, so a runaway allocation loop is stopped here; the run + /// ends at its next fuel check. + #[cold] + pub fn out_of_memory(&mut self) { + if self.fatal.is_none() { + self.fatal = Some(( + DiagnosticKind::ExecutionFailure, + "Execution exceeded its memory limit.".into(), + )); + self.fuel = 1; + } + } + + pub fn new_object(&mut self) -> Id { + let proto = self.realm.object_proto; + self.alloc(Obj::new(Some(proto), Kind::Ordinary)) + } + + pub fn new_array(&mut self, items: Vec) -> Value { + let proto = self.realm.array_proto; + Value::Obj(self.alloc(Obj::new(Some(proto), Kind::Array(items)))) + } + + pub fn char_str(&mut self, c: u16) -> Value { + match self.char_strs.get(c as usize) { + Some(s) => Value::Str(*s), + None => self.string_val(String::from_utf16_lossy(&[c])), + } + } + + #[inline] + pub fn str_val(&mut self, s: &str) -> Value { + self.string_val(s.to_owned()) + } + + #[inline] + pub fn string_val(&mut self, s: String) -> Value { + if self.atoms.bufs.len() >= MAX_STRINGS { + self.out_of_memory(); + } + Value::Str(self.atoms.alloc(s)) + } + + /// The interned string for a fixed text, without allocating a new one each time. + pub fn static_str(&mut self, s: &str) -> Value { + let a = self.atoms.intern(s); + Value::Str(self.atoms.atom_str(a)) + } + + pub fn strict_eq(&self, a: &Value, b: &Value) -> bool { + match (a, b) { + (Value::Num(x), Value::Num(y)) => x == y, + (Value::Str(x), Value::Str(y)) => x == y || self.atoms.get(*x) == self.atoms.get(*y), + (Value::Obj(x), Value::Obj(y)) => x == y, + (Value::Bool(x), Value::Bool(y)) => x == y, + (Value::Undef, Value::Undef) | (Value::Null, Value::Null) => true, + (Value::Sym(x), Value::Sym(y)) => x == y, + _ => false, + } + } + + pub fn same_value_zero(&self, a: &Value, b: &Value) -> bool { + match (a, b) { + (Value::Num(x), Value::Num(y)) => x == y || (x.is_nan() && y.is_nan()), + _ => self.strict_eq(a, b), + } + } + + #[inline] + pub fn text(&self, id: StrId) -> &str { + self.atoms.get(id) + } + + #[inline] + pub fn atom_val(&self, a: Atom) -> Value { + Value::Str(self.atoms.atom_str(a)) + } + + pub fn make_error(&mut self, proto: Id, msg: &str) -> Value { + let id = self.alloc(Obj::new(Some(proto), Kind::Error(None))); + let m = self.names.message; + let text = self.str_val(msg); + self.heap[id as usize].props.push_new(m, text, HIDDEN); + Value::Obj(id) + } + + /// An interpreter failure: a program error that also remembers its diagnostic. + pub fn failure(&mut self, proto: Id, msg: &str, kind: DiagnosticKind) -> Value { + let e = self.make_error(proto, msg); + if let Value::Obj(id) = e { + self.heap[id as usize].kind = Kind::Error(Some(Box::new(Failure { + kind, + message: msg.to_owned(), + offset: None, + }))); + } + e + } + + pub fn type_error(&mut self, msg: &str) -> Value { + let p = self.realm.type_error_proto; + self.failure(p, msg, DiagnosticKind::ExecutionFailure) + } + + pub fn range_error(&mut self, msg: &str) -> Value { + let p = self.realm.range_error_proto; + self.failure(p, msg, DiagnosticKind::ExecutionFailure) + } + + pub fn reference_error(&mut self, msg: &str) -> Value { + let p = self.realm.reference_error_proto; + self.failure(p, msg, DiagnosticKind::ExecutionFailure) + } + + pub fn syntax_error(&mut self, msg: &str) -> Value { + let p = self.realm.syntax_error_proto; + self.failure(p, msg, DiagnosticKind::ExecutionFailure) + } + + // ---------- fuel and limits ---------- + + #[inline] + fn tick(&mut self) -> Result<(), Value> { + self.fuel = self.fuel.saturating_sub(1); + if self.fuel == 0 { + self.fuel = FUEL; + return self.check_time(); + } + Ok(()) + } + + pub fn check_time(&mut self) -> Result<(), Value> { + if self.fatal.is_some() { + return Err(Value::Undef); + } + if let Some(ms) = self.limits.timeout_ms + && self.start.elapsed().as_millis() as u64 >= ms + { + self.fatal = Some(( + DiagnosticKind::TimeoutExceeded, + format!("Execution exceeded its timeout of {ms} ms."), + )); + return Err(Value::Undef); + } + Ok(()) + } + + // ---------- calls ---------- + + /// Calls any callable value from native code and runs it to completion (or its first suspension). + pub fn call(&mut self, f: &Value, this: Value, args: &[Value]) -> Res { + let probe = 0u8; + if self.stack_base.abs_diff(&probe as *const u8 as usize) > self.stack_budget { + return Err(self.range_error("Maximum call stack size exceeded")); + } + let Value::Obj(id) = f else { + let d = self.describe(f); + return Err(self.type_error(&format!("{d} is not a function"))); + }; + let id = *id; + match &self.heap[id as usize].kind { + Kind::Closure(_) => { + if self.native_depth >= MAX_NATIVE_DEPTH { + return Err(self.range_error("Maximum call stack size exceeded")); + } + let fpos = self.stack.len(); + self.push(*f); + self.push(this); + self.stack.extend(args.iter().map(|v| Slot::pack(*v))); + self.push_closure_frame(id, fpos, args.len(), true)?; + self.native_depth += 1; + let r = self.run(); + self.native_depth -= 1; + match r { + Ok(Exit::Return(v)) | Ok(Exit::Yield(v)) => Ok(v), + Err(e) => Err(e), + } + } + Kind::Native { f, .. } => { + let f = *f; + if self.native_depth >= MAX_NATIVE_DEPTH { + return Err(self.range_error("Maximum call stack size exceeded")); + } + self.native_depth += 1; + let r = f(self, this, args, id); + self.native_depth -= 1; + r + } + Kind::Bound(b) => { + let (target, bthis, bargs) = (b.0, b.1, b.2.clone()); + let mut all = bargs; + all.extend_from_slice(args); + self.call(&target, bthis, &all) + } + Kind::ToolRef(path) => { + let path = path.clone(); + self.call_tool(&path, args) + } + _ => { + let d = self.describe(f); + Err(self.type_error(&format!("{d} is not a function"))) + } + } + } + + /// Pushes a frame for the closure at `stack[fpos]`, with receiver and `argc` arguments above it. + fn push_closure_frame( + &mut self, + id: Id, + fpos: usize, + argc: usize, + is_base: bool, + ) -> Result<(), Value> { + if self.frames.len() >= MAX_DEPTH { + self.stack.truncate(fpos); + return Err(self.range_error("Maximum call stack size exceeded")); + } + self.tick()?; + let Kind::Closure(c) = &self.heap[id as usize].kind else { + return Ok(()); + }; + let proto = c.proto.clone(); + let upvals = c.upvals.clone(); + if proto.is_arrow { + self.stack[fpos + 1] = Slot::pack(c.this); + } + let base = fpos + 2; + let np = proto.nparams as usize; + let mut extra = Vec::new(); + if argc > np { + if proto.needs_extra { + extra = self.stack.drain(base + np..).map(Slot::get).collect(); + } else { + self.stack.truncate(base + np); + } + } + self.stack + .resize(base + proto.nlocals as usize, Slot::UNDEF); + let kind = if proto.is_async { + let promise = if proto.is_program { + None + } else { + Some(self.new_promise()) + }; + self.coroutines.push(Coroutine { + saved: None, + promise, + }); + FrameKind::Async(self.coroutines.len() as u32 - 1) + } else { + FrameKind::Normal + }; + let ncells = proto.ncells as usize; + // Reuse a retired frame and write its fields in place: building a fresh one on the stack and copying it in + // stalls on store forwarding. + match self.spare_frames.pop() { + Some(spare) => { + self.frames.push(spare); + let f = self.frames.last_mut().expect("frame"); + f.func = proto; + f.pc = 0; + f.base = base; + f.cells.clear(); + f.cells.resize(ncells, 0); + f.upvals = upvals; + f.handlers.clear(); + f.extra = extra; + f.argc = argc as u32; + f.kind = kind; + f.is_base = is_base; + } + None => self.frames.push(Frame { + func: proto, + pc: 0, + base, + cells: vec![0; ncells], + upvals, + handlers: Vec::new(), + extra, + argc: argc as u32, + kind, + is_base, + }), + } + Ok(()) + } + + /// The `Call` instruction: returns whether a frame was pushed. + #[inline(never)] + fn call_op(&mut self, argc: usize) -> Result { + let fpos = self.stack.len() - argc - 2; + let callee = self.stack[fpos].get(); + let Value::Obj(id) = callee else { + self.stack.truncate(fpos); + let d = self.describe(&callee); + return Err(self.type_error(&format!("{d} is not a function"))); + }; + match &self.heap[id as usize].kind { + Kind::Closure(_) => { + self.push_closure_frame(id, fpos, argc, false)?; + Ok(true) + } + Kind::Native { f, .. } => { + let f = *f; + let mut args = self.arg_pool.pop().unwrap_or_default(); + args.extend(self.stack.drain(fpos + 2..).map(Slot::get)); + let this = self.pop(); + self.stack.pop(); + let r = f(self, this, &args, id); + args.clear(); + self.arg_pool.push(args); + self.push(r?); + Ok(false) + } + Kind::Bound(b) => { + let (target, bthis, bargs) = (b.0, b.1, b.2.clone()); + let n = bargs.len(); + self.stack[fpos] = Slot::pack(target); + self.stack[fpos + 1] = Slot::pack(bthis); + let tail = self.stack.split_off(fpos + 2); + self.stack.extend(bargs.into_iter().map(Slot::pack)); + self.stack.extend(tail); + self.call_op(argc + n) + } + Kind::ToolRef(path) => { + let path = path.clone(); + let args: Vec = self.stack.drain(fpos + 2..).map(Slot::get).collect(); + self.stack.truncate(fpos); + let r = self.call_tool(&path, &args)?; + self.push(r); + Ok(false) + } + _ => { + self.stack.truncate(fpos); + let d = self.describe(&callee); + Err(self.type_error(&format!("{d} is not a function"))) + } + } + } + + #[inline(never)] + fn construct_op(&mut self, argc: usize) -> Result<(), Value> { + let fpos = self.stack.len() - argc - 2; + let callee = self.stack[fpos].get(); + let args: Vec = self.stack.drain(fpos + 2..).map(Slot::get).collect(); + self.stack.truncate(fpos); + if let Value::Obj(id) = callee { + match &self.heap[id as usize].kind { + Kind::Native { f, ctor: true, .. } => { + let f = *f; + let r = f(self, Value::Uninit, &args, id)?; + self.push(r); + return Ok(()); + } + Kind::Closure(_) => { + return Err(self.type_error( + "User-defined constructors are not supported; call a function that returns an object instead", + )); + } + _ => {} + } + } + let d = self.describe(&callee); + Err(self.type_error(&format!("{d} is not a constructor"))) + } + + pub fn call_tool(&mut self, path: &str, args: &[Value]) -> Res { + let p = self.new_promise(); + let outcome = self.invoke_tool(path, args); + self.inbox.push_back((p, outcome)); + Ok(Value::Obj(p)) + } + + fn invoke_tool( + &mut self, + path: &str, + args: &[Value], + ) -> Result { + if args.len() > 1 { + return Err(( + DiagnosticKind::InvalidDataValue, + format!("Tool '{path}' expects at most one input object."), + )); + } + let tools = self.tools; + let Some(tool) = tools.get(path) else { + let under = format!("{path}."); + let message = if tools.keys().any(|k| k.starts_with(&under)) { + format!("Tool '{path}' is not callable, it is a namespace.") + } else { + format!("Unknown tool '{path}'.") + }; + return Err((DiagnosticKind::UnknownTool, message)); + }; + let input = match args.first() { + None => Json::Object(serde_json::Map::new()), + Some(v) => match crate::convert::to_json(self, v) { + Ok(j) => j, + Err(e) => { + let msg = self.error_text(&e); + return Err(( + DiagnosticKind::InvalidDataValue, + format!("Invalid input for tool '{path}': {msg}"), + )); + } + }, + }; + if let Some(max) = self.limits.max_tool_calls + && self.tool_calls.len() as u64 >= max + { + return Err(( + DiagnosticKind::ToolCallLimitExceeded, + format!("Execution exceeded its tool-call limit of {max}."), + )); + } + self.tool_calls.push(ToolCall { + path: path.to_owned(), + input: input.clone(), + }); + tool(&input).map_err(|m| (DiagnosticKind::ToolFailure, m)) + } + + pub fn tool_ref(&mut self, path: &str) -> Value { + if let Some(id) = self.tool_refs.get(path) { + return Value::Obj(*id); + } + let proto = self.realm.function_proto; + let rc: Rc = Rc::from(path); + let id = self.alloc(Obj::new(Some(proto), Kind::ToolRef(rc.clone()))); + self.tool_refs.insert(rc, id); + Value::Obj(id) + } + + // ---------- exceptions ---------- + + /// Fills in the source location of a failure raised by the instruction before `pc`. + #[inline(never)] + fn locate(&mut self, e: &Value, func: &FuncProto, pc: usize) { + if let Value::Obj(id) = e + && let Kind::Error(Some(f)) = &mut self.heap[*id as usize].kind + && f.offset.is_none() + && matches!( + f.kind, + DiagnosticKind::ExecutionFailure | DiagnosticKind::InvalidDataValue + ) + { + f.offset = func.pos.get(pc.saturating_sub(1)).copied(); + } + } + + fn is_return_signal(&self, e: &Value) -> bool { + matches!(e, Value::Obj(id) if matches!(self.heap[*id as usize].kind, Kind::ReturnSignal(_))) + } + + /// Unwinds to the nearest handler. `Err` carries what `run` must return when the base frame is left. + #[inline(never)] + fn handle_throw(&mut self, e: Value) -> Result<(), Result> { + let fatal = self.fatal.is_some(); + let returning = self.is_return_signal(&e); + loop { + let Some(f) = self.frames.last_mut() else { + return Err(Err(e)); + }; + if !fatal { + while let Some(h) = f.handlers.pop() { + if returning && !h.finally { + continue; + } + let sp = f.base + h.sp as usize; + f.pc = h.pc as usize; + self.stack.truncate(sp); + self.push(e); + return Ok(()); + } + } + let frame = self.frames.pop().expect("frame"); + self.stack.truncate(frame.base - 2); + match frame.kind { + FrameKind::Async(c) if !fatal => { + let result = match self.coroutines[c as usize].promise { + Some(p) => { + self.reject(p, e); + Value::Obj(p) + } + None => { + self.outcome = Some(Err(e)); + Value::Undef + } + }; + if frame.is_base { + return Err(Ok(Exit::Return(result))); + } + self.push(result); + return Ok(()); + } + FrameKind::Generator(g) => { + self.heap[g as usize].kind = Kind::Generator(GenState::Done); + if returning && !fatal { + let v = match &self.heap[e.as_obj().unwrap_or(0) as usize].kind { + Kind::ReturnSignal(v) => *v, + _ => Value::Undef, + }; + return Err(Ok(Exit::Return(v))); + } + if frame.is_base { + return Err(Err(e)); + } + } + _ => { + if frame.is_base { + return Err(Err(e)); + } + } + } + } + } + + #[inline(never)] + fn save_top_frame( + &mut self, + pc: usize, + started: bool, + reuse: Option>, + ) -> (Box, bool) { + let mut frame = self.frames.pop().expect("frame"); + frame.pc = pc; + let mut saved = reuse.unwrap_or_else(|| { + Box::new(SavedFrame { + frame: None, + stack: Vec::new(), + started, + }) + }); + saved.stack.clear(); + saved.stack.extend(self.stack.drain(frame.base - 2..)); + saved.started = started; + let is_base = frame.is_base; + saved.frame = Some(frame); + (saved, is_base) + } + + fn restore_frame(&mut self, saved: &mut SavedFrame) -> bool { + let Some(mut frame) = saved.frame.take() else { + return false; + }; + frame.base = self.stack.len() + 2; + frame.is_base = true; + self.stack.append(&mut saved.stack); + self.frames.push(frame); + true + } + + /// Resumes a suspended async function with the settled value of what it awaited. + pub fn resume_coroutine(&mut self, c: u32, outcome: Result) -> Result<(), Value> { + let Some(mut saved) = self.coroutines[c as usize].saved.take() else { + return Ok(()); + }; + let restored = self.restore_frame(&mut saved); + self.coroutines[c as usize].saved = Some(saved); + if !restored { + return Ok(()); + } + match outcome { + Ok(v) => self.push(v), + Err(e) => { + if let Err(r) = self.handle_throw(e) { + return r.map(|_| ()); + } + } + } + self.run().map(|_| ()) + } + + pub fn resume_generator(&mut self, g: Id, mode: u8, v: Value) -> Result<(Value, bool), Value> { + let state = std::mem::replace( + &mut self.heap[g as usize].kind, + Kind::Generator(GenState::Done), + ); + let mut saved = match state { + Kind::Generator(GenState::Suspended(s)) => s, + Kind::Generator(GenState::Running(b)) => { + self.heap[g as usize].kind = Kind::Generator(GenState::Running(b)); + return Err(self.type_error("Generator is already running")); + } + other => { + self.heap[g as usize].kind = other; + return match mode { + 0 => Ok((Value::Undef, true)), + 1 => Ok((v, true)), + _ => Err(v), + }; + } + }; + if !saved.started && mode != 0 { + self.heap[g as usize].kind = Kind::Generator(GenState::Done); + return if mode == 1 { Ok((v, true)) } else { Err(v) }; + } + let started = saved.started; + self.restore_frame(&mut saved); + self.heap[g as usize].kind = Kind::Generator(GenState::Running(Some(saved))); + let r = match mode { + 0 => { + if started { + self.push(v); + } + self.run() + } + _ => { + let e = if mode == 1 { + let proto = self.realm.object_proto; + Value::Obj(self.alloc(Obj::new(Some(proto), Kind::ReturnSignal(v)))) + } else { + v + }; + match self.handle_throw(e) { + Ok(()) => self.run(), + Err(r) => r, + } + } + }; + match r { + Ok(Exit::Yield(y)) => Ok((y, false)), + Ok(Exit::Return(v)) => { + self.heap[g as usize].kind = Kind::Generator(GenState::Done); + Ok((v, true)) + } + Err(e) => { + self.heap[g as usize].kind = Kind::Generator(GenState::Done); + Err(e) + } + } + } + + // ---------- the run loop ---------- + + #[inline(always)] + fn pop(&mut self) -> Value { + self.stack.pop().unwrap_or_default().get() + } + + #[inline(always)] + fn push(&mut self, v: Value) { + self.stack.push(Slot::pack(v)); + } + + #[inline(always)] + fn top(&self) -> Value { + self.stack.last().copied().unwrap_or_default().get() + } + + #[inline(never)] + fn make_closure(&mut self, idx: u32) -> Value { + let proto = self.protos[idx as usize].clone(); + let f = self.frames.last().expect("frame"); + let upvals: Rc<[u32]> = proto + .captures + .iter() + .map(|c| match c { + Capture::Cell(i) => f.cells[*i as usize], + Capture::Upval(i) => f.upvals[*i as usize], + }) + .collect(); + let this = if proto.is_arrow { + self.stack[f.base - 1].get() + } else { + Value::Undef + }; + let fp = self.realm.function_proto; + Value::Obj(self.alloc(Obj::new( + Some(fp), + Kind::Closure(Box::new(Closure { + proto, + upvals, + this, + })), + ))) + } + + pub fn run(&mut self) -> Result { + 'outer: loop { + let fi = self.frames.len() - 1; + let func = self.frames[fi].func.clone(); + let code: &[Op] = &func.code; + let base = self.frames[fi].base; + let mut pc = self.frames[fi].pc; + + macro_rules! throw { + ($e:expr) => {{ + let e = $e; + self.frames[fi].pc = pc; + self.locate(&e, &func, pc); + match self.handle_throw(e) { + Ok(()) => continue 'outer, + Err(r) => return r, + } + }}; + } + macro_rules! tri { + ($e:expr) => { + match $e { + Ok(v) => v, + Err(e) => throw!(e), + } + }; + } + macro_rules! num_op { + ($f:expr) => {{ + let f: fn(f64, f64) -> f64 = $f; + let n = self.stack.len(); + let (a, b) = (self.stack[n - 2], self.stack[n - 1]); + if a.is_num() && b.is_num() { + self.stack[n - 2] = Slot::num(f(a.f(), b.f())); + self.stack.pop(); + } else { + let b = self.pop(); + let a = self.pop(); + let x = tri!(self.number_of(&a)); + let y = tri!(self.number_of(&b)); + self.push(Value::Num(f(x, y))); + } + }}; + } + macro_rules! int_op { + ($f:expr) => {{ + let b = self.pop(); + let a = self.pop(); + let x = tri!(self.number_of(&a)); + let y = tri!(self.number_of(&b)); + let f: fn(f64, f64) -> f64 = $f; + self.push(Value::Num(f(x, y))); + }}; + } + macro_rules! cmp_op { + ($op:tt, $swap:expr, $neg_undef:expr) => {{ + let n = self.stack.len(); + let (a, b) = (self.stack[n - 2], self.stack[n - 1]); + if a.is_num() && b.is_num() { + let r = a.f() $op b.f(); + self.stack.pop(); + self.stack[n - 2] = Slot::pack(Value::Bool(r)); + continue; + } + let b = self.pop(); + let a = self.pop(); + let r = match (&a, &b) { + (Value::Num(x), Value::Num(y)) => *x $op *y, + (Value::Str(x), Value::Str(y)) => self.atoms.get(*x) $op self.atoms.get(*y), + _ => { + let (l, r) = if $swap { (b, a) } else { (a, b) }; + let c = tri!(self.less_than(&l, &r, !$swap)); + match c { + Some(v) => if $neg_undef { !v } else { v }, + None => false, + } + } + }; + self.push(Value::Bool(r)); + }}; + } + + loop { + let op = code[pc]; + pc += 1; + match op { + Op::Nop => {} + Op::Pop => { + self.stack.pop(); + } + Op::Dup => { + let v = self.stack.last().copied().unwrap_or_default(); + if v.is_str() { + self.atoms.bufs[v.payload() as usize].builder = false; + } + self.stack.push(v); + } + Op::Dup2 => { + let n = self.stack.len(); + let (a, b) = (self.stack[n - 2], self.stack[n - 1]); + self.stack.push(a); + self.stack.push(b); + } + Op::Swap => { + let n = self.stack.len(); + self.stack.swap(n - 1, n - 2); + } + Op::Rot3 => { + let c = self.stack.pop().unwrap_or_default(); + let n = self.stack.len(); + self.stack.insert(n - 2, c); + } + Op::Rot3Back => { + let n = self.stack.len(); + let a = self.stack.remove(n - 3); + self.stack.push(a); + } + Op::Undef => self.stack.push(Slot::UNDEF), + Op::Null => self.push(Value::Null), + Op::True => self.push(Value::Bool(true)), + Op::False => self.push(Value::Bool(false)), + Op::Uninit => self.stack.push(Slot::UNINIT), + Op::Int(i) => self.stack.push(Slot::num(i as f64)), + Op::Const(i) => { + let v = self.consts[i as usize]; + self.push(v); + } + Op::GetLocal(i) => { + let v = self.stack[base + i as usize]; + if v.is_str() { + self.atoms.bufs[v.payload() as usize].builder = false; + } + self.stack.push(v); + } + Op::GetLocal2(a, b) => { + for i in [a, b] { + let v = self.stack[base + i as usize]; + if v.is_str() { + self.atoms.bufs[v.payload() as usize].builder = false; + } + self.stack.push(v); + } + } + Op::ArithI(op, k) => { + let n = self.stack.len(); + let a = self.stack[n - 1]; + let y = k as f64; + if a.is_num() { + let x = a.f(); + self.stack[n - 1] = match op { + Arith::Add => Slot::num(x + y), + Arith::Sub => Slot::num(x - y), + Arith::Mul => Slot::num(x * y), + Arith::Div => Slot::num(x / y), + Arith::Mod => Slot::num(js_rem(x, y)), + Arith::Lt => Slot::pack(Value::Bool(x < y)), + Arith::Le => Slot::pack(Value::Bool(x <= y)), + Arith::Gt => Slot::pack(Value::Bool(x > y)), + Arith::Ge => Slot::pack(Value::Bool(x >= y)), + Arith::StrictEq => Slot::pack(Value::Bool(x == y)), + Arith::StrictNe => Slot::pack(Value::Bool(x != y)), + }; + } else { + let r = tri!(self.arith(op, a.get(), Value::Num(y))); + self.stack[n - 1] = Slot::pack(r); + } + } + Op::SetLocal(i) => { + let v = self.stack.pop().unwrap_or_default(); + self.stack[base + i as usize] = v; + } + Op::GetLocalChk(i, name) => { + let v = self.stack[base + i as usize]; + if v == Slot::UNINIT { + throw!(self.tdz_error(name)); + } + if v.is_str() { + self.atoms.bufs[v.payload() as usize].builder = false; + } + self.stack.push(v); + } + Op::NewCell(i) => { + self.cells.push(Slot::UNINIT); + let c = self.cells.len() as u32 - 1; + self.frames[fi].cells[i as usize] = c; + } + Op::GetCell(i) => { + let c = self.frames[fi].cells[i as usize]; + let v = self.cells[c as usize]; + self.stack.push(v); + } + Op::GetCellChk(i, name) => { + let c = self.frames[fi].cells[i as usize]; + let v = self.cells[c as usize]; + if v == Slot::UNINIT { + throw!(self.tdz_error(name)); + } + self.stack.push(v); + } + Op::SetCell(i) => { + let v = self.stack.pop().unwrap_or_default(); + let c = self.frames[fi].cells[i as usize]; + self.cells[c as usize] = v; + } + Op::GetUpval(i) => { + let c = self.frames[fi].upvals[i as usize]; + let v = self.cells[c as usize]; + self.stack.push(v); + } + Op::GetUpvalChk(i, name) => { + let c = self.frames[fi].upvals[i as usize]; + let v = self.cells[c as usize]; + if v == Slot::UNINIT { + throw!(self.tdz_error(name)); + } + self.stack.push(v); + } + Op::SetUpval(i) => { + let v = self.stack.pop().unwrap_or_default(); + let c = self.frames[fi].upvals[i as usize]; + self.cells[c as usize] = v; + } + Op::GetGlobal(g) => { + let v = self.globals[g as usize]; + if let Value::Uninit = v { + let name = self.protos_global_name(g); + throw!(self.reference_error(&format!("Unknown identifier '{name}'."))); + } + self.push(v); + } + Op::TypeofGlobal(g) => { + let v = self.globals[g as usize]; + let t = if let Value::Uninit = v { + "undefined" + } else { + self.type_of(&v) + }; + let t = self.static_str(t); + self.push(t); + } + Op::ThrowConst(name) => { + let n = self.atoms.text(name).to_owned(); + throw!(self.type_error(&format!("Cannot assign to constant '{n}'."))); + } + Op::ThrowRef(name) => { + let n = self.atoms.text(name).to_owned(); + throw!(self.reference_error(&format!("Unknown identifier '{n}'."))); + } + Op::ThrowType(msg) => { + let m = match self.consts[msg as usize] { + Value::Str(s) => self.text(s).to_owned(), + _ => String::new(), + }; + throw!(self.type_error(&m)); + } + Op::This => { + let v = self.stack[base - 1].get(); + self.push(v); + } + Op::Callee => { + let v = self.stack[base - 2].get(); + self.push(v); + } + Op::Arguments => { + let f = &self.frames[fi]; + let n = (f.argc as usize).min(func.nparams as usize); + let mut items: Vec = + self.stack[base..base + n].iter().map(|s| s.get()).collect(); + for v in &items { + if let Value::Str(id) = v { + self.atoms.bufs[*id as usize].builder = false; + } + } + items.extend(f.extra.iter().cloned()); + let proto = self.realm.object_proto; + let id = self.alloc(Obj::new(Some(proto), Kind::Arguments(items))); + self.push(Value::Obj(id)); + } + Op::Rest(_) => { + let extra = self.frames[fi].extra.clone(); + let a = self.new_array(extra); + self.push(a); + } + + Op::GetProp(a) => { + let o = self.pop(); + let v = tri!(self.get(&o, a)); + self.push(v); + } + Op::SetProp(a) => { + let v = self.pop(); + let o = self.pop(); + tri!(self.set(&o, a, v)); + self.push(v); + } + Op::GetElem => { + let k = self.pop(); + let o = self.pop(); + let v = tri!(self.get_elem(&o, &k)); + self.push(v); + } + Op::SetElem => { + let v = self.pop(); + let k = self.pop(); + let o = self.pop(); + tri!(self.set_elem(&o, &k, v)); + self.push(v); + } + Op::GetMethod(a) => { + let o = self.pop(); + let f = tri!(self.get(&o, a)); + self.push(f); + self.push(o); + } + Op::DelProp(a) => { + let o = self.pop(); + let r = tri!(self.delete(&o, a)); + self.push(Value::Bool(r)); + } + Op::DelElem => { + let k = self.pop(); + let o = self.pop(); + let a = tri!(self.key_of(&k)); + let r = tri!(self.delete(&o, a)); + self.push(Value::Bool(r)); + } + Op::In => { + let o = self.pop(); + let k = self.pop(); + let r = tri!(self.has_property(&o, &k)); + self.push(Value::Bool(r)); + } + Op::InstanceOf => { + let c = self.pop(); + let v = self.pop(); + let r = tri!(self.instance_of(&v, &c)); + self.push(Value::Bool(r)); + } + Op::DefineField(a) => { + let v = self.pop(); + if let Value::Obj(id) = self.top() { + self.define(id, a, v); + } + } + Op::DefineElem => { + let v = self.pop(); + let k = self.pop(); + let a = tri!(self.key_of(&k)); + if let Value::Obj(id) = self.top() { + self.define(id, a, v); + } + } + Op::NewObject => { + let id = self.new_object(); + self.push(Value::Obj(id)); + } + Op::NewArray(n) => { + let items = self + .stack + .drain(self.stack.len() - n as usize..) + .map(Slot::get) + .collect(); + let a = self.new_array(items); + self.push(a); + } + Op::ArrayPush => { + let v = self.pop(); + if let Value::Obj(id) = self.top() + && let Kind::Array(items) = &mut self.heap[id as usize].kind + { + items.push(v); + } + } + Op::ArraySpread => { + let src = self.pop(); + let items = tri!(self.iterate_to_vec(&src)); + if let Value::Obj(id) = self.top() + && let Kind::Array(arr) = &mut self.heap[id as usize].kind + { + arr.extend(items); + } + } + Op::ObjectSpread => { + let src = self.pop(); + if let Value::Obj(id) = self.top() { + tri!(self.copy_props(id, &src, &[])); + } + } + Op::ObjRest(n) => { + let keys: Vec = self + .stack + .drain(self.stack.len() - n as usize..) + .map(Slot::get) + .collect(); + let src = self.pop(); + let mut excluded = Vec::with_capacity(keys.len()); + for k in &keys { + excluded.push(tri!(self.key_of(k))); + } + let id = self.new_object(); + tri!(self.copy_props(id, &src, &excluded)); + self.push(Value::Obj(id)); + } + Op::RequireCoercible => { + let v = self.top(); + if v.is_nullish() { + let t = if let Value::Null = v { + "null" + } else { + "undefined" + }; + throw!( + self.type_error(&format!("Cannot destructure '{t}' as it is {t}.")) + ); + } + } + + Op::Add => { + let n = self.stack.len(); + let (a, b) = (self.stack[n - 2], self.stack[n - 1]); + if a.is_num() && b.is_num() { + self.stack[n - 2] = Slot::num(a.f() + b.f()); + self.stack.pop(); + continue; + } + let b = self.pop(); + let a = self.pop(); + let r = match (&a, &b) { + (Value::Num(x), Value::Num(y)) => Value::Num(x + y), + _ => tri!(self.add(a, b)), + }; + self.push(r); + } + Op::Sub => num_op!(|x, y| x - y), + Op::Mul => num_op!(|x, y| x * y), + Op::Div => num_op!(|x, y| x / y), + Op::Mod => num_op!(js_rem), + Op::Pow => num_op!(js_pow), + Op::BitAnd => int_op!(|x, y| (to_i32(x) & to_i32(y)) as f64), + Op::BitOr => int_op!(|x, y| (to_i32(x) | to_i32(y)) as f64), + Op::BitXor => int_op!(|x, y| (to_i32(x) ^ to_i32(y)) as f64), + Op::Shl => int_op!(|x, y| to_i32(x).wrapping_shl(to_u32(y) & 31) as f64), + Op::Shr => int_op!(|x, y| (to_i32(x) >> (to_u32(y) & 31)) as f64), + Op::UShr => int_op!(|x, y| (to_u32(x) >> (to_u32(y) & 31)) as f64), + Op::Eq => { + let b = self.pop(); + let a = self.pop(); + let r = tri!(self.loose_eq(&a, &b)); + self.push(Value::Bool(r)); + } + Op::Ne => { + let b = self.pop(); + let a = self.pop(); + let r = tri!(self.loose_eq(&a, &b)); + self.push(Value::Bool(!r)); + } + Op::StrictEq => { + let b = self.pop(); + let a = self.pop(); + let r = self.strict_eq(&a, &b); + self.push(Value::Bool(r)); + } + Op::StrictNe => { + let b = self.pop(); + let a = self.pop(); + let r = !self.strict_eq(&a, &b); + self.push(Value::Bool(r)); + } + Op::Lt => cmp_op!(<, false, false), + Op::Gt => cmp_op!(>, true, false), + Op::Le => cmp_op!(<=, true, true), + Op::Ge => cmp_op!(>=, false, true), + Op::Neg => { + let a = self.pop(); + let x = match a { + Value::Num(x) => x, + _ => tri!(self.number_of(&a)), + }; + self.push(Value::Num(-x)); + } + Op::ToNumber | Op::ToNumeric => { + let a = self.pop(); + let x = match a { + Value::Num(x) => x, + _ => tri!(self.number_of(&a)), + }; + self.push(Value::Num(x)); + } + Op::Not => { + let a = self.pop(); + self.push(Value::Bool(!self.truthy(&a))); + } + Op::BitNot => { + let a = self.pop(); + let x = tri!(self.number_of(&a)); + self.push(Value::Num(!to_i32(x) as f64)); + } + Op::Typeof => { + let a = self.pop(); + let t = self.type_of(&a); + let t = self.static_str(t); + self.push(t); + } + Op::Inc | Op::Dec => { + let a = self.pop(); + let x = match a { + Value::Num(x) => x, + _ => tri!(self.number_of(&a)), + }; + self.push(Value::Num(if op == Op::Inc { x + 1.0 } else { x - 1.0 })); + } + Op::ToStr => { + let a = self.pop(); + let s = match a { + Value::Str(_) => a, + _ => Value::Str(tri!(self.string_of(&a))), + }; + self.push(s); + } + Op::Concat(n) => { + let parts: Vec = self + .stack + .drain(self.stack.len() - n as usize..) + .map(Slot::get) + .collect(); + let mut len = 0; + for p in &parts { + if let Value::Str(s) = p { + len += self.atoms.get(*s).len(); + } + } + let mut out = String::with_capacity(len); + for p in &parts { + if let Value::Str(s) = p { + out.push_str(self.atoms.get(*s)); + } + } + let v = self.string_val(out); + self.push(v); + } + Op::AddLocal(i) => { + let b = self.pop(); + let slot = base + i as usize; + let a = self.stack[slot].get(); + let r = match (a, b) { + (Value::Num(x), Value::Num(y)) => Value::Num(x + y), + (Value::Str(sa), Value::Str(sb)) + if sa != sb && self.atoms.bufs[sa as usize].builder => + { + let added = self.atoms.get(sb).len(); + if self.atoms.get(sa).len() + added > crate::ops::MAX_STRING_LEN { + throw!(self.range_error("Invalid string length")); + } + let mut buf = std::mem::take(&mut self.atoms.bufs[sa as usize].s); + buf.to_mut().push_str(self.atoms.get(sb)); + let ascii = self.atoms.bufs[sb as usize].ascii; + let entry = &mut self.atoms.bufs[sa as usize]; + entry.s = buf; + entry.ascii &= ascii; + a + } + (a, b) => { + let r = tri!(self.add(a, b)); + if let Value::Str(id) = r { + self.atoms.bufs[id as usize].builder = true; + } + r + } + }; + self.stack[slot] = Slot::pack(r); + } + Op::IncLocal(i) => { + let slot = base + i as usize; + let v = self.stack[slot]; + if v.is_num() { + self.stack[slot] = Slot::num(v.f() + 1.0); + } else { + let x = tri!(self.number_of(&v.get())); + self.stack[slot] = Slot::num(x + 1.0); + } + } + + Op::Jump(t) => { + if (t as usize) < pc { + tri!(self.tick()); + } + pc = t as usize; + } + Op::JumpIfFalse(t) => { + let v = self.pop(); + let jump = match v { + Value::Bool(b) => !b, + v => !self.truthy(&v), + }; + if jump { + pc = t as usize; + } + } + Op::JumpIfTrue(t) => { + let v = self.pop(); + if self.truthy(&v) { + if (t as usize) < pc { + tri!(self.tick()); + } + pc = t as usize; + } + } + Op::JumpIfFalseKeep(t) => { + let v = self.top(); + if !self.truthy(&v) { + pc = t as usize; + } else { + self.stack.pop(); + } + } + Op::JumpIfTrueKeep(t) => { + let v = self.top(); + if self.truthy(&v) { + pc = t as usize; + } else { + self.stack.pop(); + } + } + Op::JumpIfNotNullishKeep(t) => { + if !self.top().is_nullish() { + pc = t as usize; + } else { + self.stack.pop(); + } + } + Op::JumpIfNotUndef(t) => { + if self.stack.last() != Some(&Slot::UNDEF) { + pc = t as usize; + } + } + Op::OptChain(t) => { + if self.top().is_nullish() { + self.stack.pop(); + self.push(Value::Undef); + pc = t as usize; + } + } + Op::OptCall(t) => { + let n = self.stack.len(); + if self.stack[n - 2].get().is_nullish() { + self.stack.truncate(n - 2); + self.push(Value::Undef); + pc = t as usize; + } + } + + Op::Closure(idx) => { + let c = self.make_closure(idx); + self.push(c); + } + Op::Call(argc) => { + self.frames[fi].pc = pc; + if tri!(self.call_op(argc as usize)) { + continue 'outer; + } + } + Op::CallSpread => { + self.frames[fi].pc = pc; + let arr = self.pop(); + let args = match &arr { + Value::Obj(id) => match &self.heap[*id as usize].kind { + Kind::Array(items) => items.clone(), + _ => Vec::new(), + }, + _ => Vec::new(), + }; + let argc = args.len(); + self.stack.extend(args.into_iter().map(Slot::pack)); + if tri!(self.call_op(argc)) { + continue 'outer; + } + } + Op::New(argc) => { + self.frames[fi].pc = pc; + tri!(self.construct_op(argc as usize)); + } + Op::NewSpread => { + self.frames[fi].pc = pc; + let arr = self.pop(); + let args = match &arr { + Value::Obj(id) => match &self.heap[*id as usize].kind { + Kind::Array(items) => items.clone(), + _ => Vec::new(), + }, + _ => Vec::new(), + }; + let argc = args.len(); + self.stack.extend(args.into_iter().map(Slot::pack)); + tri!(self.construct_op(argc)); + } + Op::Return => { + let v = self.pop(); + let frame = self.frames.pop().expect("frame"); + self.stack.truncate(frame.base - 2); + let result = match frame.kind { + FrameKind::Normal => v, + FrameKind::Async(c) => match self.coroutines[c as usize].promise { + Some(p) => { + self.resolve_promise(p, v); + Value::Obj(p) + } + None => { + self.program_return(v); + Value::Undef + } + }, + FrameKind::Generator(g) => { + self.heap[g as usize].kind = Kind::Generator(GenState::Done); + v + } + }; + let is_base = frame.is_base; + self.spare_frames.push(frame); + if is_base { + return Ok(Exit::Return(result)); + } + self.push(result); + continue 'outer; + } + Op::GeneratorStart => { + let proto = self.realm.generator_proto; + let g = self.alloc(Obj::new(Some(proto), Kind::Generator(GenState::Done))); + self.frames[fi].kind = FrameKind::Generator(g); + let (saved, is_base) = self.save_top_frame(pc, false, None); + self.heap[g as usize].kind = Kind::Generator(GenState::Suspended(saved)); + if is_base { + return Ok(Exit::Return(Value::Obj(g))); + } + self.push(Value::Obj(g)); + continue 'outer; + } + Op::Await => { + let v = self.pop(); + let FrameKind::Async(c) = self.frames[fi].kind else { + throw!(self.syntax_error("await is only valid in async functions")); + }; + let reuse = self.coroutines[c as usize].saved.take(); + let (saved, is_base) = self.save_top_frame(pc, true, reuse); + self.coroutines[c as usize].saved = Some(saved); + self.await_value(v, c); + let result = match self.coroutines[c as usize].promise { + Some(p) => Value::Obj(p), + None => Value::Undef, + }; + if is_base { + return Ok(Exit::Return(result)); + } + self.push(result); + continue 'outer; + } + Op::Yield => { + let v = self.pop(); + let FrameKind::Generator(g) = self.frames[fi].kind else { + throw!(self.syntax_error("yield is only valid in generators")); + }; + let reuse = match std::mem::replace( + &mut self.heap[g as usize].kind, + Kind::Generator(GenState::Done), + ) { + Kind::Generator(GenState::Running(b)) => b, + _ => None, + }; + let (saved, _) = self.save_top_frame(pc, true, reuse); + self.heap[g as usize].kind = Kind::Generator(GenState::Suspended(saved)); + return Ok(Exit::Yield(v)); + } + + Op::Throw => { + let v = self.pop(); + throw!(v); + } + Op::PushCatch(t) | Op::PushFinally(t) => { + let sp = (self.stack.len() - base) as u32; + self.frames[fi].handlers.push(Handler { + pc: t, + sp, + finally: matches!(op, Op::PushFinally(_)), + }); + } + Op::PopTry => { + self.frames[fi].handlers.pop(); + } + + Op::GetIter(slot) => { + self.frames[fi].pc = pc; + let v = self.pop(); + let it = tri!(self.get_iterator(&v)); + self.stack[base + slot as usize] = Slot::pack(it); + } + Op::IterNext(slot, exit) => { + self.frames[fi].pc = pc; + let it = self.stack[base + slot as usize].get(); + match tri!(self.iter_step(&it)) { + Some(v) => self.push(v), + None => { + self.stack[base + slot as usize] = Slot::UNDEF; + pc = exit as usize; + } + } + } + Op::DelegateNext(slot, exit) => { + self.frames[fi].pc = pc; + let it = self.stack[base + slot as usize].get(); + let (v, done) = tri!(self.delegate_step(&it)); + self.push(v); + if done { + self.stack[base + slot as usize] = Slot::UNDEF; + pc = exit as usize; + } + } + Op::IterStep(slot) => { + self.frames[fi].pc = pc; + let it = self.stack[base + slot as usize].get(); + match tri!(self.iter_step(&it)) { + Some(v) => self.push(v), + None => { + self.stack[base + slot as usize] = Slot::UNDEF; + self.push(Value::Undef); + } + } + } + Op::IterRest(slot) => { + self.frames[fi].pc = pc; + let it = self.stack[base + slot as usize].get(); + let mut items = Vec::new(); + while let Some(v) = tri!(self.iter_step(&it)) { + items.push(v); + } + self.stack[base + slot as usize] = Slot::UNDEF; + let a = self.new_array(items); + self.push(a); + } + Op::IterClose(slot) | Op::IterCloseQuiet(slot) => { + self.frames[fi].pc = pc; + let it = std::mem::take(&mut self.stack[base + slot as usize]).get(); + let r = self.iter_close(&it); + if matches!(op, Op::IterClose(_)) || self.fatal.is_some() { + tri!(r); + } + } + Op::ForIn(slot) => { + let v = self.pop(); + let keys = self.for_in_keys(&v); + let proto = self.realm.iter_proto; + let id = self.alloc(Obj::new( + Some(proto), + Kind::ListIter { + items: keys.into(), + pos: 0, + }, + )); + self.stack[base + slot as usize] = Slot::pack(Value::Obj(id)); + } + } + } + } + } + + fn protos_global_name(&self, g: u32) -> String { + self.global_names + .get(g as usize) + .map(|a| self.atoms.text(*a).to_owned()) + .unwrap_or_default() + } + + #[inline(never)] + fn tdz_error(&mut self, name: Atom) -> Value { + let n = self.atoms.text(name).to_owned(); + self.reference_error(&format!("Cannot access '{n}' before initialization")) + } + + #[inline(never)] + fn program_return(&mut self, v: Value) { + let thenable = match &v { + Value::Obj(id) => { + matches!(self.heap[*id as usize].kind, Kind::Promise(_)) || { + let then = self.names.then; + let t = self.get_obj(*id, then); + self.is_callable(&t) + } + } + _ => false, + }; + if thenable { + let p = self.promise_resolve(v); + self.perform_then(p, Reaction::Program); + } else { + self.outcome = Some(Ok(v)); + } + } + + // ---------- driver ---------- + + /// Runs queued jobs and delivers tool results until the program has an outcome. + pub fn drive(&mut self) -> Result<(), Value> { + loop { + if self.outcome.is_some() { + return Ok(()); + } + if self.fatal.is_some() { + return Err(Value::Undef); + } + if let Some(job) = self.jobs.pop_front() { + self.tick()?; + self.run_job(job)?; + continue; + } + if let Some((p, outcome)) = self.inbox.pop_front() { + self.check_time()?; + match outcome { + Ok(json) => { + let v = crate::convert::from_json(self, &json); + self.fulfill(p, v); + } + Err((kind, message)) => { + let proto = self.realm.error_proto; + let e = self.make_error(proto, &message); + if let Value::Obj(id) = e { + self.heap[id as usize].kind = Kind::Error(Some(Box::new(Failure { + kind, + message, + offset: None, + }))); + } + self.reject(p, e); + } + } + continue; + } + let e = self.make_error( + self.realm.error_proto, + "The program is waiting on a promise that can never settle: nothing else is running, so nothing can resolve it.", + ); + self.outcome = Some(Err(e)); + return Ok(()); + } + } +} + +#[inline] +fn to_i32(x: f64) -> i32 { + crate::value::to_int32(x) +} + +#[inline] +fn to_u32(x: f64) -> u32 { + crate::value::to_uint32(x) +} + +pub fn js_rem(x: f64, y: f64) -> f64 { + const EXACT: f64 = 9_007_199_254_740_992.0; + if x.fract() == 0.0 && y.fract() == 0.0 && x.abs() < EXACT && y.abs() < EXACT && y != 0.0 { + let r = (x as i64 % y as i64) as f64; + return if r == 0.0 && x.is_sign_negative() { + -0.0 + } else { + r + }; + } + if y == 0.0 || x.is_infinite() || x.is_nan() || y.is_nan() { + return f64::NAN; + } + if y.is_infinite() { + return x; + } + x % y +} + +pub fn js_pow(x: f64, y: f64) -> f64 { + if y.is_nan() || ((x == 1.0 || x == -1.0) && y.is_infinite()) { + return f64::NAN; + } + x.powf(y) +} diff --git a/packages/codemode-rust/crates/psychoscript/tests/api.rs b/packages/codemode-rust/crates/psychoscript/tests/api.rs new file mode 100644 index 000000000000..f8ff3a001c9c --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/tests/api.rs @@ -0,0 +1,135 @@ +//! Host-facing behavior the conformance cases do not cover: limits, diagnostics and the data boundary. + +use psychoscript::{DiagnosticKind, Json, Limits, Runtime}; +use serde_json::json; + +fn run(rt: &Runtime, code: &str) -> psychoscript::Outcome { + rt.execute(code, &serde_json::Map::new()) +} + +fn echo() -> Runtime { + Runtime::new().tool("echo", |input| Ok(input.clone())) +} + +#[test] +fn timeout_interrupts_busy_loops() { + let rt = Runtime::new().limits(Limits { + timeout_ms: Some(50), + ..Limits::default() + }); + let outcome = run(&rt, "try { while (true) {} } catch (e) { return 'caught' }"); + assert_eq!( + outcome.result.unwrap_err().kind, + DiagnosticKind::TimeoutExceeded + ); +} + +#[test] +fn tool_call_limit_counts_admitted_calls() { + let rt = echo().limits(Limits { + max_tool_calls: Some(2), + ..Limits::default() + }); + let outcome = run(&rt, "for (let i = 0; i < 5; i++) await tools.echo({ i })"); + assert_eq!( + outcome.result.unwrap_err().kind, + DiagnosticKind::ToolCallLimitExceeded + ); + assert_eq!(outcome.tool_calls.len(), 2); +} + +#[test] +fn output_limit_truncates_result_and_logs() { + let rt = Runtime::new().limits(Limits { + max_output_bytes: Some(40), + ..Limits::default() + }); + let outcome = run( + &rt, + "for (let i = 0; i < 10; i++) console.log('line ' + i); return 'x'.repeat(100)", + ); + let value = outcome.result.unwrap(); + assert!( + value + .as_str() + .unwrap() + .contains("[result truncated: 102 bytes") + ); + assert_eq!( + outcome.logs, + vec!["[logs truncated: showing 0 of 10 lines]"] + ); +} + +#[test] +fn tool_input_is_a_json_copy() { + let outcome = run( + &echo(), + "const o = { a: 1, f() {}, u: undefined, n: [NaN] }; const r = await tools.echo(o); r.a = 2; return [o.a, r]", + ); + assert_eq!(outcome.result.unwrap(), json!([1, { "a": 2, "n": [null] }])); + assert_eq!(outcome.tool_calls[0].input, json!({ "a": 1, "n": [null] })); +} + +#[test] +fn unsupported_syntax_has_a_location() { + let d = run( + &Runtime::new(), + "const a = 1\nconst o = { get x() { return a } }", + ) + .result + .unwrap_err(); + assert_eq!(d.kind, DiagnosticKind::UnsupportedSyntax); + assert_eq!(d.location, Some((2, 13))); +} + +#[test] +fn runtime_errors_report_their_location() { + let d = run(&Runtime::new(), "const x = null\nreturn x.y") + .result + .unwrap_err(); + assert_eq!(d.kind, DiagnosticKind::ExecutionFailure); + assert_eq!(d.location, Some((2, 8))); + assert!( + d.message + .starts_with("TypeError: Cannot read properties of null (reading 'y')") + ); +} + +#[test] +fn deep_input_does_not_overflow() { + let rt = Runtime::new(); + let nested = format!("return {}1{}", "(".repeat(1_000), ")".repeat(1_000)); + assert!(run(&rt, &nested).result.is_ok()); + let chain = format!("return {}1", "1+".repeat(100_000)); + assert_eq!( + run(&rt, &chain).result.unwrap_err().kind, + DiagnosticKind::ParseError + ); + let recursion = run(&rt, "const f = (n) => [n].map((x) => f(x + 1)); f(0)") + .result + .unwrap_err(); + assert!( + recursion + .message + .contains("Maximum call stack size exceeded") + ); +} + +#[test] +fn bindings_are_globals_programs_can_shadow() { + let mut bindings = serde_json::Map::new(); + bindings.insert("n".into(), Json::from(4)); + let outcome = + Runtime::new().execute("const m = n * 2; { const n = 1; return [m, n] }", &bindings); + assert_eq!(outcome.result.unwrap(), json!([8, 1])); +} + +#[test] +fn string_building_does_not_alias() { + let code = "let s = ''; const parts = []; for (let i = 0; i < 3; i++) { s += i; parts.push(s) } return parts"; + assert_eq!( + run(&Runtime::new(), code).result.unwrap(), + json!(["0", "01", "012"]) + ); +} From eeee8dc0375282bf3d8e6958506842de8fd1f295 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 16:43:59 +0100 Subject: [PATCH 002/100] test(codemode): add a test262 parity runner for the Rust port Runs the reference's pinned test262 file set, synced by the reference's own script, with the reference harness semantics. test262/rust-skipped.txt lists the files that fail here but pass in the reference; the runner fails on an unlisted failure and on a listed file that passes. --- packages/codemode-rust/AGENTS.md | 3 +- packages/codemode-rust/Cargo.lock | 7 + packages/codemode-rust/Cargo.toml | 2 +- .../crates/psychoscript/Cargo.toml | 4 + .../crates/psychoscript/src/lib.rs | 3 + .../crates/psychoscript/src/test262.rs | 425 ++ packages/codemode-rust/test262/Cargo.toml | 8 + packages/codemode-rust/test262/README.md | 21 + packages/codemode-rust/test262/run.sh | 48 + .../codemode-rust/test262/rust-skipped.txt | 4170 +++++++++++++++++ packages/codemode-rust/test262/src/main.rs | 587 +++ 11 files changed, 5276 insertions(+), 2 deletions(-) create mode 100644 packages/codemode-rust/crates/psychoscript/src/test262.rs create mode 100644 packages/codemode-rust/test262/Cargo.toml create mode 100644 packages/codemode-rust/test262/README.md create mode 100644 packages/codemode-rust/test262/run.sh create mode 100644 packages/codemode-rust/test262/rust-skipped.txt create mode 100644 packages/codemode-rust/test262/src/main.rs diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index c798c9a08a33..5b6008b9bb8c 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -10,7 +10,7 @@ In scope: - Pipeline: parse → compile to bytecode → stack VM. Values cross the host boundary as JSON copies (`serde_json::Value`), never shared. - Host API in `crates/psychoscript/src/lib.rs`: synchronous tools at dotted paths, JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. -Out of scope: classes (rejected, like the reference), `export`/modules/`import`, snapshots and suspend/resume, OpenAPI tools, Effect integration, extensions/globals, async host tools, `search`, RegExp, URL, Date, BigInt, Symbol beyond iterators, test262 parity. +Out of scope: classes (rejected, like the reference), `export`/modules/`import`, snapshots and suspend/resume, OpenAPI tools, Effect integration, extensions/globals, async host tools, `search`, RegExp, URL, Date, BigInt, Symbol beyond iterators. ## Rules @@ -18,6 +18,7 @@ Out of scope: classes (rejected, like the reference), `export`/modules/`import`, - Unsupported syntax returns `UnsupportedSyntax` with a location; never panic on user input. - No `unsafe` unless measured and justified in a comment. - Dependencies: pure Rust only, and few. Justify each in the commit that adds it. +- test262 parity: `bash test262/run.sh` must pass, and `test262/rust-skipped.txt` may only shrink. - `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` must pass. - Benchmark claims need the command, machine and numbers in `bench/RESULTS.md`. - Nothing in the repo mentions internal tooling, private chats, home paths, hostnames or secrets. diff --git a/packages/codemode-rust/Cargo.lock b/packages/codemode-rust/Cargo.lock index f8c103572786..3c7f1615fe93 100644 --- a/packages/codemode-rust/Cargo.lock +++ b/packages/codemode-rust/Cargo.lock @@ -578,6 +578,13 @@ dependencies = [ "serde_json", ] +[[package]] +name = "psychoscript-test262" +version = "0.0.0" +dependencies = [ + "psychoscript", +] + [[package]] name = "quote" version = "1.0.47" diff --git a/packages/codemode-rust/Cargo.toml b/packages/codemode-rust/Cargo.toml index 158b6353d9aa..8007589e4991 100644 --- a/packages/codemode-rust/Cargo.toml +++ b/packages/codemode-rust/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "3" -members = ["crates/psychoscript", "bench"] +members = ["crates/psychoscript", "bench", "test262"] [workspace.package] edition = "2024" diff --git a/packages/codemode-rust/crates/psychoscript/Cargo.toml b/packages/codemode-rust/crates/psychoscript/Cargo.toml index f86cffdff61c..f056dfe9e6e5 100644 --- a/packages/codemode-rust/crates/psychoscript/Cargo.toml +++ b/packages/codemode-rust/crates/psychoscript/Cargo.toml @@ -5,6 +5,10 @@ edition.workspace = true license.workspace = true description = "Embeddable Rust port of OpenCode's Code Mode language" +[features] +# The test262 harness globals, for the parity runner in test262/ only. +test262 = [] + [dependencies] oxc_allocator = "0.159" oxc_ast = "0.159" diff --git a/packages/codemode-rust/crates/psychoscript/src/lib.rs b/packages/codemode-rust/crates/psychoscript/src/lib.rs index c15f88b3ef61..f600f38d6e13 100644 --- a/packages/codemode-rust/crates/psychoscript/src/lib.rs +++ b/packages/codemode-rust/crates/psychoscript/src/lib.rs @@ -13,6 +13,9 @@ mod ops; mod promise; mod run; mod strings; +#[cfg(feature = "test262")] +#[doc(hidden)] +pub mod test262; mod value; mod vm; diff --git a/packages/codemode-rust/crates/psychoscript/src/test262.rs b/packages/codemode-rust/crates/psychoscript/src/test262.rs new file mode 100644 index 000000000000..4091b5217a3c --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/test262.rs @@ -0,0 +1,425 @@ +//! The test262 harness globals, for the parity runner in `test262/` only. Mirrors the reference +//! `packages/codemode/test/test262/run.ts`: `$assert` with its checks, `compareArray`, `Test262Error`, `$DONE` and +//! `$DONOTEVALUATE` are host functions; `assert` itself is program code the runner prepends. + +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::rc::Rc; + +use crate::builtins::arg; +use crate::object::{Closure, Kind, Obj}; +use crate::strings::Strings; +use crate::value::{Id, Value}; +use crate::vm::{NativeFn, Res, Vm}; +use crate::{Diagnostic, DiagnosticKind, Limits, compiler, convert}; + +const STACK_SIZE: usize = 256 << 20; +const STACK_BUDGET: usize = 64 << 20; + +/// How a test262 program ended. +pub struct Run { + pub result: Result<(), Diagnostic>, + /// `None` when `$DONE` was never called, `Some(None)` when it was called without an error, and + /// `Some(Some(error))` when it was called with one. + pub done: Option>, +} + +thread_local! { + static DONE: RefCell>> = const { RefCell::new(None) }; +} + +/// Runs an already assembled test262 source with the harness globals, on its own large-stack thread. +pub fn run(code: &str, timeout_ms: u64) -> Run { + std::thread::scope(|s| { + let spawned = std::thread::Builder::new() + .stack_size(STACK_SIZE) + .spawn_scoped(s, || run_here(code, timeout_ms)); + match spawned.map(|h| h.join()) { + Ok(Ok(run)) => run, + _ => Run { + result: Err(diagnostic( + DiagnosticKind::ExecutionFailure, + "Internal interpreter error.".into(), + )), + done: None, + }, + } + }) +} + +fn diagnostic(kind: DiagnosticKind, message: String) -> Diagnostic { + Diagnostic { + kind, + message, + location: None, + } +} + +fn run_here(code: &str, timeout_ms: u64) -> Run { + let probe = 0u8; + DONE.with(|d| *d.borrow_mut() = None); + let mut atoms = Strings::new(); + let program = match compiler::compile(code, &mut atoms) { + Ok(p) => p, + Err(e) => { + return Run { + result: Err(diagnostic(e.kind, e.message)), + done: None, + }; + } + }; + let tools = BTreeMap::new(); + let limits = Limits { + timeout_ms: Some(timeout_ms), + ..Limits::default() + }; + let mut vm = Vm::new(&tools, limits, atoms); + vm.stack_base = &probe as *const u8 as usize; + vm.stack_budget = STACK_BUDGET; + vm.setup(); + harness(&mut vm); + vm.load(program); + let proto = vm.protos[0].clone(); + let fp = vm.realm.function_proto; + let main = Value::Obj(vm.alloc(Obj::new( + Some(fp), + Kind::Closure(Box::new(Closure { + proto, + upvals: Rc::from(Vec::new()), + this: Value::Undef, + })), + ))); + match vm.call(&main, Value::Undef, &[]) { + Ok(_) => { + let _ = vm.drive(); + } + Err(e) => { + if vm.outcome.is_none() { + vm.outcome = Some(Err(e)); + } + } + } + let result = match (vm.fatal.clone(), vm.outcome.take()) { + (Some((kind, message)), _) => Err(diagnostic(kind, message)), + (None, Some(Ok(v))) => match convert::to_json(&mut vm, &v) { + Ok(_) => Ok(()), + Err(e) => Err(failure(&mut vm, &e)), + }, + (None, Some(Err(e))) => Err(failure(&mut vm, &e)), + (None, None) => Err(diagnostic( + DiagnosticKind::ExecutionFailure, + "The program did not finish.".into(), + )), + }; + Run { + result, + done: DONE.with(|d| d.borrow_mut().take()), + } +} + +fn failure(vm: &mut Vm, e: &Value) -> Diagnostic { + if let Value::Obj(id) = e + && let Kind::Error(failure) = &vm.heap[*id as usize].kind + { + let id = *id; + let kind = failure + .as_ref() + .map_or(DiagnosticKind::ExecutionFailure, |f| f.kind); + return diagnostic(kind, convert::error_to_string(vm, id)); + } + let text = show(vm, e); + diagnostic( + DiagnosticKind::ExecutionFailure, + format!("Uncaught: {text}"), + ) +} + +fn global(vm: &mut Vm, name: &'static str, v: Value) { + let a = vm.atoms.intern_static(name); + vm.global_map.insert(a, v); +} + +fn harness(vm: &mut Vm) { + let object_proto = vm.realm.object_proto; + let proto = vm.alloc(Obj::new(Some(object_proto), Kind::Ordinary)); + let (nk, pk, ck) = (vm.names.name, vm.names.prototype, vm.names.constructor); + let name = vm.static_str("Test262Error"); + vm.define_hidden(proto, nk, name); + let name_atom = vm.atoms.intern_static("Test262Error"); + let fp = vm.realm.function_proto; + let ctor = vm.alloc(Obj::new( + Some(fp), + Kind::Native { + f: test262_error, + data: Value::Obj(proto), + name: name_atom, + length: 1, + ctor: true, + }, + )); + vm.heap[ctor as usize] + .props + .insert(pk, Value::Obj(proto), 0); + vm.define_hidden(proto, ck, Value::Obj(ctor)); + let thrower = vm.native_fn("thrower", 1, test262_thrower, Value::Obj(proto)); + let key = vm.atoms.intern_static("thrower"); + vm.define_hidden(ctor, key, thrower); + global(vm, "Test262Error", Value::Obj(ctor)); + + let compare = vm.native_fn("compareArray", 2, compare_array, Value::Obj(proto)); + if let Value::Obj(id) = compare { + vm.method(id, "format", 1, compare_format); + } + global(vm, "compareArray", compare); + + let assert = vm.native_fn("$assert", 2, assert_true, Value::Obj(proto)); + if let Value::Obj(id) = assert { + let checks: [(&'static str, u8, NativeFn); 5] = [ + ("sameValue", 3, assert_same_value), + ("notSameValue", 3, assert_not_same_value), + ("compareArray", 3, assert_compare_array), + ("notThrown", 2, assert_not_thrown), + ("thrown", 3, assert_thrown), + ]; + for (name, length, f) in checks { + let m = vm.native_fn(name, length, f, Value::Obj(proto)); + let key = vm.atoms.intern_static(name); + vm.define_hidden(id, key, m); + } + } + global(vm, "$assert", assert); + + let done = vm.native_fn("$DONE", 1, done, Value::Undef); + global(vm, "$DONE", done); + let not_evaluate = vm.native_fn("$DONOTEVALUATE", 0, do_not_evaluate, Value::Undef); + global(vm, "$DONOTEVALUATE", not_evaluate); +} + +/// The `Test262Error` prototype, which every harness function carries as its data. +fn error_proto(vm: &Vm, callee: Id) -> Id { + vm.native_data(callee) + .as_obj() + .unwrap_or(vm.realm.object_proto) +} + +fn fail(vm: &mut Vm, callee: Id, message: &str) -> Res { + let proto = error_proto(vm, callee); + Err(vm.make_error(proto, message)) +} + +fn test262_error(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let message = match arg(args, 0) { + Value::Undef => String::new(), + v => { + let s = vm.string_of(&v)?; + vm.text(s).to_owned() + } + }; + let proto = error_proto(vm, callee); + Ok(vm.make_error(proto, &message)) +} + +fn test262_thrower(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let s = vm.string_of(&arg(args, 0))?; + let message = vm.text(s).to_owned(); + fail(vm, callee, &message) +} + +fn same_value(vm: &Vm, a: &Value, b: &Value) -> bool { + match (a, b) { + (Value::Num(x), Value::Num(y)) => { + (x.is_nan() && y.is_nan()) || (x == y && x.is_sign_negative() == y.is_sign_negative()) + } + _ => vm.strict_eq(a, b), + } +} + +fn arrays_equal(vm: &Vm, a: &Value, b: &Value) -> bool { + let (Value::Obj(a), Value::Obj(b)) = (a, b) else { + return false; + }; + match (&vm.heap[*a as usize].kind, &vm.heap[*b as usize].kind) { + (Kind::Array(x), Kind::Array(y)) => { + x.len() == y.len() && x.iter().zip(y).all(|(x, y)| same_value(vm, x, y)) + } + _ => false, + } +} + +fn prefix(vm: &mut Vm, message: &Value) -> Result { + if let Value::Undef = message { + return Ok(String::new()); + } + let s = vm.string_of(message)?; + Ok(format!("{} ", vm.text(s))) +} + +fn compare_array(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + Ok(Value::Bool(arrays_equal(vm, &arg(args, 0), &arg(args, 1)))) +} + +fn compare_format(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let text = show(vm, &arg(args, 0)); + Ok(vm.string_val(text)) +} + +fn assert_true(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let value = arg(args, 0); + if let Value::Bool(true) = value { + return Ok(Value::Undef); + } + let message = match arg(args, 1) { + Value::Undef => format!("Expected true but got {}", show(vm, &value)), + m => { + let s = vm.string_of(&m)?; + vm.text(s).to_owned() + } + }; + fail(vm, callee, &message) +} + +fn assert_same_value(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let (a, b) = (arg(args, 0), arg(args, 1)); + if same_value(vm, &a, &b) { + return Ok(Value::Undef); + } + let p = prefix(vm, &arg(args, 2))?; + let message = format!( + "{p}Expected SameValue(«{}», «{}») to be true", + show(vm, &a), + show(vm, &b) + ); + fail(vm, callee, &message) +} + +fn assert_not_same_value(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let (a, b) = (arg(args, 0), arg(args, 1)); + if !same_value(vm, &a, &b) { + return Ok(Value::Undef); + } + let p = prefix(vm, &arg(args, 2))?; + let message = format!( + "{p}Expected SameValue(«{}», «{}») to be false", + show(vm, &a), + show(vm, &b) + ); + fail(vm, callee, &message) +} + +fn assert_compare_array(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let (a, b) = (arg(args, 0), arg(args, 1)); + if arrays_equal(vm, &a, &b) { + return Ok(Value::Undef); + } + let p = prefix(vm, &arg(args, 2))?; + let message = format!( + "Actual {} and expected {} should have the same contents. {p}", + show(vm, &a), + show(vm, &b) + ); + fail(vm, callee, &message) +} + +fn expected_name(vm: &mut Vm, ctor: &Value) -> String { + if vm.is_callable(ctor) { + let nk = vm.names.name; + if let Ok(name) = vm.get(ctor, nk) { + return match name { + Value::Str(s) => vm.text(s).to_owned(), + other => show(vm, &other), + }; + } + } + show(vm, ctor) +} + +fn assert_not_thrown(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let p = prefix(vm, &arg(args, 1))?; + let name = expected_name(vm, &arg(args, 0)); + let message = format!("{p}Expected a {name} to be thrown but no exception was thrown at all"); + fail(vm, callee, &message) +} + +fn assert_thrown(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let (expected, thrown) = (arg(args, 0), arg(args, 2)); + let p = prefix(vm, &arg(args, 1))?; + if !matches!(thrown, Value::Obj(_)) { + return fail(vm, callee, &format!("{p}Thrown value was not an object!")); + } + let ck = vm.names.constructor; + let actual = vm.get(&thrown, ck)?; + if vm.strict_eq(&actual, &expected) { + return Ok(Value::Undef); + } + let name = expected_name(vm, &expected); + // The thrown error's own message is not in the reference's text; it only names the cause in reports. + let message = format!( + "{p}Expected a {name} but got a {} ({})", + show(vm, &actual), + vm.error_text(&thrown) + ); + fail(vm, callee, &message) +} + +fn done(vm: &mut Vm, _this: Value, args: &[Value], _: Id) -> Res { + let error = match arg(args, 0) { + Value::Undef => None, + e => Some(show(vm, &e)), + }; + DONE.with(|d| { + d.borrow_mut().get_or_insert(error); + }); + Ok(Value::Undef) +} + +fn do_not_evaluate(vm: &mut Vm, _this: Value, _args: &[Value], _: Id) -> Res { + Err(vm.static_str("Test262: This statement should not be evaluated.")) +} + +/// A value as the reference harness shows it in failure messages. +fn show(vm: &mut Vm, v: &Value) -> String { + match v { + Value::Str(s) => { + let mut out = String::new(); + convert::quote(&mut out, vm.text(*s)); + out + } + Value::Num(n) if *n == 0.0 && n.is_sign_negative() => "-0".into(), + Value::Obj(id) => { + let id = *id; + match &vm.heap[id as usize].kind { + Kind::Array(items) => { + let items = items.clone(); + let parts: Vec = items.iter().map(|item| show(vm, item)).collect(); + format!("[{}]", parts.join(", ")) + } + Kind::Closure(_) => "program function".into(), + _ if vm.heap[id as usize].is_callable() => { + let nk = vm.names.name; + let name = vm.get_obj(id, nk); + vm.string_of(&name) + .map(|s| vm.text(s).to_owned()) + .unwrap_or_default() + } + _ => { + let (nk, mk) = (vm.names.name, vm.names.message); + match vm.get_obj(id, mk) { + Value::Str(m) => { + let message = vm.text(m).to_owned(); + let name = match vm.get_obj(id, nk) { + Value::Undef => "object".to_owned(), + n => vm + .string_of(&n) + .map(|s| vm.text(s).to_owned()) + .unwrap_or_default(), + }; + format!("{name}: {message}") + } + _ => "object".into(), + } + } + } + } + _ => convert::format_value(vm, v), + } +} diff --git a/packages/codemode-rust/test262/Cargo.toml b/packages/codemode-rust/test262/Cargo.toml new file mode 100644 index 000000000000..2a840afab8c0 --- /dev/null +++ b/packages/codemode-rust/test262/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "psychoscript-test262" +version = "0.0.0" +edition.workspace = true +publish = false + +[dependencies] +psychoscript = { path = "../crates/psychoscript", features = ["test262"] } diff --git a/packages/codemode-rust/test262/README.md b/packages/codemode-rust/test262/README.md new file mode 100644 index 000000000000..0498b33c5422 --- /dev/null +++ b/packages/codemode-rust/test262/README.md @@ -0,0 +1,21 @@ +# test262 parity + +Runs the reference's pinned test262 file set (`../codemode/test/test262`) with the reference's semantics and +checks the failures against `rust-skipped.txt`. + +```sh +bash test262/run.sh # what CI runs +bash test262/run.sh built-ins/Array # one directory, by path prefix +bash test262/run.sh --write # regenerate rust-skipped.txt from the current failures +``` + +- `run.sh` clones tc39/test262 at the reference manifest's revision into a cache directory (`TEST262_CHECKOUT`), + then runs the reference's own `script/sync-test262.ts` into `target/test262` (`TEST262_FILES`). The file set and + its filters are the reference's, unchanged. +- `src/main.rs` runs each file like the reference's `run.ts`: `"use strict"` and the one-line `assert` prelude + prepended on the same line, the host harness (`$assert` checks, `Test262Error`, `compareArray`, `$DONE`, + `$DONOTEVALUATE`) from the crate's `test262` feature, a 5 s timeout, negative tests judged by phase, and async + tests drained and judged by `$DONE`. +- Files in the reference's `skipped.txt` are the reference's own gaps. They run but are not checked. +- `rust-skipped.txt` lists the files that fail here but pass in the reference, each with a reason category. It is + the parity gap list and may only shrink: CI fails when an unlisted file fails, and when a listed file passes. diff --git a/packages/codemode-rust/test262/run.sh b/packages/codemode-rust/test262/run.sh new file mode 100644 index 000000000000..52d6f564c7eb --- /dev/null +++ b/packages/codemode-rust/test262/run.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Runs the reference's pinned test262 file set through PsychoScript and checks it against test262/rust-skipped.txt. +# Usage: bash test262/run.sh [--write] [prefix]. Extra arguments go to the runner; see test262/src/main.rs. +# +# - Clones tc39/test262 at the reference manifest's revision into TEST262_CHECKOUT (default: a cache directory). +# - Runs the reference's own sync script into TEST262_FILES (default: target/test262), so the file set and its +# filters are exactly the reference's. +# - The reference CodeMode package is ../codemode relative to this workspace; set CODEMODE_REF to override it. +# Needs git, bun and cargo. +set -euo pipefail +[ -n "${CODEMODE_REF:-}" ] && CODEMODE_REF=$(cd "$CODEMODE_REF" && pwd) +cd "$(dirname "$0")/.." +REF_PKG=${CODEMODE_REF:-../codemode} +MANIFEST=$REF_PKG/test/test262/manifest.json +[ -f "$MANIFEST" ] || { echo "reference test262 manifest not found at $MANIFEST" >&2; exit 1; } +REVISION=$(sed -nE 's/^ *"revision": *"([0-9a-f]+)".*/\1/p' "$MANIFEST") +CHECKOUT=${TEST262_CHECKOUT:-${XDG_CACHE_HOME:-$HOME/.cache}/test262-$REVISION} +FILES=${TEST262_FILES:-target/test262} + +# A shallow, sparse checkout of the pinned revision: the sync reads only test/built-ins and test/language. +if [ "$(git -C "$CHECKOUT" rev-parse HEAD 2>/dev/null)" != "$REVISION" ]; then + echo "fetching tc39/test262 at $REVISION into $CHECKOUT" >&2 + rm -rf "$CHECKOUT" + git init -q "$CHECKOUT" + git -C "$CHECKOUT" remote add origin https://github.com/tc39/test262.git + git -C "$CHECKOUT" sparse-checkout set test/built-ins test/language + git -C "$CHECKOUT" fetch -q --depth 1 --filter=blob:none origin "$REVISION" + git -C "$CHECKOUT" checkout -q FETCH_HEAD +fi + +# The sync script writes next to the manifest it reads, so give it a private copy of both. +SYNCED="$FILES/test/test262" +if [ "$(cat "$FILES/stamp" 2>/dev/null)" != "$REVISION $(cksum <"$MANIFEST") $(cksum <"$REF_PKG/script/sync-test262.ts")" ]; then + echo "syncing the reference's file set into $FILES" >&2 + rm -rf "$FILES" + mkdir -p "$FILES/script" "$SYNCED" + cp "$REF_PKG/script/sync-test262.ts" "$FILES/script/" + cp "$MANIFEST" "$SYNCED/" + bun run "$FILES/script/sync-test262.ts" "$CHECKOUT" >&2 + echo "$REVISION $(cksum <"$MANIFEST") $(cksum <"$REF_PKG/script/sync-test262.ts")" >"$FILES/stamp" +fi + +cargo build --release --locked -p psychoscript-test262 >&2 +exec target/release/psychoscript-test262 \ + --root "$SYNCED" \ + --reference-skipped "$REF_PKG/test/test262/skipped.txt" \ + --skipped test262/rust-skipped.txt \ + "$@" diff --git a/packages/codemode-rust/test262/rust-skipped.txt b/packages/codemode-rust/test262/rust-skipped.txt new file mode 100644 index 000000000000..e632f17b0067 --- /dev/null +++ b/packages/codemode-rust/test262/rust-skipped.txt @@ -0,0 +1,4170 @@ +# test262 files that fail here but pass in the reference: the parity gap list. Generated by +# `bash test262/run.sh --write`; CI fails when an unlisted file fails or a listed file passes. +# Fix gaps to shrink it; do not add entries. +built-ins/Array/15.4.5.1-5-1.js # wrong result +built-ins/Array/S15.4.5.1_A1.2_T2.js # wrong result +built-ins/Array/S15.4.5.1_A2.1_T1.js # wrong result +built-ins/Array/S15.4.5.2_A1_T1.js # uncaught RangeError: Invalid array length +built-ins/Array/S15.4_A1.1_T10.js # uncaught RangeError: Invalid array length +built-ins/Array/from/elements-updated-after.js # wrong result +built-ins/Array/from/iter-map-fn-err.js # uncaught Execution exceeded its memory limit +built-ins/Array/isArray/15.4.3.2-0-5.js # wrong result +built-ins/Array/isArray/15.4.3.2-1-10.js # missing global: RegExp +built-ins/Array/isArray/15.4.3.2-1-9.js # missing global: Date +built-ins/Array/length/S15.4.4_A1.3_T1.js # wrong result +built-ins/Array/length/S15.4.5.1_A1.2_T3.js # wrong result +built-ins/Array/length/S15.4.5.2_A3_T4.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/copyWithin/coerced-values-end.js # call of a missing method +built-ins/Array/prototype/copyWithin/coerced-values-start.js # call of a missing method +built-ins/Array/prototype/copyWithin/coerced-values-target.js # call of a missing method +built-ins/Array/prototype/copyWithin/fill-holes.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-end.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-out-of-bounds-end.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-out-of-bounds-start.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-out-of-bounds-target.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-start.js # call of a missing method +built-ins/Array/prototype/copyWithin/negative-target.js # call of a missing method +built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js # call of a missing method +built-ins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js # call of a missing method +built-ins/Array/prototype/copyWithin/non-negative-target-and-start.js # call of a missing method +built-ins/Array/prototype/copyWithin/non-negative-target-start-and-end.js # call of a missing method +built-ins/Array/prototype/copyWithin/undefined-end.js # call of a missing method +built-ins/Array/prototype/entries/iteration-mutable.js # wrong result +built-ins/Array/prototype/every/15.4.4.16-5-15.js # missing global: Date +built-ins/Array/prototype/every/15.4.4.16-5-16.js # missing global: RegExp +built-ins/Array/prototype/every/15.4.4.16-7-4.js # wrong result +built-ins/Array/prototype/every/15.4.4.16-7-5.js # wrong result +built-ins/Array/prototype/every/15.4.4.16-7-b-1.js # wrong result +built-ins/Array/prototype/every/15.4.4.16-7-c-iii-21.js # missing global: Date +built-ins/Array/prototype/every/15.4.4.16-7-c-iii-22.js # missing global: RegExp +built-ins/Array/prototype/exotic-array.js # wrong result +built-ins/Array/prototype/filter/15.4.4.20-5-15.js # missing global: Date +built-ins/Array/prototype/filter/15.4.4.20-5-16.js # missing global: RegExp +built-ins/Array/prototype/filter/15.4.4.20-9-4.js # wrong result +built-ins/Array/prototype/filter/15.4.4.20-9-5.js # wrong result +built-ins/Array/prototype/filter/15.4.4.20-9-b-1.js # wrong result +built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js # missing global: Date +built-ins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js # missing global: RegExp +built-ins/Array/prototype/find/predicate-is-not-callable-throws.js # unsupported syntax: regular expressions +built-ins/Array/prototype/findIndex/predicate-is-not-callable-throws.js # unsupported syntax: regular expressions +built-ins/Array/prototype/findLast/predicate-is-not-callable-throws.js # unsupported syntax: regular expressions +built-ins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js # unsupported syntax: regular expressions +built-ins/Array/prototype/forEach/15.4.4.18-5-15.js # missing global: Date +built-ins/Array/prototype/forEach/15.4.4.18-5-16.js # missing global: RegExp +built-ins/Array/prototype/forEach/15.4.4.18-7-2.js # wrong result +built-ins/Array/prototype/forEach/15.4.4.18-7-3.js # wrong result +built-ins/Array/prototype/forEach/15.4.4.18-7-4.js # wrong result +built-ins/Array/prototype/forEach/15.4.4.18-7-b-1.js # wrong result +built-ins/Array/prototype/includes/length-zero-returns-false.js # wrong result +built-ins/Array/prototype/indexOf/15.4.4.14-5-12.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/indexOf/15.4.4.14-5-16.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/indexOf/15.4.4.14-9-9.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/indexOf/15.4.4.14-9-b-1.js # wrong result +built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js # wrong result +built-ins/Array/prototype/keys/iteration-mutable.js # wrong result +built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js # uncaught RangeError: Invalid array length +built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js # wrong result +built-ins/Array/prototype/map/15.4.4.19-5-15.js # missing global: Date +built-ins/Array/prototype/map/15.4.4.19-5-16.js # missing global: RegExp +built-ins/Array/prototype/map/15.4.4.19-8-3.js # wrong result +built-ins/Array/prototype/map/15.4.4.19-8-4.js # wrong result +built-ins/Array/prototype/map/15.4.4.19-8-5.js # wrong result +built-ins/Array/prototype/map/15.4.4.19-8-b-1.js # wrong result +built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js # error not thrown: TypeError +built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js # error not thrown: TypeError +built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js # error not thrown: TypeError +built-ins/Array/prototype/reduce/15.4.4.21-9-3.js # wrong result +built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js # wrong result +built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js # wrong result +built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js # error not thrown: TypeError +built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js # error not thrown: TypeError +built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js # error not thrown: TypeError +built-ins/Array/prototype/reduceRight/15.4.4.22-9-3.js # wrong result +built-ins/Array/prototype/reduceRight/15.4.4.22-9-4.js # wrong result +built-ins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js # wrong result +built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js # wrong result +built-ins/Array/prototype/reverse/array-has-one-entry.js # uncaught TypeError: Cannot modify a frozen or non-extensible array +built-ins/Array/prototype/some/15.4.4.17-5-15.js # missing global: Date +built-ins/Array/prototype/some/15.4.4.17-5-16.js # missing global: RegExp +built-ins/Array/prototype/some/15.4.4.17-7-4.js # wrong result +built-ins/Array/prototype/some/15.4.4.17-7-5.js # wrong result +built-ins/Array/prototype/some/15.4.4.17-7-b-1.js # wrong result +built-ins/Array/prototype/some/15.4.4.17-7-c-iii-21.js # missing global: Date +built-ins/Array/prototype/some/15.4.4.17-7-c-iii-22.js # missing global: RegExp +built-ins/Array/prototype/sort/bug_596_2.js # wrong result +built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js # wrong result +built-ins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js # wrong result +built-ins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js # wrong result +built-ins/Array/prototype/toLocaleString/primitive_this_value.js # wrong result +built-ins/Array/prototype/values/iteration-mutable.js # wrong result +built-ins/ArrayIteratorPrototype/next/iteration-mutable.js # wrong result +built-ins/ArrayIteratorPrototype/next/non-own-slots.js # wrong error type: RangeError instead of TypeError +built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-prototype.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-rejected.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-unwrap-promise.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/next/return-promise.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/return/iterator-result-unwrap-promise.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/return/iterator-result.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/return/poisoned-return.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/return/result-object-error.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/return/return-undefined.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-unwrap-promise.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/throw/poisoned-throw.js # unsupported syntax: async generator functions +built-ins/AsyncFromSyncIteratorPrototype/throw/result-object-error.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorFunction/extensibility.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorFunction/prototype/extensibility.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/next/request-queue-order-state-executing.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/next/request-queue-order.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/next/request-queue-promise-resolve-order.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/next/return-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/iterator-result-prototype.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/request-queue-order-state-executing.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-state-completed.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedStart.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-return.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-throw.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/return/return-suspendedYield.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/request-queue-order-state-executing.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/return-rejected-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-state-completed.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-promise.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally.js # unsupported syntax: async generator functions +built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield.js # unsupported syntax: async generator functions +built-ins/Boolean/prototype/valueOf/S15.6.4.3_A2_T3.js # missing global: Date +built-ins/Date/15.9.1.15-1.js # missing global: Date +built-ins/Date/S15.9.2.1_A1.js # missing global: Date +built-ins/Date/S15.9.2.1_A2.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T1.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T2.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T3.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T4.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T5.js # missing global: Date +built-ins/Date/S15.9.3.1_A1_T6.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T1.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T2.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T3.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T4.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T5.js # missing global: Date +built-ins/Date/S15.9.3.1_A2_T6.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T1.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T1.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T2.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T2.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T3.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T3.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T4.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T4.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T5.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T5.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T6.1.js # missing global: Date +built-ins/Date/S15.9.3.1_A3_T6.2.js # missing global: Date +built-ins/Date/S15.9.3.1_A6_T1.js # missing global: Date +built-ins/Date/S15.9.3.1_A6_T2.js # missing global: Date +built-ins/Date/S15.9.3.1_A6_T3.js # missing global: Date +built-ins/Date/S15.9.3.1_A6_T4.js # missing global: Date +built-ins/Date/S15.9.3.1_A6_T5.js # missing global: Date +built-ins/Date/S15.9.4_A1.js # missing global: Date +built-ins/Date/S15.9.4_A2.js # missing global: Date +built-ins/Date/S15.9.4_A3.js # missing global: Date +built-ins/Date/S15.9.4_A5.js # missing global: Date +built-ins/Date/TimeClip_negative_zero.js # missing global: Date +built-ins/Date/UTC/coercion-errors.js # missing global: Date +built-ins/Date/UTC/coercion-order.js # missing global: Date +built-ins/Date/UTC/fp-evaluation-order.js # missing global: Date +built-ins/Date/UTC/infinity-make-day.js # missing global: Date +built-ins/Date/UTC/infinity-make-time.js # missing global: Date +built-ins/Date/UTC/nans.js # missing global: Date +built-ins/Date/UTC/no-arg.js # missing global: Date +built-ins/Date/UTC/non-integer-values.js # missing global: Date +built-ins/Date/UTC/overflow-make-day.js # missing global: Date +built-ins/Date/UTC/overflow-make-time.js # missing global: Date +built-ins/Date/UTC/return-value.js # missing global: Date +built-ins/Date/UTC/time-clip.js # missing global: Date +built-ins/Date/UTC/year-offset.js # missing global: Date +built-ins/Date/coercion-errors.js # missing global: Date +built-ins/Date/coercion-order.js # missing global: Date +built-ins/Date/construct_with_date.js # missing global: Date +built-ins/Date/now/15.9.4.4-0-1.js # missing global: Date +built-ins/Date/now/15.9.4.4-0-2.js # missing global: Date +built-ins/Date/now/15.9.4.4-0-3.js # missing global: Date +built-ins/Date/now/15.9.4.4-0-4.js # missing global: Date +built-ins/Date/parse/time-value-maximum-range.js # missing global: Date +built-ins/Date/parse/without-utc-offset.js # missing global: Date +built-ins/Date/parse/year-zero.js # missing global: Date +built-ins/Date/parse/zero.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A01_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A02_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A03_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A04_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A05_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A06_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A07_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A08_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A09_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A10_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A11_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A12_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A13_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A14_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A15_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A16_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A17_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A18_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A19_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A20_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A21_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A22_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A23_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A24_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A25_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A26_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A27_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A28_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A29_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A30_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A31_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A32_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A33_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A34_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A35_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A36_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A37_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A38_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A39_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A40_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A41_T1.js # missing global: Date +built-ins/Date/prototype/S15.9.5_A42_T1.js # missing global: Date +built-ins/Date/prototype/getDate/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getDate/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getDate/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getDay/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getDay/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getDay/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getFullYear/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getFullYear/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getFullYear/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getHours/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getHours/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getHours/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getMilliseconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getMilliseconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getMilliseconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getMinutes/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getMinutes/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getMinutes/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getMonth/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getMonth/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getMonth/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getSeconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getSeconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getSeconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getTime/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getTime/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getTime/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getTimezoneOffset/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getTimezoneOffset/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getTimezoneOffset/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCDate/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCDate/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCDate/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCDay/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCDay/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCDay/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCFullYear/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCFullYear/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCFullYear/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCHours/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCHours/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCHours/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMilliseconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMilliseconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCMilliseconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMinutes/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMinutes/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCMinutes/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMonth/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCMonth/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCMonth/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/getUTCSeconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/getUTCSeconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/getUTCSeconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/no-date-value.js # missing global: Date +built-ins/Date/prototype/setDate/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setDate/arg-to-number-err.js # missing global: Date +built-ins/Date/prototype/setDate/arg-to-number.js # missing global: Date +built-ins/Date/prototype/setDate/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setDate/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setDate/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setDate/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setDate/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setDate/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setFullYear/15.9.5.40_1.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-date-to-number-err.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-date-to-number.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-month-to-number-err.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-month-to-number.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-year-to-number-err.js # missing global: Date +built-ins/Date/prototype/setFullYear/arg-year-to-number.js # missing global: Date +built-ins/Date/prototype/setFullYear/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setFullYear/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setFullYear/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setFullYear/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setFullYear/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setFullYear/this-value-valid-date-date.js # missing global: Date +built-ins/Date/prototype/setFullYear/this-value-valid-date-month.js # missing global: Date +built-ins/Date/prototype/setFullYear/this-value-valid-date-year.js # missing global: Date +built-ins/Date/prototype/setHours/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setHours/arg-hour-to-number-err.js # missing global: Date +built-ins/Date/prototype/setHours/arg-hour-to-number.js # missing global: Date +built-ins/Date/prototype/setHours/arg-min-to-number-err.js # missing global: Date +built-ins/Date/prototype/setHours/arg-min-to-number.js # missing global: Date +built-ins/Date/prototype/setHours/arg-ms-to-number-err.js # missing global: Date +built-ins/Date/prototype/setHours/arg-ms-to-number.js # missing global: Date +built-ins/Date/prototype/setHours/arg-sec-to-number-err.js # missing global: Date +built-ins/Date/prototype/setHours/arg-sec-to-number.js # missing global: Date +built-ins/Date/prototype/setHours/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setHours/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setHours/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-valid-date-hour.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-valid-date-min.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-valid-date-ms.js # missing global: Date +built-ins/Date/prototype/setHours/this-value-valid-date-sec.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/arg-to-number.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-min-to-number.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-ms-to-number.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMinutes/arg-sec-to-number.js # missing global: Date +built-ins/Date/prototype/setMinutes/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setMinutes/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setMinutes/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setMinutes/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setMinutes/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setMinutes/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setMonth/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setMonth/arg-date-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMonth/arg-date-to-number.js # missing global: Date +built-ins/Date/prototype/setMonth/arg-month-to-number-err.js # missing global: Date +built-ins/Date/prototype/setMonth/arg-month-to-number.js # missing global: Date +built-ins/Date/prototype/setMonth/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setMonth/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setMonth/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setMonth/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setMonth/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setMonth/this-value-valid-date-date.js # missing global: Date +built-ins/Date/prototype/setMonth/this-value-valid-date-month.js # missing global: Date +built-ins/Date/prototype/setSeconds/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setSeconds/arg-ms-to-number-err.js # missing global: Date +built-ins/Date/prototype/setSeconds/arg-ms-to-number.js # missing global: Date +built-ins/Date/prototype/setSeconds/arg-sec-to-number-err.js # missing global: Date +built-ins/Date/prototype/setSeconds/arg-sec-to-number.js # missing global: Date +built-ins/Date/prototype/setSeconds/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setSeconds/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setSeconds/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setSeconds/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setSeconds/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setSeconds/this-value-valid-date-ms.js # missing global: Date +built-ins/Date/prototype/setSeconds/this-value-valid-date-sec.js # missing global: Date +built-ins/Date/prototype/setTime/arg-to-number-err.js # missing global: Date +built-ins/Date/prototype/setTime/arg-to-number.js # missing global: Date +built-ins/Date/prototype/setTime/new-value-time-clip.js # missing global: Date +built-ins/Date/prototype/setTime/this-value-invalid-date.js # missing global: Date +built-ins/Date/prototype/setTime/this-value-non-date.js # missing global: Date +built-ins/Date/prototype/setTime/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setUTCDate/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCDate/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCDate/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCFullYear/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCFullYear/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCHours/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCHours/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCHours/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCHours/this-value-valid-date-hour.js # missing global: Date +built-ins/Date/prototype/setUTCHours/this-value-valid-date-min.js # missing global: Date +built-ins/Date/prototype/setUTCHours/this-value-valid-date-ms.js # missing global: Date +built-ins/Date/prototype/setUTCHours/this-value-valid-date-sec.js # missing global: Date +built-ins/Date/prototype/setUTCMilliseconds/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCMilliseconds/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCMilliseconds/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCMilliseconds/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setUTCMinutes/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCMinutes/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCMinutes/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCMinutes/this-value-valid-date.js # missing global: Date +built-ins/Date/prototype/setUTCMonth/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCMonth/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCMonth/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCMonth/this-value-valid-date-date.js # missing global: Date +built-ins/Date/prototype/setUTCMonth/this-value-valid-date-month.js # missing global: Date +built-ins/Date/prototype/setUTCSeconds/arg-coercion-order.js # missing global: Date +built-ins/Date/prototype/setUTCSeconds/date-value-read-before-tonumber-when-date-is-invalid.js # missing global: Date +built-ins/Date/prototype/setUTCSeconds/date-value-read-before-tonumber-when-date-is-valid.js # missing global: Date +built-ins/Date/prototype/setUTCSeconds/this-value-valid-date-ms.js # missing global: Date +built-ins/Date/prototype/setUTCSeconds/this-value-valid-date-sec.js # missing global: Date +built-ins/Date/prototype/toDateString/format.js # unsupported syntax: regular expressions +built-ins/Date/prototype/toDateString/invalid-date.js # missing global: Date +built-ins/Date/prototype/toDateString/negative-year.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-10.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-11.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-12.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-13.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-14.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-15.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-2.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-3.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-4.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-5.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-6.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-7.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-8.js # missing global: Date +built-ins/Date/prototype/toISOString/15.9.5.43-0-9.js # missing global: Date +built-ins/Date/prototype/toString/invalid-date.js # missing global: Date +built-ins/Date/prototype/toString/non-date-receiver.js # missing global: Date +built-ins/Date/prototype/toTimeString/format.js # unsupported syntax: regular expressions +built-ins/Date/prototype/toTimeString/invalid-date.js # missing global: Date +built-ins/Date/prototype/toUTCString/day-names.js # missing global: Date +built-ins/Date/prototype/toUTCString/format.js # unsupported syntax: regular expressions +built-ins/Date/prototype/toUTCString/invalid-date.js # missing global: Date +built-ins/Date/prototype/toUTCString/month-names.js # missing global: Date +built-ins/Date/prototype/toUTCString/negative-year.js # missing global: Date +built-ins/Date/prototype/valueOf/S9.4_A3_T1.js # missing global: Date +built-ins/Date/prototype/valueOf/S9.4_A3_T2.js # missing global: Date +built-ins/Date/year-zero.js # missing global: Date +built-ins/Error/isError/non-error-objects.js # unsupported syntax: regular expressions +built-ins/Function/prototype/bind/15.3.4.5-2-9.js # missing global: Date +built-ins/Function/prototype/bind/instance-length-remaining-args.js # wrong result +built-ins/Iterator/constructor.js # wrong result +built-ins/Iterator/from/callable.js # missing global: Iterator +built-ins/Iterator/from/is-function.js # missing global: Iterator +built-ins/Iterator/from/iterable-to-iterator-fallback.js # missing global: Iterator +built-ins/Iterator/from/supports-iterator.js # missing global: Iterator +built-ins/Iterator/newtarget-or-active-function-object.js # missing global: Iterator +built-ins/Iterator/prototype/drop/callable.js # missing global: Iterator +built-ins/Iterator/prototype/drop/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/drop/limit-equals-total.js # call of a missing method +built-ins/Iterator/prototype/drop/limit-greater-than-total.js # call of a missing method +built-ins/Iterator/prototype/drop/limit-less-than-total.js # call of a missing method +built-ins/Iterator/prototype/drop/limit-rangeerror.js # call of a missing method +built-ins/Iterator/prototype/drop/result-is-iterator.js # call of a missing method +built-ins/Iterator/prototype/drop/underlying-iterator-advanced-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/drop/underlying-iterator-closed-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/drop/underlying-iterator-closed.js # call of a missing method +built-ins/Iterator/prototype/every/callable.js # missing global: Iterator +built-ins/Iterator/prototype/every/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/every/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/every/iterator-has-no-return.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-args.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-returns-falsey.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-returns-non-boolean.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-returns-truthy-then-falsey.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-returns-truthy.js # call of a missing method +built-ins/Iterator/prototype/every/predicate-this.js # call of a missing method +built-ins/Iterator/prototype/every/result-is-boolean.js # call of a missing method +built-ins/Iterator/prototype/every/this-non-callable-next.js # missing global: Iterator +built-ins/Iterator/prototype/filter/callable.js # missing global: Iterator +built-ins/Iterator/prototype/filter/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/filter/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/filter/predicate-args.js # call of a missing method +built-ins/Iterator/prototype/filter/predicate-filters.js # call of a missing method +built-ins/Iterator/prototype/filter/predicate-returns-non-boolean.js # call of a missing method +built-ins/Iterator/prototype/filter/predicate-this.js # call of a missing method +built-ins/Iterator/prototype/filter/result-is-iterator.js # call of a missing method +built-ins/Iterator/prototype/filter/throws-typeerror-when-generator-is-running.js # call of a missing method +built-ins/Iterator/prototype/filter/underlying-iterator-advanced-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/filter/underlying-iterator-closed-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/filter/underlying-iterator-closed.js # call of a missing method +built-ins/Iterator/prototype/find/callable.js # missing global: Iterator +built-ins/Iterator/prototype/find/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/find/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/find/iterator-has-no-return.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-args.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-returns-falsey-then-truthy.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-returns-falsey.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-returns-non-boolean.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-returns-truthy.js # call of a missing method +built-ins/Iterator/prototype/find/predicate-this.js # call of a missing method +built-ins/Iterator/prototype/find/this-non-callable-next.js # missing global: Iterator +built-ins/Iterator/prototype/flatMap/callable.js # missing global: Iterator +built-ins/Iterator/prototype/flatMap/flattens-iterable.js # call of a missing method +built-ins/Iterator/prototype/flatMap/flattens-iterator.js # call of a missing method +built-ins/Iterator/prototype/flatMap/flattens-only-depth-1.js # call of a missing method +built-ins/Iterator/prototype/flatMap/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/flatMap/iterable-to-iterator-fallback.js # call of a missing method +built-ins/Iterator/prototype/flatMap/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/flatMap/mapper-args.js # call of a missing method +built-ins/Iterator/prototype/flatMap/mapper-returns-closed-iterator.js # call of a missing method +built-ins/Iterator/prototype/flatMap/mapper-returns-non-object.js # call of a missing method +built-ins/Iterator/prototype/flatMap/mapper-this.js # call of a missing method +built-ins/Iterator/prototype/flatMap/result-is-iterator.js # call of a missing method +built-ins/Iterator/prototype/flatMap/return-is-forwarded-to-mapper-result.js # call of a missing method +built-ins/Iterator/prototype/flatMap/throws-typeerror-when-generator-is-running.js # call of a missing method +built-ins/Iterator/prototype/flatMap/underlying-iterator-advanced-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/flatMap/underlying-iterator-closed-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/flatMap/underlying-iterator-closed.js # call of a missing method +built-ins/Iterator/prototype/forEach/callable.js # missing global: Iterator +built-ins/Iterator/prototype/forEach/fn-args.js # call of a missing method +built-ins/Iterator/prototype/forEach/fn-called-for-each-yielded-value.js # call of a missing method +built-ins/Iterator/prototype/forEach/fn-this.js # call of a missing method +built-ins/Iterator/prototype/forEach/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/forEach/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/forEach/result-is-undefined.js # call of a missing method +built-ins/Iterator/prototype/forEach/this-non-callable-next.js # missing global: Iterator +built-ins/Iterator/prototype/map/callable.js # missing global: Iterator +built-ins/Iterator/prototype/map/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/map/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/map/mapper-args.js # call of a missing method +built-ins/Iterator/prototype/map/mapper-this.js # call of a missing method +built-ins/Iterator/prototype/map/result-is-iterator.js # call of a missing method +built-ins/Iterator/prototype/map/returned-iterator-yields-mapper-return-values.js # call of a missing method +built-ins/Iterator/prototype/map/throws-typeerror-when-generator-is-running.js # call of a missing method +built-ins/Iterator/prototype/map/underlying-iterator-advanced-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/map/underlying-iterator-closed-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/map/underlying-iterator-closed.js # call of a missing method +built-ins/Iterator/prototype/reduce/callable.js # missing global: Iterator +built-ins/Iterator/prototype/reduce/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/reduce/iterator-already-exhausted-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/iterator-already-exhausted-no-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/iterator-yields-once-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/iterator-yields-once-no-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/non-callable-reducer.js # call of a missing method +built-ins/Iterator/prototype/reduce/reducer-args-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/reducer-args-no-initial-value.js # call of a missing method +built-ins/Iterator/prototype/reduce/reducer-this.js # call of a missing method +built-ins/Iterator/prototype/reduce/this-non-callable-next.js # missing global: Iterator +built-ins/Iterator/prototype/some/callable.js # missing global: Iterator +built-ins/Iterator/prototype/some/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/some/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/some/iterator-has-no-return.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-args.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-returns-falsey-then-truthy.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-returns-falsey.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-returns-non-boolean.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-returns-truthy.js # call of a missing method +built-ins/Iterator/prototype/some/predicate-this.js # call of a missing method +built-ins/Iterator/prototype/some/result-is-boolean.js # call of a missing method +built-ins/Iterator/prototype/some/this-non-callable-next.js # missing global: Iterator +built-ins/Iterator/prototype/take/callable.js # missing global: Iterator +built-ins/Iterator/prototype/take/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/take/limit-greater-than-or-equal-to-total.js # call of a missing method +built-ins/Iterator/prototype/take/limit-less-than-total.js # call of a missing method +built-ins/Iterator/prototype/take/limit-rangeerror.js # call of a missing method +built-ins/Iterator/prototype/take/result-is-iterator.js # call of a missing method +built-ins/Iterator/prototype/take/underlying-iterator-advanced-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/take/underlying-iterator-closed-in-parallel.js # call of a missing method +built-ins/Iterator/prototype/take/underlying-iterator-closed.js # call of a missing method +built-ins/Iterator/prototype/toArray/callable.js # missing global: Iterator +built-ins/Iterator/prototype/toArray/is-function.js # missing global: Iterator +built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js # call of a missing method +built-ins/Iterator/prototype/toArray/this-non-callable-next.js # missing global: Iterator +built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js # wrong result +built-ins/JSON/stringify/value-string-escape-unicode.js # wrong result +built-ins/JSON/stringify/value-tojson-not-function.js # unsupported syntax: regular expressions +built-ins/Map/groupBy/callback-arg.js # call of a missing method +built-ins/Map/groupBy/callback-throws.js # wrong error type: TypeError instead of Test262Error +built-ins/Map/groupBy/emptyList.js # call of a missing method +built-ins/Map/groupBy/evenOdd.js # call of a missing method +built-ins/Map/groupBy/groupLength.js # call of a missing method +built-ins/Map/groupBy/iterator-next-throws.js # wrong error type: TypeError instead of Test262Error +built-ins/Map/groupBy/map-instance.js # call of a missing method +built-ins/Map/groupBy/negativeZero.js # call of a missing method +built-ins/Map/groupBy/string.js # call of a missing method +built-ins/Map/groupBy/toPropertyKey.js # call of a missing method +built-ins/Map/prototype/clear/context-is-set-object-throws.js # error not thrown: TypeError +built-ins/Map/prototype/clear/context-is-weakmap-object-throws.js # missing global: WeakMap +built-ins/Map/prototype/delete/context-is-set-object-throws.js # error not thrown: TypeError +built-ins/Map/prototype/delete/context-is-weakmap-object-throws.js # missing global: WeakMap +built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/getOrInsert/returns-value-normalized-zero-key.js # call of a missing method +built-ins/Map/prototype/getOrInsertComputed/callbackfn-throws.js # wrong error type: TypeError instead of Error +built-ins/Map/prototype/getOrInsertComputed/canonical-key-passed-to-callback.js # call of a missing method +built-ins/Map/prototype/getOrInsertComputed/check-callback-fn-args.js # call of a missing method +built-ins/Map/prototype/getOrInsertComputed/check-state-after-callback-fn-throws.js # wrong error type: TypeError instead of Error +built-ins/Map/prototype/getOrInsertComputed/does-not-evaluate-callbackfn-if-key-present.js # call of a missing method +built-ins/Map/prototype/getOrInsertComputed/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/getOrInsertComputed/overwrites-mutation-from-callbackfn.js # call of a missing method +built-ins/Map/prototype/getOrInsertComputed/returns-value-normalized-zero-key.js # call of a missing method +built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/set/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js # error not thrown: TypeError +built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js # missing global: WeakMap +built-ins/Math/hypot/Math.hypot_ToNumberErr.js # error not thrown: Test262Error +built-ins/Math/sumPrecise/sum-is-NaN.js # call of a missing method +built-ins/Math/sumPrecise/sum-is-infinite.js # call of a missing method +built-ins/Math/sumPrecise/sum-is-minus-zero.js # call of a missing method +built-ins/Math/sumPrecise/sum.js # call of a missing method +built-ins/Math/sumPrecise/throws-on-non-number.js # wrong result +built-ins/Number/S9.3.1_A2_U180E.js # interpreter panic +built-ins/Number/S9.3.1_A3_T1_U180E.js # interpreter panic +built-ins/Number/S9.3.1_A3_T2_U180E.js # interpreter panic +built-ins/Number/prototype/S15.7.4_A3.6.js # wrong result +built-ins/Number/prototype/toExponential/range.js # call of a missing method +built-ins/Number/prototype/toExponential/return-abrupt-tointeger-fractiondigits.js # wrong error type: TypeError instead of Test262Error +built-ins/Number/prototype/toExponential/return-values.js # call of a missing method +built-ins/Number/prototype/toExponential/this-is-0-fractiondigits-is-not-0.js # call of a missing method +built-ins/Number/prototype/toExponential/tointeger-fractiondigits.js # call of a missing method +built-ins/Number/prototype/toExponential/undefined-fractiondigits.js # call of a missing method +built-ins/Number/prototype/toFixed/exactness.js # wrong result +built-ins/Object/S15.2.2.1_A2_T5.js # missing global: Date +built-ins/Object/create/15.2.3.5-4-297.js # missing global: Date +built-ins/Object/freeze/15.2.3.9-2-d-6.js # missing global: Date +built-ins/Object/freeze/15.2.3.9-2-d-7.js # missing global: RegExp +built-ins/Object/fromEntries/iterator-closed-for-null-entry.js # wrong error type: Test262Error instead of TypeError +built-ins/Object/fromEntries/iterator-closed-for-string-entry.js # wrong error type: Test262Error instead of TypeError +built-ins/Object/fromEntries/string-entry-primitive-throws.js # error not thrown: TypeError +built-ins/Object/getPrototypeOf/15.2.3.2-2-25.js # missing global: Date +built-ins/Object/getPrototypeOf/15.2.3.2-2-26.js # missing global: RegExp +built-ins/Object/groupBy/callback-arg.js # call of a missing method +built-ins/Object/groupBy/callback-throws.js # wrong error type: TypeError instead of Test262Error +built-ins/Object/groupBy/emptyList.js # call of a missing method +built-ins/Object/groupBy/evenOdd.js # call of a missing method +built-ins/Object/groupBy/groupLength.js # call of a missing method +built-ins/Object/groupBy/invalid-property-key.js # wrong error type: TypeError instead of Test262Error +built-ins/Object/groupBy/iterator-next-throws.js # wrong error type: TypeError instead of Test262Error +built-ins/Object/groupBy/null-prototype.js # call of a missing method +built-ins/Object/groupBy/string.js # call of a missing method +built-ins/Object/groupBy/toPropertyKey.js # call of a missing method +built-ins/Object/isExtensible/15.2.3.13-2-10.js # missing global: RegExp +built-ins/Object/isExtensible/15.2.3.13-2-19.js # missing global: Date +built-ins/Object/isExtensible/15.2.3.13-2-20.js # missing global: RegExp +built-ins/Object/isExtensible/15.2.3.13-2-9.js # missing global: Date +built-ins/Object/isFrozen/15.2.3.12-2-a-11.js # wrong result +built-ins/Object/isFrozen/15.2.3.12-3-15.js # missing global: Date +built-ins/Object/isFrozen/15.2.3.12-3-16.js # missing global: Date +built-ins/Object/isFrozen/15.2.3.12-3-17.js # missing global: RegExp +built-ins/Object/isFrozen/15.2.3.12-3-18.js # missing global: RegExp +built-ins/Object/isSealed/15.2.3.11-4-15.js # missing global: Date +built-ins/Object/isSealed/15.2.3.11-4-16.js # missing global: Date +built-ins/Object/isSealed/15.2.3.11-4-17.js # missing global: RegExp +built-ins/Object/isSealed/15.2.3.11-4-18.js # missing global: RegExp +built-ins/Object/keys/15.2.3.14-6-5.js # missing global: Date +built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A12.js # error not thrown: TypeError +built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A13.js # error not thrown: TypeError +built-ins/Object/prototype/isPrototypeOf/null-this-and-object-arg-throws.js # error not thrown: TypeError +built-ins/Object/prototype/isPrototypeOf/undefined-this-and-object-arg-throws.js # error not thrown: TypeError +built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A12.js # error not thrown: TypeError +built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A13.js # error not thrown: TypeError +built-ins/Object/prototype/toLocaleString/S15.2.4.3_A12.js # error not thrown: TypeError +built-ins/Object/prototype/toLocaleString/S15.2.4.3_A13.js # error not thrown: TypeError +built-ins/Object/prototype/toLocaleString/S15.2.4.3_A9.js # wrong result +built-ins/Object/prototype/toLocaleString/primitive_this_value.js # wrong result +built-ins/Object/prototype/toString/Object.prototype.toString.call-date.js # missing global: Date +built-ins/Object/prototype/toString/Object.prototype.toString.call-regexp.js # unsupported syntax: regular expressions +built-ins/Object/prototype/valueOf/S15.2.4.4_A12.js # error not thrown: TypeError +built-ins/Object/prototype/valueOf/S15.2.4.4_A13.js # error not thrown: TypeError +built-ins/Object/prototype/valueOf/S15.2.4.4_A14.js # error not thrown: TypeError +built-ins/Object/prototype/valueOf/S15.2.4.4_A15.js # error not thrown: TypeError +built-ins/Object/prototype/valueOf/S15.2.4.4_A9.js # wrong result +built-ins/Object/seal/object-seal-o-is-a-date-object.js # missing global: Date +built-ins/Object/seal/object-seal-o-is-a-reg-exp-object.js # missing global: RegExp +built-ins/Object/seal/seal-date.js # missing global: Date +built-ins/Object/seal/seal-regexp.js # missing global: RegExp +built-ins/Object/seal/seal-weakmap.js # missing global: WeakMap +built-ins/Object/seal/seal-weakset.js # missing global: WeakSet +built-ins/Promise/all/S25.4.4.1_A3.1_T1.js # uncaught TypeError: N is not iterable +built-ins/Promise/all/S25.4.4.1_A3.1_T2.js # uncaught TypeError: object is not iterable +built-ins/Promise/all/S25.4.4.1_A5.1_T1.js # wrong result +built-ins/Promise/all/iter-arg-is-false-reject.js # async: wrong result +built-ins/Promise/all/iter-arg-is-null-reject.js # async: wrong result +built-ins/Promise/all/iter-arg-is-number-reject.js # async: wrong result +built-ins/Promise/all/iter-arg-is-true-reject.js # async: wrong result +built-ins/Promise/all/iter-arg-is-undefined-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-false-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-null-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-number-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-string-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-true-reject.js # async: wrong result +built-ins/Promise/all/iter-assigned-undefined-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-false-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-null-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-number-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-string-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-true-reject.js # async: wrong result +built-ins/Promise/all/iter-returns-undefined-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-arg-is-false-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-arg-is-null-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-arg-is-number-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-arg-is-true-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-arg-is-undefined-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-false-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-null-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-number-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-string-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-true-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-assigned-undefined-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-next-err-reject.js # wrong result +built-ins/Promise/allSettled/iter-returns-false-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-returns-null-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-returns-number-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-returns-string-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-returns-true-reject.js # async: wrong result +built-ins/Promise/allSettled/iter-returns-undefined-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-error-object-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-false-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-null-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-number-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-true-reject.js # async: wrong result +built-ins/Promise/any/iter-arg-is-undefined-reject.js # async: wrong result +built-ins/Promise/any/iter-returns-false-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/any/iter-returns-null-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/any/iter-returns-number-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/any/iter-returns-string-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/any/iter-returns-true-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/any/iter-returns-undefined-reject.js # uncaught TypeError: Result of the Symbol.iterator method is not an object +built-ins/Promise/race/S25.4.4.3_A2.2_T1.js # uncaught TypeError: N is not iterable +built-ins/Promise/race/S25.4.4.3_A2.2_T2.js # uncaught TypeError: object is not iterable +built-ins/Promise/race/S25.4.4.3_A4.1_T1.js # wrong result +built-ins/Promise/race/iter-arg-is-false-reject.js # async: wrong result +built-ins/Promise/race/iter-arg-is-null-reject.js # async: wrong result +built-ins/Promise/race/iter-arg-is-number-reject.js # async: wrong result +built-ins/Promise/race/iter-arg-is-true-reject.js # async: wrong result +built-ins/Promise/race/iter-arg-is-undefined-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-false-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-null-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-number-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-string-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-true-reject.js # async: wrong result +built-ins/Promise/race/iter-assigned-undefined-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-false-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-null-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-number-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-string-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-true-reject.js # async: wrong result +built-ins/Promise/race/iter-returns-undefined-reject.js # async: wrong result +built-ins/RegExp/15.10.2.15-6-1.js # missing global: RegExp +built-ins/RegExp/15.10.2.5-3-1.js # missing global: RegExp +built-ins/RegExp/15.10.4.1-1.js # missing global: RegExp +built-ins/RegExp/15.10.4.1-2.js # missing global: RegExp +built-ins/RegExp/15.10.4.1-3.js # missing global: RegExp +built-ins/RegExp/15.10.4.1-4.js # missing global: RegExp +built-ins/RegExp/S15.10.1_A1_T1.js # wrong result +built-ins/RegExp/S15.10.1_A1_T10.js # wrong result +built-ins/RegExp/S15.10.1_A1_T11.js # wrong result +built-ins/RegExp/S15.10.1_A1_T12.js # wrong result +built-ins/RegExp/S15.10.1_A1_T13.js # wrong result +built-ins/RegExp/S15.10.1_A1_T14.js # wrong result +built-ins/RegExp/S15.10.1_A1_T15.js # wrong result +built-ins/RegExp/S15.10.1_A1_T16.js # wrong result +built-ins/RegExp/S15.10.1_A1_T2.js # wrong result +built-ins/RegExp/S15.10.1_A1_T3.js # wrong result +built-ins/RegExp/S15.10.1_A1_T4.js # wrong result +built-ins/RegExp/S15.10.1_A1_T5.js # wrong result +built-ins/RegExp/S15.10.1_A1_T6.js # wrong result +built-ins/RegExp/S15.10.1_A1_T7.js # wrong result +built-ins/RegExp/S15.10.1_A1_T8.js # wrong result +built-ins/RegExp/S15.10.1_A1_T9.js # wrong result +built-ins/RegExp/S15.10.2.10_A1.1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A1.2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A1.3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A1.4_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A1.5_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A2.1_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.2.10_A2.1_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.2.10_A3.1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A3.1_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.2.10_A4.1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.10_A4.1_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.2.10_A4.1_T3.js # missing global: RegExp +built-ins/RegExp/S15.10.2.10_A5.1_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.2.11_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.11_A1_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.12_A3_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.12_A4_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T15.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A1_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A2_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A3_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A3_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.13_A3_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.15_A1_T1.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T10.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T11.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T12.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T13.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T14.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T15.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T16.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T17.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T18.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T19.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T2.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T20.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T21.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T22.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T23.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T24.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T25.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T26.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T27.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T28.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T29.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T3.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T30.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T31.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T32.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T33.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T34.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T35.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T36.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T37.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T38.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T39.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T4.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T40.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T41.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T5.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T6.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T7.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T8.js # wrong result +built-ins/RegExp/S15.10.2.15_A1_T9.js # wrong result +built-ins/RegExp/S15.10.2.3_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T15.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T16.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.3_A1_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.5_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.5_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.5_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.5_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.5_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A2_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T15.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A3_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A4_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A5_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A5_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A6_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A6_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A6_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.6_A6_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A1_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A2_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A2_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A3_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T15.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T16.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T18.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T19.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T20.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T21.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A4_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A5_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.7_A6_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A2_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T11.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T14.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T15.js # missing global: RegExp +built-ins/RegExp/S15.10.2.8_A3_T16.js # missing global: RegExp +built-ins/RegExp/S15.10.2.8_A3_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T18.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T19.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T20.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T21.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T22.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T23.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T24.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T25.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T26.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T27.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T28.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T29.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T30.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T31.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T32.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T33.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A3_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A4_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A5_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.8_A5_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.9_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.9_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.9_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2.9_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.2_A1_T1.js # wrong result +built-ins/RegExp/S15.10.3.1_A2_T1.js # wrong result +built-ins/RegExp/S15.10.3.1_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.3.1_A3_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.4.1_A1_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.4.1_A1_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.4.1_A1_T4.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A1_T5.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.4.1_A2_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.4.1_A3_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A3_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A3_T3.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A3_T4.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A3_T5.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A4_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A4_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A4_T3.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A4_T4.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A4_T5.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A5_T1.js # wrong result +built-ins/RegExp/S15.10.4.1_A5_T4.js # wrong result +built-ins/RegExp/S15.10.4.1_A5_T6.js # wrong result +built-ins/RegExp/S15.10.4.1_A5_T7.js # wrong result +built-ins/RegExp/S15.10.4.1_A5_T8.js # wrong result +built-ins/RegExp/S15.10.4.1_A5_T9.js # wrong result +built-ins/RegExp/S15.10.4.1_A6_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A7_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A7_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A8_T1.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A8_T10.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A8_T2.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A8_T3.js # missing global: RegExp +built-ins/RegExp/S15.10.4.1_A9_T1.js # wrong result +built-ins/RegExp/S15.10.4.1_A9_T2.js # wrong result +built-ins/RegExp/S15.10.4.1_A9_T3.js # wrong result +built-ins/RegExp/S15.10.5_A1.js # missing global: RegExp +built-ins/RegExp/S15.10.7_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.7_A1_T2.js # wrong result +built-ins/RegExp/S15.10.7_A2_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.7_A2_T2.js # wrong result +built-ins/RegExp/S15.10.7_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/S15.10.7_A3_T2.js # missing global: RegExp +built-ins/RegExp/call_with_regexp_not_same_constructor.js # unsupported syntax: regular expressions +built-ins/RegExp/character-class-escape-non-whitespace-u180e.js # unsupported syntax: regular expressions +built-ins/RegExp/character-class-escape-non-whitespace.js # unsupported syntax: regular expressions +built-ins/RegExp/dotall/with-dotall-unicode.js # unsupported syntax: regular expressions +built-ins/RegExp/dotall/with-dotall.js # unsupported syntax: regular expressions +built-ins/RegExp/dotall/without-dotall-unicode.js # unsupported syntax: regular expressions +built-ins/RegExp/dotall/without-dotall.js # unsupported syntax: regular expressions +built-ins/RegExp/duplicate-flags.js # missing global: RegExp +built-ins/RegExp/duplicate-named-capturing-groups-syntax.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-d.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-g.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-u.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-y.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js # missing global: RegExp +built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js # missing global: RegExp +built-ins/RegExp/escape/escaped-control-characters.js # missing global: RegExp +built-ins/RegExp/escape/escaped-lineterminator.js # missing global: RegExp +built-ins/RegExp/escape/escaped-otherpunctuators.js # missing global: RegExp +built-ins/RegExp/escape/escaped-solidus-character-mixed.js # missing global: RegExp +built-ins/RegExp/escape/escaped-solidus-character-simple.js # missing global: RegExp +built-ins/RegExp/escape/escaped-surrogates.js # missing global: RegExp +built-ins/RegExp/escape/escaped-syntax-characters-mixed.js # missing global: RegExp +built-ins/RegExp/escape/escaped-syntax-characters-simple.js # missing global: RegExp +built-ins/RegExp/escape/escaped-utf16encodecodepoint.js # missing global: RegExp +built-ins/RegExp/escape/escaped-whitespace.js # missing global: RegExp +built-ins/RegExp/escape/initial-char-escape.js # missing global: RegExp +built-ins/RegExp/escape/is-function.js # missing global: RegExp +built-ins/RegExp/escape/non-string-inputs.js # missing global: RegExp +built-ins/RegExp/escape/not-escaped-underscore.js # missing global: RegExp +built-ins/RegExp/escape/not-escaped.js # missing global: RegExp +built-ins/RegExp/lookBehind/alternations.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/back-references-to-captures.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/back-references.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/captures-negative.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/captures.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/do-not-backtrack.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/greedy-loop.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/misc.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/mutual-recursive.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/negative.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/nested-lookaround.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/simple-fixed-length.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/sliced-strings.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/start-of-line.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/sticky.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/variable-length.js # unsupported syntax: regular expressions +built-ins/RegExp/lookBehind/word-boundary.js # unsupported syntax: regular expressions +built-ins/RegExp/lookahead-quantifier-match-groups.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-array-element.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-array-matched.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-array-unicode-property-names.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-array-unmatched.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-array.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/indices-groups-object-unmatched.js # unsupported syntax: regular expressions +built-ins/RegExp/match-indices/no-indices-array.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-exec.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-group-property-enumeration-order.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-match-indices.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-match.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-replace.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-replaceall.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-search.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-split.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/duplicate-names-test.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/functional-replace-global.js # missing global: RegExp +built-ins/RegExp/named-groups/functional-replace-non-global.js # missing global: RegExp +built-ins/RegExp/named-groups/groups-object-unmatched.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/non-unicode-match.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/non-unicode-property-names-invalid.js # missing global: RegExp +built-ins/RegExp/named-groups/non-unicode-property-names-valid.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/non-unicode-property-names.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/non-unicode-references.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/string-replace-escaped.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-get.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-missing.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-nocaptures.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-numbered.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-unclosed.js # missing global: RegExp +built-ins/RegExp/named-groups/string-replace-undefined.js # missing global: RegExp +built-ins/RegExp/named-groups/unicode-property-names-invalid.js # missing global: RegExp +built-ins/RegExp/named-groups/unicode-property-names-valid.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/unicode-property-names.js # unsupported syntax: regular expressions +built-ins/RegExp/named-groups/unicode-references.js # unsupported syntax: regular expressions +built-ins/RegExp/nullable-quantifier.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_F-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_F.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Invalid-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Invalid.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_N-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_N.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_No-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_No.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_T-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_T.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Y-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Y.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Yes-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_Yes.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/character-class-range-end.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/character-class-range-no-dash-end.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/character-class-range-no-dash-start.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/character-class-range-start.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Basic_Emoji-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Basic_Emoji-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Basic_Emoji-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Emoji_Keycap_Sequence-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Emoji_Keycap_Sequence-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/Emoji_Keycap_Sequence-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Flag_Sequence-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Flag_Sequence-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Flag_Sequence-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Modifier_Sequence-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Modifier_Sequence-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Modifier_Sequence-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Tag_Sequence-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Tag_Sequence-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_Tag_Sequence-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_ZWJ_Sequence-negative-CharacterClass.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_ZWJ_Sequence-negative-P.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_ZWJ_Sequence-negative-u.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Block-implicit-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Block-implicit.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Script-implicit-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Script-implicit.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Script-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-In-prefix-Script.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-Is-prefix-Script-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-Is-prefix-Script.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-circumflex-negation-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-circumflex-negation.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-empty-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-empty.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-invalid-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-invalid.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-no-braces-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-no-braces-value-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-no-braces-value.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-no-braces.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator-and-value-only-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator-and-value-only.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator-only-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator-only.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-separator.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-unclosed-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-unclosed.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-unopened-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/grammar-extension-unopened.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-01-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-01.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-02-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-02.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-03-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-03.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-04-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-04.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-05-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-05.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-06-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-06.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-07-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-07.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-08-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-08.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-09-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-09.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-10-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-10.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-11-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-11.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-12-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-12.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-13-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-13.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-14-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/loose-matching-14.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-General_Category-equals-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-General_Category-equals.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-General_Category-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-General_Category.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script-equals-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script-equals.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script_Extensions-equals-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script_Extensions-equals.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script_Extensions-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-binary-property-without-value-Script_Extensions.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-binary-property-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-binary-property.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-and-value-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-and-value.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-existing-value-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-existing-value.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-General_Category-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-Script-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-Script.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/non-existent-property-value-general-category.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/special-property-value-Script_Extensions-Unknown.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Composition_Exclusion-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Composition_Exclusion.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFC-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFC.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFD-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFD.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFKC-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFKC.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFKD-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Expands_On_NFKD.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-FC_NFKC_Closure-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-FC_NFKC_Closure.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Full_Composition_Exclusion-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Full_Composition_Exclusion.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Grapheme_Link-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Grapheme_Link.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Hyphen-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Hyphen.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Alphabetic-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Alphabetic.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Default_Ignorable_Code_Point-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Default_Ignorable_Code_Point.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Grapheme_Extend-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Grapheme_Extend.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_ID_Continue-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_ID_Continue.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_ID_Start-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_ID_Start.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Lowercase-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Lowercase.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Math-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Math.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Uppercase-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Other_Uppercase.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Prepended_Concatenation_Mark-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-binary-property-Prepended_Concatenation_Mark.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Block-with-value-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Block-with-value.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-FC_NFKC_Closure-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-FC_NFKC_Closure.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Line_Break-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value-negated.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js # unsupported syntax: regular expressions +built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/15.10.6.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.5.1_A1.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.5.1_A2.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.6.1_A1_T1.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.6.1_A1_T2.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.6_A1_T1.js # missing global: RegExp +built-ins/RegExp/prototype/S15.10.6_A1_T2.js # missing global: RegExp +built-ins/RegExp/prototype/dotAll/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/15.10.6.2-9-e-1.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A11.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A12.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T16.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T18.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T19.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T20.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T21.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T9.js # spurious parse error: Identifier `…` has already been declared +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T1.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T10.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T2.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T3.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T7.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T8.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A2_T9.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A3_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T7.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T8.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A4_T9.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A5_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A5_T2.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A5_T3.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/S15.10.6.2_A6.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A7.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A8.js # missing global: RegExp +built-ins/RegExp/prototype/exec/S15.10.6.2_A9.js # missing global: RegExp +built-ins/RegExp/prototype/exec/duplicate-named-groups-properties.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/duplicate-named-indices-groups-properties.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/failure-lastindex-set.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/regexp-builtin-exec-v-u-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/u-captured-value.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/u-lastindex-adv.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/u-lastindex-value.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/y-fail-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/y-fail-return.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/y-init-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/exec/y-set-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/flags/return-order.js # missing global: RegExp +built-ins/RegExp/prototype/flags/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/global/S15.10.7.2_A8.js # missing global: RegExp +built-ins/RegExp/prototype/global/S15.10.7.2_A9.js # missing global: RegExp +built-ins/RegExp/prototype/hasIndices/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/ignoreCase/S15.10.7.3_A8.js # missing global: RegExp +built-ins/RegExp/prototype/ignoreCase/S15.10.7.3_A9.js # missing global: RegExp +built-ins/RegExp/prototype/multiline/S15.10.7.4_A8.js # missing global: RegExp +built-ins/RegExp/prototype/multiline/S15.10.7.4_A9.js # missing global: RegExp +built-ins/RegExp/prototype/no-regexp-matcher.js # missing global: RegExp +built-ins/RegExp/prototype/sticky/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A11.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T1.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T10.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T12.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T13.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T15.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T16.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T17.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T18.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T19.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T20.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T21.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T22.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T4.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T5.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T6.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/S15.10.6.3_A1_T9.js # spurious parse error: Identifier `…` has already been declared +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T1.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T10.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T2.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T3.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T7.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T8.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A2_T9.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A6.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A7.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A8.js # missing global: RegExp +built-ins/RegExp/prototype/test/S15.10.6.3_A9.js # missing global: RegExp +built-ins/RegExp/prototype/test/y-fail-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/y-fail-return.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/y-init-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/test/y-set-lastindex.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/toString/S15.10.6.4_A11.js # missing global: RegExp +built-ins/RegExp/prototype/toString/S15.10.6.4_A8.js # missing global: RegExp +built-ins/RegExp/prototype/toString/S15.10.6.4_A9.js # missing global: RegExp +built-ins/RegExp/prototype/unicode/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-01.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-02.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-03.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-04.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-05.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-06.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-07.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-08.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-09.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-10.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-11.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-12.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-13.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-14.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-15.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-16.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-17.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-18.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-19.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-20.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-21.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-22.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-23.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-24.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-25.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-26.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-27.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/breaking-change-from-u-to-v-28.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/this-val-regexp.js # unsupported syntax: regular expressions +built-ins/RegExp/prototype/unicodeSets/uv-flags-constructor.js # missing global: RegExp +built-ins/RegExp/quantifier-integer-limit.js # missing global: RegExp +built-ins/RegExp/regexp-class-chars.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-dotAll.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-ignoreCase.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-multiline.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-dotAll-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-ignoreCase-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-multiline-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-dotAll.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-alternatives-outside.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/remove-multiline.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js # unsupported syntax: regular expressions +built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js # unsupported syntax: regular expressions +built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js # missing global: RegExp +built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js # missing global: RegExp +built-ins/RegExp/u180e.js # unsupported syntax: regular expressions +built-ins/RegExp/unicode_character_class_backspace_escape.js # unsupported syntax: regular expressions +built-ins/RegExp/unicode_full_case_folding.js # unsupported syntax: regular expressions +built-ins/RegExp/unicode_identity_escape.js # unsupported syntax: regular expressions +built-ins/RegExp/unicode_restricted_brackets.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_character_class_escape.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_identity_escape.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_identity_escape_alpha.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_identity_escape_c.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_identity_escape_u.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_identity_escape_x.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_incomplete_quantifier.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_octal_escape.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_quantifiable_assertion.js # missing global: RegExp +built-ins/RegExp/unicode_restricted_quantifier_without_atom.js # missing global: RegExp +built-ins/RegExp/valid-flags-y.js # missing global: RegExp +built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/difference/add-not-called.js # call of a missing method +built-ins/Set/prototype/difference/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/difference/combines-Map.js # call of a missing method +built-ins/Set/prototype/difference/combines-empty-sets.js # call of a missing method +built-ins/Set/prototype/difference/combines-itself.js # call of a missing method +built-ins/Set/prototype/difference/combines-same-sets.js # call of a missing method +built-ins/Set/prototype/difference/combines-sets.js # call of a missing method +built-ins/Set/prototype/difference/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/difference/result-order.js # call of a missing method +built-ins/Set/prototype/difference/set-like-array.js # call of a missing method +built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/Set/prototype/intersection/add-not-called.js # call of a missing method +built-ins/Set/prototype/intersection/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/intersection/combines-Map.js # call of a missing method +built-ins/Set/prototype/intersection/combines-empty-sets.js # call of a missing method +built-ins/Set/prototype/intersection/combines-itself.js # call of a missing method +built-ins/Set/prototype/intersection/combines-same-sets.js # call of a missing method +built-ins/Set/prototype/intersection/combines-sets.js # call of a missing method +built-ins/Set/prototype/intersection/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/intersection/result-order.js # call of a missing method +built-ins/Set/prototype/intersection/set-like-array.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/compares-Map.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/compares-empty-sets.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/compares-itself.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/compares-same-sets.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/compares-sets.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/set-like-array.js # call of a missing method +built-ins/Set/prototype/isDisjointFrom/set-like-class-mutation.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/compares-Map.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/compares-empty-sets.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/compares-itself.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/compares-same-sets.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/compares-sets.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/set-like-array.js # call of a missing method +built-ins/Set/prototype/isSubsetOf/set-like-class-mutation.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/compares-Map.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/compares-empty-sets.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/compares-itself.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/compares-same-sets.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/compares-sets.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/set-like-array.js # call of a missing method +built-ins/Set/prototype/isSupersetOf/set-like-class-mutation.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/add-not-called.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/combines-Map.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/combines-empty-sets.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/combines-itself.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/combines-same-sets.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/combines-sets.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/result-order.js # call of a missing method +built-ins/Set/prototype/symmetricDifference/set-like-array.js # call of a missing method +built-ins/Set/prototype/union/add-not-called.js # call of a missing method +built-ins/Set/prototype/union/allows-set-like-object.js # call of a missing method +built-ins/Set/prototype/union/appends-new-values.js # call of a missing method +built-ins/Set/prototype/union/combines-Map.js # call of a missing method +built-ins/Set/prototype/union/combines-empty-sets.js # call of a missing method +built-ins/Set/prototype/union/combines-itself.js # call of a missing method +built-ins/Set/prototype/union/combines-same-sets.js # call of a missing method +built-ins/Set/prototype/union/combines-sets.js # call of a missing method +built-ins/Set/prototype/union/converts-negative-zero.js # call of a missing method +built-ins/Set/prototype/union/result-order.js # call of a missing method +built-ins/Set/prototype/union/set-like-array.js # call of a missing method +built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js # error not thrown: TypeError +built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js # missing global: WeakSet +built-ins/String/prototype/charAt/S15.5.4.4_A9.js # wrong result +built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js # wrong result +built-ins/String/prototype/codePointAt/return-first-code-unit.js # wrong result +built-ins/String/prototype/codePointAt/return-single-code-unit.js # wrong result +built-ins/String/prototype/concat/S15.5.4.6_A9.js # wrong result +built-ins/String/prototype/endsWith/searchstring-is-regexp-throws.js # unsupported syntax: regular expressions +built-ins/String/prototype/includes/searchstring-is-regexp-throws.js # unsupported syntax: regular expressions +built-ins/String/prototype/indexOf/S15.5.4.7_A9.js # wrong result +built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js # wrong result +built-ins/String/prototype/isWellFormed/returns-boolean.js # wrong result +built-ins/String/prototype/isWellFormed/to-string.js # wrong error type: TypeError instead of Test262Error +built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js # wrong result +built-ins/String/prototype/localeCompare/15.5.4.9_CE.js # wrong result +built-ins/String/prototype/localeCompare/S15.5.4.9_A9.js # wrong result +built-ins/String/prototype/match/S15.5.4.10_A1_T10.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A1_T11.js # wrong result +built-ins/String/prototype/match/S15.5.4.10_A1_T13.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A1_T14.js # missing global: RegExp +built-ins/String/prototype/match/S15.5.4.10_A1_T4.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A1_T5.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A1_T7.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A1_T8.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A2_T1.js # call of a missing method +built-ins/String/prototype/match/S15.5.4.10_A2_T10.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T11.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T12.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T13.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T14.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T15.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T16.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T17.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T18.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T2.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T3.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T4.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T5.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T6.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T7.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T8.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A2_T9.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/S15.5.4.10_A6.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/match/S15.5.4.10_A8.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/match/S15.5.4.10_A9.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/match/duplicate-named-groups-properties.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js # unsupported syntax: regular expressions +built-ins/String/prototype/match/this-value-not-obj-coercible.js # unsupported syntax: regular expressions +built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js # wrong result +built-ins/String/prototype/normalize/form-is-not-valid-throws.js # error not thrown: RangeError +built-ins/String/prototype/normalize/return-abrupt-from-form.js # error not thrown: Test262Error +built-ins/String/prototype/normalize/return-abrupt-from-this.js # wrong error type: TypeError instead of Test262Error +built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js # wrong result +built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js # wrong result +built-ins/String/prototype/normalize/return-normalized-string.js # wrong result +built-ins/String/prototype/replace/S15.5.4.11_A1_T14.js # missing global: RegExp +built-ins/String/prototype/replace/S15.5.4.11_A1_T17.js # missing global: RegExp +built-ins/String/prototype/replace/S15.5.4.11_A1_T8.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T1.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T10.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T2.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T3.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T4.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T5.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T6.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T7.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T8.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A2_T9.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A3_T1.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A3_T2.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A3_T3.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A4_T1.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A4_T2.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A4_T3.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A4_T4.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/S15.5.4.11_A5_T1.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/regexp-capture-by-index.js # unsupported syntax: regular expressions +built-ins/String/prototype/replace/replaceValue-evaluation-order-regexp-object.js # unsupported syntax: regular expressions +built-ins/String/prototype/search/S15.5.4.12_A1.1_T1.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A11.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/search/S15.5.4.12_A1_T10.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A1_T11.js # wrong result +built-ins/String/prototype/search/S15.5.4.12_A1_T13.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A1_T14.js # missing global: RegExp +built-ins/String/prototype/search/S15.5.4.12_A1_T4.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A1_T5.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A1_T7.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A1_T8.js # call of a missing method +built-ins/String/prototype/search/S15.5.4.12_A6.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/search/S15.5.4.12_A8.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/search/S15.5.4.12_A9.js # uncaught TypeError: Cannot read properties of undefined (reading '…') +built-ins/String/prototype/search/this-value-not-obj-coercible.js # unsupported syntax: regular expressions +built-ins/String/prototype/slice/S15.5.4.13_A9.js # wrong result +built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js # unsupported syntax: regular expressions +built-ins/String/prototype/split/checking-if-deleting-the-string-prototype-split-length-property-fails.js # wrong result +built-ins/String/prototype/split/separator-regexp.js # unsupported syntax: regular expressions +built-ins/String/prototype/split/separator-undef-limit-zero.js # wrong result +built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js # unsupported syntax: regular expressions +built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js # unsupported syntax: regular expressions +built-ins/String/prototype/substring/S15.5.4.15_A9.js # wrong result +built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T14.js # missing global: RegExp +built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A9.js # wrong result +built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T14.js # missing global: RegExp +built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A9.js # wrong result +built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T14.js # missing global: RegExp +built-ins/String/prototype/toLowerCase/S15.5.4.16_A9.js # wrong result +built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T14.js # missing global: RegExp +built-ins/String/prototype/toUpperCase/S15.5.4.18_A9.js # wrong result +built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js # wrong result +built-ins/String/prototype/toWellFormed/returns-well-formed-string.js # wrong result +built-ins/String/prototype/toWellFormed/to-string.js # wrong error type: TypeError instead of Test262Error +built-ins/String/prototype/trim/15.5.4.20-2-49.js # unsupported syntax: regular expressions +built-ins/String/raw/return-empty-string-from-empty-array-length.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-negative-infinity.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-not-defined.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-undefined.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-zero-NaN.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-zero-boolean.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-zero-null.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-number.js # call of a missing method +built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-string.js # call of a missing method +built-ins/String/raw/return-the-string-value-from-template.js # unsupported syntax: tagged templates +built-ins/String/raw/return-the-string-value.js # call of a missing method +built-ins/String/raw/returns-abrupt-from-next-key-toString.js # wrong error type: TypeError instead of Test262Error +built-ins/String/raw/returns-abrupt-from-substitution.js # wrong error type: TypeError instead of Test262Error +built-ins/String/raw/special-characters.js # unsupported syntax: tagged templates +built-ins/String/raw/substitutions-are-appended-on-same-index.js # call of a missing method +built-ins/String/raw/substitutions-are-limited-to-template-raw-length.js # call of a missing method +built-ins/String/raw/template-substitutions-are-appended-on-same-index.js # unsupported syntax: tagged templates +built-ins/String/raw/zero-literal-segments.js # unsupported syntax: tagged templates +built-ins/StringIteratorPrototype/next/next-iteration-surrogate-pairs.js # wrong result +built-ins/StringIteratorPrototype/next/next-missing-internal-slots.js # wrong error type: RangeError instead of TypeError +built-ins/WeakMap/constructor.js # wrong result +built-ins/WeakMap/empty-iterable.js # missing global: WeakMap +built-ins/WeakMap/iterable-failure.js # missing global: WeakMap +built-ins/WeakMap/iterator-next-failure.js # missing global: WeakMap +built-ins/WeakMap/no-iterable.js # missing global: WeakMap +built-ins/WeakMap/properties-of-map-instances.js # missing global: WeakMap +built-ins/WeakMap/properties-of-the-weakmap-prototype-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/delete-entry-with-object-key-initial-iterable.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/delete-entry-with-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-array.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/returns-false-when-object-key-not-present.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/this-not-object-throw-boolean.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/this-not-object-throw-null.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/this-not-object-throw-number.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/this-not-object-throw-string.js # missing global: WeakMap +built-ins/WeakMap/prototype/delete/this-not-object-throw-undefined.js # missing global: WeakMap +built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/get/does-not-have-weakmapdata-internal-slot.js # missing global: WeakMap +built-ins/WeakMap/prototype/get/returns-undefined-with-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/get/returns-value-with-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/adds-object-element.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/does-not-have-weakmapdata-internal-slot-array.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/does-not-have-weakmapdata-internal-slot-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/returns-value-if-key-is-not-present-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsert/returns-value-if-key-is-present-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/adds-object-element.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/callbackfn-throws.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-evaluate-callbackfn-if-key-present.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-array.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/overwrites-mutation-from-callbackfn.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/returns-value-if-key-is-not-present-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/getOrInsertComputed/returns-value-if-key-is-present-object-key.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/returns-false-when-object-key-not-present.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/returns-true-when-object-key-present.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/this-not-object-throw-null.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/this-not-object-throw-number.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/this-not-object-throw-string.js # missing global: WeakMap +built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/adds-object-element.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/returns-this.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/this-not-object-throw-null.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/this-not-object-throw-number.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/this-not-object-throw-string.js # missing global: WeakMap +built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js # missing global: WeakMap +built-ins/WeakMap/undefined-newtarget.js # missing global: WeakMap +built-ins/WeakSet/constructor.js # wrong result +built-ins/WeakSet/empty-iterable.js # missing global: WeakSet +built-ins/WeakSet/iterable-failure.js # missing global: WeakSet +built-ins/WeakSet/iterator-next-failure.js # missing global: WeakSet +built-ins/WeakSet/no-iterable.js # missing global: WeakSet +built-ins/WeakSet/properties-of-the-weakset-prototype-object.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/adds-object-element.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/returns-this.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/this-not-object-throw-null.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/this-not-object-throw-number.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/this-not-object-throw-string.js # missing global: WeakSet +built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js # missing global: WeakSet +built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/delete-object-entry.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js # missing global: WeakSet +built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/returns-false-when-object-value-not-present.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/returns-true-when-object-value-present.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/this-not-object-throw-null.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/this-not-object-throw-number.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/this-not-object-throw-string.js # missing global: WeakSet +built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js # missing global: WeakSet +built-ins/WeakSet/undefined-newtarget.js # missing global: WeakSet +built-ins/decodeURI/S15.1.3.1_A1.10_T1.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.11_T1.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.11_T2.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.12_T1.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.12_T2.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.12_T3.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.1_T1.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.2_T1.js # wrong result +built-ins/decodeURI/S15.1.3.1_A1.2_T2.js # wrong result +built-ins/decodeURI/S15.1.3.1_A3_T1.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A3_T2.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A3_T3.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A4_T1.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A4_T2.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A4_T3.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A4_T4.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A5.1.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A5.2.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A5.4.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A5.6.js # missing global: decodeURI +built-ins/decodeURI/S15.1.3.1_A5.7.js # missing global: decodeURI +built-ins/decodeURIComponent/S15.1.3.2_A1.10_T1.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.11_T1.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.11_T2.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.12_T1.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.12_T2.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.12_T3.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.1_T1.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.2_T1.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A1.2_T2.js # wrong result +built-ins/decodeURIComponent/S15.1.3.2_A3_T1.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A3_T2.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A3_T3.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A4_T1.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A4_T2.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A4_T3.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A4_T4.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A5.1.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A5.2.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A5.4.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A5.6.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/S15.1.3.2_A5.7.js # missing global: decodeURIComponent +built-ins/decodeURIComponent/throw-URIError.js # missing global: decodeURIComponent +built-ins/encodeURI/S15.1.3.3_A3.1_T1.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A3.2_T1.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A3.2_T2.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A3.2_T3.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A3.3_T1.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A4_T1.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A4_T2.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A4_T3.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A4_T4.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A5.1.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A5.2.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A5.4.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A5.6.js # missing global: encodeURI +built-ins/encodeURI/S15.1.3.3_A5.7.js # missing global: encodeURI +built-ins/encodeURIComponent/S15.1.3.4_A3.1_T1.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A3.2_T1.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A3.2_T2.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A3.2_T3.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A3.3_T1.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A4_T1.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A4_T2.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A4_T3.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A4_T4.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A5.1.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A5.2.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A5.4.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A5.6.js # missing global: encodeURIComponent +built-ins/encodeURIComponent/S15.1.3.4_A5.7.js # missing global: encodeURIComponent +built-ins/global/10.2.1.1.3-4-18-s.js # missing global: undefined +language/arguments-object/10.5-7-b-2-s.js # wrong result +language/arguments-object/10.5-7-b-3-s.js # wrong result +language/arguments-object/10.5-7-b-4-s.js # wrong result +language/arguments-object/10.6-10-c-ii-1-s.js # wrong result +language/arguments-object/S10.6_A5_T4.js # wrong result +language/arguments-object/async-gen-meth-args-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-meth-args-trailing-comma-null.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-meth-args-trailing-comma-single-args.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-meth-args-trailing-comma-spread-operator.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-meth-args-trailing-comma-undefined.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-named-func-expr-args-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-named-func-expr-args-trailing-comma-null.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-named-func-expr-args-trailing-comma-single-args.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-named-func-expr-args-trailing-comma-spread-operator.js # unsupported syntax: async generator functions +language/arguments-object/async-gen-named-func-expr-args-trailing-comma-undefined.js # unsupported syntax: async generator functions +language/arguments-object/cls-decl-async-gen-func-args-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/arguments-object/cls-decl-async-gen-func-args-trailing-comma-null.js # unsupported syntax: async generator functions +language/arguments-object/cls-decl-async-gen-func-args-trailing-comma-single-args.js # unsupported syntax: async generator functions +language/arguments-object/cls-decl-async-gen-func-args-trailing-comma-spread-operator.js # unsupported syntax: async generator functions +language/arguments-object/cls-decl-async-gen-func-args-trailing-comma-undefined.js # unsupported syntax: async generator functions +language/arguments-object/cls-expr-async-gen-func-args-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/arguments-object/cls-expr-async-gen-func-args-trailing-comma-null.js # unsupported syntax: async generator functions +language/arguments-object/cls-expr-async-gen-func-args-trailing-comma-single-args.js # unsupported syntax: async generator functions +language/arguments-object/cls-expr-async-gen-func-args-trailing-comma-spread-operator.js # unsupported syntax: async generator functions +language/arguments-object/cls-expr-async-gen-func-args-trailing-comma-undefined.js # unsupported syntax: async generator functions +language/block-scope/syntax/redeclaration-global/allowed-to-redeclare-function-declaration-with-var.js # spurious parse error: Identifier `…` has already been declared +language/block-scope/syntax/redeclaration-global/allowed-to-redeclare-var-with-function-declaration.js # spurious parse error: Identifier `…` has already been declared +language/destructuring/binding/syntax/destructuring-array-parameters-function-arguments-length.js # unsupported syntax: async generator functions +language/destructuring/binding/syntax/destructuring-object-parameters-function-arguments-length.js # unsupported syntax: async generator functions +language/destructuring/binding/syntax/recursive-array-and-object-patterns.js # spurious parse error: Identifier `…` has already been declared +language/expressions/addition/S11.6.1_A2.2_T2.js # missing global: Date +language/expressions/arrow-function/dflt-params-ref-later.js # error not thrown: ReferenceError +language/expressions/arrow-function/dflt-params-ref-self.js # error not thrown: ReferenceError +language/expressions/arrow-function/lexical-arguments.js # missing global: arguments +language/expressions/assignment/dstr/array-elem-iter-rtrn-close-null.js # error not thrown: TypeError +language/expressions/assignment/dstr/array-elem-iter-rtrn-close.js # wrong result +language/expressions/assignment/dstr/array-elem-trlg-iter-list-rtrn-close-err.js # error not thrown: Test262Error +language/expressions/assignment/dstr/array-elem-trlg-iter-list-rtrn-close-null.js # error not thrown: TypeError +language/expressions/assignment/dstr/array-elem-trlg-iter-list-rtrn-close.js # wrong result +language/expressions/async-arrow-function/dflt-params-ref-later.js # async: wrong result +language/expressions/async-arrow-function/dflt-params-ref-self.js # async: wrong result +language/expressions/async-function/named-dflt-params-ref-later.js # async: wrong result +language/expressions/async-function/named-dflt-params-ref-self.js # async: wrong result +language/expressions/async-function/named-returns-async-arrow-returns-arguments-from-parent-function.js # missing global: arguments +language/expressions/async-function/nameless-dflt-params-ref-later.js # async: wrong result +language/expressions/async-function/nameless-dflt-params-ref-self.js # async: wrong result +language/expressions/async-generator/dflt-params-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-arg-val-not-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-arg-val-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-ref-later.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-ref-prior.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-ref-self.js # unsupported syntax: async generator functions +language/expressions/async-generator/dflt-params-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-init-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/dflt-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-init-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-init-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/named-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-init-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/async-generator/dstr/obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-await-as-yield-operand.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-await-promise-as-yield-operand.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-await-thenable-as-yield-operand.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-yield-as-operand.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-yield-as-statement.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-yield-newline.js # unsupported syntax: async generator functions +language/expressions/async-generator/expression-yield-star-before-newline.js # unsupported syntax: async generator functions +language/expressions/async-generator/generator-created-after-decl-inst.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-arg-val-not-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-arg-val-undefined.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-ref-later.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-ref-prior.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-ref-self.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-dflt-params-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-params-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-params-trailing-comma-single.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next-catch.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-promise-reject-next.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-spread-arr-multiple.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-spread-arr-single.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-spread-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-expr-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-number-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-object-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-string-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-not-callable-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-null-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-number-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-string-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/named-yield-star-getiter-sync-returns-undefined-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/params-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/expressions/async-generator/params-trailing-comma-single.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next-catch.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-promise-reject-next.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-spread-arr-multiple.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-spread-arr-single.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-spread-obj.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-expr-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-not-callable-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-not-callable-number-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-not-callable-object-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-not-callable-string-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-not-callable-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-abrupt.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-null-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-number-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-string-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/async-generator/yield-star-getiter-sync-returns-undefined-throw.js # unsupported syntax: async generator functions +language/expressions/await/async-generator-interleaved.js # unsupported syntax: async generator functions +language/expressions/await/await-in-function.js # spurious parse error: The keyword '…' is reserved +language/expressions/await/await-in-generator.js # spurious parse error: The keyword '…' is reserved +language/expressions/await/for-await-of-interleaved.js # unsupported syntax: async generator functions +language/expressions/compound-assignment/S11.13.2_A7.10_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.11_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.1_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.2_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.3_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.4_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.5_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.6_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.7_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.8_T4.js # wrong result +language/expressions/compound-assignment/S11.13.2_A7.9_T4.js # wrong result +language/expressions/delete/11.4.1-4.a-17.js # wrong result +language/expressions/delete/11.4.1-4.a-9-s.js # error not thrown: TypeError +language/expressions/delete/11.4.1-5-a-28-s.js # missing global: RegExp +language/expressions/function/dflt-params-ref-later.js # error not thrown: ReferenceError +language/expressions/function/dflt-params-ref-self.js # error not thrown: ReferenceError +language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-arrow.js # error not thrown: TypeError +language/expressions/function/named-strict-error-reassign-fn-name-in-body.js # error not thrown: TypeError +language/expressions/function/params-dflt-args-unmapped.js # wrong result +language/expressions/function/scope-name-var-open-strict.js # error not thrown: TypeError +language/expressions/generators/dflt-params-ref-later.js # error not thrown: ReferenceError +language/expressions/generators/dflt-params-ref-self.js # error not thrown: ReferenceError +language/expressions/generators/has-instance.js # uncaught TypeError: Function has non-object prototype in instanceof check +language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-arrow.js # error not thrown: TypeError +language/expressions/generators/named-strict-error-reassign-fn-name-in-body.js # error not thrown: TypeError +language/expressions/generators/params-dflt-args-unmapped.js # wrong result +language/expressions/generators/prototype-typeof.js # wrong result +language/expressions/generators/prototype-uniqueness.js # wrong result +language/expressions/generators/prototype-value.js # wrong result +language/expressions/generators/scope-name-var-open-strict.js # error not thrown: TypeError +language/expressions/greater-than-or-equal/S11.8.4_A4.12_T1.js # wrong result +language/expressions/greater-than/S11.8.2_A4.12_T1.js # wrong result +language/expressions/less-than-or-equal/S11.8.3_A4.12_T1.js # wrong result +language/expressions/less-than/S11.8.1_A4.12_T1.js # wrong result +language/expressions/object/computed-property-name-topropertykey-before-value-evaluation.js # wrong result +language/expressions/object/dstr/async-gen-meth-ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-close.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-name-iter-val.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-init-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-init-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-init-undefined.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-abrupt.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-not-undefined.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-undefined.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-later.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-prior.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-self.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-dflt-params-trailing-comma.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-single.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-spread-obj.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-expr-abrupt.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-number-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-object-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-string-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-abrupt.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-boolean-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-null-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-number-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-string-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-symbol-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-undefined-throw.js # unsupported syntax: async generator functions +language/expressions/object/method-definition/async-meth-dflt-params-ref-later.js # async: wrong result +language/expressions/object/method-definition/async-meth-dflt-params-ref-self.js # async: wrong result +language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js # missing global: arguments +language/expressions/object/method-definition/gen-meth-dflt-params-ref-later.js # error not thrown: ReferenceError +language/expressions/object/method-definition/gen-meth-dflt-params-ref-self.js # error not thrown: ReferenceError +language/expressions/object/method-definition/meth-dflt-params-ref-later.js # error not thrown: ReferenceError +language/expressions/object/method-definition/meth-dflt-params-ref-self.js # error not thrown: ReferenceError +language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js # wrong result +language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js # wrong result +language/expressions/postfix-decrement/11.3.2-2-3-s.js # wrong result +language/expressions/postfix-decrement/S11.3.2_A6_T3.js # wrong result +language/expressions/postfix-increment/11.3.1-2-3.js # wrong result +language/expressions/postfix-increment/S11.3.1_A6_T3.js # wrong result +language/expressions/prefix-decrement/11.4.5-2-3-s.js # wrong result +language/expressions/prefix-decrement/S11.4.5_A6_T3.js # wrong result +language/expressions/prefix-increment/11.4.4-2-3-s.js # wrong result +language/expressions/prefix-increment/S11.4.4_A6_T3.js # wrong result +language/expressions/property-accessors/S11.2.1_A4_T9.js # missing global: Date +language/expressions/tagged-template/cache-different-functions-same-site.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-differing-expressions.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-differing-raw-strings.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-differing-string-count.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-identical-source.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-same-site-top-level.js # unsupported syntax: tagged templates +language/expressions/tagged-template/cache-same-site.js # unsupported syntax: tagged templates +language/expressions/tagged-template/call-expression-argument-list-evaluation.js # unsupported syntax: tagged templates +language/expressions/tagged-template/call-expression-context-strict.js # unsupported syntax: tagged templates +language/expressions/tagged-template/chained-application.js # unsupported syntax: tagged templates +language/expressions/tagged-template/invalid-escape-sequences.js # unsupported syntax: tagged templates +language/expressions/tagged-template/member-expression-argument-list-evaluation.js # unsupported syntax: tagged templates +language/expressions/tagged-template/member-expression-context.js # unsupported syntax: tagged templates +language/expressions/tagged-template/template-object-template-map.js # unsupported syntax: tagged templates +language/expressions/template-literal/evaluation-order.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-character-escape-sequence.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-hex-escape-sequence.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-line-continuation.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-line-terminator-sequence.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-no-substitution.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-null-character-escape-sequence.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-template-character.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-template-characters.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-template-head.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-template-middle.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-template-tail.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-utf16-escape-sequence.js # unsupported syntax: tagged templates +language/expressions/template-literal/tv-zwnbsp.js # unsupported syntax: tagged templates +language/expressions/typeof/null.js # missing global: RegExp +language/expressions/typeof/string.js # missing global: Date +language/expressions/yield/rhs-regexp.js # unsupported syntax: regular expressions +language/expressions/yield/star-rhs-iter-nrml-next-invoke.js # wrong result +language/expressions/yield/star-rhs-iter-nrml-res-value-final.js # wrong result +language/expressions/yield/star-rhs-iter-rtrn-res-value-final.js # wrong result +language/expressions/yield/star-rhs-iter-rtrn-rtrn-call-err.js # wrong result +language/expressions/yield/star-rhs-iter-rtrn-rtrn-call-non-obj.js # wrong result +language/expressions/yield/star-rhs-iter-rtrn-rtrn-invoke.js # wrong result +language/expressions/yield/star-rhs-iter-thrw-res-value-final.js # uncaught N +language/expressions/yield/star-rhs-iter-thrw-thrw-call-err.js # wrong result +language/expressions/yield/star-rhs-iter-thrw-thrw-call-non-obj.js # wrong result +language/expressions/yield/star-rhs-iter-thrw-thrw-invoke.js # uncaught N +language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-err.js # wrong result +language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-call-non-obj.js # wrong result +language/global-code/decl-func-dup.js # spurious parse error: Identifier `…` has already been declared +language/global-code/export.js # unsupported syntax: `export` +language/global-code/import.js # unsupported syntax: `import` +language/literals/null/S7.8.1_A1_T2.js # missing global: RegExp +language/literals/regexp/7.8.5-2gs.js # missing global: RegExp +language/literals/regexp/S7.8.5_A1.1_T1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A1.4_T1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A2.1_T1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A2.4_T1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T2.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T3.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T4.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T5.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A3.1_T6.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A4.1.js # unsupported syntax: regular expressions +language/literals/regexp/S7.8.5_A4.2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-add-remove-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-add-remove-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-add-remove-multi-duplicate.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s-escape.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-both-empty.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-no-colon-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-no-colon-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-no-colon-3.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-arbitrary.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-d.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-g.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-flag.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-u.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-uppercase-I.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-y.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnbsp.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s-escape.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-d.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-g.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-u.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-y.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-code-point-repeat-i-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-code-point-repeat-i-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-arbitrary.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-combining-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-combining-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-combining-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-d.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-g.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-non-display-1.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-non-display-2.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-non-flag.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-u.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-uppercase-I.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-y.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-zwj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-zwnbsp.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-other-code-point-zwnj.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-case-fold-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-unicode-escape-i.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-unicode-escape-m.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-modifiers-should-not-unicode-escape-s.js # unsupported syntax: regular expressions +language/literals/regexp/early-err-pattern.js # unsupported syntax: regular expressions +language/literals/regexp/inequality.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-braced-quantifier-exact.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-braced-quantifier-lower.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-braced-quantifier-range.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-optional-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-optional-negative-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-range-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/invalid-range-negative-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/mongolian-vowel-separator.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/forward-reference.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-2.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-3-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-3.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-4-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-4.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-5.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname-without-group-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-dangling-groupname.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-2.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-duplicate-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-duplicate-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-empty-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-empty-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-identity-escape-in-capture-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-2-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-2.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-3-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-3.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-4.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-5.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-6.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-2-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-3-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname-without-group-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-incomplete-groupname.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier-4.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-2.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-4.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-5.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-7.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-8.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-9-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-numeric-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-numeric-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-punctuator-starting-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-punctuator-within-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-unterminated-groupspecifier-u.js # unsupported syntax: regular expressions +language/literals/regexp/named-groups/invalid-unterminated-groupspecifier.js # unsupported syntax: regular expressions +language/literals/regexp/u-astral-char-class-invert.js # unsupported syntax: regular expressions +language/literals/regexp/u-case-mapping.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-class-escape.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-extended-pattern-char.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-identity-escape.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-legacy-octal-escape.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-ab.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-b.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-non-empty-class-ranges.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-oob-decimal-escape.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-optional-lookahead.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-optional-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-optional-negative-lookahead.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-optional-negative-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-range-lookahead.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-range-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-range-negative-lookahead.js # unsupported syntax: regular expressions +language/literals/regexp/u-invalid-range-negative-lookbehind.js # unsupported syntax: regular expressions +language/literals/regexp/u-null-character-escape.js # unsupported syntax: regular expressions +language/literals/regexp/u-surrogate-pairs-atom-dot.js # unsupported syntax: regular expressions +language/literals/regexp/u-surrogate-pairs-atom-escape-char-class.js # unsupported syntax: regular expressions +language/literals/regexp/u-surrogate-pairs-atom-escape-decimal.js # unsupported syntax: regular expressions +language/literals/regexp/u-surrogate-pairs.js # unsupported syntax: regular expressions +language/literals/regexp/u-unicode-esc-bounds.js # unsupported syntax: regular expressions +language/literals/regexp/u-unicode-esc-non-hex.js # unsupported syntax: regular expressions +language/literals/regexp/u-unicode-esc.js # unsupported syntax: regular expressions +language/literals/regexp/unicode-escape-nls-err.js # unsupported syntax: regular expressions +language/literals/regexp/y-assertion-start.js # unsupported syntax: regular expressions +language/reserved-words/await-script.js # spurious parse error: Cannot use `…` as an identifier in an async context +language/reserved-words/unreserved-words.js # spurious parse error: Identifier `…` has already been declared +language/statementList/block-regexp-literal-flags.js # unsupported syntax: regular expressions +language/statementList/block-regexp-literal.js # unsupported syntax: regular expressions +language/statementList/block-with-statment-regexp-literal-flags.js # unsupported syntax: regular expressions +language/statementList/block-with-statment-regexp-literal.js # unsupported syntax: regular expressions +language/statementList/fn-regexp-literal-flags.js # unsupported syntax: regular expressions +language/statementList/fn-regexp-literal.js # unsupported syntax: regular expressions +language/statements/async-function/dflt-params-ref-later.js # async: wrong result +language/statements/async-function/dflt-params-ref-self.js # async: wrong result +language/statements/async-function/evaluation-unmapped-arguments.js # async: wrong result +language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js # missing global: arguments +language/statements/async-generator/dflt-params-abrupt.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-arg-val-not-undefined.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-arg-val-undefined.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-ref-later.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-ref-prior.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-ref-self.js # unsupported syntax: async generator functions +language/statements/async-generator/dflt-params-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-direct.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-init-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-init-undefined.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/dflt-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-init-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-init-undefined.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/statements/async-generator/dstr/obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/async-generator/generator-created-after-decl-inst.js # unsupported syntax: async generator functions +language/statements/async-generator/params-trailing-comma-multiple.js # unsupported syntax: async generator functions +language/statements/async-generator/params-trailing-comma-single.js # unsupported syntax: async generator functions +language/statements/async-generator/return-undefined-implicit-and-explicit.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next-catch.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next-yield-star-async-iterator.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-promise-reject-next.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-spread-arr-multiple.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-spread-arr-single.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-spread-obj.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-expr-abrupt.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-not-callable-boolean-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-not-callable-number-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-not-callable-object-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-not-callable-string-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-not-callable-symbol-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-abrupt.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-boolean-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-null-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-number-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-string-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-symbol-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-getiter-sync-returns-undefined-throw.js # unsupported syntax: async generator functions +language/statements/async-generator/yield-star-return-missing-value-is-awaited.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-func-decl-dstr-array-elem-init-assignment.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-init-evaluation.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-init-in.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-init-order.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-iter-nrml-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-own.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-own.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-put-const.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-strict.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-target-identifier.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elision-val-array.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-elision-val-string.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-empty-val-array.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-empty-val-string.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-after-element.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-after-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-iteration.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-own.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-own.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-empty-bool.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-empty-num.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-empty-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-empty-string.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-first.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-last.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-lone.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-middle.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-trlng.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-missing.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-truthy.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-evaluation.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-in.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-id-init-order.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-missing.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-truthy.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-evaluation.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-in.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-first.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-last.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-lone.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-middle.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-trlng.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-name-evaluation.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-order.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-rest-empty-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-rest-number.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-decl-dstr-obj-rest-str-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-init-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-init-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-init-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-init.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: `for await` +language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj.js # unsupported syntax: `for await` +language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-assignment.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-evaluation.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-in.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-order.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-get-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-thrw-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-own.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-own.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-const.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-strict.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-thrw-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-array.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-string.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-empty-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-array.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-string.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-element.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-iter-nrml-close-skip.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-iteration.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-lref.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-own.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-own.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-array-rest-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-empty-bool.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-empty-num.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-empty-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-empty-string.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-first.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-last.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-lone.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-middle.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-trlng.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-missing.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-truthy.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-evaluation.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-in.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-order.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-missing.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-truthy.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-evaluation.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-in.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-target-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-first.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-last.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-lone.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-middle.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-trlng.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-name-evaluation.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj-yield-expr.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-order.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-rest-empty-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-rest-number.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-decl-dstr-obj-rest-str-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-arrow.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-cover.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-fn.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-gen.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-skipped.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-trailing-comma.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-init.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js # unsupported syntax: async generator functions +language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj.js # unsupported syntax: async generator functions +language/statements/for-await-of/head-lhs-async.js # unsupported syntax: `for await` +language/statements/for-await-of/iterator-close-throw-get-method-non-callable.js # unsupported syntax: `for await` +language/statements/for-in/head-const-bound-names-fordecl-tdz.js # error not thrown: ReferenceError +language/statements/for-in/head-let-bound-names-fordecl-tdz.js # error not thrown: ReferenceError +language/statements/for-in/scope-body-lex-open.js # error not thrown: ReferenceError +language/statements/for-in/scope-head-lex-close.js # error not thrown: ReferenceError +language/statements/for-in/scope-head-lex-open.js # error not thrown: ReferenceError +language/statements/for-of/dstr/array-elem-iter-rtrn-close-null.js # error not thrown: TypeError +language/statements/for-of/dstr/array-elem-iter-rtrn-close.js # wrong result +language/statements/for-of/dstr/array-elem-trlg-iter-list-rtrn-close-err.js # error not thrown: Test262Error +language/statements/for-of/dstr/array-elem-trlg-iter-list-rtrn-close-null.js # error not thrown: TypeError +language/statements/for-of/dstr/array-elem-trlg-iter-list-rtrn-close.js # wrong result +language/statements/for-of/head-const-bound-names-fordecl-tdz.js # error not thrown: ReferenceError +language/statements/for-of/head-let-bound-names-fordecl-tdz.js # error not thrown: ReferenceError +language/statements/for-of/iterator-close-non-throw-get-method-non-callable.js # error not thrown: TypeError +language/statements/for-of/iterator-next-error.js # wrong result +language/statements/for-of/scope-body-lex-open.js # error not thrown: ReferenceError +language/statements/for-of/scope-head-lex-close.js # error not thrown: ReferenceError +language/statements/for-of/scope-head-lex-open.js # error not thrown: ReferenceError +language/statements/for/scope-body-lex-open.js # wrong result +language/statements/function/S13.2.1_A6_T3.js # spurious parse error: Identifier `…` has already been declared +language/statements/function/S13_A11_T4.js # wrong result +language/statements/function/S13_A13_T1.js # wrong result +language/statements/function/S13_A13_T2.js # wrong result +language/statements/function/S13_A13_T3.js # wrong result +language/statements/function/S13_A19_T1.js # spurious parse error: Identifier `…` has already been declared +language/statements/function/S13_A6_T1.js # spurious parse error: Identifier `…` has already been declared +language/statements/function/S14_A5_T1.js # spurious parse error: Identifier `…` has already been declared +language/statements/function/S14_A5_T2.js # spurious parse error: Identifier `…` has already been declared +language/statements/function/dflt-params-ref-later.js # error not thrown: ReferenceError +language/statements/function/dflt-params-ref-self.js # error not thrown: ReferenceError +language/statements/function/params-dflt-args-unmapped.js # wrong result +language/statements/generators/dflt-params-ref-later.js # error not thrown: ReferenceError +language/statements/generators/dflt-params-ref-self.js # error not thrown: ReferenceError +language/statements/generators/has-instance.js # uncaught TypeError: Function has non-object prototype in instanceof check +language/statements/generators/params-dflt-args-unmapped.js # wrong result +language/statements/generators/prototype-typeof.js # wrong result +language/statements/generators/prototype-uniqueness.js # wrong result +language/statements/generators/prototype-value.js # wrong result +language/statements/labeled/value-await-non-module-escaped.js # spurious parse error: Keywords cannot contain escape characters +language/white-space/after-regular-expression-literal-carriage-return.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-em-quad.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-em-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-en-quad.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-en-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-figure-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-form-feed.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-four-per-em-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-hair-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-ideographic-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-line-feed.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-line-separator.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-medium-mathematical-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-nbsp.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-nnbsp.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-ogham-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-paragraph-separator.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-punctuation-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-six-per-em-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-tab.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-thin-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-three-per-em-space.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-vertical-tab.js # unsupported syntax: regular expressions +language/white-space/after-regular-expression-literal-zwnbsp.js # unsupported syntax: regular expressions diff --git a/packages/codemode-rust/test262/src/main.rs b/packages/codemode-rust/test262/src/main.rs new file mode 100644 index 000000000000..e04be42d45a4 --- /dev/null +++ b/packages/codemode-rust/test262/src/main.rs @@ -0,0 +1,587 @@ +//! Runs the reference's pinned test262 file set through PsychoScript with the reference harness semantics +//! (`packages/codemode/test/test262/run.ts`) and checks the outcome against `test262/rust-skipped.txt`. +//! +//! Usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE [--write] [--jobs N] [prefix] +//! +//! - `--root` is the synced tree holding `built-ins/` and `language/`; see `test262/run.sh`. +//! - Files in the reference's `skipped.txt` are gaps of the reference too: they run, but only for a count. +//! - Every other file must pass unless `--skipped` lists it, and every listed file must still fail. +//! - `--write` rewrites `--skipped` from the current failures instead of checking it. +//! +//! Each file runs in a worker process, so an abort or a hang in one file is reported as that file's failure. + +use std::collections::{BTreeMap, BTreeSet, VecDeque}; +use std::io::{BufRead, BufReader, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Child, ChildStdin, ChildStdout, Command, ExitCode, Stdio}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +use psychoscript::DiagnosticKind; + +/// The reference's per-file limit. +const TIMEOUT_MS: u64 = 5000; +/// A file still running this long after its own timeout is a hang the interpreter cannot interrupt. +const HANG: Duration = Duration::from_secs(30); + +const HEADER: &str = "\ +test262 files that fail here but pass in the reference: the parity gap list. Generated by +`bash test262/run.sh --write`; CI fails when an unlisted file fails or a listed file passes. +Fix gaps to shrink it; do not add entries. +"; + +const PRELUDE: &str = concat!( + "function assert(mustBeTrue, message) { $assert(mustBeTrue, message) } ", + "assert.sameValue = $assert.sameValue; assert.notSameValue = $assert.notSameValue; ", + "assert.compareArray = $assert.compareArray; ", + "assert.throws = function (expected, func, message) { ", + "try { func() } catch (thrown) { $assert.thrown(expected, message, thrown); return } ", + "$assert.notThrown(expected, message) };", +); + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + if args.first().map(String::as_str) == Some("--worker") { + return worker(Path::new(args.get(1).map_or(".", String::as_str))); + } + let mut root = None; + let mut reference_skipped = None; + let mut skipped = None; + let mut write = false; + let mut jobs = std::thread::available_parallelism().map_or(4, |n| n.get()); + let mut prefix = String::new(); + let mut it = args.into_iter(); + while let Some(arg) = it.next() { + match arg.as_str() { + "--root" => root = it.next().map(PathBuf::from), + "--reference-skipped" => reference_skipped = it.next().map(PathBuf::from), + "--skipped" => skipped = it.next().map(PathBuf::from), + "--write" => write = true, + "--jobs" => jobs = it.next().and_then(|n| n.parse().ok()).unwrap_or(jobs), + p if !p.starts_with("--") => prefix = p.to_owned(), + other => return usage(&format!("unknown argument {other}")), + } + } + let (Some(root), Some(reference_skipped), Some(skipped)) = (root, reference_skipped, skipped) + else { + return usage("--root, --reference-skipped and --skipped are required"); + }; + if write && !prefix.is_empty() { + return usage("--write rewrites the whole list, so it takes no prefix"); + } + + let reference = read_list(&reference_skipped); + let listed = read_list(&skipped); + let mut files = Vec::new(); + for dir in ["built-ins", "language"] { + collect(&root, &root.join(dir), &mut files); + } + files.sort(); + if files.is_empty() { + eprintln!( + "no test262 files under {}; run test262/run.sh", + root.display() + ); + return ExitCode::FAILURE; + } + let in_scope: BTreeSet = files + .iter() + .filter(|f| !reference.contains_key(*f)) + .cloned() + .collect(); + // The reference's own skipped files run too, only to report how many pass here. + let queue: VecDeque = files + .iter() + .filter(|f| f.starts_with(&prefix)) + .cloned() + .collect(); + let started = Instant::now(); + let mut results = run_all(&root, queue, jobs.max(1)); + let reference_gaps: Vec = results + .keys() + .filter(|f| !in_scope.contains(*f)) + .cloned() + .collect(); + let reference_fixed = reference_gaps + .iter() + .filter(|f| results.remove(*f).is_some_and(|r| r.is_ok())) + .count(); + let total = results.len(); + + let failures: BTreeMap<&String, &String> = results + .iter() + .filter_map(|(f, r)| r.as_ref().err().map(|reason| (f, reason))) + .collect(); + println!( + "{} pass, {} fail of {total} files in {:.1} s", + total - failures.len(), + failures.len(), + started.elapsed().as_secs_f64(), + ); + println!( + "{reference_fixed} of the {} files in the reference's skipped.txt pass here too; they are not checked", + reference_gaps.len() + ); + let mut counts: BTreeMap = BTreeMap::new(); + for reason in failures.values() { + *counts.entry(category(reason)).or_default() += 1; + } + let mut counts: Vec<_> = counts.into_iter().collect(); + counts.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); + for (category, count) in &counts { + println!("{count:>6} {category}"); + } + + if write { + let lines: String = HEADER + .lines() + .map(|line| format!("# {line}\n").replace("# \n", "#\n")) + .chain( + failures + .iter() + .map(|(file, reason)| format!("{file} # {}\n", category(reason))), + ) + .collect(); + if let Err(e) = std::fs::write(&skipped, lines) { + eprintln!("{}: {e}", skipped.display()); + return ExitCode::FAILURE; + } + println!("wrote {} entries to {}", failures.len(), skipped.display()); + return ExitCode::SUCCESS; + } + + let new: Vec<_> = failures + .iter() + .filter(|(file, _)| !listed.contains_key(**file)) + .collect(); + let fixed: Vec<_> = results + .iter() + .filter(|(file, r)| r.is_ok() && listed.contains_key(*file)) + .map(|(file, _)| file) + .collect(); + let gone: Vec<_> = if prefix.is_empty() { + listed.keys().filter(|f| !in_scope.contains(*f)).collect() + } else { + Vec::new() + }; + for (file, reason) in &new { + println!("FAIL {file} # {reason}"); + } + for file in &fixed { + println!("PASSES NOW, remove it from the list {file}"); + } + for file in &gone { + println!("NOT IN THE FILE SET, remove it from the list {file}"); + } + if new.is_empty() && fixed.is_empty() && gone.is_empty() { + println!("every failure is listed in {}", skipped.display()); + return ExitCode::SUCCESS; + } + println!( + "{} unlisted failures, {} listed files that pass, {} listed files not in the set", + new.len(), + fixed.len(), + gone.len() + ); + ExitCode::FAILURE +} + +fn usage(problem: &str) -> ExitCode { + eprintln!("{problem}"); + eprintln!( + "usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE [--write] [--jobs N] [prefix]" + ); + ExitCode::FAILURE +} + +/// A `path # reason` list; lines without `#` are ignored, as in the reference. +fn read_list(path: &Path) -> BTreeMap { + std::fs::read_to_string(path) + .unwrap_or_default() + .lines() + .filter(|line| !line.starts_with('#')) + .filter_map(|line| { + let (file, reason) = line.split_once('#')?; + Some((file.trim().to_owned(), reason.trim().to_owned())) + }) + .collect() +} + +fn collect(root: &Path, dir: &Path, out: &mut Vec) { + let Ok(entries) = std::fs::read_dir(dir) else { + return; + }; + for entry in entries.flatten() { + let path = entry.path(); + if path.is_dir() { + collect(root, &path, out); + } else if path.extension().is_some_and(|e| e == "js") + && let Ok(rel) = path.strip_prefix(root) + { + out.push(rel.to_string_lossy().replace('\\', "/")); + } + } +} + +// ---------- parent: worker pool ---------- + +type Results = BTreeMap>; + +struct Worker { + child: Child, + stdin: ChildStdin, + stdout: BufReader, +} + +fn spawn(root: &Path) -> Option { + let exe = std::env::current_exe().ok()?; + let mut child = Command::new(exe) + .arg("--worker") + .arg(root) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .ok()?; + let stdin = child.stdin.take()?; + let stdout = BufReader::new(child.stdout.take()?); + Some(Worker { + child, + stdin, + stdout, + }) +} + +fn run_all(root: &Path, queue: VecDeque, jobs: usize) -> Results { + let queue = Arc::new(Mutex::new(queue)); + let results = Arc::new(Mutex::new(Results::new())); + std::thread::scope(|s| { + for _ in 0..jobs { + let (queue, results) = (queue.clone(), results.clone()); + s.spawn(move || { + let mut worker: Option = None; + // A function call, so the queue lock is released before the file runs. + let next = || queue.lock().ok().and_then(|mut q| q.pop_front()); + while let Some(file) = next() { + let outcome = run_in_worker(root, &mut worker, &file); + if let Ok(mut r) = results.lock() { + r.insert(file, outcome); + } + } + if let Some(mut w) = worker { + drop(w.stdin); + let _ = w.child.wait(); + } + }); + } + }); + Arc::try_unwrap(results) + .ok() + .and_then(|m| m.into_inner().ok()) + .unwrap_or_default() +} + +fn run_in_worker(root: &Path, slot: &mut Option, file: &str) -> Result<(), String> { + for _ in 0..2 { + if slot.is_none() { + *slot = spawn(root); + } + let Some(w) = slot.as_mut() else { + return Err("crash: cannot start a worker".into()); + }; + if writeln!(w.stdin, "{file}") + .and_then(|_| w.stdin.flush()) + .is_err() + { + if let Some(mut w) = slot.take() { + let _ = w.child.wait(); + } + continue; + } + let mut line = String::new(); + let read = w.stdout.read_line(&mut line); + if matches!(read, Ok(n) if n > 0) { + let line = line.trim_end(); + let (status, reason) = line.split_once('\t').unwrap_or((line, "")); + if status == "hang" + && let Some(mut w) = slot.take() + { + let _ = w.child.wait(); + } + return if status == "pass" { + Ok(()) + } else { + Err(reason.to_owned()) + }; + } + let status = slot.take().and_then(|mut w| w.child.wait().ok()); + let how = status.map_or("unknown status".to_owned(), |s| s.to_string()); + return Err(format!("crash: the worker process died ({how})")); + } + Err("crash: cannot reach a worker".into()) +} + +// ---------- worker ---------- + +fn worker(root: &Path) -> ExitCode { + let current: Arc>> = Arc::new(Mutex::new(None)); + let watched = current.clone(); + std::thread::spawn(move || { + loop { + std::thread::sleep(Duration::from_millis(500)); + let started = watched.lock().ok().and_then(|c| *c); + if started.is_some_and(|t| t.elapsed() > HANG + Duration::from_millis(TIMEOUT_MS)) { + let mut out = std::io::stdout().lock(); + let _ = writeln!(out, "hang\thang: no result after {} s", HANG.as_secs()); + let _ = out.flush(); + std::process::exit(3); + } + } + }); + let stdin = std::io::stdin(); + for line in stdin.lock().lines() { + let Ok(file) = line else { break }; + if let Ok(mut c) = current.lock() { + *c = Some(Instant::now()); + } + let outcome = run_file(&root.join(&file)); + let mut out = std::io::stdout().lock(); + if let Ok(mut c) = current.lock() { + *c = None; + } + let written = match outcome { + Ok(()) => writeln!(out, "pass"), + Err(reason) => writeln!(out, "fail\t{}", printable(&reason)), + }; + if written.and_then(|_| out.flush()).is_err() { + break; + } + } + ExitCode::SUCCESS +} + +/// A reason on one line of printable text. +fn printable(reason: &str) -> String { + reason + .chars() + .map(|c| match c { + '\n' | '\r' | '\t' => " ".to_owned(), + c if c.is_control() => c.escape_unicode().to_string(), + c => c.to_string(), + }) + .collect() +} + +#[derive(Default)] +struct Frontmatter { + flags: Vec, + negative: Option<(String, String)>, +} + +/// The `flags` and `negative` keys of a test262 YAML frontmatter, in the shapes test262 writes them. +fn frontmatter(source: &str) -> Frontmatter { + let mut meta = Frontmatter::default(); + let Some(start) = source.find("/*---") else { + return meta; + }; + let body = &source[start + 5..]; + let body = &body[..body.find("---*/").unwrap_or(body.len())]; + let mut key = ""; + let (mut phase, mut kind) = (None, None); + for line in body.lines() { + let indented = line.starts_with([' ', '\t']); + let line = line.trim(); + if line.is_empty() || line.starts_with('#') { + continue; + } + if !indented { + let (k, v) = line.split_once(':').unwrap_or((line, "")); + key = k.trim(); + let v = v.trim(); + if key == "flags" + && let Some(list) = v.strip_prefix('[').and_then(|v| v.strip_suffix(']')) + { + meta.flags + .extend(list.split(',').map(|f| f.trim().to_owned())); + } + continue; + } + match key { + "flags" => { + if let Some(f) = line.strip_prefix('-') { + meta.flags.push(f.trim().to_owned()); + } + } + "negative" => { + if let Some((k, v)) = line.split_once(':') { + match k.trim() { + "phase" => phase = Some(v.trim().to_owned()), + "type" => kind = Some(v.trim().to_owned()), + _ => {} + } + } + } + _ => {} + } + } + if let (Some(phase), Some(kind)) = (phase, kind) { + meta.negative = Some((phase, kind)); + } + meta +} + +fn kind_name(kind: DiagnosticKind) -> &'static str { + match kind { + DiagnosticKind::ParseError => "ParseError", + DiagnosticKind::UnsupportedSyntax => "UnsupportedSyntax", + DiagnosticKind::UnknownTool => "UnknownTool", + DiagnosticKind::InvalidDataValue => "InvalidDataValue", + DiagnosticKind::ToolCallLimitExceeded => "ToolCallLimitExceeded", + DiagnosticKind::TimeoutExceeded => "TimeoutExceeded", + DiagnosticKind::ToolFailure => "ToolFailure", + DiagnosticKind::ExecutionFailure => "ExecutionFailure", + } +} + +/// One file, with the reference's semantics: strict mode, the prelude on the directive's line, the job queue +/// drained for async tests, and negative tests judged by phase. +fn run_file(path: &Path) -> Result<(), String> { + let source = std::fs::read_to_string(path).map_err(|e| format!("read: {e}"))?; + let meta = frontmatter(&source); + let is_async = meta.flags.iter().any(|f| f == "async"); + let drain = if is_async { + "\nfor (let i = 0; i < 100; i++) await null" + } else { + "" + }; + let code = format!("\"use strict\"; {PRELUDE}\n{source}{drain}"); + let run = psychoscript::test262::run(&code, TIMEOUT_MS); + if let Some((phase, kind)) = &meta.negative { + return match &run.result { + Ok(()) => Err(format!("expected {kind} but completed")), + Err(_) if phase == "runtime" => Ok(()), + Err(d) if d.kind == DiagnosticKind::ParseError => Ok(()), + Err(d) => Err(format!( + "expected {kind} but got {}: {}", + kind_name(d.kind), + d.message + )), + }; + } + if let Err(d) = &run.result { + return Err(format!("{}: {}", kind_name(d.kind), d.message)); + } + if !is_async { + return Ok(()); + } + match run.done { + None => Err("$DONE was never called".into()), + Some(Some(error)) => Err(format!("$DONE: {error}")), + Some(None) => Ok(()), + } +} + +/// A short, stable reason category for the gap list, from a failure message. +fn category(reason: &str) -> String { + let unsupported = |r: &str| { + let r = r.split_once("UnsupportedSyntax: ")?.1; + Some(format!( + "unsupported syntax: {}", + r.split(" is not supported").next()?.to_lowercase() + )) + }; + if let Some(c) = unsupported(reason) { + return c; + } + if let Some(rest) = reason.split("Unknown identifier '").nth(1) { + return format!("missing global: {}", rest.split('\'').next().unwrap_or("")); + } + if reason.starts_with("crash:") || reason.starts_with("hang:") { + return reason.split(" (").next().unwrap_or(reason).to_owned(); + } + if reason.contains("Internal interpreter error") { + return "interpreter panic".into(); + } + if let Some(rest) = reason.strip_prefix("expected ") { + let kind = rest.split(' ').next().unwrap_or(""); + if rest.ends_with("but completed") { + return format!("negative test completed: no {kind}"); + } + let got = rest.split(" but got ").nth(1).unwrap_or(""); + return format!( + "negative test: {} instead of a parse error", + got.split(':').next().unwrap_or(got) + ); + } + if reason == "$DONE was never called" { + return "async: $DONE never called".into(); + } + let (asynchronous, body) = match reason.strip_prefix("$DONE: ") { + Some(body) => (true, body), + None => (false, reason), + }; + let body = body + .trim_start_matches("ExecutionFailure: ") + .trim_start_matches("Uncaught: "); + let category = if let Some((_, rest)) = body.split_once("Expected a ") + && let Some((expected, rest)) = rest.split_once(" but got a ") + { + let actual = rest.split(' ').next().unwrap_or(rest); + format!("wrong error type: {actual} instead of {expected}") + } else if let Some((_, rest)) = body.split_once("Expected a ") + && rest.contains("to be thrown but no exception was thrown") + { + format!( + "error not thrown: {}", + rest.split(' ').next().unwrap_or(rest) + ) + } else if body.starts_with("Test262Error") || body.starts_with('"') { + "wrong result".into() + } else if let Some(message) = body.strip_prefix("ParseError: ") { + format!("spurious parse error: {}", normalize(message)) + } else if body.starts_with("TimeoutExceeded") { + "timeout".into() + } else if body.contains(" is not a function") { + "call of a missing method".into() + } else { + format!("uncaught {}", normalize(body)) + }; + if asynchronous { + format!("async: {category}") + } else { + category + } +} + +/// Drops what identifies the test rather than the cause: quoted names, numbers and locations. +fn normalize(message: &str) -> String { + let message = message.trim_start_matches("SyntaxError: "); + let message = message.split(" (line ").next().unwrap_or(message); + let mut out = String::new(); + let mut quote = None; + for c in message.chars() { + match quote { + Some(q) if c == q => { + out.push('…'); + out.push(c); + quote = None; + } + Some(_) => {} + None if matches!(c, '\'' | '`' | '"') => { + out.push(c); + quote = Some(c); + } + None if c.is_ascii_digit() => { + if !out.ends_with('N') { + out.push('N'); + } + } + None => out.push(c), + } + } + let out = out.trim_end_matches('.').to_owned(); + match out.char_indices().nth(80) { + Some((i, _)) => format!("{}…", &out[..i]), + None => out, + } +} From 4bc3e9716498cf5b084db0fda99f78a5873cd812 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 16:44:02 +0100 Subject: [PATCH 003/100] test(codemode): add perturbed variants and a plugin-event benchmark Each bench program gets an equivalent, differently written variant in bench/variants/, run next to its original on both implementations, with the variant / original ratio per side. A plugin-event benchmark runs the conformance reducer with a git.status tool as a 226-byte and a 3 KB source. RESULTS.md labels medians, mins and means, computes speed-ups from medians only, and notes that the reference tools validate through Effect Schema. --- packages/codemode-rust/bench/RESULTS.md | 87 ++++++++++++++----- packages/codemode-rust/bench/compare.sh | 79 +++++++++++++++++ .../bench/plugin/reducer-padded.js | 14 +++ .../codemode-rust/bench/plugin/reducer.js | 2 + packages/codemode-rust/bench/ref/plugin.ts | 60 +++++++++++++ packages/codemode-rust/bench/ref/variants.ts | 53 +++++++++++ packages/codemode-rust/bench/src/main.rs | 75 ++++++++++++++-- .../bench/variants/bench-array-callbacks.js | 19 ++++ .../bench/variants/bench-closure-recursion.js | 5 ++ .../variants/bench-generator-iteration.js | 10 +++ .../bench/variants/bench-json-round-trip.js | 12 +++ .../bench/variants/bench-map-set-ops.js | 20 +++++ .../bench/variants/bench-numeric-loop.js | 9 ++ .../bench/variants/bench-promise-fan-out.js | 8 ++ .../bench/variants/bench-string-building.js | 10 +++ .../bench/variants/bench-tool-fan-out.js | 8 ++ 16 files changed, 442 insertions(+), 29 deletions(-) create mode 100644 packages/codemode-rust/bench/plugin/reducer-padded.js create mode 100644 packages/codemode-rust/bench/plugin/reducer.js create mode 100644 packages/codemode-rust/bench/ref/plugin.ts create mode 100644 packages/codemode-rust/bench/ref/variants.ts create mode 100644 packages/codemode-rust/bench/variants/bench-array-callbacks.js create mode 100644 packages/codemode-rust/bench/variants/bench-closure-recursion.js create mode 100644 packages/codemode-rust/bench/variants/bench-generator-iteration.js create mode 100644 packages/codemode-rust/bench/variants/bench-json-round-trip.js create mode 100644 packages/codemode-rust/bench/variants/bench-map-set-ops.js create mode 100644 packages/codemode-rust/bench/variants/bench-numeric-loop.js create mode 100644 packages/codemode-rust/bench/variants/bench-promise-fan-out.js create mode 100644 packages/codemode-rust/bench/variants/bench-string-building.js create mode 100644 packages/codemode-rust/bench/variants/bench-tool-fan-out.js diff --git a/packages/codemode-rust/bench/RESULTS.md b/packages/codemode-rust/bench/RESULTS.md index c0d11842c63f..69d2b04e8a46 100644 --- a/packages/codemode-rust/bench/RESULTS.md +++ b/packages/codemode-rust/bench/RESULTS.md @@ -2,47 +2,54 @@ Generated by `bench/compare.sh` on 2026-11-17. "n/a" means the Rust side could not run the case. +Columns say whether they are a median, a min or a mean. Every speed-up and ratio is computed from medians only; +mins and means are shown for spread, never compared. + ## Environment - CPU: AMD EPYC 9554P 64-Core Processor, 8 cores, 31 GiB RAM, Linux 6.12.115 -- Reference: anomalyco/opencode 95b0de8aa3154c293bccd7d5b324e2b44dac4ad8, `packages/codemode` -- PsychoScript: 95b0de8aa3154c293bccd7d5b324e2b44dac4ad8 +- Reference: anomalyco/opencode 05e5d37e77aa443beda5b14d6a099fed0936157a, `packages/codemode` +- PsychoScript: 05e5d37e77aa443beda5b14d6a099fed0936157a (with uncommitted changes) - bun 1.4.4; rustc 1.100.0 (0ef1bc386 2026-11-09); cargo 1.100.0 (3acc79c0c 2026-11-05) ## (a) Per-case wall time, 11 iterations after one warm-up | Case | Reference median ms | Reference min ms | Rust median ms | Rust min ms | Median speedup | | -------------------------- | ------------------: | ---------------: | -------------: | ----------: | -------------: | -| numeric loop | 19.8 | 14.4 | 14.2 | 10.0 | 1.4x | -| closure recursion (fib 22) | 5.2 | 4.8 | 4.8 | 3.4 | 1.1x | -| array callbacks (50k) | 87.0 | 84.1 | 24.4 | 23.5 | 3.6x | -| promise fan-out (5k) | 11.8 | 7.5 | 2.8 | 2.8 | 4.2x | -| tool fan-out (1k) | 8.9 | 8.1 | 0.6 | 0.6 | 14.9x | -| JSON round-trip | 52.3 | 48.6 | 23.5 | 23.0 | 2.2x | -| generator iteration | 5.5 | 5.0 | 6.4 | 4.6 | 0.9x | -| string building | 18.4 | 15.8 | 11.6 | 7.3 | 1.6x | -| Map/Set ops | 15.9 | 13.8 | 13.5 | 13.2 | 1.2x | +| numeric loop | 17.2 | 14.0 | 9.6 | 9.5 | 1.8x | +| closure recursion (fib 22) | 4.5 | 4.3 | 5.0 | 3.8 | 0.9x | +| array callbacks (50k) | 79.7 | 75.3 | 25.8 | 24.3 | 3.1x | +| promise fan-out (5k) | 10.2 | 7.4 | 2.7 | 2.6 | 3.8x | +| tool fan-out (1k) ¹ | 8.3 | 7.6 | 1.1 | 1.0 | 7.8x | +| JSON round-trip | 51.6 | 47.2 | 23.2 | 22.6 | 2.2x | +| generator iteration | 5.3 | 5.1 | 4.4 | 4.3 | 1.2x | +| string building | 18.2 | 15.4 | 8.4 | 7.3 | 2.2x | +| Map/Set ops | 15.3 | 13.2 | 13.3 | 13.0 | 1.2x | + +¹ Not like for like yet: the reference `echo` tool decodes its input and output through Effect Schema +(`{ id: number }` in, `number` out), and the Rust tools do not validate. Once the Rust host API takes tool schemas, +`tools()` in `bench/src/main.rs` registers the equivalent schemas, and this row compares the same work. ## (b) Cold start: process start to the result of `return 1` | Implementation | Median wall ms (20 runs) | | ---------------------------------- | -----------------------: | -| Reference (bun bench/ref/embed.ts) | 165.5 | -| Rust (embed example) | 1.1 | +| Reference (bun bench/ref/embed.ts) | 195.4 | +| Rust (embed example) | 1.3 | ## (c) Peak RSS, each case once in a fresh process | Case | Reference peak RSS MiB | Rust peak RSS MiB | | -------------------------- | ---------------------: | ----------------: | -| numeric loop | 84.2 | 3.9 | -| closure recursion (fib 22) | 82.5 | 4.0 | -| array callbacks (50k) | 99.3 | 6.8 | -| promise fan-out (5k) | 94.2 | 8.6 | -| tool fan-out (1k) | 89.6 | 5.1 | -| JSON round-trip | 118.7 | 20.2 | -| generator iteration | 82.8 | 4.1 | -| string building | 108.8 | 7.1 | -| Map/Set ops | 97.3 | 8.3 | +| numeric loop | 83.7 | 4.1 | +| closure recursion (fib 22) | 80.2 | 4.0 | +| array callbacks (50k) | 99.3 | 6.7 | +| promise fan-out (5k) | 92.2 | 8.5 | +| tool fan-out (1k) | 89.1 | 5.2 | +| JSON round-trip | 121.1 | 20.1 | +| generator iteration | 81.1 | 4.1 | +| string building | 105.6 | 7.2 | +| Map/Set ops | 98.5 | 8.5 | ## (d) Binary size @@ -51,6 +58,36 @@ Generated by `bench/compare.sh` on 2026-11-17. "n/a" means the Rust side could n | Rust embed example, release, stripped | 2139576 | 2.04 | | bun executable (what you ship otherwise) | 107308936 | 102.34 | +## (e) Perturbed variants, 11 iterations after one warm-up + +Each program in `bench/variants/` computes the same result as its original, written differently: renamed +identifiers, equivalent constants, function expressions and named functions for callbacks, and other loop forms. A +variant / original ratio far from the reference's on one side only points at a shape-specific fast path. + +| Case | Reference original median ms | Reference variant median ms | Reference variant / original | Rust original median ms | Rust variant median ms | Rust variant / original | Rust ratio / reference ratio | +| -------------------------- | ---------------------------: | --------------------------: | ---------------------------: | ----------------------: | ---------------------: | ----------------------: | ---------------------------: | +| numeric loop | 20.2 | 19.2 | 0.95 | 9.6 | 17.4 | 1.82 | 1.91x | +| closure recursion (fib 22) | 6.8 | 7.6 | 1.11 | 3.4 | 4.8 | 1.40 | 1.26x | +| array callbacks (50k) | 84.7 | 88.2 | 1.04 | 24.5 | 27.3 | 1.12 | 1.07x | +| promise fan-out (5k) | 15.1 | 10.1 | 0.67 | 4.1 | 4.1 | 1.02 | 1.51x | +| tool fan-out (1k) | 10.0 | 10.6 | 1.05 | 0.6 | 1.2 | 1.93 | 1.83x | +| JSON round-trip | 63.2 | 57.2 | 0.90 | 40.0 | 23.1 | 0.58 | 0.64x | +| generator iteration | 5.2 | 5.3 | 1.02 | 4.4 | 4.8 | 1.10 | 1.07x | +| string building | 17.9 | 19.8 | 1.10 | 7.4 | 741.5 | 99.76 | 90.33x | +| Map/Set ops | 25.6 | 19.8 | 0.77 | 16.8 | 14.2 | 0.84 | 1.09x | + +## (f) Plugin event: µs per execute, 2000 runs after 2000 warm-up runs + +The conformance reducer (`plugin-reducer-*`) handling `{ type: "command", name: "git.status" }` with a `git.status` +tool, through `execute` once per event. `reducer.js` is its command path; `reducer-padded.js` is the whole reducer +with eleven more command handlers before the matching one. The reference's `git.status` decodes through Effect Schema +and the Rust one does not validate, as in (a). + +| Source | Bytes | Reference median µs | Reference min µs | Reference mean µs | Rust median µs | Rust min µs | Rust mean µs | Median speedup | +| -------------------------------- | ----: | ------------------: | ---------------: | ----------------: | -------------: | ----------: | -----------: | -------------: | +| `bench/plugin/reducer.js` | 226 | 378.0 | 301.6 | 502.3 | 47.9 | 29.8 | 43.4 | 7.9x | +| `bench/plugin/reducer-padded.js` | 2957 | 785.9 | 516.6 | 1007.4 | 201.3 | 137.2 | 286.1 | 3.9x | + ## Commands ```sh @@ -68,4 +105,10 @@ target/release/examples/embed # (d) strip -o embed target/release/examples/embed && stat -c %s embed stat -c %s "$(readlink -f "$(command -v bun)")" +# (e) values must match their originals, on both sides +bun bench/ref/variants.ts --iterations 11 ... +target/release/psychoscript-bench --cases bench/variants --filter --iterations 11 --json +# (f) +bun bench/ref/plugin.ts --runs 2000 bench/plugin/reducer.js bench/plugin/reducer-padded.js +target/release/psychoscript-bench --plugin --runs 2000 bench/plugin/reducer.js bench/plugin/reducer-padded.js ``` diff --git a/packages/codemode-rust/bench/compare.sh b/packages/codemode-rust/bench/compare.sh index 6000e6f4d37e..3361be5d82c8 100644 --- a/packages/codemode-rust/bench/compare.sh +++ b/packages/codemode-rust/bench/compare.sh @@ -3,6 +3,7 @@ # Usage: bash bench/compare.sh. The reference CodeMode package is ../codemode relative to this workspace; set # CODEMODE_REF to another package directory to override it. # Needs bun, cargo, jq, strip and /usr/bin/time. Rust columns read "n/a" while the core cannot run a case. +# ITERATIONS (11), COLD_RUNS (20) and PLUGIN_RUNS (2000) scale the run; CI uses smaller values. set -uo pipefail [ -n "${CODEMODE_REF:-}" ] && CODEMODE_REF=$(cd "$CODEMODE_REF" && pwd) cd "$(dirname "$0")/.." @@ -10,6 +11,7 @@ REF_PKG=${CODEMODE_REF:-../codemode} [ -f "$REF_PKG/script/bench.ts" ] || { echo "reference CodeMode package not found at $REF_PKG" >&2; exit 1; } ITERATIONS=${ITERATIONS:-11} COLD_RUNS=${COLD_RUNS:-20} +PLUGIN_RUNS=${PLUGIN_RUNS:-2000} OUT=bench/RESULTS.md TMP=$(mktemp -d) trap 'rm -rf "$TMP"' EXIT @@ -21,6 +23,9 @@ EMBED=target/release/examples/embed median() { sort -g | awk '{ v[NR] = $1 } END { print v[int(NR / 2) + 1] }'; } fmt() { [ -n "$1" ] && printf '%.1f' "$1" || printf 'n/a'; } +ratio() { # numerator, denominator, [printf format] + [ -n "$1" ] && [ -n "$2" ] && awk -v a="$1" -v b="$2" -v f="${3:-%.2f}" 'BEGIN { printf f, a / b }' || printf 'n/a' +} echo "building release binaries" >&2 cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed >&2 || echo "Rust build failed" >&2 @@ -43,10 +48,54 @@ for i in "${!SLUGS[@]}"; do r_med=$(ref_field "$name" 1) r_min=$(ref_field "$name" 2) speedup=n/a [ -n "$rm_med" ] && speedup=$(awk -v r="$r_med" -v s="$rm_med" 'BEGIN { printf "%.1fx", r / s }') + [ "$slug" = tool-fan-out ] && name+=" ¹" TABLE_A+=" | $name | $r_med | $r_min | $(fmt "$rm_med") | $(fmt "$rm_min") | $speedup |" done +# (e) Perturbed variants: each program and an equivalent, differently written one, on both sides in this run. +echo "(e) variants" >&2 +bun bench/ref/variants.ts --iterations "$ITERATIONS" "${SLUGS[@]}" >"$TMP/ref-variants.txt" || + echo "reference variants failed" >&2 +TABLE_E="| Case | Reference original median ms | Reference variant median ms | Reference variant / original | Rust original median ms | Rust variant median ms | Rust variant / original | Rust ratio / reference ratio | +|---|---:|---:|---:|---:|---:|---:|---:|" +for i in "${!SLUGS[@]}"; do + slug=${SLUGS[$i]} + echo "(e) rust $slug" >&2 + ref_line=$(grep -F "\"slug\":\"$slug\"" "$TMP/ref-variants.txt" || true) + ro_med=$(jq -r '.original.median_ms // empty' <<<"$ref_line") rv_med=$(jq -r '.variant.median_ms // empty' <<<"$ref_line") + so_med="" sv_med="" note="" + if [ -x "$BENCH" ] && + "$BENCH" --filter "$slug" --iterations "$ITERATIONS" --json >"$TMP/orig-$slug.json" 2>/dev/null && + "$BENCH" --cases bench/variants --filter "$slug" --iterations "$ITERATIONS" --json >"$TMP/var-$slug.json" 2>/dev/null; then + so_med=$(jq '.[0].median_ms' "$TMP/orig-$slug.json") sv_med=$(jq '.[0].median_ms' "$TMP/var-$slug.json") + [ "$(jq -c '.[0].value' "$TMP/orig-$slug.json")" = "$(jq -c '.[0].value' "$TMP/var-$slug.json")" ] || + note=" (variant result differs)" + fi + r_ratio=$(ratio "$rv_med" "$ro_med") s_ratio=$(ratio "$sv_med" "$so_med") + rel=n/a + [ "$r_ratio" != n/a ] && [ "$s_ratio" != n/a ] && rel=$(ratio "$(ratio "$sv_med" "$so_med" %.6f)" "$(ratio "$rv_med" "$ro_med" %.6f)" '%.2fx') + TABLE_E+=" +| ${NAMES[$i]}$note | $(fmt "$ro_med") | $(fmt "$rv_med") | $r_ratio | $(fmt "$so_med") | $(fmt "$sv_med") | $s_ratio | $rel |" +done + +# (f) Plugin event: the conformance reducer handling a git.status command, PLUGIN_RUNS warm-up then PLUGIN_RUNS timed. +echo "(f) plugin event" >&2 +PLUGIN_SOURCES=(bench/plugin/reducer.js bench/plugin/reducer-padded.js) +bun bench/ref/plugin.ts --runs "$PLUGIN_RUNS" "${PLUGIN_SOURCES[@]}" >"$TMP/ref-plugin.txt" || echo "reference plugin failed" >&2 +[ -x "$BENCH" ] && "$BENCH" --plugin --runs "$PLUGIN_RUNS" "${PLUGIN_SOURCES[@]}" >"$TMP/rust-plugin.txt" 2>/dev/null || + echo "Rust plugin failed" >&2 +TABLE_F="| Source | Bytes | Reference median µs | Reference min µs | Reference mean µs | Rust median µs | Rust min µs | Rust mean µs | Median speedup | +|---|---:|---:|---:|---:|---:|---:|---:|---:|" +for source in "${PLUGIN_SOURCES[@]}"; do + ref_line=$(grep -F "\"source\":\"$source\"" "$TMP/ref-plugin.txt" || true) + rust_line=$(grep -F "\"source\":\"$source\"" "$TMP/rust-plugin.txt" 2>/dev/null || true) + field() { jq -r ".$2 // empty" <<<"$1"; } + r_med=$(field "$ref_line" median_us) s_med=$(field "$rust_line" median_us) + TABLE_F+=" +| \`$source\` | $(stat -c %s "$source") | $(fmt "$r_med") | $(fmt "$(field "$ref_line" min_us)") | $(fmt "$(field "$ref_line" mean_us)") | $(fmt "$s_med") | $(fmt "$(field "$rust_line" min_us)") | $(fmt "$(field "$rust_line" mean_us)") | $(ratio "$r_med" "$s_med" '%.1fx') |" +done + # (b) Cold start: process start to a printed result for `return 1`, median of COLD_RUNS processes. cold() { # command... "$@" >/dev/null 2>&1 || return 1 @@ -104,6 +153,9 @@ cat >"$OUT" <... +target/release/psychoscript-bench --cases bench/variants --filter --iterations $ITERATIONS --json +# (f) +bun bench/ref/plugin.ts --runs $PLUGIN_RUNS bench/plugin/reducer.js bench/plugin/reducer-padded.js +target/release/psychoscript-bench --plugin --runs $PLUGIN_RUNS bench/plugin/reducer.js bench/plugin/reducer-padded.js \`\`\` EOF echo "wrote $OUT" >&2 diff --git a/packages/codemode-rust/bench/plugin/reducer-padded.js b/packages/codemode-rust/bench/plugin/reducer-padded.js new file mode 100644 index 000000000000..2b42208bb424 --- /dev/null +++ b/packages/codemode-rust/bench/plugin/reducer-padded.js @@ -0,0 +1,14 @@ +if (event.type === "init") return { state: { runs: 0 }, commands: [{ name: "git.status", key: "ctrl+g" }] } +if (event.type === "command" && event.name === "git.log") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.log" }, slots: { statusbar: { text: "log " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.diff") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.diff" }, slots: { statusbar: { text: "diff " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.branch") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.branch" }, slots: { statusbar: { text: "branch " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.stash") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.stash" }, slots: { statusbar: { text: "stash " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.fetch") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.fetch" }, slots: { statusbar: { text: "fetch " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.pull") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.pull" }, slots: { statusbar: { text: "pull " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.push") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.push" }, slots: { statusbar: { text: "push " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.commit") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.commit" }, slots: { statusbar: { text: "commit " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.reset") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.reset" }, slots: { statusbar: { text: "reset " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.merge") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.merge" }, slots: { statusbar: { text: "merge " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.rebase") { const s = await tools.git.status(); return { state: { runs: state.runs + 1, last: "git.rebase" }, slots: { statusbar: { text: "rebase " + s.branch + (s.dirty ? " *" : "") } } } } +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } \ No newline at end of file diff --git a/packages/codemode-rust/bench/plugin/reducer.js b/packages/codemode-rust/bench/plugin/reducer.js new file mode 100644 index 000000000000..cba1075313f3 --- /dev/null +++ b/packages/codemode-rust/bench/plugin/reducer.js @@ -0,0 +1,2 @@ +if (event.type === "command" && event.name === "git.status") { const s = await tools.git.status(); return { state: { runs: state.runs + 1 }, slots: { statusbar: { text: s.branch + (s.dirty ? " *" : "") } } } } +return { state } \ No newline at end of file diff --git a/packages/codemode-rust/bench/ref/plugin.ts b/packages/codemode-rust/bench/ref/plugin.ts new file mode 100644 index 000000000000..140e72a71f85 --- /dev/null +++ b/packages/codemode-rust/bench/ref/plugin.ts @@ -0,0 +1,60 @@ +// Plugin-event benchmark, reference side: the conformance reducer handling a `git.status` command event. +// Counterpart of `psychoscript-bench --plugin`. Prints one JSON line per source: median, min and mean µs per execute. +// Usage: bun bench/ref/plugin.ts [--runs N] ... +import { resolve } from "node:path" + +// The reference CodeMode package: CODEMODE_REF, or by default ../codemode relative to this workspace. + +const pkg = + process.env.CODEMODE_REF === undefined + ? resolve(import.meta.dir, "../../../codemode") + : resolve(process.env.CODEMODE_REF) +const { Effect, Schema } = await import(Bun.resolveSync("effect", resolve(pkg, "src"))) +const { CodeMode, Tool } = await import(resolve(pkg, "src/index.ts")) + +// The tool of conformance/generate.ts. +const runtime = CodeMode.make({ + tools: { + git: { + status: Tool.make({ + description: "Working tree status", + input: Schema.Struct({}), + output: Schema.Struct({ branch: Schema.String, dirty: Schema.Boolean }), + execute: () => Effect.succeed({ branch: "main", dirty: true }), + }), + }, + }, +}) + +const bindings = { event: { type: "command", name: "git.status" }, state: { runs: 2 } } +const expected = JSON.stringify({ state: { runs: 3 }, slots: { statusbar: { text: "main *" } } }) +const flag = process.argv.indexOf("--runs") +const runs = flag === -1 ? 2000 : Number(process.argv[flag + 1]) +const sources = process.argv.slice(2).filter((arg, i, all) => arg !== "--runs" && all[i - 1] !== "--runs") + +for (const source of sources) { + const code = await Bun.file(source).text() + const execute = () => Effect.runPromise(runtime.execute(code, bindings)) + // Warm-up, as many runs as are measured; the first also checks the result. + const warm = await execute() + if (warm.ok !== true || JSON.stringify(warm.value) !== expected) + throw new Error(`${source}: unexpected outcome ${JSON.stringify(warm)}`) + for (let i = 1; i < runs; i++) await execute() + const times: Array = [] + for (let i = 0; i < runs; i++) { + const start = performance.now() + await execute() + times.push((performance.now() - start) * 1000) + } + const sorted = [...times].sort((a, b) => a - b) + const mean = times.reduce((a, b) => a + b, 0) / runs + console.log( + JSON.stringify({ + source, + bytes: Buffer.byteLength(code), + median_us: sorted[Math.floor(runs / 2)], + min_us: sorted[0], + mean_us: mean, + }), + ) +} diff --git a/packages/codemode-rust/bench/ref/variants.ts b/packages/codemode-rust/bench/ref/variants.ts new file mode 100644 index 000000000000..f9dc180d07c4 --- /dev/null +++ b/packages/codemode-rust/bench/ref/variants.ts @@ -0,0 +1,53 @@ +// Runs each bench program and its perturbed variant through the reference, with the tools of script/bench.ts. +// Checks the variant returns what the original does, then prints one JSON line per program: median and min ms. +// Usage: bun bench/ref/variants.ts [--iterations N] ... +import { resolve } from "node:path" + +// The reference CodeMode package: CODEMODE_REF, or by default ../codemode relative to this workspace. + +const pkg = + process.env.CODEMODE_REF === undefined + ? resolve(import.meta.dir, "../../../codemode") + : resolve(process.env.CODEMODE_REF) +const { Effect, Schema } = await import(Bun.resolveSync("effect", resolve(pkg, "src"))) +const { CodeMode, Tool } = await import(resolve(pkg, "src/index.ts")) + +const runtime = CodeMode.make({ + tools: { + echo: Tool.make({ + description: "Echo an id", + input: Schema.Struct({ id: Schema.Number }), + output: Schema.Number, + execute: ({ id }: { id: number }) => Effect.succeed(id), + }), + }, +}) + +const flag = process.argv.indexOf("--iterations") +const iterations = flag === -1 ? 11 : Number(process.argv[flag + 1]) +const slugs = process.argv.slice(2).filter((arg, i, all) => arg !== "--iterations" && all[i - 1] !== "--iterations") + +const measure = async (path: string) => { + const code = await Bun.file(path).text() + // One warm-up run, which also checks the program succeeds. + const warm = await Effect.runPromise(runtime.execute(code)) + if (warm.ok !== true) throw new Error(`${path} failed: ${JSON.stringify(warm)}`) + const times: Array = [] + for (let i = 0; i < iterations; i++) { + const start = performance.now() + await Effect.runPromise(runtime.execute(code)) + times.push(performance.now() - start) + } + const sorted = [...times].sort((a, b) => a - b) + return { value: warm.value, median_ms: sorted[Math.floor(sorted.length / 2)], min_ms: sorted[0] } +} + +for (const slug of slugs) { + const original = await measure(resolve(import.meta.dir, `../../conformance/cases/bench-${slug}.js`)) + const variant = await measure(resolve(import.meta.dir, `../variants/bench-${slug}.js`)) + if (JSON.stringify(original.value) !== JSON.stringify(variant.value)) + throw new Error( + `${slug}: the variant returns ${JSON.stringify(variant.value)}, not ${JSON.stringify(original.value)}`, + ) + console.log(JSON.stringify({ slug, original, variant })) +} diff --git a/packages/codemode-rust/bench/src/main.rs b/packages/codemode-rust/bench/src/main.rs index 5cd9cb47cb92..e0cc585b5e99 100644 --- a/packages/codemode-rust/bench/src/main.rs +++ b/packages/codemode-rust/bench/src/main.rs @@ -2,11 +2,15 @@ //! program. Each iteration calls `execute` on the source, with one warm-up run that also checks the program succeeds. //! Usage: psychoscript-bench [--iterations N] [--filter name] [--json] [--cases DIR] //! `--iterations 0` runs only the warm-up, for one-shot measurements such as peak RSS. +//! +//! `psychoscript-bench --plugin [--runs N] SOURCE...` is the plugin-event benchmark instead: the conformance +//! reducer handling a `git.status` command, N warm-up runs then N timed runs, as JSON lines of µs per execute. use std::path::PathBuf; use std::time::Instant; use psychoscript::{Json, Runtime}; +use serde_json::json; /// Case files and reference names, in the reference order. const CASES: [(&str, &str); 9] = [ @@ -21,7 +25,24 @@ const CASES: [(&str, &str); 9] = [ ("map-set-ops", "Map/Set ops"), ]; +/// Registers the bench tools: this is the switch for schema fairness. The reference decodes `echo`'s input and output +/// through Effect Schema (`{ id: number }` in, `number` out) and `git.status`'s likewise (`{}` in, +/// `{ branch: string, dirty: boolean }` out); these Rust tools do not validate yet. Once `Runtime` takes tool schemas, +/// register both with the equivalent validating schemas here, so each side pays for validation. +fn tools(runtime: Runtime) -> Runtime { + runtime + .tool("echo", |input| { + Ok(input.get("id").cloned().unwrap_or(Json::Null)) + }) + .tool("git.status", |_| { + Ok(json!({ "branch": "main", "dirty": true })) + }) +} + fn main() { + if std::env::args().nth(1).as_deref() == Some("--plugin") { + return plugin(std::env::args().skip(2)); + } let mut iterations = 11usize; let mut filter = String::new(); let mut json = false; @@ -42,9 +63,7 @@ fn main() { } } - let runtime = Runtime::new().tool("echo", |input| { - Ok(input.get("id").cloned().unwrap_or(Json::Null)) - }); + let runtime = tools(Runtime::new()); let bindings = serde_json::Map::new(); let mut report = Vec::new(); for (slug, name) in CASES { @@ -54,9 +73,10 @@ fn main() { let path = dir.join(format!("bench-{slug}.js")); let code = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); - if let Err(d) = runtime.execute(&code, &bindings).result { - panic!("{name} failed: {d:?}"); - } + let value = match runtime.execute(&code, &bindings).result { + Ok(value) => value, + Err(d) => panic!("{name} failed: {d:?}"), + }; let times: Vec = (0..iterations) .map(|_| { let start = Instant::now(); @@ -71,7 +91,7 @@ fn main() { sorted.sort_by(f64::total_cmp); let (median, min) = (sorted[sorted.len() / 2], sorted[0]); if json { - report.push(serde_json::json!({ "slug": slug, "name": name, "median_ms": median, "min_ms": min, "times_ms": times })); + report.push(json!({ "slug": slug, "name": name, "value": value, "median_ms": median, "min_ms": min, "times_ms": times })); } else { println!("{name:<28} {median:>8.1} ms (min {min:.1} ms)"); } @@ -80,3 +100,44 @@ fn main() { println!("{}", Json::from(report)); } } + +fn plugin(mut args: impl Iterator) { + let mut runs = 2000usize; + let mut sources = Vec::new(); + while let Some(arg) = args.next() { + match arg.as_str() { + "--runs" => runs = args.next().and_then(|n| n.parse().ok()).expect("--runs N"), + _ => sources.push(arg), + } + } + let runtime = tools(Runtime::new()); + let bindings = + json!({ "event": { "type": "command", "name": "git.status" }, "state": { "runs": 2 } }); + let bindings = bindings.as_object().cloned().unwrap_or_default(); + let expected = + json!({ "state": { "runs": 3 }, "slots": { "statusbar": { "text": "main *" } } }); + for source in sources { + let code = std::fs::read_to_string(&source).unwrap_or_else(|e| panic!("{source}: {e}")); + match runtime.execute(&code, &bindings).result { + Ok(value) if value == expected => {} + other => panic!("{source}: unexpected outcome {other:?}"), + } + for _ in 1..runs { + let _ = runtime.execute(&code, &bindings); + } + let times: Vec = (0..runs) + .map(|_| { + let start = Instant::now(); + let _ = runtime.execute(&code, &bindings); + start.elapsed().as_secs_f64() * 1e6 + }) + .collect(); + let mut sorted = times.clone(); + sorted.sort_by(f64::total_cmp); + let mean = times.iter().sum::() / runs.max(1) as f64; + println!( + "{}", + json!({ "source": source, "bytes": code.len(), "median_us": sorted[runs / 2], "min_us": sorted[0], "mean_us": mean }) + ); + } +} diff --git a/packages/codemode-rust/bench/variants/bench-array-callbacks.js b/packages/codemode-rust/bench/variants/bench-array-callbacks.js new file mode 100644 index 000000000000..e72899bed4da --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-array-callbacks.js @@ -0,0 +1,19 @@ +const COUNT = 5e4 +const values = Array.from({ length: COUNT }, function (unused, idx) { + return (7919 * idx) % COUNT +}) +function twice(v) { + return v + v +} +const kept = values.map(twice).filter(function (v) { + return v % 3 != 0 +}) +const sum = kept.reduce(function (acc, v) { + return acc + v +}, 0) +function ascending(left, right) { + return left < right ? -1 : left > right ? 1 : 0 +} +const ordered = kept.slice(0, 2e4).sort(ascending) +const last = ordered.length - 1 +return [sum, ordered[0], ordered[last]] diff --git a/packages/codemode-rust/bench/variants/bench-closure-recursion.js b/packages/codemode-rust/bench/variants/bench-closure-recursion.js new file mode 100644 index 000000000000..ac9319602c16 --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-closure-recursion.js @@ -0,0 +1,5 @@ +function fibonacci(m) { + if (m <= 1) return m + return fibonacci(m - 2) + fibonacci(m - 1) +} +return fibonacci(2 * 11) diff --git a/packages/codemode-rust/bench/variants/bench-generator-iteration.js b/packages/codemode-rust/bench/variants/bench-generator-iteration.js new file mode 100644 index 000000000000..602e8c5f869f --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-generator-iteration.js @@ -0,0 +1,10 @@ +const numbers = function* (limit) { + let v = 0 + while (v < limit) { + yield v + v++ + } +} +let total = 0 +for (const n of numbers(5e4)) total = total + n +return total diff --git a/packages/codemode-rust/bench/variants/bench-json-round-trip.js b/packages/codemode-rust/bench/variants/bench-json-round-trip.js new file mode 100644 index 000000000000..7d16e8e95c34 --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-json-round-trip.js @@ -0,0 +1,12 @@ +function build(level) { + if (level <= 0) return { a: 1, b: "two", c: [1, 2, 3], d: null } + const branch = level - 1 + return { left: build(branch), right: build(branch), list: [level, `${level}`] } +} +let bytes = 0 +let rounds = 20 +while (rounds-- > 0) { + const text = JSON.stringify(build(9)) + bytes += JSON.stringify(JSON.parse(text)).length +} +return bytes diff --git a/packages/codemode-rust/bench/variants/bench-map-set-ops.js b/packages/codemode-rust/bench/variants/bench-map-set-ops.js new file mode 100644 index 000000000000..59884843acd4 --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-map-set-ops.js @@ -0,0 +1,20 @@ +const table = new Map() +const seen = new Set() +let i = 0 +while (i < 3e4) { + table.set(`k${i % 5000}`, i) + seen.add(i % 7000) + i++ +} +let acc = 0 +table.forEach(function (value) { + acc += value +}) +seen.forEach((value) => { + acc += value +}) +for (let j = 5000; j > 0; j--) { + table.delete("k" + (j - 1)) + seen.delete(j - 1) +} +return acc + table.size + seen.size diff --git a/packages/codemode-rust/bench/variants/bench-numeric-loop.js b/packages/codemode-rust/bench/variants/bench-numeric-loop.js new file mode 100644 index 000000000000..0a0de8202e01 --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-numeric-loop.js @@ -0,0 +1,9 @@ +const LIMIT = 3e5 +const MODULUS = 0xf4243 +let acc = 0 +let k = 0 +while (k < LIMIT) { + acc = (acc + 3 * k) % MODULUS + k += 1 +} +return acc diff --git a/packages/codemode-rust/bench/variants/bench-promise-fan-out.js b/packages/codemode-rust/bench/variants/bench-promise-fan-out.js new file mode 100644 index 000000000000..967d4f3affc1 --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-promise-fan-out.js @@ -0,0 +1,8 @@ +async function task(n) { + await undefined + return n + n +} +const pending = [] +for (let j = 0; j < 5e3; j++) pending.push(task(j)) +const settled = await Promise.all(pending) +return settled.length diff --git a/packages/codemode-rust/bench/variants/bench-string-building.js b/packages/codemode-rust/bench/variants/bench-string-building.js new file mode 100644 index 000000000000..2258e46d58cd --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-string-building.js @@ -0,0 +1,10 @@ +const BASE = "a".charCodeAt(0) +let text = "" +let idx = 0 +while (idx < 5e4) { + text = text + String.fromCharCode(BASE + (idx % 26)) + idx++ +} +const pieces = [] +for (let n = 0; n < 2e4; n += 1) pieces.push("item-" + n) +return text.length + pieces.join(",").length diff --git a/packages/codemode-rust/bench/variants/bench-tool-fan-out.js b/packages/codemode-rust/bench/variants/bench-tool-fan-out.js new file mode 100644 index 000000000000..9a2f54f36b3c --- /dev/null +++ b/packages/codemode-rust/bench/variants/bench-tool-fan-out.js @@ -0,0 +1,8 @@ +const calls = [] +let n = 0 +while (n < 1e3) { + calls.push(tools.echo({ id: n })) + n++ +} +const answers = await Promise.all(calls) +return answers.length From 13570b74402b4ac401227d2a55d697bf62093105 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 16:44:40 +0100 Subject: [PATCH 004/100] chore(codemode): pin the Rust toolchain and prepare compare.sh for CI Runs fmt, Clippy and the tests including conformance; regenerates every conformance expectation from the reference and fails on a diff; runs the test262 parity check; and runs the benchmarks into the job summary without gating. The toolchain is pinned in rust-toolchain.toml with a minimal profile, and every cargo call is --locked. The workflow file itself follows in a separate commit. --- packages/codemode-rust/bench/compare.sh | 4 ++-- packages/codemode-rust/rust-toolchain.toml | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 packages/codemode-rust/rust-toolchain.toml diff --git a/packages/codemode-rust/bench/compare.sh b/packages/codemode-rust/bench/compare.sh index 3361be5d82c8..f73a2bd5508b 100644 --- a/packages/codemode-rust/bench/compare.sh +++ b/packages/codemode-rust/bench/compare.sh @@ -28,7 +28,7 @@ ratio() { # numerator, denominator, [printf format] } echo "building release binaries" >&2 -cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed >&2 || echo "Rust build failed" >&2 +cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed >&2 || echo "Rust build failed" >&2 # (a) Per-case median and min. echo "(a) reference bench" >&2 @@ -204,7 +204,7 @@ $TABLE_F \`\`\`sh bash bench/compare.sh # reference at ../codemode, or CODEMODE_REF= -cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed +cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed # (a) (cd ../codemode && bun run script/bench.ts --iterations $ITERATIONS) target/release/psychoscript-bench --filter --iterations $ITERATIONS --json diff --git a/packages/codemode-rust/rust-toolchain.toml b/packages/codemode-rust/rust-toolchain.toml new file mode 100644 index 000000000000..63202c6f2e9c --- /dev/null +++ b/packages/codemode-rust/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.100.0" +profile = "minimal" +components = ["rustfmt", "clippy"] From 5b1125c55ab03b4b0ca382bdecb06e40607bce81 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 16:44:44 +0100 Subject: [PATCH 005/100] fix(codemode): stop compare.sh flagging its own output as an uncommitted change --- packages/codemode-rust/bench/compare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/codemode-rust/bench/compare.sh b/packages/codemode-rust/bench/compare.sh index f73a2bd5508b..ceeb321c82d8 100644 --- a/packages/codemode-rust/bench/compare.sh +++ b/packages/codemode-rust/bench/compare.sh @@ -160,7 +160,7 @@ mins and means are shown for spread, never compared. - CPU: $CPU, $(nproc) cores, $MEM RAM, Linux $(uname -r) - Reference: anomalyco/opencode $(git -C "$REF_PKG" rev-parse HEAD), \`packages/codemode\` -- PsychoScript: $(git rev-parse HEAD)$(git diff --quiet HEAD -- crates bench conformance || echo " (with uncommitted changes)") +- PsychoScript: $(git rev-parse HEAD)$(git diff --quiet HEAD -- crates bench conformance ':!bench/RESULTS.md' || echo " (with uncommitted changes)") - bun $(bun --version); $(rustc --version); $(cargo --version) ## (a) Per-case wall time, $ITERATIONS iterations after one warm-up From f89740d1471794b027bef67444b43ecb9232dd59 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Nov 2026 16:44:47 +0100 Subject: [PATCH 006/100] test(codemode): regenerate the benchmark results with variants and plugin events --- packages/codemode-rust/bench/RESULTS.md | 68 ++++++++++++------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/codemode-rust/bench/RESULTS.md b/packages/codemode-rust/bench/RESULTS.md index 69d2b04e8a46..23ed3e5e63a1 100644 --- a/packages/codemode-rust/bench/RESULTS.md +++ b/packages/codemode-rust/bench/RESULTS.md @@ -8,23 +8,23 @@ mins and means are shown for spread, never compared. ## Environment - CPU: AMD EPYC 9554P 64-Core Processor, 8 cores, 31 GiB RAM, Linux 6.12.115 -- Reference: anomalyco/opencode 05e5d37e77aa443beda5b14d6a099fed0936157a, `packages/codemode` -- PsychoScript: 05e5d37e77aa443beda5b14d6a099fed0936157a (with uncommitted changes) +- Reference: anomalyco/opencode e992c253aab199cc9df1d5e8ce6ff3735c996d9d, `packages/codemode` +- PsychoScript: e992c253aab199cc9df1d5e8ce6ff3735c996d9d - bun 1.4.4; rustc 1.100.0 (0ef1bc386 2026-11-09); cargo 1.100.0 (3acc79c0c 2026-11-05) ## (a) Per-case wall time, 11 iterations after one warm-up | Case | Reference median ms | Reference min ms | Rust median ms | Rust min ms | Median speedup | | -------------------------- | ------------------: | ---------------: | -------------: | ----------: | -------------: | -| numeric loop | 17.2 | 14.0 | 9.6 | 9.5 | 1.8x | -| closure recursion (fib 22) | 4.5 | 4.3 | 5.0 | 3.8 | 0.9x | -| array callbacks (50k) | 79.7 | 75.3 | 25.8 | 24.3 | 3.1x | -| promise fan-out (5k) | 10.2 | 7.4 | 2.7 | 2.6 | 3.8x | -| tool fan-out (1k) ¹ | 8.3 | 7.6 | 1.1 | 1.0 | 7.8x | -| JSON round-trip | 51.6 | 47.2 | 23.2 | 22.6 | 2.2x | -| generator iteration | 5.3 | 5.1 | 4.4 | 4.3 | 1.2x | -| string building | 18.2 | 15.4 | 8.4 | 7.3 | 2.2x | -| Map/Set ops | 15.3 | 13.2 | 13.3 | 13.0 | 1.2x | +| numeric loop | 14.3 | 13.9 | 9.2 | 9.2 | 1.5x | +| closure recursion (fib 22) | 5.0 | 4.7 | 3.4 | 3.3 | 1.5x | +| array callbacks (50k) | 81.7 | 77.2 | 25.0 | 24.1 | 3.3x | +| promise fan-out (5k) | 10.9 | 7.1 | 2.7 | 2.7 | 4.0x | +| tool fan-out (1k) ¹ | 8.4 | 7.5 | 0.7 | 0.6 | 12.5x | +| JSON round-trip | 49.8 | 47.5 | 23.2 | 22.0 | 2.1x | +| generator iteration | 5.0 | 5.0 | 4.4 | 4.3 | 1.1x | +| string building | 17.3 | 15.0 | 7.5 | 7.2 | 2.3x | +| Map/Set ops | 14.9 | 13.5 | 12.8 | 12.5 | 1.2x | ¹ Not like for like yet: the reference `echo` tool decodes its input and output through Effect Schema (`{ id: number }` in, `number` out), and the Rust tools do not validate. Once the Rust host API takes tool schemas, @@ -34,22 +34,22 @@ mins and means are shown for spread, never compared. | Implementation | Median wall ms (20 runs) | | ---------------------------------- | -----------------------: | -| Reference (bun bench/ref/embed.ts) | 195.4 | -| Rust (embed example) | 1.3 | +| Reference (bun bench/ref/embed.ts) | 225.9 | +| Rust (embed example) | 1.4 | ## (c) Peak RSS, each case once in a fresh process | Case | Reference peak RSS MiB | Rust peak RSS MiB | | -------------------------- | ---------------------: | ----------------: | -| numeric loop | 83.7 | 4.1 | -| closure recursion (fib 22) | 80.2 | 4.0 | -| array callbacks (50k) | 99.3 | 6.7 | -| promise fan-out (5k) | 92.2 | 8.5 | -| tool fan-out (1k) | 89.1 | 5.2 | -| JSON round-trip | 121.1 | 20.1 | -| generator iteration | 81.1 | 4.1 | -| string building | 105.6 | 7.2 | -| Map/Set ops | 98.5 | 8.5 | +| numeric loop | 82.1 | 4.0 | +| closure recursion (fib 22) | 79.7 | 4.0 | +| array callbacks (50k) | 102.5 | 6.6 | +| promise fan-out (5k) | 91.3 | 8.6 | +| tool fan-out (1k) | 87.9 | 5.2 | +| JSON round-trip | 111.6 | 20.1 | +| generator iteration | 79.3 | 4.1 | +| string building | 103.6 | 7.1 | +| Map/Set ops | 91.0 | 8.2 | ## (d) Binary size @@ -66,15 +66,15 @@ variant / original ratio far from the reference's on one side only points at a s | Case | Reference original median ms | Reference variant median ms | Reference variant / original | Rust original median ms | Rust variant median ms | Rust variant / original | Rust ratio / reference ratio | | -------------------------- | ---------------------------: | --------------------------: | ---------------------------: | ----------------------: | ---------------------: | ----------------------: | ---------------------------: | -| numeric loop | 20.2 | 19.2 | 0.95 | 9.6 | 17.4 | 1.82 | 1.91x | -| closure recursion (fib 22) | 6.8 | 7.6 | 1.11 | 3.4 | 4.8 | 1.40 | 1.26x | -| array callbacks (50k) | 84.7 | 88.2 | 1.04 | 24.5 | 27.3 | 1.12 | 1.07x | -| promise fan-out (5k) | 15.1 | 10.1 | 0.67 | 4.1 | 4.1 | 1.02 | 1.51x | -| tool fan-out (1k) | 10.0 | 10.6 | 1.05 | 0.6 | 1.2 | 1.93 | 1.83x | -| JSON round-trip | 63.2 | 57.2 | 0.90 | 40.0 | 23.1 | 0.58 | 0.64x | -| generator iteration | 5.2 | 5.3 | 1.02 | 4.4 | 4.8 | 1.10 | 1.07x | -| string building | 17.9 | 19.8 | 1.10 | 7.4 | 741.5 | 99.76 | 90.33x | -| Map/Set ops | 25.6 | 19.8 | 0.77 | 16.8 | 14.2 | 0.84 | 1.09x | +| numeric loop | 17.2 | 16.7 | 0.97 | 11.8 | 11.9 | 1.01 | 1.04x | +| closure recursion (fib 22) | 5.2 | 4.9 | 0.94 | 3.6 | 3.8 | 1.04 | 1.11x | +| array callbacks (50k) | 83.4 | 83.1 | 1.00 | 24.6 | 26.9 | 1.10 | 1.10x | +| promise fan-out (5k) | 11.4 | 7.3 | 0.64 | 4.0 | 2.8 | 0.71 | 1.11x | +| tool fan-out (1k) | 8.7 | 7.3 | 0.84 | 0.6 | 0.6 | 1.07 | 1.27x | +| JSON round-trip | 55.0 | 47.8 | 0.87 | 22.6 | 24.2 | 1.07 | 1.24x | +| generator iteration | 4.9 | 4.9 | 1.00 | 4.3 | 4.6 | 1.05 | 1.05x | +| string building | 16.8 | 17.1 | 1.02 | 7.2 | 724.7 | 100.65 | 99.15x | +| Map/Set ops | 14.0 | 18.2 | 1.30 | 13.7 | 12.6 | 0.93 | 0.71x | ## (f) Plugin event: µs per execute, 2000 runs after 2000 warm-up runs @@ -85,14 +85,14 @@ and the Rust one does not validate, as in (a). | Source | Bytes | Reference median µs | Reference min µs | Reference mean µs | Rust median µs | Rust min µs | Rust mean µs | Median speedup | | -------------------------------- | ----: | ------------------: | ---------------: | ----------------: | -------------: | ----------: | -----------: | -------------: | -| `bench/plugin/reducer.js` | 226 | 378.0 | 301.6 | 502.3 | 47.9 | 29.8 | 43.4 | 7.9x | -| `bench/plugin/reducer-padded.js` | 2957 | 785.9 | 516.6 | 1007.4 | 201.3 | 137.2 | 286.1 | 3.9x | +| `bench/plugin/reducer.js` | 226 | 377.1 | 296.5 | 470.7 | 31.5 | 30.2 | 68.5 | 12.0x | +| `bench/plugin/reducer-padded.js` | 2957 | 640.8 | 487.0 | 870.8 | 185.5 | 133.4 | 768.9 | 3.5x | ## Commands ```sh bash bench/compare.sh # reference at ../codemode, or CODEMODE_REF= -cargo build --release -p psychoscript-bench --bin psychoscript-bench --example embed +cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed # (a) (cd ../codemode && bun run script/bench.ts --iterations 11) target/release/psychoscript-bench --filter --iterations 11 --json From 251dfc8205af2f8b10f36499a762910e3c61dbf2 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:47:27 +0000 Subject: [PATCH 007/100] chore(codemode): add a CI workflow for the Rust port Runs format, Clippy and tests, checks the conformance expectations against the TypeScript reference, runs test262 against the committed gap list, and posts informational benchmarks to the job summary. --- .github/workflows/codemode-rust.yml | 125 ++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 .github/workflows/codemode-rust.yml diff --git a/.github/workflows/codemode-rust.yml b/.github/workflows/codemode-rust.yml new file mode 100644 index 000000000000..b6fe2929e3ce --- /dev/null +++ b/.github/workflows/codemode-rust.yml @@ -0,0 +1,125 @@ +name: Codemode Rust + +on: + pull_request: + paths: + - packages/codemode-rust/** + - packages/codemode/** + - .github/workflows/codemode-rust.yml + push: + branches: [dev] + paths: + - packages/codemode-rust/** + - packages/codemode/** + - .github/workflows/codemode-rust.yml + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +defaults: + run: + working-directory: packages/codemode-rust + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: "0" + +jobs: + check: + name: Format, Clippy and tests + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 20 + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + # The toolchain, profile and components come from packages/codemode-rust/rust-toolchain.toml. + - name: Install Rust + run: rustup toolchain install --no-self-update + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 + with: + shared-key: codemode-rust-dev + workspaces: packages/codemode-rust -> target + - run: cargo fmt --check + - run: cargo clippy --locked --workspace --all-targets -- -D warnings + # Includes bench/tests/conformance.rs, which checks every conformance case against the reference outcome. + - run: cargo test --locked --workspace + + conformance-fresh: + name: Conformance expectations match the reference + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 10 + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - uses: ./.github/actions/setup-bun + # A change to the reference fails here until the Rust side is updated and the expectations regenerated. + - name: Regenerate every expectation from ../codemode + run: bun conformance/generate.ts + - name: Check nothing changed + run: | + git status --porcelain -- conformance + git diff --exit-code -- conformance + test -z "$(git status --porcelain -- conformance)" + + test262: + name: test262 parity + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 20 + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + # The sync script needs only Bun itself, not the workspace's dependencies. + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: package.json + - name: Install Rust + run: rustup toolchain install --no-self-update + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 + with: + shared-key: codemode-rust-release + workspaces: packages/codemode-rust -> target + - name: Read the pinned test262 revision + id: test262 + run: | + revision=$(jq -r .revision ../codemode/test/test262/manifest.json) + echo "revision=$revision" >> "$GITHUB_OUTPUT" + echo "checkout=$HOME/.cache/test262-$revision" >> "$GITHUB_OUTPUT" + - name: Cache the test262 checkout + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: ${{ steps.test262.outputs.checkout }} + key: test262-${{ steps.test262.outputs.revision }} + # Fails when a file fails that test262/rust-skipped.txt does not list, or a listed file passes. + - name: Run test262 against rust-skipped.txt + env: + TEST262_CHECKOUT: ${{ steps.test262.outputs.checkout }} + run: bash test262/run.sh + + bench: + name: Benchmarks (informational) + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 20 + # Shared runners are too noisy for a performance gate; the numbers go to the job summary only. + continue-on-error: true + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - uses: ./.github/actions/setup-bun + - name: Install Rust + run: rustup toolchain install --no-self-update + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 + with: + shared-key: codemode-rust-release + workspaces: packages/codemode-rust -> target + - name: Install GNU time + run: "[ -x /usr/bin/time ] || (sudo apt-get update && sudo apt-get install -y time)" + - run: cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed + - name: Compare with the reference + env: + ITERATIONS: "5" + COLD_RUNS: "5" + PLUGIN_RUNS: "2000" + run: bash bench/compare.sh + - name: Write the results to the job summary + run: cat bench/RESULTS.md >> "$GITHUB_STEP_SUMMARY" From 9ab959572aee426c5a822dd5d19ab8641e92e864 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:48:51 +0000 Subject: [PATCH 008/100] docs(codemode): keep the TypeScript and Rust packages equally capable --- packages/codemode-rust/AGENTS.md | 8 ++++++++ packages/codemode/AGENTS.md | 1 + 2 files changed, 9 insertions(+) diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index 5b6008b9bb8c..fb5f8c5cabd0 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -2,6 +2,14 @@ A Rust port of OpenCode's Code Mode (`packages/codemode` in anomalyco/opencode, the reference implementation), embeddable in Rust programs with no Bun, Node or other JavaScript engine at build or run time. +## Parity with the TypeScript package + +This package is a second way to run and embed the same language, not a replacement. `packages/codemode` stays, and the two packages must stay equally capable in both directions. + +- A language feature, built-in or host API lands in both packages or in neither. Rust-native forms of a reference API (futures instead of Effects, closures or traits instead of services) are fine; Rust-only capabilities are not. +- Conformance expectations are always generated from `packages/codemode`; never edit them by hand. CI regenerates them and fails on any difference. +- `test262/rust-skipped.txt` lists reference-passing files Rust still fails; it may only shrink. + ## Scope: minimal, targeted In scope: diff --git a/packages/codemode/AGENTS.md b/packages/codemode/AGENTS.md index 66f962e081ee..4bd969945f0e 100644 --- a/packages/codemode/AGENTS.md +++ b/packages/codemode/AGENTS.md @@ -4,3 +4,4 @@ - Program values are `Value` (`src/runtime/objects.ts`). Host values are `unknown` and enter only through `fromHost` and `fromJson`; do not widen program-facing signatures to `unknown`. - Each built-in object kind is one `Obj` subclass (`Wrapper` or `Opaque`) that overrides the hooks it needs. Ask the object instead of adding `instanceof` ladders. - The core VM, compiler, prelude, snapshot, and stdlib modules must not import `effect`; Effect lives only in the host boundary and driver (`src/runtime/`, `src/openapi/`, and the top-level tool/runtime entrypoints). +- `packages/codemode-rust` runs and embeds the same language from Rust. The two packages must stay equally capable: a feature lands in both or neither. Its conformance expectations are generated from this package, so a behavior change here fails its CI until the Rust side matches. From 833099b5ef2bea9b066191e44c1889c7c3432f43 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:55:34 +0000 Subject: [PATCH 009/100] test(codemode): check test262 parity in both directions The runner now checks the files in the reference's skipped.txt too: those that pass here are gaps on the TypeScript side, listed with a category in test262/reference-gaps.txt. The check fails when an unlisted one passes, a listed one fails here or leaves the reference's skipped.txt, or the reference's own runner, through test262/reference.ts, passes a listed one. Each category says whether Rust really has the behaviour or passes through a looser check where the reference is strict on purpose. --- .github/workflows/codemode-rust.yml | 12 +- packages/codemode-rust/AGENTS.md | 2 +- packages/codemode-rust/test262/README.md | 15 ++- .../codemode-rust/test262/reference-gaps.txt | 93 +++++++++++++ packages/codemode-rust/test262/reference.ts | 35 +++++ packages/codemode-rust/test262/run.sh | 32 ++++- packages/codemode-rust/test262/src/main.rs | 125 +++++++++++++++--- 7 files changed, 279 insertions(+), 35 deletions(-) create mode 100644 packages/codemode-rust/test262/reference-gaps.txt create mode 100644 packages/codemode-rust/test262/reference.ts diff --git a/.github/workflows/codemode-rust.yml b/.github/workflows/codemode-rust.yml index b6fe2929e3ce..fc8b296f116c 100644 --- a/.github/workflows/codemode-rust.yml +++ b/.github/workflows/codemode-rust.yml @@ -70,10 +70,8 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - # The sync script needs only Bun itself, not the workspace's dependencies. - - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 - with: - bun-version-file: package.json + # The reference runs the listed reference gaps, so its dependencies are installed too. + - uses: ./.github/actions/setup-bun - name: Install Rust run: rustup toolchain install --no-self-update - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 @@ -91,8 +89,10 @@ jobs: with: path: ${{ steps.test262.outputs.checkout }} key: test262-${{ steps.test262.outputs.revision }} - # Fails when a file fails that test262/rust-skipped.txt does not list, or a listed file passes. - - name: Run test262 against rust-skipped.txt + # Parity both ways. Fails when a file fails that test262/rust-skipped.txt does not list, or a listed file + # passes; and when a file the reference skips passes but test262/reference-gaps.txt does not list it, or a + # listed file fails here, leaves the reference's skipped.txt, or passes in the reference. + - name: Run test262 against rust-skipped.txt and reference-gaps.txt env: TEST262_CHECKOUT: ${{ steps.test262.outputs.checkout }} run: bash test262/run.sh diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index fb5f8c5cabd0..30c606f5cd10 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -26,7 +26,7 @@ Out of scope: classes (rejected, like the reference), `export`/modules/`import`, - Unsupported syntax returns `UnsupportedSyntax` with a location; never panic on user input. - No `unsafe` unless measured and justified in a comment. - Dependencies: pure Rust only, and few. Justify each in the commit that adds it. -- test262 parity: `bash test262/run.sh` must pass, and `test262/rust-skipped.txt` may only shrink. +- test262 parity runs both ways: `bash test262/run.sh` must pass, and `test262/rust-skipped.txt` and `test262/reference-gaps.txt` may only shrink. - `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` must pass. - Benchmark claims need the command, machine and numbers in `bench/RESULTS.md`. - Nothing in the repo mentions internal tooling, private chats, home paths, hostnames or secrets. diff --git a/packages/codemode-rust/test262/README.md b/packages/codemode-rust/test262/README.md index 0498b33c5422..59597b2332ee 100644 --- a/packages/codemode-rust/test262/README.md +++ b/packages/codemode-rust/test262/README.md @@ -6,7 +6,7 @@ checks the failures against `rust-skipped.txt`. ```sh bash test262/run.sh # what CI runs bash test262/run.sh built-ins/Array # one directory, by path prefix -bash test262/run.sh --write # regenerate rust-skipped.txt from the current failures +bash test262/run.sh --write # regenerate both gap lists from the current outcomes ``` - `run.sh` clones tc39/test262 at the reference manifest's revision into a cache directory (`TEST262_CHECKOUT`), @@ -16,6 +16,13 @@ bash test262/run.sh --write # regenerate rust-skipped.txt from the curre prepended on the same line, the host harness (`$assert` checks, `Test262Error`, `compareArray`, `$DONE`, `$DONOTEVALUATE`) from the crate's `test262` feature, a 5 s timeout, negative tests judged by phase, and async tests drained and judged by `$DONE`. -- Files in the reference's `skipped.txt` are the reference's own gaps. They run but are not checked. -- `rust-skipped.txt` lists the files that fail here but pass in the reference, each with a reason category. It is - the parity gap list and may only shrink: CI fails when an unlisted file fails, and when a listed file passes. +- Parity runs both ways, with one list per direction. Both may only shrink. + - `rust-skipped.txt` lists the files that fail here but pass in the reference, each with a reason category. CI + fails when an unlisted file fails, and when a listed file passes. + - `reference-gaps.txt` lists the files in the reference's `skipped.txt` that pass here: gaps on the TypeScript + side. Each category starts with `real` (Rust has the behaviour, TypeScript lacks it) or `accident` (Rust passes + through a looser check where the reference is deliberately strict; Rust should match the reference). CI fails + when an unlisted file passes, when a listed file fails here or leaves the reference's `skipped.txt`, and when + `reference.ts`, which runs the listed files through the reference's own `run.ts`, sees one pass. +- `--write` regenerates both lists. It keeps the categories already in `reference-gaps.txt` and marks new entries + `uncategorised`, with the reference's reason, for a person to judge. diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt new file mode 100644 index 000000000000..559d86b759f4 --- /dev/null +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -0,0 +1,93 @@ +# test262 files the reference skips (its skipped.txt) that pass here: gaps on the TypeScript side. Categories start +# with "real" (Rust has the behaviour and TypeScript lacks it) or "accident" (Rust passes through a looser check, +# where the reference is deliberately strict). Generated by `bash test262/run.sh --write`, which keeps the categories; +# CI fails when an unlisted file passes, a listed file fails here, or the reference passes a listed file. +built-ins/AggregateError/message-undefined-no-prop.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/Array/length/S15.4.5.1_A1.3_T2.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/at/index-argument-tointeger.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/fill/return-abrupt-from-end.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/fill/return-abrupt-from-start.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/forEach/15.4.4.18-7-5.js # real: array holes read inherited Array.prototype indexes +built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/includes/tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js # accident: circular values are allowed; the reference rejects them on purpose when created +built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js # accident: circular values are allowed; the reference rejects them on purpose when created +built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js # real: array holes read inherited Array.prototype indexes +built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js # real: array holes read inherited Array.prototype indexes +built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/some/15.4.4.17-7-6.js # real: array holes read inherited Array.prototype indexes +built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/sort/bug_596_1.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/ArrayIteratorPrototype/Symbol.toStringTag/value-from-to-string.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/AsyncFunction/AsyncFunctionPrototype-is-not-callable.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/GeneratorFunction/prototype/not-callable.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/JSON/parse/text-object.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/JSON/stringify/value-array-circular.js # accident: circular values are allowed; the reference rejects them on purpose when created +built-ins/Promise/all/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does +built-ins/Promise/allSettled/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does +built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does +built-ins/Promise/any/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does +built-ins/Promise/race/S25.4.4.3_A5.1_T1.js # accident: Promise.race([]) never settles; the reference rejects it on purpose with a hint +built-ins/Promise/withResolvers/resolvers.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/Set/prototype/keys/keys.js # real: built-in object model details (names, prototypes, toStringTag, own message) +built-ins/String/fromCharCode/S9.7_A3.1_T4.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) +language/expressions/addition/S11.6.1_A2.2_T3.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/addition/S11.6.1_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/assignment/target-member-identifier-reference-null.js # real: assignment to a member of null or undefined evaluates the right side first +language/expressions/assignment/target-member-identifier-reference-undefined.js # real: assignment to a member of null or undefined evaluates the right side first +language/expressions/bitwise-and/S11.10.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/bitwise-not/S11.4.8_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/bitwise-or/S11.10.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/bitwise-xor/S11.10.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/delete/non-reference-return-true.js # real: delete of a non-reference unary chain is true +language/expressions/division/S11.5.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/greater-than-or-equal/S11.8.4_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/greater-than/S11.8.2_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/left-shift/S11.7.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/less-than-or-equal/S11.8.3_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/less-than/S11.8.1_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/modulus/S11.5.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/multiplication/S11.5.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/new/ctorExpr-isCtor-after-args-eval-fn-wrapup.js # real: new evaluates its arguments before the constructor check +language/expressions/new/ctorExpr-isCtor-after-args-eval.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-mult-err-expr-throws.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-mult-err-itr-get-call.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-mult-err-itr-step.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-mult-err-obj-unresolvable.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-mult-err-unresolvable.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-sngl-err-expr-throws.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-sngl-err-itr-get-call.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-sngl-err-itr-step.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-sngl-err-obj-unresolvable.js # real: new evaluates its arguments before the constructor check +language/expressions/new/spread-err-sngl-err-unresolvable.js # real: new evaluates its arguments before the constructor check +language/expressions/postfix-decrement/S11.3.2_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/postfix-decrement/S11.3.2_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/postfix-increment/S11.3.1_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/postfix-increment/S11.3.1_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/prefix-decrement/S11.4.5_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/prefix-decrement/S11.4.5_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/prefix-increment/S11.4.4_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/prefix-increment/S11.4.4_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/right-shift/S11.7.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/subtraction/S11.6.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/unary-minus/S11.4.7_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/unary-plus/S11.4.6_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/expressions/unsigned-right-shift/S11.7.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) +language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) +language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) +language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) +language/identifiers/start-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode-rust/test262/reference.ts b/packages/codemode-rust/test262/reference.ts new file mode 100644 index 000000000000..93f0b3486186 --- /dev/null +++ b/packages/codemode-rust/test262/reference.ts @@ -0,0 +1,35 @@ +#!/usr/bin/env bun + +// Runs test262 files through the reference's own runner, `test/test262/run.ts` of the reference package, over the +// synced tree. The runner reads files next to itself, so a copy goes into the tree with its imports pointed back at +// the reference package; its harness and semantics are unchanged. +// Usage: bun test262/reference.ts [prefix] +// Prints `pass\t` or `fail\t\t` for every `path # ...` line of the list under the prefix. +import path from "node:path" + +const [pkg, tree, list, prefix = ""] = process.argv.slice(2).map((arg, i) => (i < 3 ? path.resolve(arg) : arg)) +if (pkg === undefined || tree === undefined || list === undefined) { + console.error("usage: bun test262/reference.ts [prefix]") + process.exit(1) +} + +const runner = await Bun.file(path.join(pkg, "test/test262/run.ts")).text() +const effect = Bun.resolveSync("effect", path.join(pkg, "src")) +await Bun.write( + path.join(tree, "reference-run.ts"), + runner + .replaceAll('from "../../src/', `from "${path.join(pkg, "src")}/`) + .replaceAll('from "effect"', `from "${effect}"`), +) +await Bun.write(path.join(tree, "skipped.txt"), Bun.file(path.join(pkg, "test/test262/skipped.txt"))) +const { run } = await import(path.join(tree, "reference-run.ts")) + +const files = (await Bun.file(list).text()) + .split("\n") + .filter((line) => !line.startsWith("#") && line.includes("#")) + .map((line) => line.slice(0, line.indexOf("#")).trim()) + .filter((file) => file.startsWith(prefix)) +for (const file of files) { + const outcome = await run(file).catch((error: unknown) => ({ status: "fail", reason: `runner error: ${error}` })) + console.log(outcome.status === "pass" ? `pass\t${file}` : `fail\t${file}\t${outcome.reason.replace(/\s+/g, " ")}`) +} diff --git a/packages/codemode-rust/test262/run.sh b/packages/codemode-rust/test262/run.sh index 52d6f564c7eb..d88216d70c46 100644 --- a/packages/codemode-rust/test262/run.sh +++ b/packages/codemode-rust/test262/run.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash -# Runs the reference's pinned test262 file set through PsychoScript and checks it against test262/rust-skipped.txt. +# Runs the reference's pinned test262 file set through PsychoScript and checks both gap lists: +# test262/rust-skipped.txt (fails here, passes in the reference) and test262/reference-gaps.txt (passes here, skipped by +# the reference, and still failing when the reference runs it). # Usage: bash test262/run.sh [--write] [prefix]. Extra arguments go to the runner; see test262/src/main.rs. # # - Clones tc39/test262 at the reference manifest's revision into TEST262_CHECKOUT (default: a cache directory). # - Runs the reference's own sync script into TEST262_FILES (default: target/test262), so the file set and its # filters are exactly the reference's. # - The reference CodeMode package is ../codemode relative to this workspace; set CODEMODE_REF to override it. -# Needs git, bun and cargo. +# Needs git, bun, cargo, and the reference package's dependencies installed (bun install). set -euo pipefail [ -n "${CODEMODE_REF:-}" ] && CODEMODE_REF=$(cd "$CODEMODE_REF" && pwd) cd "$(dirname "$0")/.." @@ -41,8 +43,30 @@ if [ "$(cat "$FILES/stamp" 2>/dev/null)" != "$REVISION $(cksum <"$MANIFEST") $(c fi cargo build --release --locked -p psychoscript-test262 >&2 -exec target/release/psychoscript-test262 \ +status=0 +target/release/psychoscript-test262 \ --root "$SYNCED" \ --reference-skipped "$REF_PKG/test/test262/skipped.txt" \ --skipped test262/rust-skipped.txt \ - "$@" + --reference-gaps test262/reference-gaps.txt \ + "$@" || status=$? + +# The other direction: every listed reference gap must still fail in the reference itself. +WRITE="" PREFIX="" SKIP="" +for arg in "$@"; do + if [ -n "$SKIP" ]; then SKIP=""; continue; fi + case $arg in + --write) WRITE=1 ;; + --jobs) SKIP=1 ;; + --*) ;; + *) PREFIX=$arg ;; + esac +done +if [ -z "$WRITE" ]; then + bun test262/reference.ts "$REF_PKG" "$SYNCED" test262/reference-gaps.txt "$PREFIX" >"$FILES/reference.txt" || status=1 + passing=$(grep -c '^pass' "$FILES/reference.txt" || true) + sed -n 's/^pass\t/PASSES IN THE REFERENCE NOW, remove it from reference-gaps.txt /p' "$FILES/reference.txt" + echo "the reference fails $(grep -c '^fail' "$FILES/reference.txt" || true) of the listed reference gaps and passes $passing" + [ "$passing" = 0 ] || status=1 +fi +exit "$status" diff --git a/packages/codemode-rust/test262/src/main.rs b/packages/codemode-rust/test262/src/main.rs index e04be42d45a4..ab8dd0611749 100644 --- a/packages/codemode-rust/test262/src/main.rs +++ b/packages/codemode-rust/test262/src/main.rs @@ -1,12 +1,18 @@ //! Runs the reference's pinned test262 file set through PsychoScript with the reference harness semantics -//! (`packages/codemode/test/test262/run.ts`) and checks the outcome against `test262/rust-skipped.txt`. +//! (`packages/codemode/test/test262/run.ts`) and checks the outcome in both directions: against +//! `test262/rust-skipped.txt` (gaps here) and `test262/reference-gaps.txt` (gaps in the reference). //! -//! Usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE [--write] [--jobs N] [prefix] +//! Usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE --reference-gaps FILE +//! [--write] [--jobs N] [prefix] //! //! - `--root` is the synced tree holding `built-ins/` and `language/`; see `test262/run.sh`. -//! - Files in the reference's `skipped.txt` are gaps of the reference too: they run, but only for a count. -//! - Every other file must pass unless `--skipped` lists it, and every listed file must still fail. -//! - `--write` rewrites `--skipped` from the current failures instead of checking it. +//! - A file outside the reference's `skipped.txt` must pass unless `--skipped` lists it, and every listed file must +//! still fail. +//! - A file in the reference's `skipped.txt` must fail unless `--reference-gaps` lists it, and every listed file must +//! still pass and still be in the reference's `skipped.txt`. `test262/reference.ts` checks that the reference +//! still fails them. +//! - `--write` rewrites both lists from the current outcomes instead of checking them. Entries already in +//! `--reference-gaps` keep their category; new ones are marked uncategorised, with the reference's reason. //! //! Each file runs in a worker process, so an abort or a hang in one file is reported as that file's failure. @@ -30,6 +36,13 @@ test262 files that fail here but pass in the reference: the parity gap list. Gen Fix gaps to shrink it; do not add entries. "; +const REFERENCE_HEADER: &str = "\ +test262 files the reference skips (its skipped.txt) that pass here: gaps on the TypeScript side. Categories start +with \"real\" (Rust has the behaviour and TypeScript lacks it) or \"accident\" (Rust passes through a looser check, +where the reference is deliberately strict). Generated by `bash test262/run.sh --write`, which keeps the categories; +CI fails when an unlisted file passes, a listed file fails here, or the reference passes a listed file. +"; + const PRELUDE: &str = concat!( "function assert(mustBeTrue, message) { $assert(mustBeTrue, message) } ", "assert.sameValue = $assert.sameValue; assert.notSameValue = $assert.notSameValue; ", @@ -47,6 +60,7 @@ fn main() -> ExitCode { let mut root = None; let mut reference_skipped = None; let mut skipped = None; + let mut gaps_path = None; let mut write = false; let mut jobs = std::thread::available_parallelism().map_or(4, |n| n.get()); let mut prefix = String::new(); @@ -56,15 +70,17 @@ fn main() -> ExitCode { "--root" => root = it.next().map(PathBuf::from), "--reference-skipped" => reference_skipped = it.next().map(PathBuf::from), "--skipped" => skipped = it.next().map(PathBuf::from), + "--reference-gaps" => gaps_path = it.next().map(PathBuf::from), "--write" => write = true, "--jobs" => jobs = it.next().and_then(|n| n.parse().ok()).unwrap_or(jobs), p if !p.starts_with("--") => prefix = p.to_owned(), other => return usage(&format!("unknown argument {other}")), } } - let (Some(root), Some(reference_skipped), Some(skipped)) = (root, reference_skipped, skipped) + let (Some(root), Some(reference_skipped), Some(skipped), Some(gaps_path)) = + (root, reference_skipped, skipped, gaps_path) else { - return usage("--root, --reference-skipped and --skipped are required"); + return usage("--root, --reference-skipped, --skipped and --reference-gaps are required"); }; if write && !prefix.is_empty() { return usage("--write rewrites the whole list, so it takes no prefix"); @@ -72,6 +88,7 @@ fn main() -> ExitCode { let reference = read_list(&reference_skipped); let listed = read_list(&skipped); + let listed_gaps = read_list(&gaps_path); let mut files = Vec::new(); for dir in ["built-ins", "language"] { collect(&root, &root.join(dir), &mut files); @@ -89,7 +106,6 @@ fn main() -> ExitCode { .filter(|f| !reference.contains_key(*f)) .cloned() .collect(); - // The reference's own skipped files run too, only to report how many pass here. let queue: VecDeque = files .iter() .filter(|f| f.starts_with(&prefix)) @@ -97,15 +113,20 @@ fn main() -> ExitCode { .collect(); let started = Instant::now(); let mut results = run_all(&root, queue, jobs.max(1)); - let reference_gaps: Vec = results + // The reference's own skipped files, checked against `--reference-gaps`. + let reference_results: BTreeMap> = results .keys() .filter(|f| !in_scope.contains(*f)) .cloned() + .collect::>() + .into_iter() + .filter_map(|f| results.remove(&f).map(|r| (f, r))) .collect(); - let reference_fixed = reference_gaps + let reference_passes: Vec<&String> = reference_results .iter() - .filter(|f| results.remove(*f).is_some_and(|r| r.is_ok())) - .count(); + .filter(|(_, r)| r.is_ok()) + .map(|(f, _)| f) + .collect(); let total = results.len(); let failures: BTreeMap<&String, &String> = results @@ -119,8 +140,9 @@ fn main() -> ExitCode { started.elapsed().as_secs_f64(), ); println!( - "{reference_fixed} of the {} files in the reference's skipped.txt pass here too; they are not checked", - reference_gaps.len() + "{} of the {} files in the reference's skipped.txt pass here: gaps on the reference side", + reference_passes.len(), + reference_results.len() ); let mut counts: BTreeMap = BTreeMap::new(); for reason in failures.values() { @@ -147,6 +169,26 @@ fn main() -> ExitCode { return ExitCode::FAILURE; } println!("wrote {} entries to {}", failures.len(), skipped.display()); + let lines: String = REFERENCE_HEADER + .lines() + .map(|line| format!("# {line}\n")) + .chain(reference_passes.iter().map(|file| { + let category = listed_gaps.get(*file).cloned().unwrap_or_else(|| { + let reason = reference.get(*file).map_or("", String::as_str); + format!("uncategorised: the reference says {reason}") + }); + format!("{file} # {category}\n") + })) + .collect(); + if let Err(e) = std::fs::write(&gaps_path, lines) { + eprintln!("{}: {e}", gaps_path.display()); + return ExitCode::FAILURE; + } + println!( + "wrote {} entries to {}", + reference_passes.len(), + gaps_path.display() + ); return ExitCode::SUCCESS; } @@ -164,32 +206,75 @@ fn main() -> ExitCode { } else { Vec::new() }; + let unlisted_gaps: Vec<_> = reference_passes + .iter() + .filter(|f| !listed_gaps.contains_key(**f)) + .collect(); + let failing_gaps: Vec<_> = reference_results + .iter() + .filter_map(|(f, r)| match r { + Err(reason) if listed_gaps.contains_key(f) => Some((f, reason)), + _ => None, + }) + .collect(); + let not_skipped: Vec<_> = listed_gaps + .keys() + .filter(|f| { + f.starts_with(&prefix) + && (!reference.contains_key(*f) || files.binary_search(f).is_err()) + }) + .collect(); for (file, reason) in &new { println!("FAIL {file} # {reason}"); } for file in &fixed { - println!("PASSES NOW, remove it from the list {file}"); + println!("PASSES NOW, remove it from rust-skipped.txt {file}"); } for file in &gone { - println!("NOT IN THE FILE SET, remove it from the list {file}"); + println!("NOT IN THE FILE SET, remove it from rust-skipped.txt {file}"); + } + for file in &unlisted_gaps { + println!("PASSES BUT THE REFERENCE SKIPS IT, add it to reference-gaps.txt {file}"); } - if new.is_empty() && fixed.is_empty() && gone.is_empty() { - println!("every failure is listed in {}", skipped.display()); + for (file, reason) in &failing_gaps { + println!("FAILS NOW, remove it from reference-gaps.txt {file} # {reason}"); + } + for file in ¬_skipped { + println!("NOT A SKIPPED FILE OF THE REFERENCE, remove it from reference-gaps.txt {file}"); + } + let problems = new.len() + + fixed.len() + + gone.len() + + unlisted_gaps.len() + + failing_gaps.len() + + not_skipped.len(); + if problems == 0 { + println!( + "every failure is listed in {}, and every pass the reference skips in {}", + skipped.display(), + gaps_path.display() + ); return ExitCode::SUCCESS; } println!( - "{} unlisted failures, {} listed files that pass, {} listed files not in the set", + "rust-skipped.txt: {} unlisted failures, {} listed files that pass, {} listed files not in the set", new.len(), fixed.len(), gone.len() ); + println!( + "reference-gaps.txt: {} unlisted passes, {} listed files that fail, {} listed files the reference no longer skips or no longer has", + unlisted_gaps.len(), + failing_gaps.len(), + not_skipped.len() + ); ExitCode::FAILURE } fn usage(problem: &str) -> ExitCode { eprintln!("{problem}"); eprintln!( - "usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE [--write] [--jobs N] [prefix]" + "usage: psychoscript-test262 --root DIR --reference-skipped FILE --skipped FILE --reference-gaps FILE [--write] [--jobs N] [prefix]" ); ExitCode::FAILURE } From 871b1af6f825fd7dab45a0fc04d71667471459d3 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:57:50 +0000 Subject: [PATCH 010/100] feat(codemode): add schema tools, search, hooks, async host calls and extensions to the Rust port Tools take validating or render-only JSON Schemas (the Rust form of Effect Schemas and the reference's JsonSchema), render byte-identical TypeScript signatures, and report InvalidToolInput and InvalidToolOutput. Namespaces, freeform tools, the catalog, toolExpression, searchSignature and the BM25 search built-in follow tool-runtime.ts; conformance/catalog.ts regenerates the expectations from the reference. Tools and extension globals may return futures. execute_async runs on any executor; execute drives it with a small built-in block_on, and a shared timer thread enforces timeouts while host work is pending. Dropping a run cancels its calls, which after hooks see as interrupted. Extensions cross values as copies both ways, including functions in results, errors, maps and sets, and programs load them with import, require and import() by Node module name. Runtime::program adds the reference's program API with run ids. --- packages/codemode-rust/AGENTS.md | 6 +- .../codemode-rust/bench/tests/conformance.rs | 61 +- .../codemode-rust/conformance/catalog.json | 2097 +++++++++++++++++ packages/codemode-rust/conformance/catalog.ts | 305 +++ .../crates/psychoscript/src/compiler.rs | 105 +- .../crates/psychoscript/src/exec.rs | 290 +++ .../crates/psychoscript/src/extension.rs | 321 +++ .../crates/psychoscript/src/hooks.rs | 128 + .../crates/psychoscript/src/host.rs | 1160 +++++++++ .../crates/psychoscript/src/lib.rs | 198 +- .../crates/psychoscript/src/ops.rs | 4 + .../crates/psychoscript/src/program.rs | 138 ++ .../crates/psychoscript/src/run.rs | 180 +- .../crates/psychoscript/src/schema.rs | 1179 +++++++++ .../crates/psychoscript/src/search.rs | 386 +++ .../crates/psychoscript/src/tool.rs | 345 +++ .../crates/psychoscript/src/vm.rs | 90 +- .../crates/psychoscript/tests/catalog.rs | 140 ++ .../crates/psychoscript/tests/hooks.rs | 480 ++++ .../crates/psychoscript/tests/tools.rs | 496 ++++ 20 files changed, 7924 insertions(+), 185 deletions(-) create mode 100644 packages/codemode-rust/conformance/catalog.json create mode 100644 packages/codemode-rust/conformance/catalog.ts create mode 100644 packages/codemode-rust/crates/psychoscript/src/exec.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/extension.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/hooks.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/host.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/program.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/schema.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/search.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/tool.rs create mode 100644 packages/codemode-rust/crates/psychoscript/tests/catalog.rs create mode 100644 packages/codemode-rust/crates/psychoscript/tests/hooks.rs create mode 100644 packages/codemode-rust/crates/psychoscript/tests/tools.rs diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index c798c9a08a33..781c99660819 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -8,9 +8,11 @@ In scope: - The language subset needed by the nine reference benchmark programs (`conformance/cases/bench-*`), the plugin reducer example, and the other conformance cases. - Pipeline: parse → compile to bytecode → stack VM. Values cross the host boundary as JSON copies (`serde_json::Value`), never shared. -- Host API in `crates/psychoscript/src/lib.rs`: synchronous tools at dotted paths, JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. +- Host API in `crates/psychoscript/src/lib.rs`, the Rust form of the reference's README API: schema-described tools (sync or futures) at dotted paths with namespaces, the catalog and `search`, hooks, extensions with `import`/`require`, programs (`Runtime::program`), JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. +- Parity runs both ways: add no language feature or host API the reference lacks. Rust-native forms of reference APIs (futures for Effects, a blocking `execute`) are fine. +- `conformance/catalog.json` is generated by `bun conformance/catalog.ts` from the reference; never edit it by hand. -Out of scope: classes (rejected, like the reference), `export`/modules/`import`, snapshots and suspend/resume, OpenAPI tools, Effect integration, extensions/globals, async host tools, `search`, RegExp, URL, Date, BigInt, Symbol beyond iterators, test262 parity. +Out of scope: classes (rejected, like the reference), `export`, snapshots and suspend/resume, OpenAPI tools, Effect integration, RegExp, URL, Date, BigInt, Symbol beyond iterators, test262 parity. ## Rules diff --git a/packages/codemode-rust/bench/tests/conformance.rs b/packages/codemode-rust/bench/tests/conformance.rs index 2bc8ad442c9b..2ac9640539e7 100644 --- a/packages/codemode-rust/bench/tests/conformance.rs +++ b/packages/codemode-rust/bench/tests/conformance.rs @@ -4,33 +4,46 @@ use std::panic::{self, AssertUnwindSafe}; use std::path::Path; -use psychoscript::{DiagnosticKind, Json, Limits, Runtime}; +use psychoscript::{Json, Limits, Runtime, Schema, Tool}; +use serde_json::json; +/// The reference generator's tools, with the same schemas. fn runtime(limits: Limits) -> Runtime { + let empty = json!({ "type": "object", "properties": {}, "additionalProperties": false }); Runtime::new() - .tool("echo", |input| { - Ok(input.get("id").cloned().unwrap_or(Json::Null)) - }) - .tool("fail", |_| Err("boom".to_owned())) - .tool("git.status", |_| { - Ok(serde_json::json!({ "branch": "main", "dirty": true })) - }) + .with_tool( + "echo", + Tool::new("Echo an id", |input, _| Ok(input["id"].clone())) + .input(Schema::validated(json!({ + "type": "object", + "properties": { "id": { "type": "number" } }, + "required": ["id"], + "additionalProperties": false + }))) + .output(Schema::validated(json!({ "type": "number" }))), + ) + .with_tool( + "fail", + Tool::new("Always fails", |_, _| Err("boom".into())) + .input(Schema::validated(empty.clone())) + .output(Schema::validated(json!({ "type": "number" }))), + ) + .with_tool( + "git.status", + Tool::new("Working tree status", |_, _| { + Ok(json!({ "branch": "main", "dirty": true })) + }) + .input(Schema::validated(empty)) + .output(Schema::validated(json!({ + "type": "object", + "properties": { "branch": { "type": "string" }, "dirty": { "type": "boolean" } }, + "required": ["branch", "dirty"], + "additionalProperties": false + }))), + ) .limits(limits) } -fn kind_name(kind: DiagnosticKind) -> &'static str { - match kind { - DiagnosticKind::ParseError => "ParseError", - DiagnosticKind::UnsupportedSyntax => "UnsupportedSyntax", - DiagnosticKind::UnknownTool => "UnknownTool", - DiagnosticKind::InvalidDataValue => "InvalidDataValue", - DiagnosticKind::ToolCallLimitExceeded => "ToolCallLimitExceeded", - DiagnosticKind::TimeoutExceeded => "TimeoutExceeded", - DiagnosticKind::ToolFailure => "ToolFailure", - DiagnosticKind::ExecutionFailure => "ExecutionFailure", - } -} - /// JSON equality where numbers compare by value, so `3` equals `3.0`. fn same(a: &Json, b: &Json) -> bool { match (a, b) { @@ -81,11 +94,11 @@ fn check(name: &str, code: &str, expected: &Json) -> Result<(), String> { } } (Err(d), Some(false)) => { - if kind_name(d.kind) != expected["kind"] { + if d.kind.name() != expected["kind"] { problems.push(format!( "kind: expected {}, got {} ({})", expected["kind"], - kind_name(d.kind), + d.kind.name(), d.message )); } @@ -97,7 +110,7 @@ fn check(name: &str, code: &str, expected: &Json) -> Result<(), String> { (Err(d), _) => problems.push(format!( "expected ok {}, got {}: {}", expected["value"], - kind_name(d.kind), + d.kind.name(), d.message )), } diff --git a/packages/codemode-rust/conformance/catalog.json b/packages/codemode-rust/conformance/catalog.json new file mode 100644 index 000000000000..91e73b072922 --- /dev/null +++ b/packages/codemode-rust/conformance/catalog.json @@ -0,0 +1,2097 @@ +{ + "tools": [ + { + "path": "orders.lookup", + "description": "Look up an order by ID", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ], + "additionalProperties": false + } + }, + "output": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "status": { + "type": "string" + } + }, + "required": [ + "id", + "status" + ], + "additionalProperties": false + } + } + }, + { + "path": "orders.list", + "description": "List orders, newest first", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "open", + "closed" + ], + "description": "Filter by status" + }, + "limit": { + "type": "integer", + "maximum": 100, + "exclusiveMinimum": 0 + }, + "cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + } + }, + "output": { + "validated": true, + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "total": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string", + "enum": [ + "Infinity", + "-Infinity", + "NaN" + ] + } + ] + } + }, + "required": [ + "id", + "total" + ], + "additionalProperties": false + } + } + } + }, + { + "path": "users.get", + "description": "Get a user and the users they follow", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "login": { + "type": "string", + "description": "GitHub login\n\nCase-insensitive." + } + }, + "required": [ + "login" + ], + "additionalProperties": false + } + }, + "output": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "user": { + "$ref": "#/$defs/User" + }, + "follows": { + "type": "array", + "items": { + "$ref": "#/$defs/User" + } + }, + "tags": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string", + "enum": [ + "Infinity", + "-Infinity", + "NaN" + ] + } + ] + } + } + }, + "required": [ + "user", + "follows", + "tags" + ], + "additionalProperties": false, + "$defs": { + "User": { + "type": "object", + "properties": { + "login": { + "type": "string" + }, + "id": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string", + "enum": [ + "Infinity", + "-Infinity", + "NaN" + ] + } + ] + } + }, + "required": [ + "login", + "id" + ], + "additionalProperties": false + } + } + } + } + }, + { + "path": "net.ping", + "description": "Ping a host", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "host": { + "type": "string" + } + }, + "required": [ + "host" + ], + "additionalProperties": false + } + } + }, + { + "path": "util.now", + "description": "The current time", + "input": { + "validated": true, + "schema": { + "not": { + "type": "null" + } + } + }, + "output": { + "validated": true, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + } + }, + { + "path": "fetchPage", + "description": "Fetch a page", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "Page URL" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + } + }, + "output": { + "validated": true, + "schema": { + "type": "string" + } + }, + "freeform": true + }, + { + "path": "context7.resolve-library-id", + "description": "Resolve a library ID", + "input": { + "validated": true, + "schema": { + "type": "object", + "properties": { + "libraryName": { + "type": "string" + } + }, + "required": [ + "libraryName" + ], + "additionalProperties": false + } + }, + "output": { + "validated": true, + "schema": { + "type": "string" + } + } + }, + { + "path": "adapter.call", + "description": "Call an adapter-described tool", + "input": { + "validated": false, + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "count": { + "type": "number" + } + }, + "required": [ + "id" + ] + } + } + }, + { + "path": "files.upload", + "description": "Send a document to the workspace", + "input": { + "validated": false, + "schema": { + "type": "object", + "properties": { + "attachment": { + "type": "string", + "description": "Local path of the payload to send" + } + }, + "required": [ + "attachment" + ] + } + }, + "output": { + "validated": false, + "schema": { + "type": "object", + "properties": { + "sent": { + "type": "boolean" + } + }, + "required": [ + "sent" + ] + } + } + }, + { + "path": "files.patch", + "description": "Apply a patch", + "input": { + "validated": false, + "schema": { + "type": "object", + "properties": { + "patchText": { + "type": "string", + "description": "The full patch text, */ included", + "minLength": 1 + } + }, + "required": [ + "patchText" + ] + } + }, + "freeform": true + }, + { + "path": "search.advanced", + "description": "Every keyword the renderer knows", + "input": { + "validated": false, + "schema": { + "type": "object", + "$defs": { + "Tag": { + "type": "string", + "enum": [ + "a", + "b" + ], + "description": "A tag" + } + }, + "properties": { + "when": { + "type": "string", + "format": "date-time", + "default": "now", + "deprecated": true + }, + "count": { + "type": "integer", + "minimum": 1, + "maximum": 10, + "multipleOf": 2 + }, + "ratio": { + "type": "number", + "exclusiveMinimum": 0, + "exclusiveMaximum": 1 + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 64, + "pattern": "^[a-z]+$" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/$defs/Tag" + }, + "minItems": 1, + "maxItems": 5, + "uniqueItems": true + }, + "either": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "null" + } + ] + }, + "one": { + "oneOf": [ + { + "const": 1 + }, + { + "const": "one" + } + ] + }, + "both": { + "allOf": [ + { + "type": "object", + "properties": { + "a": { + "type": "string" + } + } + }, + { + "type": "object", + "properties": { + "b": { + "type": "number" + } + } + } + ] + }, + "multi": { + "type": [ + "string", + "null" + ] + }, + "map": { + "type": "object", + "additionalProperties": { + "type": "number", + "description": "A count" + } + }, + "mixed": { + "type": "object", + "properties": { + "k": { + "type": "string" + } + }, + "additionalProperties": { + "type": "boolean" + } + }, + "kebab-key": { + "type": "boolean" + }, + "nested": { + "type": "object", + "description": "A deeply nested value whose documentation is long enough that it cannot fit on the same line as its tags at all", + "properties": { + "deeper": { + "type": "object", + "properties": { + "deepest": { + "type": "array", + "items": { + "type": "object", + "properties": { + "x": { + "type": "number" + } + } + } + } + } + } + } + }, + "anything": {}, + "missing": { + "$ref": "#/$defs/Missing" + } + }, + "required": [ + "count", + "kebab-key" + ] + } + }, + "output": { + "validated": false, + "schema": { + "$ref": "#/definitions/Out", + "definitions": { + "Out": { + "type": "object", + "properties": { + "ok": { + "type": "boolean" + } + } + } + } + } + } + }, + { + "path": "issues", + "description": "All issues", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "issues.list", + "description": "List issues", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "issues.archive", + "description": "Archive an issue", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "issues.create", + "description": "Create an issue", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "issues.get", + "description": "Get one issue", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "issues.close", + "description": "Close an issue", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "gmail.list_labels", + "description": "List the labels in the mailbox", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "gmail.list_messages", + "description": "List messages", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "slack.list_channels", + "description": "List channels", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "slack.list_users", + "description": "List users", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "slack.list_user_groups", + "description": "List user groups", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "slack.get_schedules", + "description": "Get scheduled messages", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "slack.admin.users.list", + "description": "List workspace administrators", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "cloud.describe_vm", + "description": "Describe a virtual machine", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "cloud.list_all_issues", + "description": "List issues", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "cloudflare.get_timezones", + "description": "List timezones", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "cloudflare.get_zones", + "description": "List zones", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "tracker.fetch_all", + "description": "Fetch every open issue in the project", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "k8s.getCronJob", + "description": "Read a CronJob in the cluster", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "mail.send", + "description": "Send an email", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "mail.archive", + "description": "Archive a thread", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "thread.uploadFile", + "description": "Upload one readable local file to the current Discord thread", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "thread.generateImage", + "description": "Generate an image and upload it to the current Discord thread", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + }, + { + "path": "unicode.émoji", + "description": "Résumé café naïve 🎉 tools", + "input": { + "validated": false, + "schema": { + "type": "object" + } + }, + "output": { + "validated": false, + "schema": { + "type": "string" + } + } + } + ], + "namespaces": [ + { + "path": "orders", + "description": "Purchases, fulfillment, and shipment tracking" + }, + { + "path": "slack.admin", + "description": "Directory and account administration" + } + ], + "catalog": [ + { + "path": "adapter.call", + "description": "Call an adapter-described tool", + "signature": "tools.adapter.call({\n id: string,\n count?: number,\n}): Promise" + }, + { + "path": "cloud.describe_vm", + "description": "Describe a virtual machine", + "signature": "tools.cloud.describe_vm(): Promise" + }, + { + "path": "cloud.list_all_issues", + "description": "List issues", + "signature": "tools.cloud.list_all_issues(): Promise" + }, + { + "path": "cloudflare.get_timezones", + "description": "List timezones", + "signature": "tools.cloudflare.get_timezones(): Promise" + }, + { + "path": "cloudflare.get_zones", + "description": "List zones", + "signature": "tools.cloudflare.get_zones(): Promise" + }, + { + "path": "context7.resolve-library-id", + "description": "Resolve a library ID", + "signature": "tools.context7[\"resolve-library-id\"]({\n libraryName: string,\n}): Promise" + }, + { + "path": "fetchPage", + "description": "Fetch a page", + "signature": "tools.fetchPage(/** Page URL */ url: string): Promise" + }, + { + "path": "files.patch", + "description": "Apply a patch", + "signature": "tools.files.patch(/** The full patch text, * / included. @minLength 1 */ patchText: string): Promise" + }, + { + "path": "files.upload", + "description": "Send a document to the workspace", + "signature": "tools.files.upload({\n /** Local path of the payload to send */\n attachment: string,\n}): Promise<{\n sent: boolean,\n}>" + }, + { + "path": "gmail.list_labels", + "description": "List the labels in the mailbox", + "signature": "tools.gmail.list_labels(): Promise" + }, + { + "path": "gmail.list_messages", + "description": "List messages", + "signature": "tools.gmail.list_messages(): Promise" + }, + { + "path": "issues", + "description": "All issues", + "signature": "tools.issues(): Promise" + }, + { + "path": "issues.archive", + "description": "Archive an issue", + "signature": "tools.issues.archive(): Promise" + }, + { + "path": "issues.close", + "description": "Close an issue", + "signature": "tools.issues.close(): Promise" + }, + { + "path": "issues.create", + "description": "Create an issue", + "signature": "tools.issues.create(): Promise" + }, + { + "path": "issues.get", + "description": "Get one issue", + "signature": "tools.issues.get(): Promise" + }, + { + "path": "issues.list", + "description": "List issues", + "signature": "tools.issues.list(): Promise" + }, + { + "path": "k8s.getCronJob", + "description": "Read a CronJob in the cluster", + "signature": "tools.k8s.getCronJob(): Promise" + }, + { + "path": "mail.archive", + "description": "Archive a thread", + "signature": "tools.mail.archive(): Promise" + }, + { + "path": "mail.send", + "description": "Send an email", + "signature": "tools.mail.send(): Promise" + }, + { + "path": "net.ping", + "description": "Ping a host", + "signature": "tools.net.ping({\n host: string,\n}): Promise" + }, + { + "path": "orders.list", + "description": "List orders, newest first", + "signature": "tools.orders.list({\n /** Filter by status */\n status?: \"open\" | \"closed\",\n /** @integer @maximum 100 @exclusiveMinimum 0 */\n limit?: number,\n cursor?: string | null,\n}): Promise>" + }, + { + "path": "orders.lookup", + "description": "Look up an order by ID", + "signature": "tools.orders.lookup({\n id: string,\n}): Promise<{\n id: string,\n status: string,\n}>" + }, + { + "path": "search.advanced", + "description": "Every keyword the renderer knows", + "signature": "tools.search.advanced({\n /** @deprecated @default \"now\" @format date-time */\n when?: string,\n /** @integer @minimum 1 @maximum 10 @multipleOf 2 */\n count: number,\n /** @exclusiveMinimum 0 @exclusiveMaximum 1 */\n ratio?: number,\n /** @minLength 1 @maxLength 64 @pattern ^[a-z]+$ */\n name?: string,\n /** @minItems 1 @maxItems 5 @uniqueItems true */\n tags?: Array<\"a\" | \"b\">,\n either?: string | number | null,\n one?: 1 | \"one\",\n both?: {\n a?: string,\n } & {\n b?: number,\n },\n multi?: string | null,\n /** Each value: A count */\n map?: {\n [key: string]: number,\n },\n mixed?: {\n k?: string,\n [key: string]: boolean,\n },\n \"kebab-key\": boolean,\n /** A deeply nested value whose documentation is long enough that it cannot fit on the same line as its tags at all */\n nested?: {\n deeper?: {\n deepest?: Array<{\n x?: number,\n }>,\n },\n },\n anything?: unknown,\n missing?: unknown,\n}): Promise<{\n ok?: boolean,\n}>" + }, + { + "path": "slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + }, + { + "path": "slack.get_schedules", + "description": "Get scheduled messages", + "signature": "tools.slack.get_schedules(): Promise" + }, + { + "path": "slack.list_channels", + "description": "List channels", + "signature": "tools.slack.list_channels(): Promise" + }, + { + "path": "slack.list_user_groups", + "description": "List user groups", + "signature": "tools.slack.list_user_groups(): Promise" + }, + { + "path": "slack.list_users", + "description": "List users", + "signature": "tools.slack.list_users(): Promise" + }, + { + "path": "thread.generateImage", + "description": "Generate an image and upload it to the current Discord thread", + "signature": "tools.thread.generateImage(): Promise" + }, + { + "path": "thread.uploadFile", + "description": "Upload one readable local file to the current Discord thread", + "signature": "tools.thread.uploadFile(): Promise" + }, + { + "path": "tracker.fetch_all", + "description": "Fetch every open issue in the project", + "signature": "tools.tracker.fetch_all(): Promise" + }, + { + "path": "unicode.émoji", + "description": "Résumé café naïve 🎉 tools", + "signature": "tools.unicode[\"émoji\"](): Promise" + }, + { + "path": "users.get", + "description": "Get a user and the users they follow", + "signature": "tools.users.get({\n /**\n * GitHub login\n *\n * Case-insensitive.\n */\n login: string,\n}): Promise<{\n user: {\n login: string,\n id: number,\n },\n follows: Array<{\n login: string,\n id: number,\n }>,\n tags: {\n [key: string]: number,\n },\n}>" + }, + { + "path": "util.now", + "description": "The current time", + "signature": "tools.util.now(): Promise" + } + ], + "searchSignature": "search(query: string | {\n query?: string,\n namespace?: string,\n /** @integer @exclusiveMinimum 0 */\n limit?: number,\n /** @integer @minimum 0 */\n offset?: number,\n}): {\n items: Array<{\n path: string,\n description: string,\n signature: string,\n }>,\n /** @integer @minimum 0 */\n remaining: number,\n next: {\n /** @integer @minimum 0 */\n offset: number,\n } | null,\n}", + "expressions": [ + [ + "a", + "tools.a" + ], + [ + "a.b", + "tools.a.b" + ], + [ + "context7.resolve-library-id", + "tools.context7[\"resolve-library-id\"]" + ], + [ + "x.1st", + "tools.x[\"1st\"]" + ], + [ + "$ok._fine", + "tools.$ok._fine" + ], + [ + "naïve", + "tools[\"naïve\"]" + ] + ], + "programs": [ + { + "code": "return search({})", + "ok": true, + "value": { + "items": [ + { + "path": "tools.adapter.call", + "description": "Call an adapter-described tool", + "signature": "tools.adapter.call({\n id: string,\n count?: number,\n}): Promise" + }, + { + "path": "tools.cloud.describe_vm", + "description": "Describe a virtual machine", + "signature": "tools.cloud.describe_vm(): Promise" + }, + { + "path": "tools.cloud.list_all_issues", + "description": "List issues", + "signature": "tools.cloud.list_all_issues(): Promise" + }, + { + "path": "tools.cloudflare.get_timezones", + "description": "List timezones", + "signature": "tools.cloudflare.get_timezones(): Promise" + }, + { + "path": "tools.cloudflare.get_zones", + "description": "List zones", + "signature": "tools.cloudflare.get_zones(): Promise" + }, + { + "path": "tools.context7[\"resolve-library-id\"]", + "description": "Resolve a library ID", + "signature": "tools.context7[\"resolve-library-id\"]({\n libraryName: string,\n}): Promise" + }, + { + "path": "tools.fetchPage", + "description": "Fetch a page", + "signature": "tools.fetchPage(/** Page URL */ url: string): Promise" + }, + { + "path": "tools.files.patch", + "description": "Apply a patch", + "signature": "tools.files.patch(/** The full patch text, * / included. @minLength 1 */ patchText: string): Promise" + }, + { + "path": "tools.files.upload", + "description": "Send a document to the workspace", + "signature": "tools.files.upload({\n /** Local path of the payload to send */\n attachment: string,\n}): Promise<{\n sent: boolean,\n}>" + }, + { + "path": "tools.gmail.list_labels", + "description": "List the labels in the mailbox", + "signature": "tools.gmail.list_labels(): Promise" + } + ], + "remaining": 25, + "next": { + "offset": 10 + } + }, + "toolCalls": 1 + }, + { + "code": "return search({ limit: 3 })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.adapter.call", + "description": "Call an adapter-described tool", + "signature": "tools.adapter.call({\n id: string,\n count?: number,\n}): Promise" + }, + { + "path": "tools.cloud.describe_vm", + "description": "Describe a virtual machine", + "signature": "tools.cloud.describe_vm(): Promise" + }, + { + "path": "tools.cloud.list_all_issues", + "description": "List issues", + "signature": "tools.cloud.list_all_issues(): Promise" + } + ], + "remaining": 32, + "next": { + "offset": 3 + } + }, + "toolCalls": 1 + }, + { + "code": "return search({ limit: 2, offset: 4 })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.cloudflare.get_zones", + "description": "List zones", + "signature": "tools.cloudflare.get_zones(): Promise" + }, + { + "path": "tools.context7[\"resolve-library-id\"]", + "description": "Resolve a library ID", + "signature": "tools.context7[\"resolve-library-id\"]({\n libraryName: string,\n}): Promise" + } + ], + "remaining": 29, + "next": { + "offset": 6 + } + }, + "toolCalls": 1 + }, + { + "code": "return search({ offset: 100 })", + "ok": true, + "value": { + "items": [], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search(\"issues\")", + "ok": true, + "value": { + "items": [ + { + "path": "tools.issues", + "description": "All issues", + "signature": "tools.issues(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search(\"users\")", + "ok": true, + "value": { + "items": [ + { + "path": "tools.users.get", + "description": "Get a user and the users they follow", + "signature": "tools.users.get({\n /**\n * GitHub login\n *\n * Case-insensitive.\n */\n login: string,\n}): Promise<{\n user: {\n login: string,\n id: number,\n },\n follows: Array<{\n login: string,\n id: number,\n }>,\n tags: {\n [key: string]: number,\n },\n}>" + }, + { + "path": "tools.slack.list_users", + "description": "List users", + "signature": "tools.slack.list_users(): Promise" + }, + { + "path": "tools.slack.list_user_groups", + "description": "List user groups", + "signature": "tools.slack.list_user_groups(): Promise" + }, + { + "path": "tools.slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"users\", namespace: \"slack\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.slack.list_users", + "description": "List users", + "signature": "tools.slack.list_users(): Promise" + }, + { + "path": "tools.slack.list_user_groups", + "description": "List user groups", + "signature": "tools.slack.list_user_groups(): Promise" + }, + { + "path": "tools.slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"\", namespace: \"slack.admin\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"\", namespace: \"tools.issues\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.issues", + "description": "All issues", + "signature": "tools.issues(): Promise" + }, + { + "path": "tools.issues.archive", + "description": "Archive an issue", + "signature": "tools.issues.archive(): Promise" + }, + { + "path": "tools.issues.close", + "description": "Close an issue", + "signature": "tools.issues.close(): Promise" + }, + { + "path": "tools.issues.create", + "description": "Create an issue", + "signature": "tools.issues.create(): Promise" + }, + { + "path": "tools.issues.get", + "description": "Get one issue", + "signature": "tools.issues.get(): Promise" + }, + { + "path": "tools.issues.list", + "description": "List issues", + "signature": "tools.issues.list(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"account administration\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"purchases\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.orders.list", + "description": "List orders, newest first", + "signature": "tools.orders.list({\n /** Filter by status */\n status?: \"open\" | \"closed\",\n /** @integer @maximum 100 @exclusiveMinimum 0 */\n limit?: number,\n cursor?: string | null,\n}): Promise>" + }, + { + "path": "tools.orders.lookup", + "description": "Look up an order by ID", + "signature": "tools.orders.lookup({\n id: string,\n}): Promise<{\n id: string,\n status: string,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"list gmail labels\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.gmail.list_labels", + "description": "List the labels in the mailbox", + "signature": "tools.gmail.list_labels(): Promise" + }, + { + "path": "tools.gmail.list_messages", + "description": "List messages", + "signature": "tools.gmail.list_messages(): Promise" + }, + { + "path": "tools.issues.list", + "description": "List issues", + "signature": "tools.issues.list(): Promise" + }, + { + "path": "tools.slack.admin.users.list", + "description": "List workspace administrators", + "signature": "tools.slack.admin.users.list(): Promise" + }, + { + "path": "tools.orders.list", + "description": "List orders, newest first", + "signature": "tools.orders.list({\n /** Filter by status */\n status?: \"open\" | \"closed\",\n /** @integer @maximum 100 @exclusiveMinimum 0 */\n limit?: number,\n cursor?: string | null,\n}): Promise>" + }, + { + "path": "tools.slack.list_channels", + "description": "List channels", + "signature": "tools.slack.list_channels(): Promise" + }, + { + "path": "tools.slack.list_users", + "description": "List users", + "signature": "tools.slack.list_users(): Promise" + }, + { + "path": "tools.cloud.list_all_issues", + "description": "List issues", + "signature": "tools.cloud.list_all_issues(): Promise" + }, + { + "path": "tools.slack.list_user_groups", + "description": "List user groups", + "signature": "tools.slack.list_user_groups(): Promise" + }, + { + "path": "tools.cloudflare.get_timezones", + "description": "List timezones", + "signature": "tools.cloudflare.get_timezones(): Promise" + } + ], + "remaining": 1, + "next": { + "offset": 10 + } + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"schedu\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.slack.get_schedules", + "description": "Get scheduled messages", + "signature": "tools.slack.get_schedules(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"vms\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.cloud.describe_vm", + "description": "Describe a virtual machine", + "signature": "tools.cloud.describe_vm(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"all\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.issues", + "description": "All issues", + "signature": "tools.issues(): Promise" + }, + { + "path": "tools.tracker.fetch_all", + "description": "Fetch every open issue in the project", + "signature": "tools.tracker.fetch_all(): Promise" + }, + { + "path": "tools.cloud.list_all_issues", + "description": "List issues", + "signature": "tools.cloud.list_all_issues(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"zones\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.cloudflare.get_zones", + "description": "List zones", + "signature": "tools.cloudflare.get_zones(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"cronjob\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.k8s.getCronJob", + "description": "Read a CronJob in the cluster", + "signature": "tools.k8s.getCronJob(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"attachment\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.files.upload", + "description": "Send a document to the workspace", + "signature": "tools.files.upload({\n /** Local path of the payload to send */\n attachment: string,\n}): Promise<{\n sent: boolean,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"docum\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.files.upload", + "description": "Send a document to the workspace", + "signature": "tools.files.upload({\n /** Local path of the payload to send */\n attachment: string,\n}): Promise<{\n sent: boolean,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"email\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.mail.send", + "description": "Send an email", + "signature": "tools.mail.send(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"archive thread\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.mail.archive", + "description": "Archive a thread", + "signature": "tools.mail.archive(): Promise" + }, + { + "path": "tools.issues.archive", + "description": "Archive an issue", + "signature": "tools.issues.archive(): Promise" + }, + { + "path": "tools.thread.uploadFile", + "description": "Upload one readable local file to the current Discord thread", + "signature": "tools.thread.uploadFile(): Promise" + }, + { + "path": "tools.thread.generateImage", + "description": "Generate an image and upload it to the current Discord thread", + "signature": "tools.thread.generateImage(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"send message attachment upload file to current Discord thread\", limit: 2 })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.files.upload", + "description": "Send a document to the workspace", + "signature": "tools.files.upload({\n /** Local path of the payload to send */\n attachment: string,\n}): Promise<{\n sent: boolean,\n}>" + }, + { + "path": "tools.thread.uploadFile", + "description": "Upload one readable local file to the current Discord thread", + "signature": "tools.thread.uploadFile(): Promise" + } + ], + "remaining": 7, + "next": { + "offset": 2 + } + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"resume cafe\" })", + "ok": true, + "value": { + "items": [], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"tools.orders.lookup\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.orders.lookup", + "description": "Look up an order by ID", + "signature": "tools.orders.lookup({\n id: string,\n}): Promise<{\n id: string,\n status: string,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"orders.lookup\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.orders.lookup", + "description": "Look up an order by ID", + "signature": "tools.orders.lookup({\n id: string,\n}): Promise<{\n id: string,\n status: string,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: 'tools.context7[\"resolve-library-id\"]' })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.context7[\"resolve-library-id\"]", + "description": "Resolve a library ID", + "signature": "tools.context7[\"resolve-library-id\"]({\n libraryName: string,\n}): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"issues\", namespace: \"tracker\" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.tracker.fetch_all", + "description": "Fetch every open issue in the project", + "signature": "tools.tracker.fetch_all(): Promise" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"labels\", namespace: \"slack\" })", + "ok": true, + "value": { + "items": [], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \" order \" })", + "ok": true, + "value": { + "items": [ + { + "path": "tools.orders.list", + "description": "List orders, newest first", + "signature": "tools.orders.list({\n /** Filter by status */\n status?: \"open\" | \"closed\",\n /** @integer @maximum 100 @exclusiveMinimum 0 */\n limit?: number,\n cursor?: string | null,\n}): Promise>" + }, + { + "path": "tools.orders.lookup", + "description": "Look up an order by ID", + "signature": "tools.orders.lookup({\n id: string,\n}): Promise<{\n id: string,\n status: string,\n}>" + } + ], + "remaining": 0, + "next": null + }, + "toolCalls": 1 + }, + { + "code": "return search({ query: \"order\", limit: 0.5 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'search': SchemaError(Expected an integer\n at [\"limit\"])", + "suggestions": [ + "Pass search a query string or an object, such as search(\"issues\") or search({ namespace: \"github\" })." + ] + }, + "toolCalls": 0 + }, + { + "code": "return search({ query: \"order\", offset: -1 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'search': SchemaError(Expected a value greater than or equal to 0\n at [\"offset\"])", + "suggestions": [ + "Pass search a query string or an object, such as search(\"issues\") or search({ namespace: \"github\" })." + ] + }, + "toolCalls": 0 + }, + { + "code": "return search({ query: \"order\", namespace: 7 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'search': SchemaError(Expected string\n at [\"namespace\"])", + "suggestions": [ + "Pass search a query string or an object, such as search(\"issues\") or search({ namespace: \"github\" })." + ] + }, + "toolCalls": 0 + }, + { + "code": "return search(42)", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'search': SchemaError(Expected object)", + "suggestions": [ + "Pass search a query string or an object, such as search(\"issues\") or search({ namespace: \"github\" })." + ] + }, + "toolCalls": 0 + }, + { + "code": "return search(\"notes\", {})", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Tool 'search' expects at most one input object." + }, + "toolCalls": 0 + }, + { + "code": "return tools.search({ query: \"order\" })", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Tool 'search' is not callable, it is a namespace. Did you mean tools.search.advanced?", + "suggestions": [ + "Use search to find available tools." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.issues.missing({})", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Unknown tool 'issues.missing'.", + "suggestions": [ + "Use search to find available tools." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.issues[\"get-list\"]({})", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Unknown tool 'issues.get-list'. Did you mean tools.issues.get?", + "suggestions": [ + "Use search to find available tools." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders({})", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Tool 'orders' is not callable, it is a namespace. Did you mean tools.orders.list or tools.orders.lookup?", + "suggestions": [ + "Use search to find available tools." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.slack({})", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Tool 'slack' is not callable, it is a namespace. Did you mean tools.slack.get_schedules, tools.slack.list_channels, or tools.slack.list_users?", + "suggestions": [ + "2 more under 'slack'. Use search({ namespace: \"slack\" }) to list them." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.nothing.here({})", + "ok": false, + "error": { + "kind": "UnknownTool", + "message": "Unknown tool 'nothing.here'.", + "suggestions": [ + "Use search to find available tools." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.lookup({ id: 1 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.lookup': SchemaError(Expected string\n at [\"id\"])", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.lookup({})", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.lookup': SchemaError(Missing key\n at [\"id\"])", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.lookup(\"o1\")", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.lookup': SchemaError(Expected object)", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.lookup({ id: \"o1\" }, {})", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Tool 'orders.lookup' expects at most one input object." + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.lookup({ id: \"o1\", extra: true })", + "ok": true, + "value": { + "id": "o1", + "status": "open" + }, + "toolCalls": 1 + }, + { + "code": "return await tools.orders.list({ status: \"pending\" })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.list': SchemaError(Expected \"open\" | \"closed\"\n at [\"status\"])", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.list({ limit: 0 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.list': SchemaError(Expected a value greater than 0\n at [\"limit\"])", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.list({ limit: 1.5 })", + "ok": false, + "error": { + "kind": "InvalidToolInput", + "message": "Invalid input for tool 'orders.list': SchemaError(Expected an integer\n at [\"limit\"])", + "suggestions": [ + "The signature may have changed. Use search to get the current signature." + ] + }, + "toolCalls": 0 + }, + { + "code": "return await tools.orders.list({ status: \"open\", limit: 5, extra: 1 })", + "ok": true, + "value": [ + { + "id": "o1", + "total": 3 + } + ], + "toolCalls": 1 + }, + { + "code": "return await tools.fetchPage(\"https://a.test/\")", + "ok": true, + "value": "page", + "toolCalls": 1 + }, + { + "code": "return await tools.net.ping({ host: \"a\" })", + "ok": true, + "value": null, + "toolCalls": 1 + }, + { + "code": "return await tools.util.now()", + "ok": true, + "value": null, + "toolCalls": 1 + }, + { + "code": "return await tools.context7[\"resolve-library-id\"]({ libraryName: \"ts\" })", + "ok": true, + "value": "/lib", + "toolCalls": 1 + }, + { + "code": "return await tools.adapter.call({ id: 42 })", + "ok": true, + "value": null, + "toolCalls": 1 + }, + { + "code": "return [Object.keys(tools), Object.keys(tools.slack), Object.keys(tools.issues)]", + "ok": true, + "value": [ + [ + "orders", + "users", + "net", + "util", + "fetchPage", + "context7", + "adapter", + "files", + "search", + "issues", + "gmail", + "slack", + "cloud", + "cloudflare", + "tracker", + "k8s", + "mail", + "thread", + "unicode" + ], + [ + "list_channels", + "list_users", + "list_user_groups", + "get_schedules", + "admin" + ], + [ + "list", + "archive", + "create", + "get", + "close" + ] + ], + "toolCalls": 0 + } + ] +} diff --git a/packages/codemode-rust/conformance/catalog.ts b/packages/codemode-rust/conformance/catalog.ts new file mode 100644 index 000000000000..b4aa41786e0d --- /dev/null +++ b/packages/codemode-rust/conformance/catalog.ts @@ -0,0 +1,305 @@ +#!/usr/bin/env bun + +// Regenerates conformance/catalog.json from the reference CodeMode: a set of tools as JSON Schema documents, and what +// the reference makes of them: the catalog with its generated signatures, `searchSignature`, `toolExpression`, and +// the results of programs that search, call unknown tools, and pass invalid input. +// Usage: bun conformance/catalog.ts [reference] — the reference CodeMode package directory, from the argument, +// CODEMODE_REF, or by default ../codemode relative to this workspace. +// +// Effect Schema tools are written out as the JSON Schema document the reference renders them from (with +// `validated: true`); the Rust side declares them with `Schema::validated`. + +import { writeFileSync } from "node:fs" +import { join, resolve } from "node:path" + +const override = process.argv[2] ?? process.env.CODEMODE_REF +const pkg = override === undefined ? resolve(import.meta.dir, "../../codemode") : resolve(override) +const { Effect, Schema } = await import(Bun.resolveSync("effect", join(pkg, "src"))) +const { CodeMode, Namespace, Tool, searchSignature, toolExpression } = await import(join(pkg, "src/index.ts")) + +type Spec = { + path: string + description: string + input: unknown + output?: unknown + freeform?: boolean + result?: unknown +} + +const document = (schema: unknown, decoded = false) => { + const doc = Schema.toJsonSchemaDocument(decoded ? Schema.toType(schema) : schema, { onExcessProperty: "error" }) + const defs = doc.definitions as Record + return Object.keys(defs).length === 0 ? doc.schema : { ...doc.schema, $defs: defs } +} + +const User = Schema.Struct({ login: Schema.String, id: Schema.Number }).annotate({ identifier: "User" }) +const effect = { + "orders.lookup": { + description: "Look up an order by ID", + input: Schema.Struct({ id: Schema.String }), + output: Schema.Struct({ id: Schema.String, status: Schema.String }), + }, + "orders.list": { + description: "List orders, newest first", + input: Schema.Struct({ + status: Schema.optionalKey(Schema.Literals(["open", "closed"])).annotate({ description: "Filter by status" }), + limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(100))), + cursor: Schema.optional(Schema.String), + }), + output: Schema.Array(Schema.Struct({ id: Schema.String, total: Schema.Number })), + }, + "users.get": { + description: "Get a user and the users they follow", + input: Schema.Struct({ login: Schema.String.annotate({ description: "GitHub login\n\nCase-insensitive." }) }), + output: Schema.Struct({ user: User, follows: Schema.Array(User), tags: Schema.Record(Schema.String, Schema.Number) }), + }, + "net.ping": { + description: "Ping a host", + input: Schema.Struct({ host: Schema.String }), + output: undefined, + }, + "util.now": { + description: "The current time", + input: Schema.Struct({}), + output: Schema.NullOr(Schema.String), + }, + fetchPage: { + description: "Fetch a page", + input: Schema.Struct({ url: Schema.String.annotate({ description: "Page URL" }) }), + output: Schema.String, + freeform: true, + }, + "context7.resolve-library-id": { + description: "Resolve a library ID", + input: Schema.Struct({ libraryName: Schema.String }), + output: Schema.String, + }, +} + +const json: Array = [ + { + path: "adapter.call", + description: "Call an adapter-described tool", + input: { type: "object", properties: { id: { type: "string" }, count: { type: "number" } }, required: ["id"] }, + }, + { + path: "files.upload", + description: "Send a document to the workspace", + input: { + type: "object", + properties: { attachment: { type: "string", description: "Local path of the payload to send" } }, + required: ["attachment"], + }, + output: { type: "object", properties: { sent: { type: "boolean" } }, required: ["sent"] }, + }, + { + path: "files.patch", + description: "Apply a patch", + input: { + type: "object", + properties: { patchText: { type: "string", description: "The full patch text, */ included", minLength: 1 } }, + required: ["patchText"], + }, + freeform: true, + }, + { + path: "search.advanced", + description: "Every keyword the renderer knows", + input: { + type: "object", + $defs: { Tag: { type: "string", enum: ["a", "b"], description: "A tag" } }, + properties: { + when: { type: "string", format: "date-time", default: "now", deprecated: true }, + count: { type: "integer", minimum: 1, maximum: 10, multipleOf: 2 }, + ratio: { type: "number", exclusiveMinimum: 0, exclusiveMaximum: 1 }, + name: { type: "string", minLength: 1, maxLength: 64, pattern: "^[a-z]+$" }, + tags: { type: "array", items: { $ref: "#/$defs/Tag" }, minItems: 1, maxItems: 5, uniqueItems: true }, + either: { anyOf: [{ type: "string" }, { type: "number" }, { type: "null" }] }, + one: { oneOf: [{ const: 1 }, { const: "one" }] }, + both: { allOf: [{ type: "object", properties: { a: { type: "string" } } }, { type: "object", properties: { b: { type: "number" } } }] }, + multi: { type: ["string", "null"] }, + map: { type: "object", additionalProperties: { type: "number", description: "A count" } }, + mixed: { type: "object", properties: { k: { type: "string" } }, additionalProperties: { type: "boolean" } }, + "kebab-key": { type: "boolean" }, + nested: { + type: "object", + description: + "A deeply nested value whose documentation is long enough that it cannot fit on the same line as its tags at all", + properties: { deeper: { type: "object", properties: { deepest: { type: "array", items: { type: "object", properties: { x: { type: "number" } } } } } } }, + }, + anything: {}, + missing: { $ref: "#/$defs/Missing" }, + }, + required: ["count", "kebab-key"], + }, + output: { $ref: "#/definitions/Out", definitions: { Out: { type: "object", properties: { ok: { type: "boolean" } } } } }, + }, + { + path: "issues", + description: "All issues", + input: { type: "object" }, + output: { type: "string" }, + }, + { path: "issues.list", description: "List issues", input: { type: "object" }, output: { type: "string" } }, + { path: "issues.archive", description: "Archive an issue", input: { type: "object" }, output: { type: "string" } }, + { path: "issues.create", description: "Create an issue", input: { type: "object" }, output: { type: "string" } }, + { path: "issues.get", description: "Get one issue", input: { type: "object" }, output: { type: "string" } }, + { path: "issues.close", description: "Close an issue", input: { type: "object" }, output: { type: "string" } }, + ...[ + ["gmail.list_labels", "List the labels in the mailbox"], + ["gmail.list_messages", "List messages"], + ["slack.list_channels", "List channels"], + ["slack.list_users", "List users"], + ["slack.list_user_groups", "List user groups"], + ["slack.get_schedules", "Get scheduled messages"], + ["slack.admin.users.list", "List workspace administrators"], + ["cloud.describe_vm", "Describe a virtual machine"], + ["cloud.list_all_issues", "List issues"], + ["cloudflare.get_timezones", "List timezones"], + ["cloudflare.get_zones", "List zones"], + ["tracker.fetch_all", "Fetch every open issue in the project"], + ["k8s.getCronJob", "Read a CronJob in the cluster"], + ["mail.send", "Send an email"], + ["mail.archive", "Archive a thread"], + ["thread.uploadFile", "Upload one readable local file to the current Discord thread"], + ["thread.generateImage", "Generate an image and upload it to the current Discord thread"], + ["unicode.émoji", "Résumé café naïve 🎉 tools"], + ].map(([path, description]) => ({ path, description, input: { type: "object" }, output: { type: "string" } })), +] + +const namespaces: Array<{ path: string; description: string }> = [ + { path: "orders", description: "Purchases, fulfillment, and shipment tracking" }, + { path: "slack.admin", description: "Directory and account administration" }, +] + +const specs: Array = [ + ...Object.entries(effect).map(([path, t]) => ({ + path, + description: t.description, + input: { validated: true, schema: document(t.input) }, + ...(t.output === undefined ? {} : { output: { validated: true, schema: document(t.output, true) } }), + ...("freeform" in t ? { freeform: true } : {}), + })), + ...json.map((t) => ({ + ...t, + input: { validated: false, schema: t.input }, + ...(t.output === undefined ? {} : { output: { validated: false, schema: t.output } }), + })), +] + +// The reference tools: Effect Schema ones as declared, JSON Schema ones as given. Each returns a fixed value. +const tools: Record = {} +const results: Record = { + "orders.lookup": { id: "o1", status: "open" }, + "orders.list": [{ id: "o1", total: 3 }], + "util.now": null, + fetchPage: "page", + "context7.resolve-library-id": "/lib", +} +for (const [path, t] of Object.entries(effect)) { + tools[path] = Tool.make({ ...t, execute: (input: unknown) => Effect.succeed(path in results ? results[path] : input) }) +} +for (const t of json) { + tools[t.path] = Tool.make({ ...t, execute: (input: unknown) => Effect.succeed(t.path in results ? results[t.path] : input) }) +} +// Each described namespace wraps its tools in `Namespace.make`, in the place its first tool had. +const nested: Record = {} +for (const [path, tool] of Object.entries(tools)) { + const ns = namespaces.find((n) => path.startsWith(`${n.path}.`)) + if (ns === undefined) { + nested[path] = tool + continue + } + if (nested[ns.path] !== undefined) continue + const under = Object.keys(tools).filter((p) => p.startsWith(`${ns.path}.`)) + nested[ns.path] = Namespace.make({ + description: ns.description, + tools: Object.fromEntries(under.map((p) => [p.slice(ns.path.length + 1), tools[p]])), + }) +} +const runtime = CodeMode.make({ tools: nested }) + +const programs = [ + ...[ + `search({})`, + `search({ limit: 3 })`, + `search({ limit: 2, offset: 4 })`, + `search({ offset: 100 })`, + `search("issues")`, + `search("users")`, + `search({ query: "users", namespace: "slack" })`, + `search({ query: "", namespace: "slack.admin" })`, + `search({ query: "", namespace: "tools.issues" })`, + `search({ query: "account administration" })`, + `search({ query: "purchases" })`, + `search({ query: "list gmail labels" })`, + `search({ query: "schedu" })`, + `search({ query: "vms" })`, + `search({ query: "all" })`, + `search({ query: "zones" })`, + `search({ query: "cronjob" })`, + `search({ query: "attachment" })`, + `search({ query: "docum" })`, + `search({ query: "email" })`, + `search({ query: "archive thread" })`, + `search({ query: "send message attachment upload file to current Discord thread", limit: 2 })`, + `search({ query: "resume cafe" })`, + `search({ query: "tools.orders.lookup" })`, + `search({ query: "orders.lookup" })`, + `search({ query: 'tools.context7["resolve-library-id"]' })`, + `search({ query: "issues", namespace: "tracker" })`, + `search({ query: "labels", namespace: "slack" })`, + `search({ query: " order " })`, + `search({ query: "order", limit: 0.5 })`, + `search({ query: "order", offset: -1 })`, + `search({ query: "order", namespace: 7 })`, + `search(42)`, + `search("notes", {})`, + `tools.search({ query: "order" })`, + ].map((call) => `return ${call}`), + `return await tools.issues.missing({})`, + `return await tools.issues["get-list"]({})`, + `return await tools.orders({})`, + `return await tools.slack({})`, + `return await tools.nothing.here({})`, + `return await tools.orders.lookup({ id: 1 })`, + `return await tools.orders.lookup({})`, + `return await tools.orders.lookup("o1")`, + `return await tools.orders.lookup({ id: "o1" }, {})`, + `return await tools.orders.lookup({ id: "o1", extra: true })`, + `return await tools.orders.list({ status: "pending" })`, + `return await tools.orders.list({ limit: 0 })`, + `return await tools.orders.list({ limit: 1.5 })`, + `return await tools.orders.list({ status: "open", limit: 5, extra: 1 })`, + `return await tools.fetchPage("https://a.test/")`, + `return await tools.net.ping({ host: "a" })`, + `return await tools.util.now()`, + `return await tools.context7["resolve-library-id"]({ libraryName: "ts" })`, + `return await tools.adapter.call({ id: 42 })`, + `return [Object.keys(tools), Object.keys(tools.slack), Object.keys(tools.issues)]`, +] + +const outcome = async (code: string) => { + const result = await Effect.runPromise(runtime.execute(code)) + return result.ok + ? { ok: true, value: result.value, toolCalls: result.toolCalls.length } + : { ok: false, error: result.error, toolCalls: result.toolCalls.length } +} + +const expected = { + tools: specs, + namespaces, + catalog: runtime.catalog.map((tool: { path: string; description: string; signature: string }) => ({ + path: tool.path, + description: tool.description, + signature: tool.signature, + })), + searchSignature, + expressions: ["a", "a.b", "context7.resolve-library-id", "x.1st", "$ok._fine", "naïve"].map((path) => [ + path, + toolExpression(path), + ]), + programs: await Promise.all(programs.map(async (code) => ({ code, ...(await outcome(code)) }))), +} +writeFileSync(join(import.meta.dir, "catalog.json"), JSON.stringify(expected, null, 2) + "\n") +console.log(`${expected.catalog.length} tools, ${expected.programs.length} programs`) diff --git a/packages/codemode-rust/crates/psychoscript/src/compiler.rs b/packages/codemode-rust/crates/psychoscript/src/compiler.rs index 0abe011bee34..09a4a0008fca 100644 --- a/packages/codemode-rust/crates/psychoscript/src/compiler.rs +++ b/packages/codemode-rust/crates/psychoscript/src/compiler.rs @@ -501,6 +501,100 @@ impl<'a, 's> Compiler<'a, 's> { } } + /// Binds every `import` before the body runs, loading each module through the host's `%import(specifier, + /// kind, name)` global: kind 0 a default import, 1 a namespace, 2 a named export, 3 a bare import. + fn imports(&mut self, stmts: &'a [Statement<'a>]) -> R<()> { + for st in stmts { + let Statement::ImportDeclaration(d) = st else { + continue; + }; + if d.import_kind.is_type() || d.phase.is_some() { + return Err(unsupported("This form of `import`", d.span)); + } + let source = js_str(&d.source.value); + let source = source.as_str(); + let Some(specifiers) = &d.specifiers else { + self.import_call( + d.span.start, + |c| { + c.push_str(source); + Ok(()) + }, + 3, + None, + )?; + self.emit(Op::Pop); + continue; + }; + if specifiers.is_empty() { + self.import_call( + d.span.start, + |c| { + c.push_str(source); + Ok(()) + }, + 3, + None, + )?; + self.emit(Op::Pop); + } + for spec in specifiers { + let (kind, name, local, pos) = match spec { + ImportDeclarationSpecifier::ImportDefaultSpecifier(x) => { + (0, None, &x.local, x.span.start) + } + ImportDeclarationSpecifier::ImportNamespaceSpecifier(x) => { + (1, None, &x.local, x.span.start) + } + ImportDeclarationSpecifier::ImportSpecifier(x) => { + (2, Some(x.imported.name().as_str()), &x.local, x.span.start) + } + }; + self.import_call( + pos, + |c| { + c.push_str(source); + Ok(()) + }, + kind, + name, + )?; + match local.symbol_id.get() { + Some(s) => self.store_symbol(s, BindMode::Init, pos)?, + None => { + self.emit(Op::Pop); + } + } + } + } + Ok(()) + } + + /// `%import(, kind, name)`, leaving its result on the stack. + fn import_call( + &mut self, + pos: u32, + specifier: impl FnOnce(&mut Self) -> R<()>, + kind: u8, + name: Option<&str>, + ) -> R<()> { + let g = self.global_slot(crate::host::IMPORT_GLOBAL); + self.emit(Op::GetGlobal(g)); + self.emit(Op::Undef); + specifier(self)?; + self.push_num(f64::from(kind)); + let argc = match name { + Some(name) => { + self.push_str(name); + 3 + } + None => 2, + }; + self.pos = pos; + self.emit(Op::Call(argc)); + Ok(()) + } + fn hoist_functions(&mut self, stmts: &'a [Statement<'a>]) -> R<()> { for st in stmts { if let Statement::FunctionDeclaration(f) = st { @@ -670,6 +764,7 @@ impl<'a, 's> Compiler<'a, 's> { None => Vec::new(), }; self.init_scope(&syms); + self.imports(&program.body)?; self.hoist_functions(&program.body)?; if program.body.is_empty() && let Some(d) = program.directives.last() @@ -948,7 +1043,8 @@ impl<'a, 's> Compiler<'a, 's> { Statement::TryStatement(t) => self.try_stmt(t), Statement::ClassDeclaration(c) => Err(unsupported("Classes", c.span)), Statement::WithStatement(w) => Err(unsupported("`with`", w.span)), - Statement::ImportDeclaration(d) => Err(unsupported("`import`", d.span)), + // Bound before the body runs; see `imports`. + Statement::ImportDeclaration(_) => Ok(()), Statement::ExportAllDeclaration(d) => Err(unsupported("`export`", d.span)), Statement::ExportDefaultDeclaration(d) => Err(unsupported("`export`", d.span)), Statement::ExportNamedDeclaration(d) => Err(unsupported("`export`", d.span)), @@ -1822,7 +1918,12 @@ impl<'a, 's> Compiler<'a, 's> { return Err(unsupported("Tagged templates", t.span)); } Expression::Super(s) => return Err(unsupported("`super`", s.span)), - Expression::ImportExpression(i) => return Err(unsupported("`import()`", i.span)), + Expression::ImportExpression(i) => { + if i.options.is_some() { + return Err(unsupported("Import options", i.span)); + } + self.import_call(i.span.start, |c| c.expr(&i.source), 4, None)?; + } Expression::ImportMeta(m) => return Err(unsupported("`import.meta`", m.span)), Expression::NewTarget(m) => return Err(unsupported("`new.target`", m.span)), Expression::PrivateFieldExpression(p) => { diff --git a/packages/codemode-rust/crates/psychoscript/src/exec.rs b/packages/codemode-rust/crates/psychoscript/src/exec.rs new file mode 100644 index 000000000000..0387809258d4 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/exec.rs @@ -0,0 +1,290 @@ +//! The small amount of executor a run needs without depending on one: a set of host futures woken individually, +//! a thread-parking `block_on`, and one shared timer thread that wakes runs at their deadline. + +use std::collections::BinaryHeap; +use std::future::Future; +use std::pin::pin; +use std::sync::{Arc, Condvar, Mutex, OnceLock}; +use std::task::{Context, Poll, Wake, Waker}; +use std::time::Instant; + +use crate::tool::BoxFuture; + +// ---------- block_on ---------- + +struct Parker { + woken: Mutex, + signal: Condvar, +} + +impl Wake for Parker { + fn wake(self: Arc) { + self.wake_by_ref(); + } + + fn wake_by_ref(self: &Arc) { + let mut woken = self.woken.lock().unwrap_or_else(|e| e.into_inner()); + *woken = true; + self.signal.notify_one(); + } +} + +/// Drives a future to completion on the calling thread, parking it while the future waits. +pub fn block_on(future: F) -> F::Output { + let mut future = pin!(future); + let parker = Arc::new(Parker { + woken: Mutex::new(false), + signal: Condvar::new(), + }); + let waker = Waker::from(parker.clone()); + let mut cx = Context::from_waker(&waker); + loop { + if let Poll::Ready(v) = future.as_mut().poll(&mut cx) { + return v; + } + let mut woken = parker.woken.lock().unwrap_or_else(|e| e.into_inner()); + while !*woken { + woken = parker.signal.wait(woken).unwrap_or_else(|e| e.into_inner()); + } + *woken = false; + } +} + +// ---------- the task set ---------- + +/// Which tasks were woken since the run last looked, and the run's own waker to pass the news on. +#[derive(Default)] +struct Shared { + ready: Vec, + parent: Option, +} + +struct TaskWaker { + index: usize, + shared: Arc>, +} + +impl Wake for TaskWaker { + fn wake(self: Arc) { + self.wake_by_ref(); + } + + fn wake_by_ref(self: &Arc) { + let parent = { + let mut shared = self.shared.lock().unwrap_or_else(|e| e.into_inner()); + shared.ready.push(self.index); + shared.parent.clone() + }; + if let Some(parent) = parent { + parent.wake(); + } + } +} + +struct ParentWaker(Arc>); + +impl Wake for ParentWaker { + fn wake(self: Arc) { + self.wake_by_ref(); + } + + fn wake_by_ref(self: &Arc) { + let parent = self + .0 + .lock() + .unwrap_or_else(|e| e.into_inner()) + .parent + .clone(); + if let Some(parent) = parent { + parent.wake(); + } + } +} + +struct Slot<'a, T> { + future: BoxFuture<'a, T>, + waker: Waker, + tag: u32, +} + +/// The host futures a run has in flight. Each has its own waker, so only woken ones are polled again. Dropping the +/// set drops, and so cancels, every one of them. +pub struct Tasks<'a, T> { + slots: Vec>>, + free: Vec, + live: usize, + shared: Arc>, +} + +impl<'a, T> Default for Tasks<'a, T> { + fn default() -> Self { + Self { + slots: Vec::new(), + free: Vec::new(), + live: 0, + shared: Arc::default(), + } + } +} + +impl<'a, T> Tasks<'a, T> { + pub fn is_empty(&self) -> bool { + self.live == 0 + } + + /// Starts a future: it is polled once now, so its work begins at the call. `Ready` means it finished already. + pub fn spawn(&mut self, tag: u32, future: BoxFuture<'a, T>) -> Poll { + let index = self.free.pop().unwrap_or_else(|| { + self.slots.push(None); + self.slots.len() - 1 + }); + let waker = Waker::from(Arc::new(TaskWaker { + index, + shared: self.shared.clone(), + })); + let mut slot = Slot { future, waker, tag }; + let mut cx = Context::from_waker(&slot.waker); + if let Poll::Ready(v) = slot.future.as_mut().poll(&mut cx) { + self.free.push(index); + return Poll::Ready(v); + } + self.slots[index] = Some(slot); + self.live += 1; + Poll::Pending + } + + /// Polls every task woken since the last call; returns the finished ones with their tags, in completion order. + pub fn poll_ready(&mut self) -> Vec<(u32, T)> { + let ready = { + let mut shared = self.shared.lock().unwrap_or_else(|e| e.into_inner()); + std::mem::take(&mut shared.ready) + }; + let mut done = Vec::new(); + for index in ready { + let Some(Some(slot)) = self.slots.get_mut(index) else { + continue; + }; + let mut cx = Context::from_waker(&slot.waker); + if let Poll::Ready(v) = slot.future.as_mut().poll(&mut cx) { + let tag = slot.tag; + self.slots[index] = None; + self.free.push(index); + self.live -= 1; + done.push((tag, v)); + } + } + done + } + + /// Whether some task was woken and waits to be polled. + pub fn has_ready(&self) -> bool { + !self + .shared + .lock() + .unwrap_or_else(|e| e.into_inner()) + .ready + .is_empty() + } + + /// The waker to wake when a task becomes ready; `None` when nobody waits. + pub fn set_parent(&self, waker: Option<&Waker>) { + let mut shared = self.shared.lock().unwrap_or_else(|e| e.into_inner()); + shared.parent = waker.cloned(); + } + + /// A waker that wakes whoever waits on the set when it fires, even if that changes after it was made. + pub fn parent_waker(&self) -> Waker { + Waker::from(Arc::new(ParentWaker(self.shared.clone()))) + } + + /// Cancels every task by dropping it. + pub fn clear(&mut self) { + self.slots.clear(); + self.free.clear(); + self.live = 0; + } +} + +// ---------- the timer ---------- + +struct Timer { + queue: Mutex>, + signal: Condvar, +} + +struct Deadline { + at: Instant, + waker: Waker, +} + +impl PartialEq for Deadline { + fn eq(&self, other: &Self) -> bool { + self.at == other.at + } +} + +impl Eq for Deadline {} + +impl PartialOrd for Deadline { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Deadline { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + other.at.cmp(&self.at) + } +} + +/// Wakes `waker` at `at`, from one timer thread shared by every run, started the first time a run waits with a +/// timeout. A run that already ended just gets a spurious wake. +pub fn wake_at(at: Instant, waker: &Waker) { + static TIMER: OnceLock>> = OnceLock::new(); + let timer = TIMER.get_or_init(|| { + let timer = Arc::new(Timer { + queue: Mutex::new(BinaryHeap::new()), + signal: Condvar::new(), + }); + let worker = timer.clone(); + std::thread::Builder::new() + .name("psychoscript-timer".into()) + .spawn(move || run_timer(&worker)) + .ok() + .map(|_| timer) + }); + match timer { + Some(timer) => { + let mut queue = timer.queue.lock().unwrap_or_else(|e| e.into_inner()); + queue.push(Deadline { + at, + waker: waker.clone(), + }); + timer.signal.notify_one(); + } + // No thread to wait on: wake now, so the run polls again and finds its deadline. + None => waker.wake_by_ref(), + } +} + +fn run_timer(timer: &Timer) { + let mut queue = timer.queue.lock().unwrap_or_else(|e| e.into_inner()); + loop { + let now = Instant::now(); + while queue.peek().is_some_and(|d| d.at <= now) { + if let Some(d) = queue.pop() { + d.waker.wake(); + } + } + queue = match queue.peek().map(|d| d.at) { + Some(at) => { + timer + .signal + .wait_timeout(queue, at.saturating_duration_since(now)) + .unwrap_or_else(|e| e.into_inner()) + .0 + } + None => timer.signal.wait(queue).unwrap_or_else(|e| e.into_inner()), + }; + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/extension.rs b/packages/codemode-rust/crates/psychoscript/src/extension.rs new file mode 100644 index 000000000000..c296add71e62 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/extension.rs @@ -0,0 +1,321 @@ +//! Extensions: host functions and objects of functions a program reaches directly as globals, like `fetch` or `fs`. +//! +//! Every value crossing in either direction is a copy ([`HostValue`]), never shared. A function inside a result +//! becomes a program function that crosses the same way. Extension calls are not tool calls: they are not in the +//! catalog and do not count against `max_tool_calls`. + +use std::fmt; +use std::future::Future; +use std::sync::Arc; + +use crate::tool::BoxFuture; + +/// A value on the host's side of the boundary. +#[derive(Clone, Debug, Default)] +pub enum HostValue { + #[default] + Undefined, + Null, + Bool(bool), + Number(f64), + String(String), + /// `None` is a hole. + Array(Vec>), + Object(Vec<(String, HostValue)>), + Map(Vec<(HostValue, HostValue)>), + Set(Vec), + Function(HostFunction), + Error(Box), +} + +impl HostValue { + pub fn object>(fields: impl IntoIterator) -> Self { + HostValue::Object(fields.into_iter().map(|(k, v)| (k.into(), v)).collect()) + } + + pub fn array(items: impl IntoIterator) -> Self { + HostValue::Array(items.into_iter().map(Some).collect()) + } + + /// A field of an object, if it is one. + pub fn get(&self, key: &str) -> Option<&HostValue> { + match self { + HostValue::Object(fields) => fields.iter().find(|(k, _)| k == key).map(|(_, v)| v), + _ => None, + } + } + + pub fn as_str(&self) -> Option<&str> { + match self { + HostValue::String(s) => Some(s), + _ => None, + } + } + + pub fn as_f64(&self) -> Option { + match self { + HostValue::Number(n) => Some(*n), + _ => None, + } + } + + /// Plain JSON data as a host value. + pub fn from_json(json: &crate::Json) -> Self { + use crate::Json; + match json { + Json::Null => HostValue::Null, + Json::Bool(b) => HostValue::Bool(*b), + Json::Number(n) => HostValue::Number(n.as_f64().unwrap_or(f64::NAN)), + Json::String(s) => HostValue::String(s.clone()), + Json::Array(items) => HostValue::array(items.iter().map(HostValue::from_json)), + Json::Object(map) => HostValue::Object( + map.iter() + .map(|(k, v)| (k.clone(), HostValue::from_json(v))) + .collect(), + ), + } + } + + /// The value as JSON, the way `JSON.stringify` would see it: functions and `undefined` vanish. + pub fn to_json(&self) -> Option { + use crate::Json; + Some(match self { + HostValue::Undefined | HostValue::Function(_) => return None, + HostValue::Null => Json::Null, + HostValue::Bool(b) => Json::Bool(*b), + HostValue::Number(n) => { + serde_json::Number::from_f64(*n).map_or(Json::Null, Json::Number) + } + HostValue::String(s) => Json::String(s.clone()), + HostValue::Array(items) => Json::Array( + items + .iter() + .map(|i| { + i.as_ref() + .and_then(HostValue::to_json) + .unwrap_or(Json::Null) + }) + .collect(), + ), + HostValue::Set(items) => Json::Array( + items + .iter() + .map(|i| i.to_json().unwrap_or(Json::Null)) + .collect(), + ), + HostValue::Object(fields) => Json::Object( + fields + .iter() + .filter_map(|(k, v)| v.to_json().map(|j| (k.clone(), j))) + .collect(), + ), + HostValue::Map(_) => Json::Object(Default::default()), + HostValue::Error(e) => { + let mut map = serde_json::Map::new(); + map.insert("name".into(), Json::String(e.name.clone())); + map.insert("message".into(), Json::String(e.message.clone())); + Json::Object(map) + } + }) + } +} + +impl From<&str> for HostValue { + fn from(s: &str) -> Self { + HostValue::String(s.to_owned()) + } +} + +impl From for HostValue { + fn from(s: String) -> Self { + HostValue::String(s) + } +} + +impl From for HostValue { + fn from(n: f64) -> Self { + HostValue::Number(n) + } +} + +impl From for HostValue { + fn from(b: bool) -> Self { + HostValue::Bool(b) + } +} + +impl From for HostValue { + fn from(f: HostFunction) -> Self { + HostValue::Function(f) + } +} + +impl From for HostValue { + fn from(e: HostError) -> Self { + HostValue::Error(Box::new(e)) + } +} + +/// An error crossing the boundary: its name (`TypeError`, ...), message, cause, and own data such as Node's `code`. +#[derive(Clone, Debug, Default)] +pub struct HostError { + pub name: String, + pub message: String, + pub cause: Option>, + pub fields: Vec<(String, HostValue)>, +} + +impl HostError { + /// An `Error`. + pub fn new(message: impl Into) -> Self { + Self::named("Error", message) + } + + /// An error of a built-in type: `TypeError`, `RangeError`, `SyntaxError`, ... Other names become `Error`. + pub fn named(name: impl Into, message: impl Into) -> Self { + Self { + name: name.into(), + message: message.into(), + cause: None, + fields: Vec::new(), + } + } + + pub fn with_cause(mut self, cause: impl Into) -> Self { + self.cause = Some(Box::new(cause.into())); + self + } + + pub fn with_field(mut self, key: impl Into, value: impl Into) -> Self { + self.fields.push((key.into(), value.into())); + self + } +} + +impl fmt::Display for HostError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.message.is_empty() { + f.write_str(&self.name) + } else { + write!(f, "{}: {}", self.name, self.message) + } + } +} + +impl std::error::Error for HostError {} + +/// What a host function gives back: a value, or a value it throws (usually a [`HostValue::Error`]). +pub type HostResult = Result; + +type SyncFn = dyn Fn(Vec) -> HostResult + Send + Sync; +type AsyncFn = dyn Fn(Vec) -> BoxFuture<'static, HostResult> + Send + Sync; + +#[derive(Clone)] +pub(crate) enum Body { + Sync(Arc), + Async(Arc), +} + +/// A host function the program can call. +/// +/// A synchronous function returns before the next statement, like `fs.readFileSync`; it may block the thread to do +/// so. An asynchronous one hands the program a promise, and its future runs on whatever drives the program. A denied +/// call fails the way the function would: an asynchronous function rejects its promise, a synchronous one throws. +#[derive(Clone)] +pub struct HostFunction { + pub(crate) name: String, + pub(crate) length: u8, + pub(crate) body: Body, +} + +impl HostFunction { + /// `length` is what the program reads as the function's `length`. + pub fn new( + name: impl Into, + length: u8, + f: impl Fn(Vec) -> HostResult + Send + Sync + 'static, + ) -> Self { + Self { + name: name.into(), + length, + body: Body::Sync(Arc::new(f)), + } + } + + pub fn new_async( + name: impl Into, + length: u8, + f: impl Fn(Vec) -> F + Send + Sync + 'static, + ) -> Self + where + F: Future + Send + 'static, + { + Self { + name: name.into(), + length, + body: Body::Async(Arc::new(move |args| Box::pin(f(args)))), + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn is_async(&self) -> bool { + matches!(self.body, Body::Async(_)) + } +} + +impl fmt::Debug for HostFunction { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "[Function {}]", self.name) + } +} + +/// A named group of globals, the counterpart of the reference's `Extension.make`. Programs can also load a global +/// by its Node module name with `import`, `require` and `import()`. +#[derive(Clone, Debug)] +pub struct Extension { + name: String, + globals: Vec<(String, HostValue)>, +} + +impl Extension { + pub fn new(name: impl Into) -> Self { + Self { + name: name.into(), + globals: Vec::new(), + } + } + + /// A global function. + pub fn function(mut self, name: impl Into, f: HostFunction) -> Self { + self.globals.push((name.into(), HostValue::Function(f))); + self + } + + /// A global object, such as `fs`. Every function reachable from it is an entry point named by its path + /// (`fs.readFile`, `fs.promises.readFile`), so calls fire the extension hooks. + /// + /// # Panics + /// + /// When `value` is not an object, as the reference throws from `Extension.make`. + pub fn object(mut self, name: impl Into, value: HostValue) -> Self { + let name = name.into(); + assert!( + matches!(value, HostValue::Object(_)), + "Extension \"{}\" global \"{name}\" must be a function or an object.", + self.name + ); + self.globals.push((name, value)); + self + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn globals(&self) -> &[(String, HostValue)] { + &self.globals + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/hooks.rs b/packages/codemode-rust/crates/psychoscript/src/hooks.rs new file mode 100644 index 000000000000..2b0d671b5bd8 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/hooks.rs @@ -0,0 +1,128 @@ +//! Hooks around every call a program makes into the host, the counterpart of the reference's `Hooks`. +//! +//! A `before` hook is a future, so it can ask someone before a call goes ahead; failing denies the call, which then +//! fails the way the call itself would. An `after` hook is a plain function: it observes how a call ended and cannot +//! change it, and it must also run when a call is cancelled by dropping it, where there is nothing to await. + +use std::future::Future; +use std::sync::Arc; + +use crate::Json; +use crate::extension::{HostError, HostValue}; +use crate::tool::{BoxFuture, ToolError}; + +/// A tool call the program is making, with its decoded input. +#[derive(Clone, Debug, PartialEq)] +pub struct ToolInvocation { + pub name: String, + pub input: Json, + /// The call's idempotency key, `:`: the same at every hook. + pub key: String, +} + +/// A call the program is making to an extension global, or to a function of a global object named by its path +/// (`fs.readFile`), with copies of its arguments. +#[derive(Clone, Debug)] +pub struct ExtensionInvocation { + pub extension: String, + pub name: String, + pub args: Vec, +} + +/// How a call ended. +#[derive(Clone, Copy, Debug)] +pub enum CallResult<'a, V> { + Success(&'a V), + /// The failure's message, or the thrown value as the program would print it. + Failure(&'a str), + Interrupted, +} + +impl CallResult<'_, V> { + /// `"success"`, `"failure"` or `"interrupted"`. + pub fn status(&self) -> &'static str { + match self { + CallResult::Success(_) => "success", + CallResult::Failure(_) => "failure", + CallResult::Interrupted => "interrupted", + } + } +} + +pub type ToolBefore = + dyn Fn(&ToolInvocation) -> BoxFuture<'static, Result<(), ToolError>> + Send + Sync; +pub type ToolAfter = dyn Fn(&ToolInvocation, CallResult<'_, Json>) + Send + Sync; +pub type ExtensionBefore = + dyn Fn(&ExtensionInvocation) -> BoxFuture<'static, Result<(), HostError>> + Send + Sync; +pub type ExtensionAfter = dyn Fn(&ExtensionInvocation, CallResult<'_, HostValue>) + Send + Sync; + +/// `tool.before`, `tool.after`, `extension.before` and `extension.after`. +#[derive(Clone, Default)] +pub struct Hooks { + pub tool_before: Option>, + pub tool_after: Option>, + pub extension_before: Option>, + pub extension_after: Option>, +} + +impl Hooks { + pub fn new() -> Self { + Self::default() + } + + /// `tool.before` that decides at once. A `ToolError` denies the call: the program's promise rejects with it. + pub fn tool_before( + self, + f: impl Fn(&ToolInvocation) -> Result<(), ToolError> + Send + Sync + 'static, + ) -> Self { + self.tool_before_async(move |call| std::future::ready(f(call))) + } + + /// `tool.before` as a future, such as a permission prompt. + pub fn tool_before_async( + mut self, + f: impl Fn(&ToolInvocation) -> F + Send + Sync + 'static, + ) -> Self + where + F: Future> + Send + 'static, + { + self.tool_before = Some(Arc::new(move |call| Box::pin(f(call)))); + self + } + + pub fn tool_after( + mut self, + f: impl Fn(&ToolInvocation, CallResult<'_, Json>) + Send + Sync + 'static, + ) -> Self { + self.tool_after = Some(Arc::new(f)); + self + } + + /// `extension.before` that decides at once. A `HostError` denies the call: an asynchronous global's promise + /// rejects with it and a synchronous global throws it. + pub fn extension_before( + self, + f: impl Fn(&ExtensionInvocation) -> Result<(), HostError> + Send + Sync + 'static, + ) -> Self { + self.extension_before_async(move |call| std::future::ready(f(call))) + } + + pub fn extension_before_async( + mut self, + f: impl Fn(&ExtensionInvocation) -> F + Send + Sync + 'static, + ) -> Self + where + F: Future> + Send + 'static, + { + self.extension_before = Some(Arc::new(move |call| Box::pin(f(call)))); + self + } + + pub fn extension_after( + mut self, + f: impl Fn(&ExtensionInvocation, CallResult<'_, HostValue>) + Send + Sync + 'static, + ) -> Self { + self.extension_after = Some(Arc::new(f)); + self + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/host.rs b/packages/codemode-rust/crates/psychoscript/src/host.rs new file mode 100644 index 000000000000..480d9ab956df --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/host.rs @@ -0,0 +1,1160 @@ +//! The VM's side of host work: tool calls, the `search` built-in, extension globals and modules, and the host +//! futures a run has in flight. Arguments cross out and results cross in as copies. + +use std::sync::Arc; +use std::task::Poll; + +use rustc_hash::FxHashMap; + +use crate::exec::{Tasks, block_on}; +use crate::extension::{Body, HostError, HostFunction, HostResult, HostValue}; +use crate::hooks::{CallResult, ExtensionInvocation, Hooks, ToolInvocation}; +use crate::object::*; +use crate::schema; +use crate::search; +use crate::strings::Atom; +use crate::tool::{BoxFuture, Execute, Tool, ToolContext, tool_expression}; +use crate::value::{Id, Value}; +use crate::vm::{Res, Vm}; +use crate::{DiagnosticKind, Json, Setup, ToolCall}; + +/// Globals every program has before extensions apply, as the reference names them; an extension may not shadow one. +pub const BUILTIN_GLOBALS: &[&str] = &[ + "tools", + "search", + "require", + "undefined", + "NaN", + "Infinity", + "Object", + "Function", + "Array", + "Math", + "JSON", + "console", + "Promise", + "Symbol", + "Iterator", + "Number", + "String", + "Boolean", + "parseInt", + "parseFloat", + "isFinite", + "isNaN", + "Date", + "RegExp", + "Map", + "Set", + "WeakMap", + "WeakSet", + "URL", + "URLSearchParams", + "Headers", + "Uint8Array", + "Buffer", + "TextEncoder", + "TextDecoder", + "encodeURI", + "encodeURIComponent", + "decodeURI", + "decodeURIComponent", + "atob", + "btoa", + "crypto", + "structuredClone", + "globalThis", + "Error", + "TypeError", + "RangeError", + "SyntaxError", + "ReferenceError", + "EvalError", + "URIError", + "AggregateError", +]; + +/// The hidden global the compiler loads modules through. Not an identifier, so programs cannot name it. +pub const IMPORT_GLOBAL: &str = "%import"; + +/// How a host call settles its promise. +pub enum Settlement { + Json(Json), + Undefined, + Failure(Box), + /// An extension call's value, or what it threw, with the label that names it in conversion errors. + Host(Box<(HostResult, String)>), +} + +/// A host call's failure. Boxed, so the common successful settlement stays small. +pub struct Failed { + kind: DiagnosticKind, + message: String, + suggestions: Vec, +} + +impl Settlement { + fn failure(kind: DiagnosticKind, message: String) -> Self { + Settlement::Failure(Box::new(Failed { + kind, + message, + suggestions: Vec::new(), + })) + } +} + +/// A host function the program holds: what it calls, the path that names it, and whether it is an entry point, +/// whose calls fire the extension hooks. +pub struct FnEntry { + f: HostFunction, + label: String, + extension: String, + entry: bool, +} + +/// The host state of one run. +pub struct RunHost<'rt> { + pub setup: &'rt Setup, + pub run_id: Arc, + next_call: u64, + /// The context handed to synchronous tools, its call id set for each call. + ctx: ToolContext, + pub tasks: Tasks<'rt, Settlement>, + functions: Vec, + /// Suggestions attached to failure values, by error object. + pub suggestions: FxHashMap>, + promise_like: Option, + modules: FxHashMap, + namespaces: FxHashMap, +} + +impl<'rt> RunHost<'rt> { + pub fn new(setup: &'rt Setup, run_id: String) -> Self { + Self { + setup, + ctx: ToolContext::new(Arc::from(run_id.as_str()), 0), + run_id: Arc::from(run_id), + next_call: 0, + tasks: Tasks::default(), + functions: Vec::new(), + suggestions: FxHashMap::default(), + promise_like: None, + modules: FxHashMap::default(), + namespaces: FxHashMap::default(), + } + } + + /// Whether host work is still in flight, so an idle program is waiting rather than stuck. + pub fn waiting(&self) -> bool { + !self.tasks.is_empty() + } + + fn next_call(&mut self) -> u64 { + let id = self.next_call; + self.next_call += 1; + id + } + + fn context(&mut self) -> ToolContext { + let id = self.next_call(); + ToolContext::new(self.run_id.clone(), id) + } +} + +// ---------- setup ---------- + +/// Defines `search`, `require`, the import hook and the extensions' globals. +pub fn install(vm: &mut Vm) { + let search = native(vm, "search", 0, search_native, Value::Undef); + global(vm, "search", search); + let require = native(vm, "require", 1, require_native, Value::Undef); + global(vm, "require", require); + let import = native(vm, "import", 2, import_native, Value::Undef); + global(vm, IMPORT_GLOBAL, import); + let setup = vm.host.setup; + for extension in &setup.extensions { + for (name, value) in extension.globals() { + let v = from_host(vm, value, name, Some((extension.name(), true)), 0) + .unwrap_or(Value::Undef); + global(vm, name, v); + } + } +} + +fn global(vm: &mut Vm, name: &str, v: Value) { + let a = vm.atoms.intern(name); + vm.global_map.insert(a, v); +} + +fn native(vm: &mut Vm, name: &str, length: u8, f: crate::vm::NativeFn, data: Value) -> Value { + let name = vm.atoms.intern(name); + let proto = vm.realm.function_proto; + Value::Obj(vm.alloc(Obj::new( + Some(proto), + Kind::Native { + f, + data, + name, + length, + ctor: false, + }, + ))) +} + +// ---------- tool calls ---------- + +/// `tools.(...args)`: returns a promise at once; the call starts now and settles it later. +pub fn call_tool(vm: &mut Vm, path: &str, args: &[Value]) -> Res { + let p = vm.new_promise(); + match start_tool(vm, path, args) { + Started::Now(s) => vm.inbox.push_back((p, s)), + Started::Later(future) => { + if let Poll::Ready(s) = vm.host.tasks.spawn(p, future) { + vm.inbox.push_back((p, s)); + } + } + } + Ok(Value::Obj(p)) +} + +enum Started<'rt> { + Now(Settlement), + Later(BoxFuture<'rt, Settlement>), +} + +/// Everything about a call that happens before its tool runs: the reference's `decode` and `admit`. +struct Admitted<'rt> { + tool: &'rt Tool, + input: Json, + call: u64, +} + +fn start_tool<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Started<'rt> { + let setup = vm.host.setup; + // Models often write `tools.search(...)` for the bare `search(...)`; honor it unless a tool owns that path. + if path == "search" && !setup.registry.exists("search") { + return match run_search(vm, args) { + Ok(json) => Started::Now(Settlement::Json(json)), + Err(s) => Started::Now(s), + }; + } + let admitted = match admit(vm, path, args) { + Ok(a) => a, + Err(s) => return Started::Now(s), + }; + let hooks = &setup.hooks; + if hooks.tool_before.is_none() + && hooks.tool_after.is_none() + && let Execute::Sync(f) = &admitted.tool.execute + { + vm.host.ctx.call = admitted.call; + let raw = f(admitted.input, &vm.host.ctx); + return Started::Now(finish(path, admitted.tool, raw)); + } + let ctx = ToolContext::new(vm.host.run_id.clone(), admitted.call); + Started::Later(Box::pin(hooked_tool(hooks, path.to_owned(), admitted, ctx))) +} + +fn admit<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Result, Settlement> { + let setup = vm.host.setup; + let Some(tool) = setup.registry.get(path) else { + return Err(unknown_tool(setup, path)); + }; + let tool: &'rt Tool = tool; + let entry_field = tool + .freeform + .then(|| schema::string_parameter(tool.input.document()).map(|(name, _)| name)) + .flatten(); + let input = decode(vm, path, &tool.input, entry_field.as_deref(), args, false)?; + admit_call(vm, path, &input)?; + let call = vm.host.next_call(); + Ok(Admitted { tool, input, call }) +} + +/// Copies the call's argument out as JSON and decodes it with the tool's input schema. +fn decode( + vm: &mut Vm, + name: &str, + schema: &crate::Schema, + string_field: Option<&str>, + args: &[Value], + search: bool, +) -> Result { + if args.len() > 1 { + return Err(Settlement::failure( + DiagnosticKind::InvalidToolInput, + format!("Tool '{name}' expects at most one input object."), + )); + } + let input = match args.first() { + None => Json::Object(serde_json::Map::new()), + Some(v) => match crate::convert::to_json(vm, v) { + Ok(j) => j, + Err(e) => { + let msg = vm.error_text(&e); + return Err(Settlement::failure( + DiagnosticKind::InvalidDataValue, + format!("Invalid input for tool '{name}': {msg}"), + )); + } + }, + }; + let input = match (string_field, input) { + (Some(field), Json::String(s)) => { + let mut map = serde_json::Map::new(); + map.insert(field.to_owned(), Json::String(s)); + Json::Object(map) + } + (_, input) => input, + }; + schema + .validate(input) + .map_err(|e| Settlement::Failure(Box::new(Failed { + kind: DiagnosticKind::InvalidToolInput, + message: format!("Invalid input for tool '{name}': {e}"), + suggestions: vec![if search { + "Pass search a query string or an object, such as search(\"issues\") or search({ namespace: \"github\" }).".into() + } else { + "The signature may have changed. Use search to get the current signature.".into() + }], + }))) +} + +/// Counts a call against `max_tool_calls` and records it. +fn admit_call(vm: &mut Vm, path: &str, input: &Json) -> Result<(), Settlement> { + if let Some(max) = vm.limits.max_tool_calls + && vm.tool_calls.len() as u64 >= max + { + return Err(Settlement::failure( + DiagnosticKind::ToolCallLimitExceeded, + format!("Execution exceeded its tool-call limit of {max}."), + )); + } + vm.tool_calls.push(ToolCall { + path: path.to_owned(), + input: input.clone(), + }); + Ok(()) +} + +/// A tool's raw result as the program receives it. +fn finish(name: &str, tool: &Tool, raw: Result) -> Settlement { + match raw { + Err(e) => Settlement::failure(DiagnosticKind::ToolFailure, e.message), + Ok(raw) => match &tool.output { + None => Settlement::Undefined, + Some(schema) => match schema.validate(raw) { + Ok(json) => Settlement::Json(json), + Err(e) => Settlement::failure( + DiagnosticKind::InvalidToolOutput, + format!("Invalid output from tool '{name}': {e}"), + ), + }, + }, + } +} + +/// Runs `tool.after` as interrupted if the call is dropped while its tool runs. +struct AfterGuard<'h> { + hooks: &'h Hooks, + call: Option, +} + +impl AfterGuard<'_> { + fn end(mut self, s: &Settlement) { + let (Some(after), Some(call)) = (&self.hooks.tool_after, self.call.take()) else { + return; + }; + let null = Json::Null; + match s { + Settlement::Json(v) => after(&call, CallResult::Success(v)), + Settlement::Undefined => after(&call, CallResult::Success(&null)), + Settlement::Failure(f) => after(&call, CallResult::Failure(&f.message)), + Settlement::Host(_) => {} + } + } +} + +impl Drop for AfterGuard<'_> { + fn drop(&mut self) { + if let (Some(after), Some(call)) = (&self.hooks.tool_after, self.call.take()) { + after(&call, CallResult::Interrupted); + } + } +} + +async fn hooked_tool(hooks: &Hooks, name: String, a: Admitted<'_>, ctx: ToolContext) -> Settlement { + let call = ToolInvocation { + name: name.clone(), + input: a.input.clone(), + key: ctx.key(), + }; + if let Some(before) = &hooks.tool_before + && let Err(e) = before(&call).await + { + return Settlement::failure(DiagnosticKind::ToolFailure, e.message); + } + let guard = AfterGuard { + hooks, + call: Some(call), + }; + let raw = match &a.tool.execute { + Execute::Sync(f) => f(a.input, &ctx), + Execute::Async(f) => f(a.input, ctx).await, + }; + let s = finish(&name, a.tool, raw); + guard.end(&s); + s +} + +fn unknown_tool(setup: &Setup, path: &str) -> Settlement { + let registry = &setup.registry; + let entries = registry.entries(); + let index = registry.word_index(); + let segments: Vec<&str> = path.split('.').collect(); + if !registry.is_namespace(path) { + let first = segments[0]; + let ns = (segments.len() > 1 && registry.exists(first)).then_some(first); + let (scope, query): (Vec, String) = match ns { + Some(ns) => { + let under = format!("{ns}."); + ( + (0..entries.len()) + .filter(|&i| entries[i].path.starts_with(&under)) + .collect(), + segments[1..].join(" "), + ) + } + None => ((0..entries.len()).collect(), path.to_owned()), + }; + let closest = search::rank(entries, index, &scope, &query) + .into_iter() + .next(); + let message = match closest { + Some(i) => format!( + "Unknown tool '{path}'. Did you mean {}?", + tool_expression(&entries[i].path) + ), + None => format!("Unknown tool '{path}'."), + }; + return Settlement::Failure(Box::new(Failed { + kind: DiagnosticKind::UnknownTool, + message, + suggestions: vec!["Use search to find available tools.".into()], + })); + } + let under = format!("{path}."); + let scope: Vec = (0..entries.len()) + .filter(|&i| entries[i].path.starts_with(&under)) + .collect(); + let mut shown = search::rank( + entries, + index, + &scope, + segments.last().copied().unwrap_or(""), + ); + for &i in &scope { + if !shown.contains(&i) { + shown.push(i); + } + } + shown.truncate(3); + let shown: Vec = shown + .iter() + .map(|&i| tool_expression(&entries[i].path)) + .collect(); + let more = scope.len() - shown.len(); + let message = if shown.is_empty() { + format!("Tool '{path}' is not callable.") + } else { + format!( + "Tool '{path}' is not callable, it is a namespace. Did you mean {}?", + disjunction(&shown) + ) + }; + let suggestion = if more > 0 { + format!( + "{more} more under '{path}'. Use search({{ namespace: {} }}) to list them.", + schema::js_stringify(&Json::String(path.to_owned())) + ) + } else { + "Use search to find available tools.".into() + }; + Settlement::Failure(Box::new(Failed { + kind: DiagnosticKind::UnknownTool, + message, + suggestions: vec![suggestion], + })) +} + +/// `Intl.ListFormat("en", { type: "disjunction" })`. +fn disjunction(items: &[String]) -> String { + match items { + [] => String::new(), + [a] => a.clone(), + [a, b] => format!("{a} or {b}"), + [rest @ .., last] => format!("{}, or {last}", rest.join(", ")), + } +} + +/// Settles a host call's promise with what it ended with. +#[inline] +pub fn settle(vm: &mut Vm, p: Id, s: Settlement) { + match s { + Settlement::Json(json) => { + let v = crate::convert::from_json(vm, &json); + vm.fulfill(p, v); + } + Settlement::Undefined => vm.fulfill(p, Value::Undef), + Settlement::Failure(f) => { + let e = failure_value(vm, f.kind, f.message, f.suggestions); + vm.reject(p, e); + } + Settlement::Host(host) => match *host { + (Ok(v), label) => match from_host(vm, &v, &label, None, 0) { + Ok(v) => vm.fulfill(p, v), + Err(e) => vm.reject(p, e), + }, + (Err(thrown), label) => { + let e = from_host(vm, &thrown, &label, None, 0).unwrap_or_else(|e| e); + vm.reject(p, e); + } + }, + } +} + +fn failure_value( + vm: &mut Vm, + kind: DiagnosticKind, + message: String, + suggestions: Vec, +) -> Value { + let proto = vm.realm.error_proto; + let e = vm.failure(proto, &message, kind); + if !suggestions.is_empty() + && let Value::Obj(id) = e + { + vm.host.suggestions.insert(id, suggestions); + } + e +} + +// ---------- search ---------- + +fn search_native(vm: &mut Vm, _this: Value, args: &[Value], _callee: Id) -> Res { + match run_search(vm, args) { + Ok(json) => { + let v = crate::convert::from_json(vm, &json); + if let Value::Obj(id) = v { + vm.heap[id as usize].proto = Some(promise_like_proto(vm)); + } + Ok(v) + } + Err(Settlement::Failure(f)) => Err(failure_value(vm, f.kind, f.message, f.suggestions)), + Err(_) => Ok(Value::Undef), + } +} + +/// The built-in search, blocking: decode, admit, the hooks, then the ranking. +fn run_search(vm: &mut Vm, args: &[Value]) -> Result { + let setup = vm.host.setup; + let args: Vec = match args.first() { + Some(Value::Str(s)) => { + let query = vm.text(*s).to_owned(); + let id = vm.new_object(); + let q = vm.str_val(&query); + let key = vm.atoms.intern("query"); + vm.define(id, key, q); + let mut rest = vec![Value::Obj(id)]; + rest.extend_from_slice(&args[1..]); + rest + } + _ => args.to_vec(), + }; + let input = decode(vm, "search", &search::input_schema(), None, &args, true)?; + admit_call(vm, "search", &input)?; + let key = vm.host.context().key(); + let hooks = &setup.hooks; + let call = ToolInvocation { + name: "search".into(), + input: input.clone(), + key, + }; + if let Some(before) = &hooks.tool_before + && let Err(e) = block_on(before(&call)) + { + return Err(Settlement::failure(DiagnosticKind::ToolFailure, e.message)); + } + let registry = &setup.registry; + let result = search::search(registry.entries(), registry.word_index(), &input); + if let Some(after) = &hooks.tool_after { + after(&call, CallResult::Success(&result)); + } + Ok(result) +} + +/// The prototype of `search` results: an ordinary object whose `then`, `catch` and `finally` act on a settled copy, +/// so a result can be used directly, awaited, or chained, while data views see only its own fields. +fn promise_like_proto(vm: &mut Vm) -> Id { + if let Some(id) = vm.host.promise_like { + return id; + } + let object_proto = vm.realm.object_proto; + let id = vm.alloc(Obj::new(Some(object_proto), Kind::Ordinary)); + for (name, length) in [("then", 2u8), ("catch", 1), ("finally", 1)] { + let key = vm.atoms.intern(name); + let f = native( + vm, + name, + length, + promise_like_method, + Value::Str(vm.atoms.atom_str(key)), + ); + vm.define_hidden(id, key, f); + } + vm.host.promise_like = Some(id); + id +} + +fn promise_like_method(vm: &mut Vm, this: Value, args: &[Value], callee: Id) -> Res { + let Value::Obj(source) = this else { + return Err(vm.type_error("Method called on a non-object")); + }; + let copy = vm.new_object(); + for (k, v) in vm.own_entries(source) { + vm.define(copy, k, v); + } + let p = vm.new_promise(); + vm.fulfill(p, Value::Obj(copy)); + let Value::Str(name) = vm.native_data(callee) else { + return Ok(Value::Undef); + }; + let name = vm.text(name).to_owned(); + let key = vm.atoms.intern(&name); + let method = vm.get(&Value::Obj(p), key)?; + vm.call(&method, Value::Obj(p), args) +} + +// ---------- extensions ---------- + +fn describe(vm: &Vm, v: &Value) -> &'static str { + match v { + Value::Sym(_) => "a symbol", + Value::Obj(id) => match &vm.heap[*id as usize].kind { + Kind::Closure(_) | Kind::Native { .. } | Kind::Bound(_) => "a function", + Kind::ToolRef(_) => "a tool reference", + Kind::Promise(_) => "an un-awaited Promise", + Kind::Generator(_) + | Kind::ArrayIter { .. } + | Kind::MapIter { .. } + | Kind::StrIter { .. } + | Kind::ListIter { .. } => "an iterator", + _ => "an object", + }, + _ => "a value", + } +} + +/// A program value copied out for a host function. +fn to_host( + vm: &mut Vm, + v: &Value, + label: &str, + depth: usize, + seen: &mut Vec, +) -> Result { + if depth > crate::convert::MAX_VALUE_DEPTH { + let msg = format!( + "{label} exceeds the maximum value depth of {}.", + crate::convert::MAX_VALUE_DEPTH + ); + return Err(vm.type_error(&msg)); + } + let id = match v { + Value::Undef | Value::Uninit => return Ok(HostValue::Undefined), + Value::Null => return Ok(HostValue::Null), + Value::Bool(b) => return Ok(HostValue::Bool(*b)), + Value::Num(n) => return Ok(HostValue::Number(*n)), + Value::Str(s) => return Ok(HostValue::String(vm.text(*s).to_owned())), + Value::Sym(_) => { + let msg = format!("{label} contains a symbol, which cannot be passed to an extension."); + return Err(vm.type_error(&msg)); + } + Value::Obj(id) => *id, + }; + let opaque = !matches!( + vm.heap[id as usize].kind, + Kind::Ordinary + | Kind::Array(_) + | Kind::Arguments(_) + | Kind::Error(_) + | Kind::Map(_) + | Kind::Set(_) + ); + if opaque { + let msg = format!( + "{label} contains {}, which cannot be passed to an extension.", + describe(vm, v) + ); + return Err(vm.type_error(&msg)); + } + if seen.contains(&id) { + return Err(vm.type_error(&format!("{label} contains a circular value."))); + } + seen.push(id); + let out = match &vm.heap[id as usize].kind { + Kind::Array(items) | Kind::Arguments(items) => { + let items = items.clone(); + let mut out = Vec::with_capacity(items.len()); + for item in &items { + out.push(Some(to_host(vm, item, label, depth + 1, seen)?)); + } + HostValue::Array(out) + } + Kind::Map(m) | Kind::Set(m) => { + let is_map = matches!(vm.heap[id as usize].kind, Kind::Map(_)); + let entries: Vec<(Value, Value)> = m.entries.iter().flatten().copied().collect(); + if is_map { + let mut out = Vec::with_capacity(entries.len()); + for (k, val) in &entries { + out.push(( + to_host(vm, k, label, depth + 1, seen)?, + to_host(vm, val, label, depth + 1, seen)?, + )); + } + HostValue::Map(out) + } else { + let mut out = Vec::with_capacity(entries.len()); + for (k, _) in &entries { + out.push(to_host(vm, k, label, depth + 1, seen)?); + } + HostValue::Set(out) + } + } + Kind::Error(_) => { + let (name, message) = crate::convert::error_parts(vm, id); + let mut error = HostError::named(name, message); + let cause_key = vm.names.cause; + if vm.has_own(id, cause_key) { + let cause = vm.get_obj(id, cause_key); + if let Ok(c) = to_host(vm, &cause, label, depth + 1, seen) { + error.cause = Some(Box::new(c)); + } + } + for (k, val) in vm.own_entries(id) { + let key = vm.atoms.text(k).to_owned(); + if matches!( + key.as_str(), + "stack" + | "message" + | "constructor" + | "toString" + | "__proto__" + | "cause" + | "name" + ) { + continue; + } + // A field that cannot cross is left behind, so the error itself always arrives. + if let Ok(item) = to_host(vm, &val, label, depth + 1, seen) { + error.fields.push((key, item)); + } + } + HostValue::Error(Box::new(error)) + } + _ => { + let mut out = Vec::new(); + for (k, val) in vm.own_entries(id) { + let key = vm.atoms.text(k).to_owned(); + if key == "__proto__" { + continue; + } + out.push((key, to_host(vm, &val, label, depth + 1, seen)?)); + } + HostValue::Object(out) + } + }; + seen.pop(); + Ok(out) +} + +/// A host value copied in. `entry` is the extension of a global object whose functions are entry points. +fn from_host( + vm: &mut Vm, + v: &HostValue, + label: &str, + entry: Option<(&str, bool)>, + depth: usize, +) -> Result { + if depth > crate::convert::MAX_VALUE_DEPTH { + let msg = format!( + "{label} exceeds the maximum value depth of {}.", + crate::convert::MAX_VALUE_DEPTH + ); + return Err(vm.type_error(&msg)); + } + let next = |key: &str| format!("{label}.{key}"); + Ok(match v { + HostValue::Undefined => Value::Undef, + HostValue::Null => Value::Null, + HostValue::Bool(b) => Value::Bool(*b), + HostValue::Number(n) => Value::Num(*n), + HostValue::String(s) => vm.str_val(s), + HostValue::Function(f) => wrap(vm, f, label, entry), + HostValue::Array(items) => { + if items.len() > 10_000_000 { + let msg = format!( + "{label} produced an array of {} items; at most 10000000 can cross.", + items.len() + ); + return Err(vm.range_error(&msg)); + } + let mut out = Vec::with_capacity(items.len()); + for (i, item) in items.iter().enumerate() { + out.push(match item { + Some(item) => from_host(vm, item, &format!("{label}[{i}]"), entry, depth + 1)?, + None => Value::Undef, + }); + } + vm.new_array(out) + } + HostValue::Object(fields) => { + let id = vm.new_object(); + for (k, item) in fields { + let val = from_host(vm, item, &next(k), entry, depth + 1)?; + let key = vm.atoms.intern(k); + vm.define(id, key, val); + } + Value::Obj(id) + } + HostValue::Map(entries) => { + let proto = vm.realm.map_proto; + let id = vm.alloc(Obj::new(Some(proto), Kind::Map(Box::default()))); + for (k, item) in entries { + let k = from_host(vm, k, label, entry, depth + 1)?; + let item = from_host(vm, item, label, entry, depth + 1)?; + let mk = vm.map_key(&k); + if let Kind::Map(m) = &mut vm.heap[id as usize].kind { + m.set(mk, k, item); + } + } + Value::Obj(id) + } + HostValue::Set(items) => { + let proto = vm.realm.set_proto; + let id = vm.alloc(Obj::new(Some(proto), Kind::Set(Box::default()))); + for item in items { + let k = from_host(vm, item, label, entry, depth + 1)?; + let mk = vm.map_key(&k); + if let Kind::Set(m) = &mut vm.heap[id as usize].kind { + m.set(mk, k, Value::Undef); + } + } + Value::Obj(id) + } + HostValue::Error(e) => { + let proto = match e.name.as_str() { + "TypeError" => vm.realm.type_error_proto, + "RangeError" => vm.realm.range_error_proto, + "SyntaxError" => vm.realm.syntax_error_proto, + "ReferenceError" => vm.realm.reference_error_proto, + "AggregateError" => vm.realm.aggregate_error_proto, + _ => vm.realm.error_proto, + }; + let err = vm.make_error(proto, &e.message); + if let Value::Obj(id) = err { + if let Some(cause) = &e.cause + && let Ok(c) = from_host(vm, cause, &next("cause"), None, depth + 1) + { + let key = vm.names.cause; + vm.define_hidden(id, key, c); + } + for (k, item) in &e.fields { + if matches!( + k.as_str(), + "stack" | "message" | "constructor" | "toString" | "__proto__" + ) { + continue; + } + if matches!(item, HostValue::Function(_)) { + continue; + } + if let Ok(val) = from_host(vm, item, &next(k), None, depth + 1) { + let key = vm.atoms.intern(k); + vm.define(id, key, val); + } + } + } + err + } + }) +} + +/// A host function as a program function, at `label`. Inside a global object, it is an entry point. +fn wrap(vm: &mut Vm, f: &HostFunction, label: &str, entry: Option<(&str, bool)>) -> Value { + let index = vm.host.functions.len(); + vm.host.functions.push(FnEntry { + f: f.clone(), + label: label.to_owned(), + extension: entry.map(|(e, _)| e.to_owned()).unwrap_or_default(), + entry: entry.is_some_and(|(_, e)| e), + }); + native( + vm, + &f.name.clone(), + f.length, + extension_native, + Value::Num(index as f64), + ) +} + +fn extension_native(vm: &mut Vm, _this: Value, args: &[Value], callee: Id) -> Res { + let Value::Num(index) = vm.native_data(callee) else { + return Ok(Value::Undef); + }; + let entry = &vm.host.functions[index as usize]; + let (f, label, extension, hooked) = ( + entry.f.clone(), + entry.label.clone(), + entry.extension.clone(), + entry.entry, + ); + let mut host_args = Vec::with_capacity(args.len()); + for (i, a) in args.iter().enumerate() { + let mut seen = Vec::new(); + host_args.push(to_host( + vm, + a, + &format!("Argument {} to {label}", i + 1), + 0, + &mut seen, + )?); + } + let setup = vm.host.setup; + let hooks = &setup.hooks; + let invocation = hooked.then(|| ExtensionInvocation { + extension, + name: label.clone(), + args: host_args.clone(), + }); + match &f.body { + Body::Sync(body) => { + if let (Some(call), Some(before)) = (&invocation, &hooks.extension_before) + && let Err(e) = block_on(before(call)) + { + let thrown = HostValue::Error(Box::new(e)); + return Err(from_host(vm, &thrown, &label, None, 0).unwrap_or_else(|e| e)); + } + let result = body(host_args); + if let (Some(call), Some(after)) = (&invocation, &hooks.extension_after) { + report(after.as_ref(), call, &result); + } + match result { + Ok(v) => from_host(vm, &v, &label, None, 0), + Err(thrown) => Err(from_host(vm, &thrown, &label, None, 0).unwrap_or_else(|e| e)), + } + } + Body::Async(body) => { + let p = vm.new_promise(); + let body = body.clone(); + let future: BoxFuture<'_, Settlement> = Box::pin(async move { + if let (Some(call), Some(before)) = (&invocation, &hooks.extension_before) + && let Err(e) = before(call).await + { + return Settlement::Host(Box::new((Err(HostValue::Error(Box::new(e))), label))); + } + let guard = ExtensionGuard { + hooks, + call: invocation, + }; + let result = body(host_args).await; + guard.end(&result); + Settlement::Host(Box::new((result, label))) + }); + if let Poll::Ready(s) = vm.host.tasks.spawn(p, future) { + vm.inbox.push_back((p, s)); + } + Ok(Value::Obj(p)) + } + } +} + +fn report(after: &crate::hooks::ExtensionAfter, call: &ExtensionInvocation, result: &HostResult) { + match result { + Ok(v) => after(call, CallResult::Success(v)), + Err(thrown) => { + let text = thrown_text(thrown); + after(call, CallResult::Failure(&text)); + } + } +} + +fn thrown_text(v: &HostValue) -> String { + match v { + HostValue::Error(e) => e.message.clone(), + HostValue::String(s) => s.clone(), + other => other + .to_json() + .map(|j| schema::js_stringify(&j)) + .unwrap_or_default(), + } +} + +struct ExtensionGuard<'h> { + hooks: &'h Hooks, + call: Option, +} + +impl ExtensionGuard<'_> { + fn end(mut self, result: &HostResult) { + if let (Some(after), Some(call)) = (&self.hooks.extension_after, self.call.take()) { + report(after.as_ref(), &call, result); + } + } +} + +impl Drop for ExtensionGuard<'_> { + fn drop(&mut self) { + if let (Some(after), Some(call)) = (&self.hooks.extension_after, self.call.take()) { + after(&call, CallResult::Interrupted); + } + } +} + +// ---------- modules ---------- + +fn module_name(specifier: &str) -> &str { + specifier.strip_prefix("node:").unwrap_or(specifier) +} + +fn global_value(vm: &mut Vm, name: &str) -> Option { + let a = vm.atoms.intern(name); + match vm.global_map.get(&a) { + Some(Value::Undef) | None => None, + Some(v) => Some(*v), + } +} + +/// A module, as `require` returns it and a default import binds it: a global, by its Node module name. +fn module(vm: &mut Vm, specifier: &str) -> Res { + let name = module_name(specifier).to_owned(); + if let Some(v) = vm.host.modules.get(&name) { + return Ok(*v); + } + let found = match global_value(vm, &name) { + Some(v) => Some(v), + None => match name.as_str() { + "fs/promises" => match global_value(vm, "fs") { + Some(fs @ Value::Obj(_)) => { + let key = vm.atoms.intern("promises"); + match vm.get(&fs, key)? { + Value::Undef => None, + v => Some(v), + } + } + _ => None, + }, + "url" => pick(vm, &["URL", "URLSearchParams"]), + "util" => pick(vm, &["TextEncoder", "TextDecoder"]), + "buffer" => pick(vm, &["Buffer", "atob", "btoa"]), + _ => None, + }, + }; + let Some(found) = found else { + let message = format!( + "Cannot import \"{specifier}\": it isn't available in Code Mode, which can't load packages or files. Use the provided globals, or call tools through `tools`." + ); + let proto = vm.realm.error_proto; + return Err(vm.make_error(proto, &message)); + }; + vm.host.modules.insert(name, found); + Ok(found) +} + +fn pick(vm: &mut Vm, names: &[&str]) -> Option { + let found: Vec<(&str, Value)> = names + .iter() + .filter_map(|n| global_value(vm, n).map(|v| (*n, v))) + .collect(); + if found.is_empty() { + return None; + } + let id = vm.alloc(Obj::new(None, Kind::Ordinary)); + for (name, v) in found { + let key = vm.atoms.intern(name); + vm.define(id, key, v); + } + Some(Value::Obj(id)) +} + +/// What `import * as` and `import()` see: the module's own properties, and the module itself as `default`. +fn namespace(vm: &mut Vm, specifier: &str) -> Res { + let module = module(vm, specifier)?; + let name = module_name(specifier).to_owned(); + if let Some(v) = vm.host.namespaces.get(&name) { + return Ok(*v); + } + let id = vm.alloc(Obj::new(None, Kind::Ordinary)); + if let Value::Obj(m) = module { + for (k, v) in vm.own_entries(m) { + vm.define(id, k, v); + } + } + let key = vm.atoms.intern("default"); + vm.define(id, key, module); + vm.host.namespaces.insert(name, Value::Obj(id)); + Ok(Value::Obj(id)) +} + +fn require_native(vm: &mut Vm, _this: Value, args: &[Value], _callee: Id) -> Res { + let Some(Value::Str(s)) = args.first() else { + return Err(vm.type_error("require expects a module name string.")); + }; + let specifier = vm.text(*s).to_owned(); + module(vm, &specifier) +} + +/// The compiler's import hook: `%import(specifier, kind, name)`. Kinds: 0 a default import, 1 a namespace, 2 a +/// named export, 3 a side-effect import, 4 `import()`. +fn import_native(vm: &mut Vm, _this: Value, args: &[Value], _callee: Id) -> Res { + let specifier = match args.first() { + Some(Value::Str(s)) => vm.text(*s).to_owned(), + Some(other) => { + let other = *other; + let s = vm.string_of(&other)?; + vm.text(s).to_owned() + } + None => String::new(), + }; + let kind = match args.get(1) { + Some(Value::Num(n)) => *n as u8, + _ => 0, + }; + match kind { + 0 => module(vm, &specifier), + 1 => namespace(vm, &specifier), + 2 => { + let ns = namespace(vm, &specifier)?; + let Some(Value::Str(name)) = args.get(2) else { + return Ok(Value::Undef); + }; + let name = vm.text(*name).to_owned(); + let key: Atom = vm.atoms.intern(&name); + let ns_id = ns.as_obj().unwrap_or(0); + if !vm.has_own(ns_id, key) { + let msg = format!("\"{specifier}\" has no export named \"{name}\"."); + return Err(vm.syntax_error(&msg)); + } + Ok(vm.get_obj(ns_id, key)) + } + 3 => module(vm, &specifier).map(|_| Value::Undef), + _ => { + let p = vm.new_promise(); + match namespace(vm, &specifier) { + Ok(ns) => vm.fulfill(p, ns), + Err(e) => vm.reject(p, e), + } + Ok(Value::Obj(p)) + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/lib.rs b/packages/codemode-rust/crates/psychoscript/src/lib.rs index c15f88b3ef61..c478ec653ca4 100644 --- a/packages/codemode-rust/crates/psychoscript/src/lib.rs +++ b/packages/codemode-rust/crates/psychoscript/src/lib.rs @@ -1,22 +1,40 @@ //! PsychoScript: a confined, JavaScript-like language for calling host tools, embeddable in Rust. //! //! The public API below is shared with the benchmark and conformance harnesses, so change it only together with them. - -use std::collections::BTreeMap; +//! +//! The pieces mirror the reference's (`packages/codemode`) in Rust form: [`Tool`] is `Tool.make`, [`Runtime`] is +//! `CodeMode.make`, [`Extension`] is `Extension.make`, [`Hooks`] are the call hooks, and [`Program`] is +//! `runtime.program`. Host work is a [`Future`](std::future::Future) instead of an Effect; [`Runtime::execute_async`] +//! runs on any executor, and [`Runtime::execute`] drives it on the calling thread. mod builtins; mod bytecode; mod compiler; mod convert; +mod exec; +mod extension; +mod hooks; +mod host; mod object; mod ops; +mod program; mod promise; mod run; +mod schema; +mod search; mod strings; +mod tool; mod value; mod vm; +pub use extension::{Extension, HostError, HostFunction, HostValue}; +pub use hooks::{CallResult, ExtensionInvocation, Hooks, ToolInvocation}; +pub use program::Program; +pub use schema::Schema; pub use serde_json::Value as Json; +pub use tool::{ + BoxFuture, ConfigError, Execute, Tool, ToolContext, ToolDescription, ToolError, tool_expression, +}; /// A host tool: plain data in, plain data out. A failure is thrown into the program as an error. pub type ToolFn = Box Result + Send + Sync>; @@ -33,11 +51,34 @@ pub enum DiagnosticKind { ParseError, UnsupportedSyntax, UnknownTool, + InvalidToolInput, + InvalidToolOutput, InvalidDataValue, ToolCallLimitExceeded, TimeoutExceeded, ToolFailure, ExecutionFailure, + /// Warning only: additional warnings were omitted by `max_output_bytes`. + Truncated, +} + +impl DiagnosticKind { + /// The reference's name for the kind, such as `"UnknownTool"`. + pub fn name(self) -> &'static str { + match self { + DiagnosticKind::ParseError => "ParseError", + DiagnosticKind::UnsupportedSyntax => "UnsupportedSyntax", + DiagnosticKind::UnknownTool => "UnknownTool", + DiagnosticKind::InvalidToolInput => "InvalidToolInput", + DiagnosticKind::InvalidToolOutput => "InvalidToolOutput", + DiagnosticKind::InvalidDataValue => "InvalidDataValue", + DiagnosticKind::ToolCallLimitExceeded => "ToolCallLimitExceeded", + DiagnosticKind::TimeoutExceeded => "TimeoutExceeded", + DiagnosticKind::ToolFailure => "ToolFailure", + DiagnosticKind::ExecutionFailure => "ExecutionFailure", + DiagnosticKind::Truncated => "Truncated", + } + } } #[derive(Clone, Debug)] @@ -46,6 +87,8 @@ pub struct Diagnostic { pub message: String, /// 1-based line and column in the program source, when known. pub location: Option<(u32, u32)>, + /// What the model could do about it, such as `"Use search to find available tools."`. + pub suggestions: Vec, } #[derive(Clone, Debug)] @@ -58,43 +101,171 @@ pub struct ToolCall { pub struct Outcome { /// `Ok(value)` is JSON-safe; `undefined` becomes `null`. pub result: Result, + /// Non-fatal diagnostics. + pub warnings: Vec, pub logs: Vec, + /// Whether `max_output_bytes` cut the retained result or logs. + pub truncated: bool, pub tool_calls: Vec, } -/// Reusable runtime: tools and limits are fixed, each `execute` is an independent run. +/// What a runtime shares with every run it starts. +pub(crate) struct Setup { + pub registry: tool::Registry, + pub hooks: Hooks, + pub extensions: Vec, + pub limits: Limits, +} + +/// Reusable runtime: tools, extensions, hooks and limits are fixed, each `execute` is an independent run. pub struct Runtime { - tools: BTreeMap, - limits: Limits, + setup: Setup, } impl Runtime { pub fn new() -> Self { Self { - tools: BTreeMap::new(), - limits: Limits::default(), + setup: Setup { + registry: tool::Registry::default(), + hooks: Hooks::default(), + extensions: Vec::new(), + limits: Limits::default(), + }, } } /// Registers a tool at a dotted path, callable as `tools.(input)`; `"git.status"` is `tools.git.status`. + /// Its schemas accept anything, so its signature is `(unknown): Promise`. + /// + /// # Panics + /// + /// When the path has an empty segment. pub fn tool( - mut self, + self, path: &str, f: impl Fn(&Json) -> Result + Send + Sync + 'static, ) -> Self { - self.tools.insert(path.to_owned(), Box::new(f)); + self.with_tool( + path, + Tool::new("", move |input, _| f(&input).map_err(ToolError::from)) + .output(Schema::render_only(Json::Object(Default::default()))), + ) + } + + /// Registers a schema-described tool at a dotted path. A later tool at the same canonical path replaces it. + /// + /// # Panics + /// + /// When the path has an empty segment, as the reference throws from `CodeMode.make`. + pub fn with_tool(self, path: &str, tool: Tool) -> Self { + self.try_with_tool(path, tool) + .unwrap_or_else(|e| panic!("{e}")) + } + + pub fn try_with_tool(mut self, path: &str, tool: Tool) -> Result { + tool::check_path(path)?; + self.setup.registry.insert(path, tool); + Ok(self) + } + + /// Describes the namespace at a dotted path, like the reference's `Namespace.make`. The description is + /// model-visible through search: it matches every tool under the namespace. + /// + /// # Panics + /// + /// When the path has an empty segment. + pub fn namespace(mut self, path: &str, description: &str) -> Self { + if let Err(e) = tool::check_path(path) { + panic!("{e}"); + } + self.setup.registry.namespace(path, description); self } + /// Adds host globals. See [`Extension`]. + /// + /// # Panics + /// + /// When a global shadows a built-in or another extension's global. + pub fn extension(self, extension: Extension) -> Self { + self.try_extension(extension) + .unwrap_or_else(|e| panic!("{e}")) + } + + pub fn try_extension(mut self, extension: Extension) -> Result { + for (name, _) in extension.globals() { + let taken = host::BUILTIN_GLOBALS.contains(&name.as_str()) + || self + .setup + .extensions + .iter() + .any(|e| e.globals().iter().any(|(n, _)| n == name)); + if taken { + return Err(ConfigError(format!( + "Extension \"{}\" global \"{name}\" is already defined.", + extension.name() + ))); + } + } + self.setup.extensions.push(extension); + Ok(self) + } + + pub fn hooks(mut self, hooks: Hooks) -> Self { + self.setup.hooks = hooks; + self + } + + /// # Panics + /// + /// When `timeout_ms` is `Some(0)`, which the reference refuses with a `RangeError`. pub fn limits(mut self, limits: Limits) -> Self { - self.limits = limits; + assert!( + limits.timeout_ms != Some(0), + "timeoutMs must be a safe integer greater than or equal to 1." + ); + self.setup.limits = limits; self } - /// Parses, compiles and runs `code`. `bindings` become top-level constants. + /// Every tool with its exact path, description and generated TypeScript signature, sorted by path. + pub fn catalog(&self) -> Vec { + self.setup + .registry + .entries() + .iter() + .map(tool::Entry::describe) + .collect() + } + + /// Parses, compiles and runs `code` on the calling thread, blocking on asynchronous host work. `bindings` become + /// top-level constants. pub fn execute(&self, code: &str, bindings: &serde_json::Map) -> Outcome { run::execute(self, code, bindings) } + + /// Runs `code` as a future on any executor. Dropping it interrupts the run and every host call in flight. + pub async fn execute_async( + &self, + code: &str, + bindings: &serde_json::Map, + ) -> Outcome { + self.program(code, bindings, None).run_async().await + } + + /// A program ready to run once; nothing runs until [`Program::run`] or [`Program::run_async`]. Host calls get the keys `:`; a random run id by default. + pub fn program( + &self, + code: &str, + bindings: &serde_json::Map, + run_id: Option<&str>, + ) -> Program<'_> { + Program::new(self, code, bindings, run_id) + } + + pub(crate) fn setup(&self) -> &Setup { + &self.setup + } } impl Default for Runtime { @@ -102,3 +273,8 @@ impl Default for Runtime { Self::new() } } + +/// The exact callable signature of the built-in `search(...)`, for host-owned instructions. +pub fn search_signature() -> String { + search::search_signature() +} diff --git a/packages/codemode-rust/crates/psychoscript/src/ops.rs b/packages/codemode-rust/crates/psychoscript/src/ops.rs index fcb606a0b908..cf6c6fb03aca 100644 --- a/packages/codemode-rust/crates/psychoscript/src/ops.rs +++ b/packages/codemode-rust/crates/psychoscript/src/ops.rs @@ -482,6 +482,10 @@ impl<'rt> Vm<'rt> { /// Own enumerable string keys in JavaScript order: integer keys ascending, then insertion order. pub fn own_keys(&mut self, id: Id) -> Vec { + if let Kind::ToolRef(path) = &self.heap[id as usize].kind { + let children = self.host.setup.registry.children(path); + return children.iter().map(|c| self.atoms.intern(c)).collect(); + } let mut out = Vec::new(); let len = match &self.heap[id as usize].kind { Kind::Array(items) | Kind::Arguments(items) => items.len(), diff --git a/packages/codemode-rust/crates/psychoscript/src/program.rs b/packages/codemode-rust/crates/psychoscript/src/program.rs new file mode 100644 index 000000000000..2e5731c2d9fa --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/program.rs @@ -0,0 +1,138 @@ +//! One run of a program, the counterpart of the reference's `runtime.program(...)`: nothing runs until it is driven, +//! and it is driven to its end on the calling thread or as a future. + +use std::task::{Context, Poll}; +use std::time::Duration; + +use crate::exec; +use crate::run; +use crate::vm::Vm; +use crate::{Json, Outcome, Runtime}; + +enum State<'rt> { + Ready { + code: String, + bindings: serde_json::Map, + run_id: String, + }, + Running(Box>), + Done, +} + +pub(crate) struct Running<'rt> { + pub vm: Vm<'rt>, + pub code: String, + started: bool, + timer_armed: bool, +} + +/// A program ready to run once. Dropping it interrupts the run and cancels every host call in flight. +pub struct Program<'rt> { + rt: &'rt Runtime, + state: State<'rt>, + /// How much of the native stack below the point it is driven from the run may use. + pub(crate) stack_budget: usize, +} + +impl<'rt> Program<'rt> { + pub(crate) fn new( + rt: &'rt Runtime, + code: &str, + bindings: &serde_json::Map, + run_id: Option<&str>, + ) -> Self { + Self { + rt, + state: State::Ready { + code: code.to_owned(), + bindings: bindings.clone(), + run_id: run_id.map_or_else(run::random_run_id, str::to_owned), + }, + stack_budget: run::INLINE_STACK_BUDGET, + } + } + + /// Runs the program to its end on the calling thread, blocking on asynchronous host work. + pub fn run(mut self) -> Outcome { + exec::block_on(std::future::poll_fn(|cx| self.advance(cx))) + } + + /// Runs the program as a future on any executor. Asynchronous host calls run on that executor; a timeout wakes + /// the run from a shared timer thread. Dropping the future interrupts the run and every host call in flight. + pub async fn run_async(mut self) -> Outcome { + std::future::poll_fn(|cx| self.advance(cx)).await + } + + fn advance(&mut self, cx: &mut Context<'_>) -> Poll { + let probe = 0u8; + if let State::Ready { .. } = self.state { + let State::Ready { + code, + bindings, + run_id, + } = std::mem::replace(&mut self.state, State::Done) + else { + unreachable!() + }; + match run::start(self.rt, code, &bindings, run_id) { + Ok(vm) => self.state = State::Running(vm), + Err(outcome) => return Poll::Ready(*outcome), + } + } + let State::Running(r) = &mut self.state else { + return Poll::Pending; + }; + // Between jobs no native frame of the run is on the stack, so it may continue from wherever it is polled. + r.vm.stack_base = &probe as *const u8 as usize; + r.vm.stack_budget = self.stack_budget; + loop { + if r.vm.check_time().is_err() { + break; + } + if !r.started { + r.started = true; + run::call_main(&mut r.vm); + } + for (p, s) in r.vm.host.tasks.poll_ready() { + r.vm.inbox.push_back((p, s)); + } + let _ = r.vm.drive(); + if r.vm.outcome.is_some() || r.vm.fatal.is_some() { + break; + } + if r.vm.host.tasks.has_ready() { + continue; + } + r.vm.host.tasks.set_parent(Some(cx.waker())); + if !r.timer_armed + && let Some(ms) = r.vm.limits.timeout_ms + { + r.timer_armed = true; + exec::wake_at( + r.vm.start + Duration::from_millis(ms), + &r.vm.host.tasks.parent_waker(), + ); + } + // A task may have finished between the poll and handing over the waker. + if r.vm.host.tasks.has_ready() { + continue; + } + return Poll::Pending; + } + let State::Running(r) = std::mem::replace(&mut self.state, State::Done) else { + unreachable!() + }; + Poll::Ready(run::finish(*r)) + } +} + +impl<'rt> Running<'rt> { + pub fn new(vm: Vm<'rt>, code: String) -> Self { + Self { + vm, + code, + started: false, + timer_armed: false, + } + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/run.rs b/packages/codemode-rust/crates/psychoscript/src/run.rs index a62f44eaa90b..230d68184373 100644 --- a/packages/codemode-rust/crates/psychoscript/src/run.rs +++ b/packages/codemode-rust/crates/psychoscript/src/run.rs @@ -1,11 +1,13 @@ -//! One `execute`: compile, set up a fresh heap and built-ins, run to an outcome, and copy it out. +//! Compiling a program, setting up its heap, built-ins and host globals, and copying its outcome out. use std::panic::AssertUnwindSafe; use std::rc::Rc; use crate::compiler; use crate::convert; +use crate::host::{self, RunHost}; use crate::object::{Closure, Kind, Obj}; +use crate::program::Running; use crate::strings::Strings; use crate::value::Value; use crate::vm::Vm; @@ -16,22 +18,27 @@ use crate::{Diagnostic, DiagnosticKind, Json, Outcome, Runtime}; /// committed. const INLINE_SOURCE_BYTES: usize = 2048; const INLINE_BRACKET_DEPTH: usize = 64; -const INLINE_STACK_BUDGET: usize = 512 << 10; +pub const INLINE_STACK_BUDGET: usize = 512 << 10; const STACK_SIZE: usize = 256 << 20; const THREAD_STACK_BUDGET: usize = 64 << 20; pub fn execute(rt: &Runtime, code: &str, bindings: &serde_json::Map) -> Outcome { if code.len() <= INLINE_SOURCE_BYTES && bracket_depth(code) <= INLINE_BRACKET_DEPTH { - let run = AssertUnwindSafe(|| execute_here(rt, code, bindings, INLINE_STACK_BUDGET)); + let program = rt.program(code, bindings, None); + let run = AssertUnwindSafe(|| program.run()); return std::panic::catch_unwind(run).unwrap_or_else(|_| internal_error()); } std::thread::scope(|s| { let spawned = std::thread::Builder::new() .stack_size(STACK_SIZE) - .spawn_scoped(s, || execute_here(rt, code, bindings, THREAD_STACK_BUDGET)); + .spawn_scoped(s, || { + let mut program = rt.program(code, bindings, None); + program.stack_budget = THREAD_STACK_BUDGET; + program.run() + }); match spawned { Ok(handle) => handle.join().unwrap_or_else(|_| internal_error()), - Err(_) => execute_here(rt, code, bindings, INLINE_STACK_BUDGET), + Err(_) => rt.program(code, bindings, None).run(), } }) } @@ -54,51 +61,85 @@ fn bracket_depth(code: &str) -> usize { /// A defect in the interpreter, reported instead of unwinding into the host. fn internal_error() -> Outcome { + failed(Diagnostic { + kind: DiagnosticKind::ExecutionFailure, + message: "Internal interpreter error.".into(), + location: None, + suggestions: Vec::new(), + }) +} + +fn failed(error: Diagnostic) -> Outcome { Outcome { - result: Err(Diagnostic { - kind: DiagnosticKind::ExecutionFailure, - message: "Internal interpreter error.".into(), - location: None, - }), + result: Err(error), + warnings: Vec::new(), logs: Vec::new(), + truncated: false, tool_calls: Vec::new(), } } -fn execute_here( - rt: &Runtime, - code: &str, +/// A random run id, as the reference uses a random UUID. +pub fn random_run_id() -> String { + use std::sync::atomic::{AtomicU64, Ordering}; + static COUNTER: AtomicU64 = AtomicU64::new(0); + let seed = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_nanos() as u64) + .unwrap_or(0) + ^ COUNTER.fetch_add(0x9e37_79b9_7f4a_7c15, Ordering::Relaxed); + let mix = |mut z: u64| { + z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); + z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); + z ^ (z >> 31) + }; + let (a, b) = (mix(seed), mix(seed.wrapping_add(0x9e37_79b9_7f4a_7c15))); + format!( + "{:08x}-{:04x}-4{:03x}-{:04x}-{:012x}", + a >> 32, + (a >> 16) & 0xffff, + a & 0x0fff, + ((b >> 48) & 0x3fff) | 0x8000, + b & 0xffff_ffff_ffff + ) +} + +/// Compiles a program and sets up its run, or the outcome when it does not compile. +pub fn start<'rt>( + rt: &'rt Runtime, + code: String, bindings: &serde_json::Map, - budget: usize, -) -> Outcome { - let probe = 0u8; + run_id: String, +) -> Result>, Box> { let mut atoms = Strings::new(); - let program = match compiler::compile(code, &mut atoms) { + let program = match compiler::compile(&code, &mut atoms) { Ok(p) => p, Err(e) => { - let location = e.offset.map(|o| line_col(code, o)); + let location = e.offset.map(|o| line_col(&code, o)); let message = format!("{}{}", e.message, suffix(location)); - return Outcome { - result: Err(Diagnostic { - kind: e.kind, - message, - location, - }), - logs: Vec::new(), - tool_calls: Vec::new(), - }; + return Err(Box::new(failed(Diagnostic { + kind: e.kind, + message, + location, + suggestions: Vec::new(), + }))); } }; - let mut vm = Vm::new(&rt.tools, rt.limits, atoms); - vm.stack_base = &probe as *const u8 as usize; - vm.stack_budget = budget; + let setup = rt.setup(); + let mut vm = Vm::new(RunHost::new(setup, run_id), setup.limits, atoms); vm.setup(); + host::install(&mut vm); for (k, v) in bindings { let val = convert::from_json(&mut vm, v); let a = vm.atoms.intern(k); vm.global_map.insert(a, val); } vm.load(program); + Ok(Box::new(Running::new(vm, code))) +} + +/// Runs the program's body to its first suspension. +pub fn call_main(vm: &mut Vm) { let proto = vm.protos[0].clone(); let fp = vm.realm.function_proto; let main = Value::Obj(vm.alloc(Obj::new( @@ -109,39 +150,33 @@ fn execute_here( this: Value::Undef, })), ))); - match vm.call(&main, Value::Undef, &[]) { - Ok(_) => { - let _ = vm.drive(); - } - Err(e) => { - if vm.outcome.is_none() { - vm.outcome = Some(Err(e)); - } - } + if let Err(e) = vm.call(&main, Value::Undef, &[]) + && vm.outcome.is_none() + { + vm.outcome = Some(Err(e)); } +} + +/// The outcome of a run that ended: host work it left running is interrupted, then the result is copied out. +pub fn finish(r: Running<'_>) -> Outcome { + let Running { mut vm, code, .. } = r; + vm.host.tasks.clear(); + let vm = &mut vm; + let code = code.as_str(); let result = match (vm.fatal.clone(), vm.outcome.take()) { - (Some((kind, message)), _) => Err(Diagnostic { - kind, - message, - location: None, - }), - (None, Some(Ok(v))) => match convert::to_json(&mut vm, &v) { + (Some((kind, message)), _) => Err(diagnostic(kind, message)), + (None, Some(Ok(v))) => match convert::to_json(vm, &v) { Ok(j) => Ok(j), - Err(e) => Err(diagnose(&mut vm, &e, code)), + Err(e) => Err(diagnose(vm, &e, code)), }, - (None, Some(Err(e))) => Err(diagnose(&mut vm, &e, code)), - (None, None) => Err(Diagnostic { - kind: DiagnosticKind::ExecutionFailure, - message: "The program did not finish.".into(), - location: None, - }), + (None, Some(Err(e))) => Err(diagnose(vm, &e, code)), + (None, None) => Err(diagnostic( + DiagnosticKind::ExecutionFailure, + "The program did not finish.".into(), + )), }; let result = match (vm.fatal.clone(), result) { - (Some((kind, message)), Ok(_)) => Err(Diagnostic { - kind, - message, - location: None, - }), + (Some((kind, message)), Ok(_)) => Err(diagnostic(kind, message)), (_, r) => r, }; let logs = std::mem::take(&mut vm.logs); @@ -149,13 +184,24 @@ fn execute_here( bound_output( Outcome { result, + warnings: Vec::new(), logs, + truncated: false, tool_calls, }, - rt.limits.max_output_bytes, + vm.limits.max_output_bytes, ) } +fn diagnostic(kind: DiagnosticKind, message: String) -> Diagnostic { + Diagnostic { + kind, + message, + location: None, + suggestions: Vec::new(), + } +} + fn diagnose(vm: &mut Vm, e: &Value, code: &str) -> Diagnostic { if let Value::Obj(id) = e && let Kind::Error(failure) = &vm.heap[*id as usize].kind @@ -174,21 +220,17 @@ fn diagnose(vm: &mut Vm, e: &Value, code: &str) -> Diagnostic { kind: f.kind, message, location, + suggestions: vm.host.suggestions.get(&id).cloned().unwrap_or_default(), }; } let message = convert::error_to_string(vm, id); - return Diagnostic { - kind: DiagnosticKind::ExecutionFailure, - message, - location: None, - }; + return diagnostic(DiagnosticKind::ExecutionFailure, message); } let text = convert::format_value(vm, e); - Diagnostic { - kind: DiagnosticKind::ExecutionFailure, - message: format!("Uncaught: {text}"), - location: None, - } + diagnostic( + DiagnosticKind::ExecutionFailure, + format!("Uncaught: {text}"), + ) } fn suffix(location: Option<(u32, u32)>) -> String { @@ -224,6 +266,7 @@ fn bound_output(mut outcome: Outcome, max: Option) -> Outcome { "{} [result truncated: {value_bytes} bytes exceeds the {max}-byte output limit; return a smaller value]", &text[..cut] ))); + outcome.truncated = true; } } let budget = max.saturating_sub(value_bytes.min(max)); @@ -242,6 +285,7 @@ fn bound_output(mut outcome: Outcome, max: Option) -> Outcome { outcome .logs .push(format!("[logs truncated: showing {kept} of {total} lines]")); + outcome.truncated = true; } outcome } diff --git a/packages/codemode-rust/crates/psychoscript/src/schema.rs b/packages/codemode-rust/crates/psychoscript/src/schema.rs new file mode 100644 index 000000000000..0c142370e151 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/schema.rs @@ -0,0 +1,1179 @@ +//! Tool schemas: JSON Schema documents rendered into model-visible TypeScript signatures, and optionally validated. +//! +//! The reference takes either an Effect Schema, which validates, or a render-only JSON Schema. Here both are JSON +//! Schema documents: [`Schema::validated`] plays the Effect Schema's part and [`Schema::render_only`] the plain JSON +//! Schema's. Rendering follows `tool-schema.ts` line by line, so signatures match it byte for byte. + +use crate::Json; +use crate::convert::quote; +use crate::value::write_num; + +/// A tool's input or output contract. +#[derive(Clone, Debug)] +pub struct Schema { + doc: Json, + validator: Option>, +} + +impl Schema { + /// A schema that also checks values, the way the reference decodes an Effect Schema: input is checked before the + /// tool runs and output before the program sees it. See [`Schema::validate`] for the keywords it checks. + pub fn validated(doc: Json) -> Self { + let validator = Some(std::sync::Arc::new(Validator::new(&doc))); + Self { doc, validator } + } + + /// A schema that only shapes the model-visible signature; values pass through unchecked. + pub fn render_only(doc: Json) -> Self { + Self { + doc, + validator: None, + } + } + + pub fn document(&self) -> &Json { + &self.doc + } + + pub fn is_validating(&self) -> bool { + self.validator.is_some() + } + + /// The value as the tool or program receives it, or the reference's `SchemaError(...)` text. + /// + /// Checked: `type` (one or several), `enum`, `const`, `properties`, `required`, `additionalProperties` (excess + /// properties are dropped when it is `false`, as an Effect `Struct` drops them, and checked when it is a schema), + /// `items`, `anyOf`, `oneOf`, `allOf`, `$ref` into `$defs`/`definitions`, `minimum`, `maximum`, + /// `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`, `minLength`, `maxLength`, `minItems`, `maxItems` and + /// `uniqueItems`: the constraints an Effect Schema's JSON Schema document is made of. `pattern` and `format` only + /// render: the crate has no regular-expression engine, and Effect's `format` is an annotation. + pub fn validate(&self, value: Json) -> Result { + let Some(v) = &self.validator else { + return Ok(value); + }; + let mut path = Vec::new(); + check(&v.root, value, v, &mut path, 0) + .map_err(|(message, path)| format!("SchemaError({message}{})", render_path(&path))) + } +} + +// ---------- rendering ---------- + +const MAX_RENDER_DEPTH: usize = 8; +const MIN_SAFE_INTEGER: f64 = -9_007_199_254_740_991.0; +const MAX_SAFE_INTEGER: f64 = 9_007_199_254_740_991.0; + +type Defs = Vec<(String, Json)>; + +#[derive(Clone)] +struct Ctx { + definitions: Defs, + pretty: bool, +} + +/// A property of a schema object, with JSON `null` read as absent the way the reference's `??` and truthiness read +/// `undefined`. +fn field<'a>(s: &'a Json, key: &str) -> Option<&'a Json> { + match s.get(key) { + None | Some(Json::Null) => None, + Some(v) => Some(v), + } +} + +fn truthy(v: Option<&Json>) -> bool { + match v { + None | Some(Json::Null) | Some(Json::Bool(false)) => false, + Some(Json::Number(n)) => n.as_f64().is_some_and(|n| n != 0.0), + Some(Json::String(s)) => !s.is_empty(), + Some(_) => true, + } +} + +fn type_is(s: &Json, name: &str) -> bool { + s.get("type").and_then(Json::as_str) == Some(name) +} + +fn number(s: &Json, key: &str) -> Option { + s.get(key).and_then(Json::as_f64) +} + +fn utf16_len(s: &str) -> usize { + s.encode_utf16().count() +} + +/// `JSON.stringify` of host JSON: compact, with JavaScript number formatting. +pub fn js_stringify(v: &Json) -> String { + let mut out = String::new(); + write_js_json(&mut out, v); + out +} + +fn write_js_json(out: &mut String, v: &Json) { + match v { + Json::Null => out.push_str("null"), + Json::Bool(b) => out.push_str(if *b { "true" } else { "false" }), + Json::Number(n) => match n.as_f64() { + Some(x) if x.is_finite() => write_num(out, x), + _ => out.push_str("null"), + }, + Json::String(s) => quote(out, s), + Json::Array(items) => { + out.push('['); + for (i, item) in items.iter().enumerate() { + if i > 0 { + out.push(','); + } + write_js_json(out, item); + } + out.push(']'); + } + Json::Object(map) => { + out.push('{'); + for (i, (k, item)) in map.iter().enumerate() { + if i > 0 { + out.push(','); + } + quote(out, k); + out.push(':'); + write_js_json(out, item); + } + out.push('}'); + } + } +} + +fn js_num(x: f64) -> String { + let mut s = String::new(); + write_num(&mut s, x); + s +} + +/// `/^[A-Za-z_$][A-Za-z0-9_$]*$/` +pub fn is_identifier(name: &str) -> bool { + let mut chars = name.chars(); + match chars.next() { + Some(c) if c.is_ascii_alphabetic() || c == '_' || c == '$' => {} + _ => return false, + } + chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$') +} + +fn render_key(name: &str) -> String { + if is_identifier(name) { + name.to_owned() + } else { + js_stringify(&Json::String(name.to_owned())) + } +} + +/// The definition a local `$ref` names: `#/$defs/` or `#/definitions/`. +fn definition_name(reference: &str) -> Option { + let fragment = reference.strip_prefix('#')?; + let decoded = percent_decode(fragment)?; + if decoded.is_empty() { + return None; + } + let rest = decoded.strip_prefix('/')?; + let tokens: Vec = rest + .split('/') + .map(|t| t.replace("~1", "/").replace("~0", "~")) + .collect(); + if tokens.len() == 2 && (tokens[0] == "$defs" || tokens[0] == "definitions") { + return Some(tokens[1].clone()); + } + None +} + +fn percent_decode(s: &str) -> Option { + let bytes = s.as_bytes(); + let mut out = Vec::with_capacity(bytes.len()); + let mut i = 0; + while i < bytes.len() { + if bytes[i] == b'%' { + let hex = s.get(i + 1..i + 3)?; + out.push(u8::from_str_radix(hex, 16).ok()?); + i += 3; + } else { + out.push(bytes[i]); + i += 1; + } + } + String::from_utf8(out).ok() +} + +fn lookup<'a>(defs: &'a Defs, name: &str) -> Option<&'a Json> { + defs.iter().rev().find(|(k, _)| k == name).map(|(_, v)| v) +} + +fn extend_defs(defs: &mut Defs, map: Option<&Json>) { + if let Some(Json::Object(m)) = map { + defs.extend(m.iter().map(|(k, v)| (k.clone(), v.clone()))); + } +} + +/// `{ ...schema, key: undefined }`: kept as `null`, which reads as absent, so the key still counts in key checks. +fn without(s: &Json, key: &str) -> Json { + let mut copy = s.clone(); + if let Json::Object(m) = &mut copy { + m.insert(key.to_owned(), Json::Null); + } + copy +} + +fn effect_number_sentinel(s: &Json) -> bool { + type_is(s, "string") + && match s.get("enum") { + Some(Json::Array(values)) => { + !values.is_empty() + && values.iter().all(|v| { + matches!( + v.as_str(), + Some("NaN") | Some("Infinity") | Some("-Infinity") + ) + }) + } + _ => false, + } +} + +const ANNOTATIONS: [&str; 6] = [ + "title", + "description", + "default", + "examples", + "readOnly", + "writeOnly", +]; + +fn is_effect_empty_struct(s: &Json) -> bool { + let Some(not) = field(s, "not") else { + return false; + }; + type_is(not, "null") + && not.as_object().is_some_and(|m| m.len() == 1) + && s.as_object().is_some_and(|m| { + m.keys() + .all(|k| k == "not" || ANNOTATIONS.contains(&k.as_str())) + }) +} + +fn intersection(members: Vec) -> String { + let concrete: Vec = members.into_iter().filter(|m| m != "unknown").collect(); + match concrete.len() { + 0 => "unknown".into(), + 1 => concrete.into_iter().next().unwrap_or_default(), + _ => concrete + .iter() + .map(|m| { + if m.contains(" | ") { + format!("({m})") + } else { + m.clone() + } + }) + .collect::>() + .join(" & "), + } +} + +fn children(s: &Json) -> Vec<&Json> { + let mut out = Vec::new(); + for key in ["anyOf", "oneOf", "allOf"] { + if let Some(Json::Array(items)) = field(s, key) { + out.extend(items.iter()); + } + } + if let Some(Json::Object(props)) = field(s, "properties") { + out.extend(props.values()); + } + if let Some(items) = field(s, "items") { + out.push(items); + } + if let Some(a @ Json::Object(_)) = field(s, "additionalProperties") { + out.push(a); + } + out +} + +fn has_unresolved_ref(s: &Json, defs: &Defs, seen: &[String], depth: usize) -> bool { + // Schemas are trees here, so the reference's identity guard against cycles becomes a depth bound. + if depth > 64 { + return false; + } + if let Some(reference) = field(s, "$ref") { + let Some(name) = reference.as_str().and_then(definition_name) else { + return true; + }; + let Some(def) = lookup(defs, &name) else { + return true; + }; + if seen.contains(&name) { + return true; + } + let mut next = seen.to_vec(); + next.push(name); + if has_unresolved_ref(def, defs, &next, depth + 1) { + return true; + } + } + children(s) + .into_iter() + .any(|c| has_unresolved_ref(c, defs, seen, depth + 1)) +} + +fn doc_tags(s: &Json) -> Vec { + let mut tags = Vec::new(); + if s.get("deprecated") == Some(&Json::Bool(true)) { + tags.push("@deprecated".to_owned()); + } + if let Some(d) = s.get("default") { + tags.push(format!("@default {}", js_stringify(d))); + } + if let Some(f) = s.get("format").and_then(Json::as_str) { + tags.push(format!("@format {f}")); + } + let integer = type_is(s, "integer"); + if integer { + tags.push("@integer".to_owned()); + } + if let Some(m) = number(s, "minimum") + && !(integer && m == MIN_SAFE_INTEGER) + { + tags.push(format!("@minimum {}", js_num(m))); + } + if let Some(m) = number(s, "maximum") + && !(integer && m == MAX_SAFE_INTEGER) + { + tags.push(format!("@maximum {}", js_num(m))); + } + for key in [ + "exclusiveMinimum", + "exclusiveMaximum", + "multipleOf", + "minLength", + "maxLength", + ] { + if let Some(m) = number(s, key) { + tags.push(format!("@{key} {}", js_num(m))); + } + } + if let Some(p) = s.get("pattern").and_then(Json::as_str) { + tags.push(format!("@pattern {p}")); + } + for key in ["minItems", "maxItems"] { + if let Some(m) = number(s, key) { + tags.push(format!("@{key} {}", js_num(m))); + } + } + if s.get("uniqueItems") == Some(&Json::Bool(true)) { + tags.push("@uniqueItems true".to_owned()); + } + tags +} + +fn is_js_space(c: char) -> bool { + c.is_whitespace() || c == '\u{feff}' +} + +fn doc_lines(s: &Json, width: usize) -> Vec { + let summary = doc_tags(s).join(" "); + let description = s.get("description").and_then(Json::as_str).unwrap_or(""); + let mut lines: Vec = description + .split('\n') + .map(|l| l.trim_end_matches(is_js_space).to_owned()) + .collect(); + while lines + .first() + .is_some_and(|l| l.trim_matches(is_js_space).is_empty()) + { + lines.remove(0); + } + while lines + .last() + .is_some_and(|l| l.trim_matches(is_js_space).is_empty()) + { + lines.pop(); + } + let inline = if lines.len() == 1 { + let dot = if lines[0].ends_with('.') { "" } else { "." }; + format!("{}{dot} {summary}", lines[0]) + } else { + summary.clone() + }; + if !summary.is_empty() + && lines.len() == 1 + && !summary.contains('\n') + && width + utf16_len(&inline) + 7 <= 120 + { + return vec![inline]; + } + if !summary.is_empty() { + lines.extend(summary.split('\n').map(str::to_owned)); + } + lines +} + +fn types_of(s: &Json) -> Vec { + match s.get("type") { + Some(Json::String(t)) => vec![t.clone()], + Some(Json::Array(items)) => items + .iter() + .filter_map(|t| t.as_str().map(str::to_owned)) + .collect(), + _ => Vec::new(), + } +} + +fn jsdoc(s: &Json, pad: &str) -> String { + let pad_len = utf16_len(pad); + let mut content = doc_lines(s, pad_len); + let types = types_of(s); + let mut append = |label: &str, child: &Json| { + for (i, line) in doc_lines(child, pad_len + label.len() + 2) + .into_iter() + .enumerate() + { + if i == 0 { + content.push(format!("{label}: {line}")); + } else if line.is_empty() { + content.push(String::new()); + } else { + content.push(format!(" {line}")); + } + } + }; + if types.iter().any(|t| t == "array") + && let Some(items) = s.get("items") + && truthy(Some(items)) + { + append("Each item", items); + } + if (types.iter().any(|t| t == "object") || truthy(s.get("properties"))) + && let Some(additional @ Json::Object(_)) = s.get("additionalProperties") + { + let has_props = s + .get("properties") + .and_then(Json::as_object) + .is_some_and(|m| !m.is_empty()); + let label = if has_props { + "Each additional value" + } else { + "Each value" + }; + append(label, additional); + } + if content.is_empty() { + return String::new(); + } + let escaped: Vec = content.iter().map(|l| l.replace("*/", "* /")).collect(); + if escaped.len() == 1 && pad_len + utf16_len(&escaped[0]) + 7 <= 120 { + return format!("{pad}/** {} */\n", escaped[0]); + } + let body: Vec = escaped + .iter() + .map(|l| { + if l.is_empty() { + format!("{pad} *") + } else { + format!("{pad} * {l}") + } + }) + .collect(); + format!("{pad}/**\n{}\n{pad} */\n", body.join("\n")) +} + +fn render(s: &Json, ctx: &Ctx, depth: usize, seen: &[String]) -> String { + if depth > MAX_RENDER_DEPTH { + return "unknown".into(); + } + let nested_owned; + let nested = if field(s, "definitions").is_none() && field(s, "$defs").is_none() { + ctx + } else { + let mut defs = ctx.definitions.clone(); + extend_defs(&mut defs, field(s, "definitions")); + extend_defs(&mut defs, field(s, "$defs")); + nested_owned = Ctx { + definitions: defs, + pretty: ctx.pretty, + }; + &nested_owned + }; + if truthy(s.get("$ref")) { + let name = s + .get("$ref") + .and_then(Json::as_str) + .and_then(definition_name); + let Some(name) = name else { + return "unknown".into(); + }; + let Some(def) = lookup(&nested.definitions, &name) else { + return "unknown".into(); + }; + if seen.contains(&name) { + return "unknown".into(); + } + let mut next = seen.to_vec(); + next.push(name); + let def = def.clone(); + return intersection(vec![ + render(&def, nested, depth, &next), + render(&without(s, "$ref"), nested, depth + 1, seen), + ]); + } + if let Some(c) = s.get("const") { + return js_stringify(c); + } + if truthy(s.get("enum")) { + return match s.get("enum") { + Some(Json::Array(values)) => values + .iter() + .map(js_stringify) + .collect::>() + .join(" | "), + _ => "unknown".into(), + }; + } + let listed = field(s, "anyOf").or_else(|| field(s, "oneOf")); + if let Some(listed) = listed { + let Json::Array(listed) = listed else { + return "unknown".into(); + }; + let alternatives: Vec<&Json> = if listed.iter().any(|i| type_is(i, "number")) { + listed + .iter() + .filter(|i| !effect_number_sentinel(i)) + .collect() + } else { + listed.iter().collect() + }; + if alternatives.iter().any(|i| type_is(i, "number")) + && alternatives + .iter() + .all(|i| type_is(i, "number") || effect_number_sentinel(i)) + { + return "number".into(); + } + if alternatives.len() == 2 + && type_is(alternatives[0], "object") + && alternatives[0].get("properties").is_none() + && type_is(alternatives[1], "array") + && alternatives[1].get("items").is_none() + { + return "{}".into(); + } + let members: Vec = alternatives + .iter() + .map(|i| render(i, nested, depth + 1, seen)) + .collect(); + if members.iter().any(|m| m == "unknown") { + return "unknown".into(); + } + let rest = without(&without(s, "anyOf"), "oneOf"); + return intersection(vec![ + members.join(" | "), + render(&rest, nested, depth + 1, seen), + ]); + } + if let Some(all) = field(s, "allOf") { + let Json::Array(all) = all else { + return "unknown".into(); + }; + if all + .iter() + .any(|i| has_unresolved_ref(i, &nested.definitions, &[], 0)) + { + return "unknown".into(); + } + let mut members = vec![render(&without(s, "allOf"), nested, depth + 1, seen)]; + members.extend(all.iter().map(|i| render(i, nested, depth + 1, seen))); + return intersection(members); + } + if let Some(Json::Array(types)) = s.get("type") { + return types + .iter() + .map(|t| { + let mut copy = s.clone(); + if let Json::Object(m) = &mut copy { + m.insert("type".into(), t.clone()); + } + render(©, nested, depth + 1, seen) + }) + .collect::>() + .join(" | "); + } + match s.get("type").and_then(Json::as_str) { + Some("string") => return "string".into(), + Some("number") | Some("integer") => return "number".into(), + Some("boolean") => return "boolean".into(), + Some("null") => return "null".into(), + Some("array") => { + let empty = Json::Object(serde_json::Map::new()); + let items = field(s, "items").unwrap_or(&empty); + return format!("Array<{}>", render(items, nested, depth + 1, seen)); + } + _ => {} + } + if type_is(s, "object") || truthy(s.get("properties")) { + let required: Vec<&str> = match field(s, "required") { + Some(Json::Array(r)) => r.iter().filter_map(Json::as_str).collect(), + _ => Vec::new(), + }; + let empty = serde_json::Map::new(); + let properties = s + .get("properties") + .and_then(Json::as_object) + .unwrap_or(&empty); + let index_type = match s.get("additionalProperties") { + Some(a @ Json::Object(_)) => Some(render(a, nested, depth + 1, seen)), + _ => None, + }; + let field_text = |name: &str, value: &Json| { + let optional = if required.contains(&name) { "" } else { "?" }; + format!( + "{}{optional}: {}", + render_key(name), + render(value, nested, depth + 1, seen) + ) + }; + if !ctx.pretty { + let mut fields: Vec = + properties.iter().map(|(k, v)| field_text(k, v)).collect(); + if let Some(t) = &index_type { + fields.push(format!("[key: string]: {t}")); + } + return if fields.is_empty() { + "{}".into() + } else { + format!("{{ {} }}", fields.join("; ")) + }; + } + if properties.is_empty() && index_type.is_none() { + return "{}".into(); + } + let pad = " ".repeat(depth + 1); + let mut lines: Vec = properties + .iter() + .map(|(k, v)| format!("{}{pad}{},", jsdoc(v, &pad), field_text(k, v))) + .collect(); + if let Some(t) = &index_type { + lines.push(format!("{pad}[key: string]: {t},")); + } + return format!("{{\n{}\n{}}}", lines.join("\n"), " ".repeat(depth)); + } + if is_effect_empty_struct(s) { + return "{}".into(); + } + "unknown".into() +} + +/// The TypeScript type a schema document renders to, as in the reference's `jsonSchemaToTypeScript`. +pub fn to_typescript(doc: &Json, pretty: bool) -> String { + render( + doc, + &Ctx { + definitions: Vec::new(), + pretty, + }, + 0, + &[], + ) +} + +/// The input's root object schema and the definitions it may refer to. +fn input_document(doc: &Json) -> Option<(Json, Defs)> { + let mut defs = Vec::new(); + extend_defs(&mut defs, field(doc, "definitions")); + extend_defs(&mut defs, field(doc, "$defs")); + if doc.get("$ref").is_none() { + return Some((doc.clone(), defs)); + } + let name = doc + .get("$ref") + .and_then(Json::as_str) + .and_then(definition_name)?; + let schema = lookup(&defs, &name)?.clone(); + Some((schema, defs)) +} + +/// Names of the input's top-level properties, which search indexes. +pub fn input_property_names(doc: &Json) -> Vec { + input_document(doc) + .and_then(|(s, _)| s.get("properties").and_then(Json::as_object).cloned()) + .map(|m| m.keys().cloned().collect()) + .unwrap_or_default() +} + +/// For a freeform tool whose input is one required string field: that field's name and the call's parameter list. +pub fn string_parameter(doc: &Json) -> Option<(String, String)> { + let (schema, defs) = input_document(doc)?; + let properties = schema.get("properties").and_then(Json::as_object)?; + if properties.len() != 1 { + return None; + } + let (name, f) = properties.iter().next()?; + let required = match schema.get("required") { + Some(Json::Array(r)) => r.iter().any(|v| v.as_str() == Some(name)), + _ => false, + }; + if !type_is(f, "string") || !required { + return None; + } + let label = if is_identifier(name) { name } else { "input" }; + let ty = render( + f, + &Ctx { + definitions: defs, + pretty: false, + }, + 0, + &[], + ); + let doc = jsdoc(f, ""); + let doc = doc + .strip_suffix('\n') + .map(|d| format!("{d} ")) + .unwrap_or(doc); + Some((name.clone(), format!("({doc}{label}: {ty})"))) +} + +/// Whether a tool takes no input, so its signature shows `()`. +pub fn is_empty_input(schema: &Schema) -> bool { + (schema.is_validating() && is_effect_empty_struct(&schema.doc)) + || to_typescript(&schema.doc, false) == "{}" +} + +// ---------- validation ---------- + +/// A schema compiled for checking values: every keyword read once, so checking does no lookups by name. +#[derive(Debug, Default)] +struct Node { + never: bool, + reference: Option, + constant: Option, + enumeration: Option>, + any_of: Vec, + all_of: Vec, + /// Type names, or empty for any type. + types: Vec, + expected: String, + minimum: Option, + maximum: Option, + exclusive_minimum: Option, + exclusive_maximum: Option, + multiple_of: Option, + min_length: Option, + max_length: Option, + min_items: Option, + max_items: Option, + unique_items: bool, + items: Option>, + properties: Vec<(String, Node)>, + required: Vec, + additional: Additional, +} + +#[derive(Debug, Default)] +enum Additional { + #[default] + Keep, + Drop, + Check(Box), +} + +/// A compiled schema: its root and the definitions `$ref`s name, by position. +#[derive(Debug)] +pub(crate) struct Validator { + root: Node, + defs: Vec, +} + +impl Validator { + fn new(doc: &Json) -> Self { + let mut names: Vec<(String, Json)> = Vec::new(); + gather_defs(doc, &mut names, 0); + let mut v = Validator { + root: Node::default(), + defs: Vec::new(), + }; + let index = |name: &str| names.iter().rposition(|(n, _)| n == name); + v.defs = names.iter().map(|(_, d)| compile(d, &index, 0)).collect(); + v.root = compile(doc, &index, 0); + v + } +} + +/// Every definition reachable in the document; later ones of the same name win, like the renderer's spread. +fn gather_defs(s: &Json, out: &mut Vec<(String, Json)>, depth: usize) { + if depth > 64 { + return; + } + for key in ["definitions", "$defs"] { + if let Some(Json::Object(m)) = field(s, key) { + for (k, v) in m { + out.push((k.clone(), v.clone())); + gather_defs(v, out, depth + 1); + } + } + } + for c in children(s) { + gather_defs(c, out, depth + 1); + } +} + +fn compile(s: &Json, index: &dyn Fn(&str) -> Option, depth: usize) -> Node { + let mut n = Node::default(); + let Json::Object(_) = s else { + n.never = *s == Json::Bool(false); + return n; + }; + if depth > 64 { + return n; + } + let sub = |s: &Json| compile(s, index, depth + 1); + n.reference = field(s, "$ref") + .and_then(Json::as_str) + .and_then(definition_name) + .and_then(|name| index(&name)); + n.constant = s.get("const").cloned(); + if let Some(Json::Array(values)) = s.get("enum") { + n.enumeration = Some(values.clone()); + } + if let Some(Json::Array(alts)) = field(s, "anyOf").or_else(|| field(s, "oneOf")) { + // Effect's JSON Schema for a number also lists the strings its JSON codec uses for non-finite numbers; + // decoding a value, Effect accepts numbers only. + let numeric = alts.iter().any(|a| type_is(a, "number")); + n.any_of = alts + .iter() + .filter(|a| !(numeric && effect_number_sentinel(a))) + .map(sub) + .collect(); + } + if let Some(Json::Array(all)) = field(s, "allOf") { + n.all_of = all.iter().map(sub).collect(); + } + n.types = types_of(s); + n.expected = expected(s); + n.minimum = number(s, "minimum"); + n.maximum = number(s, "maximum"); + n.exclusive_minimum = number(s, "exclusiveMinimum"); + n.exclusive_maximum = number(s, "exclusiveMaximum"); + n.multiple_of = number(s, "multipleOf").filter(|m| *m != 0.0); + n.min_length = number(s, "minLength"); + n.max_length = number(s, "maxLength"); + n.min_items = number(s, "minItems"); + n.max_items = number(s, "maxItems"); + n.unique_items = s.get("uniqueItems") == Some(&Json::Bool(true)); + n.items = field(s, "items").map(|i| Box::new(sub(i))); + if let Some(Json::Object(props)) = s.get("properties") { + n.properties = props.iter().map(|(k, v)| (k.clone(), sub(v))).collect(); + } + if let Some(Json::Array(r)) = s.get("required") { + n.required = r + .iter() + .filter_map(|v| v.as_str().map(str::to_owned)) + .collect(); + } + n.additional = match s.get("additionalProperties") { + Some(Json::Bool(false)) => Additional::Drop, + Some(extra @ Json::Object(_)) => Additional::Check(Box::new(sub(extra))), + _ => Additional::Keep, + }; + n +} + +type Failure = (String, Vec); + +#[derive(Clone)] +enum PathPart { + Key(String), + Index(usize), +} + +fn render_path(path: &[PathPart]) -> String { + if path.is_empty() { + return String::new(); + } + let mut out = String::from("\n at "); + for p in path { + match p { + PathPart::Key(k) => { + out.push('['); + quote(&mut out, k); + out.push(']'); + } + PathPart::Index(i) => out.push_str(&format!("[{i}]")), + } + } + out +} + +fn json_type(v: &Json) -> &'static str { + match v { + Json::Null => "null", + Json::Bool(_) => "boolean", + Json::Number(_) => "number", + Json::String(_) => "string", + Json::Array(_) => "array", + Json::Object(_) => "object", + } +} + +fn matches_type(t: &str, v: &Json) -> bool { + match t { + "integer" | "number" => v.is_number(), + other => json_type(v) == other, + } +} + +/// What a schema accepts, for an `Expected ...` message. +fn expected(s: &Json) -> String { + if let Some(c) = s.get("const") { + return js_stringify(c); + } + if let Some(Json::Array(values)) = s.get("enum") { + return values + .iter() + .map(js_stringify) + .collect::>() + .join(" | "); + } + if let Some(Json::Array(alts)) = field(s, "anyOf").or_else(|| field(s, "oneOf")) { + let numeric = alts.iter().any(|a| type_is(a, "number")); + return alts + .iter() + .filter(|a| !(numeric && effect_number_sentinel(a))) + .map(expected) + .collect::>() + .join(" | "); + } + let types = types_of(s); + if types.is_empty() { + return "unknown".into(); + } + types + .iter() + .map(|t| if t == "integer" { "number" } else { t.as_str() }) + .collect::>() + .join(" | ") +} + +fn fail(message: impl Into, path: &[PathPart]) -> Result { + Err((message.into(), path.to_vec())) +} + +fn check( + n: &Node, + mut value: Json, + v: &Validator, + path: &mut Vec, + depth: usize, +) -> Result { + if depth > 64 { + return fail("Schema nesting is too deep", path); + } + if n.never { + return fail("Expected never", path); + } + if let Some(r) = n.reference { + value = check(&v.defs[r], value, v, path, depth + 1)?; + } + if let Some(c) = &n.constant + && !json_eq(c, &value) + { + return fail(format!("Expected {}", js_stringify(c)), path); + } + if let Some(values) = &n.enumeration + && !values.iter().any(|c| json_eq(c, &value)) + { + return fail(format!("Expected {}", n.expected), path); + } + if !n.any_of.is_empty() { + value = check_union(n, value, v, path, depth)?; + } + for part in &n.all_of { + value = check(part, value, v, path, depth + 1)?; + } + if !n.types.is_empty() { + if !n.types.iter().any(|t| matches_type(t, &value)) { + return fail(format!("Expected {}", n.expected), path); + } + if n.types.iter().all(|t| t == "integer") + && value.as_f64().is_some_and(|x| x.fract() != 0.0) + { + return fail("Expected an integer", path); + } + } + match &mut value { + Json::Number(x) => check_number(n, x.as_f64().unwrap_or(f64::NAN), path)?, + Json::String(text) => check_length(utf16_len(text), n.min_length, n.max_length, path)?, + Json::Array(items) => { + check_length(items.len(), n.min_items, n.max_items, path)?; + if n.unique_items { + for i in 0..items.len() { + if items[..i].iter().any(|prev| json_eq(prev, &items[i])) { + return fail("Expected an array of unique items", path); + } + } + } + if let Some(item_node) = &n.items { + for (i, item) in items.iter_mut().enumerate() { + path.push(PathPart::Index(i)); + *item = check(item_node, std::mem::take(item), v, path, depth + 1)?; + path.pop(); + } + } + } + Json::Object(map) => check_object(n, map, v, path, depth)?, + _ => {} + } + Ok(value) +} + +fn check_union( + n: &Node, + value: Json, + v: &Validator, + path: &mut Vec, + depth: usize, +) -> Result { + let mut candidate = None; + let mut same_type = 0; + for alt in &n.any_of { + match check(alt, value.clone(), v, path, depth + 1) { + Ok(decoded) => return Ok(decoded), + Err(e) => { + if alt.types.iter().any(|t| matches_type(t, &value)) { + same_type += 1; + candidate = Some(e); + } + } + } + } + // Like Effect, a single member of the value's own type explains the failure; otherwise the union does. + match candidate { + Some(e) if same_type == 1 => Err(e), + _ => fail(format!("Expected {}", n.expected), path), + } +} + +fn check_number(n: &Node, x: f64, path: &[PathPart]) -> Result<(), Failure> { + if let Some(m) = n.minimum + && x < m + { + return fail( + format!("Expected a value greater than or equal to {}", js_num(m)), + path, + ); + } + if let Some(m) = n.maximum + && x > m + { + return fail( + format!("Expected a value less than or equal to {}", js_num(m)), + path, + ); + } + if let Some(m) = n.exclusive_minimum + && x <= m + { + return fail(format!("Expected a value greater than {}", js_num(m)), path); + } + if let Some(m) = n.exclusive_maximum + && x >= m + { + return fail(format!("Expected a value less than {}", js_num(m)), path); + } + if let Some(m) = n.multiple_of + && (x / m).fract() != 0.0 + { + return fail( + format!("Expected a value that is a multiple of {}", js_num(m)), + path, + ); + } + Ok(()) +} + +fn check_length( + len: usize, + min: Option, + max: Option, + path: &[PathPart], +) -> Result<(), Failure> { + if let Some(m) = min + && (len as f64) < m + { + return fail( + format!("Expected a value with a length of at least {}", js_num(m)), + path, + ); + } + if let Some(m) = max + && (len as f64) > m + { + return fail( + format!("Expected a value with a length of at most {}", js_num(m)), + path, + ); + } + Ok(()) +} + +fn check_object( + n: &Node, + map: &mut serde_json::Map, + v: &Validator, + path: &mut Vec, + depth: usize, +) -> Result<(), Failure> { + for name in &n.required { + if !map.contains_key(name) { + path.push(PathPart::Key(name.clone())); + return fail("Missing key", path); + } + } + for (name, prop) in &n.properties { + if let Some(item) = map.get_mut(name) { + path.push(PathPart::Key(name.clone())); + *item = check(prop, std::mem::take(item), v, path, depth + 1)?; + path.pop(); + } + } + let known = |k: &str| n.properties.iter().any(|(p, _)| p == k); + match &n.additional { + Additional::Keep => {} + Additional::Drop => { + if map.len() > n.properties.len() || map.keys().any(|k| !known(k)) { + map.retain(|k, _| known(k)); + } + } + Additional::Check(extra) => { + for (name, item) in map.iter_mut() { + if known(name) { + continue; + } + path.push(PathPart::Key(name.clone())); + *item = check(extra, std::mem::take(item), v, path, depth + 1)?; + path.pop(); + } + } + } + Ok(()) +} + +/// JSON equality where numbers compare by value. +fn json_eq(a: &Json, b: &Json) -> bool { + match (a, b) { + (Json::Number(x), Json::Number(y)) => x.as_f64() == y.as_f64(), + (Json::Array(x), Json::Array(y)) => { + x.len() == y.len() && x.iter().zip(y).all(|(x, y)| json_eq(x, y)) + } + (Json::Object(x), Json::Object(y)) => { + x.len() == y.len() + && x.iter() + .all(|(k, v)| y.get(k).is_some_and(|w| json_eq(v, w))) + } + _ => a == b, + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/search.rs b/packages/codemode-rust/crates/psychoscript/src/search.rs new file mode 100644 index 000000000000..f19310cdd142 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/search.rs @@ -0,0 +1,386 @@ +//! The `search` built-in: field-weighted BM25 over tool paths, descriptions, parameter names and namespace +//! descriptions, ported from the reference's `tool-runtime.ts` so the same queries rank the same tools. + +use std::collections::HashMap; + +use serde_json::json; + +use crate::Json; +use crate::schema::{self, Schema}; +use crate::tool::{Entry, compare_text, tool_expression}; + +const DEFAULT_LIMIT: usize = 10; +const K1: f64 = 1.2; +const LENGTH_NORMALIZATION: f64 = 0.75; +/// score × (1 + BREVITY_BOOST / words in the tool name): "users" prefers `list_users` over `list_user_groups`. +const BREVITY_BOOST: f64 = 0.5; +/// A query word of 4+ letters also matches longer words it starts with, at this weight: `term` → `terminal`. +const PREFIX_WEIGHT: f64 = 0.3; + +/// Fields in the reference's order, with their weights: name, namespace, description, namespace description, +/// parameters. +const FIELDS: usize = 5; +const WEIGHTS: [f64; FIELDS] = [3.0, 2.0, 1.0, 0.4, 0.3]; + +/// Words split at case changes and non-alphanumerics: `listUserGroups` → list, user, groups. +fn split_words(text: &str) -> Vec { + let chars: Vec = text.chars().collect(); + let mut spaced = String::with_capacity(text.len() + 8); + for (i, &c) in chars.iter().enumerate() { + spaced.push(c); + if (c.is_ascii_lowercase() || c.is_ascii_digit()) + && chars.get(i + 1).is_some_and(char::is_ascii_uppercase) + { + spaced.push(' '); + } + } + spaced + .to_lowercase() + .split(|c: char| !(c.is_ascii_lowercase() || c.is_ascii_digit())) + .filter(|w| !w.is_empty()) + .map(str::to_owned) + .collect() +} + +/// Plural endings only, applied the same everywhere: `settings` → `setting`, `statuses` → `status`, `vms` → `vm`. +fn stem(word: String) -> String { + let len = word.len(); + if len > 4 && word.ends_with("ies") { + return format!("{}y", &word[..len - 3]); + } + if len > 4 + && ["sses", "shes", "ches", "xes", "zes", "uses"] + .iter() + .any(|e| word.ends_with(e)) + { + return word[..len - 2].to_owned(); + } + if len > 2 && word.ends_with('s') && !["ss", "us", "is"].iter().any(|e| word.ends_with(e)) { + return word[..len - 1].to_owned(); + } + word +} + +/// Searchable words of a text: its split words, plus each camelCase word whole (`CronJob` → cron, job, cronjob). +fn search_words(text: &str) -> Vec { + let mut words = split_words(text); + // `/[A-Za-z0-9]*[a-z0-9][A-Z][A-Za-z0-9]*/g` matches whole alphanumeric runs holding a lower-to-upper change. + for run in text.split(|c: char| !c.is_ascii_alphanumeric()) { + let bytes = run.as_bytes(); + if bytes.windows(2).any(|w| { + (w[0].is_ascii_lowercase() || w[0].is_ascii_digit()) && w[1].is_ascii_uppercase() + }) { + words.push(run.to_ascii_lowercase()); + } + } + words.into_iter().map(stem).collect() +} + +/// For each word, the tools containing it and their field-weighted, length-normalized term frequency. +pub struct WordIndex { + postings: HashMap, Vec)>, + documents: usize, + /// Sorted indexed words, for partial-word matching. + words: Vec, + /// Words in each tool's own name (the last path segment). + name_lengths: Vec, +} + +impl WordIndex { + pub fn build(entries: &[Entry]) -> Self { + let mut cache: HashMap> = HashMap::new(); + let mut words_of = |texts: &[String]| -> Vec { + texts + .iter() + .flat_map(|t| { + cache + .entry(t.clone()) + .or_insert_with(|| search_words(t)) + .clone() + }) + .collect() + }; + let fields: Vec<[Vec; FIELDS]> = entries + .iter() + .map(|e| { + let segments: Vec = e.path.split('.').map(str::to_owned).collect(); + let (name, namespace) = segments + .split_last() + .map_or((String::new(), &[][..]), |(n, ns)| (n.clone(), ns)); + [ + words_of(&[name]), + words_of(namespace), + words_of(std::slice::from_ref(&e.tool.description)), + words_of(&e.namespaces), + words_of(&schema::input_property_names(e.tool.input.document())), + ] + }) + .collect(); + let count = entries.len(); + let mut average = [0.0; FIELDS]; + for (f, avg) in average.iter_mut().enumerate() { + let total: usize = fields.iter().map(|e| e[f].len()).sum(); + let mean = total as f64 / count as f64; + *avg = if mean == 0.0 || mean.is_nan() { + 1.0 + } else { + mean + }; + } + let mut postings: HashMap, Vec)> = HashMap::new(); + for (position, entry) in fields.iter().enumerate() { + let mut weights: Vec<(String, f64)> = Vec::new(); + for f in 0..FIELDS { + let weight = WEIGHTS[f] + / (1.0 - LENGTH_NORMALIZATION + + LENGTH_NORMALIZATION * entry[f].len() as f64 / average[f]); + for word in &entry[f] { + match weights.iter_mut().find(|(w, _)| w == word) { + Some((_, total)) => *total += weight, + None => weights.push((word.clone(), weight)), + } + } + } + for (word, weight) in weights { + let posting = postings.entry(word).or_default(); + posting.0.push(position as u32); + // The reference keeps weights in a Float32Array; rounding the same way keeps ties the same. + posting.1.push(weight as f32); + } + } + let mut words: Vec = postings.keys().cloned().collect(); + words.sort(); + let name_lengths = entries + .iter() + .map(|e| split_words(e.path.rsplit('.').next().unwrap_or("")).len()) + .collect(); + Self { + postings, + documents: count, + words, + name_lengths, + } + } + + /// Indexed words longer than a 4+ letter query word that start with it. + fn prefix_matches(&self, term: &str) -> Vec<&str> { + if term.encode_utf16().count() < 4 { + return Vec::new(); + } + let start = self.words.partition_point(|w| w.as_str() < term); + self.words[start..] + .iter() + .take_while(|w| w.starts_with(term)) + .filter(|w| w.as_str() != term) + .map(String::as_str) + .collect() + } +} + +/// Positions of `scope` (indexes into `entries`) ranked for `query`; an empty query sorts them by path. +pub fn rank(entries: &[Entry], index: &WordIndex, scope: &[usize], query: &str) -> Vec { + let terms = search_words(query); + if terms.is_empty() { + let mut out = scope.to_vec(); + out.sort_by(|a, b| compare_text(&entries[*a].path, &entries[*b].path)); + return out; + } + let all = scope.len() == entries.len(); + let mut allowed = vec![all; entries.len()]; + if !all { + for &p in scope { + allowed[p] = true; + } + } + let mut order: Vec = Vec::new(); + let mut scores: HashMap = HashMap::new(); + for term in &terms { + let mut best: Vec<(usize, f64)> = Vec::new(); + let candidates = std::iter::once((term.as_str(), 1.0)).chain( + index + .prefix_matches(term) + .into_iter() + .map(|w| (w, PREFIX_WEIGHT)), + ); + for (word, factor) in candidates { + let Some((positions, weights)) = index.postings.get(word) else { + continue; + }; + let df = positions.len() as f64; + let idf = (1.0 + (index.documents as f64 - df + 0.5) / (df + 0.5)).ln(); + for (i, &position) in positions.iter().enumerate() { + let position = position as usize; + if !allowed[position] { + continue; + } + let weight = weights[i] as f64; + let score = factor * idf * weight * (K1 + 1.0) / (weight + K1); + match best.iter_mut().find(|(p, _)| *p == position) { + Some((_, b)) => { + if score > *b { + *b = score; + } + } + None if score > 0.0 => best.push((position, score)), + None => {} + } + } + } + for (position, score) in best { + let total = scores.entry(position).or_insert_with(|| { + order.push(position); + 0.0 + }); + *total += score; + } + } + let mut ranked: Vec<(usize, f64)> = order + .into_iter() + .map(|p| { + let boost = 1.0 + BREVITY_BOOST / index.name_lengths[p].max(1) as f64; + (p, scores[&p] * boost) + }) + .collect(); + ranked.sort_by(|a, b| { + b.1.partial_cmp(&a.1) + .unwrap_or(std::cmp::Ordering::Equal) + .then_with(|| compare_text(&entries[a.0].path, &entries[b.0].path)) + }); + ranked.into_iter().map(|(p, _)| p).collect() +} + +/// The schema `search` decodes its input with, as the reference's Effect `SearchInput` renders to JSON Schema. +pub fn input_schema() -> Schema { + Schema::validated(json!({ + "type": "object", + "properties": { + "query": { "type": "string" }, + "namespace": { "type": "string" }, + "limit": { "type": "integer", "maximum": 9007199254740991i64, "exclusiveMinimum": 0 }, + "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991i64 } + }, + "additionalProperties": false + })) +} + +fn output_schema() -> Json { + let int = json!({ "type": "integer", "minimum": 0, "maximum": 9007199254740991i64 }); + json!({ + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "path": { "type": "string" }, + "description": { "type": "string" }, + "signature": { "type": "string" } + }, + "required": ["path", "description", "signature"], + "additionalProperties": false + } + }, + "remaining": int, + "next": { + "anyOf": [ + { + "type": "object", + "properties": { "offset": int }, + "required": ["offset"], + "additionalProperties": false + }, + { "type": "null" } + ] + } + }, + "required": ["items", "remaining", "next"], + "additionalProperties": false + }) +} + +/// The exact callable signature of the built-in `search`, for host-owned instructions. +pub fn search_signature() -> String { + format!( + "search(query: string | {}): {}", + schema::to_typescript(input_schema().document(), true), + schema::to_typescript(&output_schema(), true) + ) +} + +/// Runs a decoded search request over a runtime's tools. +pub fn search(entries: &[Entry], index: &WordIndex, request: &Json) -> Json { + let query = request.get("query").and_then(Json::as_str).unwrap_or(""); + let offset = request.get("offset").and_then(Json::as_f64).unwrap_or(0.0) as usize; + let limit = request + .get("limit") + .and_then(Json::as_f64) + .map_or(DEFAULT_LIMIT, |l| l as usize); + let mut namespace = request.get("namespace").and_then(Json::as_str); + if let Some(ns) = namespace + && !entries.iter().any(|e| e.path.starts_with("tools.")) + { + namespace = if ns == "tools" { + None + } else { + Some(ns.strip_prefix("tools.").unwrap_or(ns)) + }; + } + let scoped: Vec = match namespace { + None => (0..entries.len()).collect(), + Some(ns) => { + let under = format!("{ns}."); + (0..entries.len()) + .filter(|&i| entries[i].path == ns || entries[i].path.starts_with(&under)) + .collect() + } + }; + let trimmed = query.trim_matches(|c: char| c.is_whitespace() || c == '\u{feff}'); + let path_query = trimmed.strip_prefix("tools.").unwrap_or(trimmed); + let exact = (!path_query.is_empty()) + .then(|| { + scoped.iter().copied().find(|&i| { + entries[i].path == path_query || tool_expression(&entries[i].path) == trimmed + }) + }) + .flatten(); + let ranked = match exact { + Some(i) => vec![i], + None => rank(entries, index, &scoped, path_query), + }; + let items: Vec = ranked + .iter() + .skip(offset) + .take(limit) + .map(|&i| { + let e = &entries[i]; + json!({ + "path": tool_expression(&e.path), + "description": e.tool.description, + "signature": e.signature(), + }) + }) + .collect(); + let remaining = ranked.len().saturating_sub(offset + items.len()); + let next = if remaining > 0 { + json!({ "offset": offset + items.len() }) + } else { + Json::Null + }; + json!({ "items": items, "remaining": remaining, "next": next }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn words_split_and_stem_like_the_reference() { + assert_eq!(split_words("listUserGroups"), ["list", "user", "groups"]); + assert_eq!(search_words("CronJob"), ["cron", "job", "cronjob"]); + assert_eq!( + search_words("settings statuses vms issues class"), + ["setting", "status", "vm", "issue", "class"] + ); + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/tool.rs b/packages/codemode-rust/crates/psychoscript/src/tool.rs new file mode 100644 index 000000000000..56c9673215ad --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/tool.rs @@ -0,0 +1,345 @@ +//! Tools: their declaration, the namespace tree a runtime indexes them in, and the catalog it describes them with. + +use std::collections::BTreeMap; +use std::fmt; +use std::future::Future; +use std::pin::Pin; +use std::sync::{Arc, OnceLock}; + +use crate::Json; +use crate::schema::{self, Schema}; + +/// A boxed future a host hands the runtime. `Send`, so a run can move between threads. +pub type BoxFuture<'a, T> = Pin + Send + 'a>>; + +/// What a tool call knows about itself: its stable idempotency key, `:`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ToolContext { + run_id: Arc, + pub(crate) call: u64, +} + +impl ToolContext { + pub(crate) fn new(run_id: Arc, call: u64) -> Self { + Self { run_id, call } + } + + /// `:`, the same at every hook. + pub fn key(&self) -> String { + format!("{}:{}", self.run_id, self.call) + } +} + +/// A tool's refusal or failure, reported as `ToolFailure` and thrown into the program as an `Error`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ToolError { + pub message: String, +} + +impl ToolError { + pub fn new(message: impl Into) -> Self { + Self { + message: message.into(), + } + } +} + +impl fmt::Display for ToolError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.message) + } +} + +impl std::error::Error for ToolError {} + +impl From for ToolError { + fn from(message: String) -> Self { + Self { message } + } +} + +impl From<&str> for ToolError { + fn from(message: &str) -> Self { + Self::new(message) + } +} + +pub type SyncExecute = dyn Fn(Json, &ToolContext) -> Result + Send + Sync; +pub type AsyncExecute = + dyn Fn(Json, ToolContext) -> BoxFuture<'static, Result> + Send + Sync; + +#[derive(Clone)] +pub enum Execute { + /// Runs to completion when the program calls it. + Sync(Arc), + /// Starts when the program calls it; the program holds a promise until the future completes. + Async(Arc), +} + +/// One schema-described tool, the counterpart of the reference's `Tool.make`. +#[derive(Clone)] +pub struct Tool { + pub description: String, + pub input: Schema, + /// `None` renders `Promise` and hands the program `undefined`, whatever the tool returns. + pub output: Option, + /// The input is one required string field that programs may pass directly: `tools.patch("...")`. + pub freeform: bool, + pub execute: Execute, +} + +impl Tool { + /// A tool with a synchronous body. Like the reference, a tool without an output schema renders `Promise` + /// and hands the program `undefined`; the input defaults to a render-only schema that accepts anything. + pub fn new( + description: impl Into, + execute: impl Fn(Json, &ToolContext) -> Result + Send + Sync + 'static, + ) -> Self { + Self::with(description, Execute::Sync(Arc::new(execute))) + } + + /// A tool whose body is a future; it runs on whatever executor drives the program. + pub fn new_async( + description: impl Into, + execute: impl Fn(Json, ToolContext) -> F + Send + Sync + 'static, + ) -> Self + where + F: Future> + Send + 'static, + { + Self::with( + description, + Execute::Async(Arc::new(move |input, ctx| Box::pin(execute(input, ctx)))), + ) + } + + fn with(description: impl Into, execute: Execute) -> Self { + Self { + description: description.into(), + input: Schema::render_only(Json::Object(Default::default())), + output: None, + freeform: false, + execute, + } + } + + pub fn input(mut self, schema: Schema) -> Self { + self.input = schema; + self + } + + pub fn output(mut self, schema: Schema) -> Self { + self.output = Some(schema); + self + } + + pub fn freeform(mut self) -> Self { + self.freeform = true; + self + } +} + +/// A tool as the catalog and search describe it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ToolDescription { + /// The canonical dotted path, such as `orders.lookup`. + pub path: String, + pub description: String, + /// The generated TypeScript call signature, such as `tools.orders.lookup({ ... }): Promise<...>`. + pub signature: String, +} + +/// The expression that calls a tool: `tools.a.b`, with bracket notation for segments that are not identifiers. +pub fn tool_expression(path: &str) -> String { + let mut out = String::from("tools"); + for segment in path.split('.') { + if schema::is_identifier(segment) { + out.push('.'); + out.push_str(segment); + } else { + out.push('['); + out.push_str(&schema::js_stringify(&Json::String(segment.to_owned()))); + out.push(']'); + } + } + out +} + +/// A registered tool with its rendering done once, on first use. +pub struct Entry { + pub path: String, + pub tool: Tool, + /// Descriptions of the namespaces enclosing it, outermost first. + pub namespaces: Vec, + signature: OnceLock, +} + +impl Entry { + pub fn new(path: String, tool: Tool, namespaces: Vec) -> Self { + Self { + path, + tool, + namespaces, + signature: OnceLock::new(), + } + } + + pub fn signature(&self) -> &str { + self.signature + .get_or_init(|| signature(&self.path, &self.tool)) + } + + pub fn describe(&self) -> ToolDescription { + ToolDescription { + path: self.path.clone(), + description: self.tool.description.clone(), + signature: self.signature().to_owned(), + } + } +} + +fn signature(path: &str, tool: &Tool) -> String { + let params = tool + .freeform + .then(|| schema::string_parameter(tool.input.document())) + .flatten() + .map(|(_, sig)| sig) + .unwrap_or_else(|| { + if schema::is_empty_input(&tool.input) { + "()".into() + } else { + format!("({})", schema::to_typescript(tool.input.document(), true)) + } + }); + let output = match &tool.output { + None => "void".into(), + Some(s) => schema::to_typescript(s.document(), true), + }; + format!("{}{params}: Promise<{output}>", tool_expression(path)) +} + +/// A configuration mistake the reference reports by throwing from `CodeMode.make`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ConfigError(pub String); + +impl fmt::Display for ConfigError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.0) + } +} + +impl std::error::Error for ConfigError {} + +/// Checks a dotted tool or namespace path; empty segments are refused like the reference refuses them. +pub fn check_path(path: &str) -> Result<(), ConfigError> { + if path.split('.').any(str::is_empty) { + return Err(ConfigError(format!( + "Tool name '{path}' contains an empty segment." + ))); + } + Ok(()) +} + +/// Every tool of a runtime, by canonical dotted path, and the namespace descriptions around them. +#[derive(Default)] +pub struct Registry { + pub tools: BTreeMap>, + pub namespaces: BTreeMap, + /// Paths in first-insertion order, which is the order namespaces enumerate their children in. + order: Vec, + entries: OnceLock>, + index: OnceLock, +} + +impl Registry { + pub fn insert(&mut self, path: &str, tool: Tool) { + if self.tools.insert(path.to_owned(), Arc::new(tool)).is_none() { + self.order.push(path.to_owned()); + } + self.entries = OnceLock::new(); + self.index = OnceLock::new(); + } + + /// The search word index over [`Registry::entries`], built on the first query. + pub fn word_index(&self) -> &crate::search::WordIndex { + self.index + .get_or_init(|| crate::search::WordIndex::build(self.entries())) + } + + pub fn namespace(&mut self, path: &str, description: &str) { + self.namespaces + .insert(path.to_owned(), description.to_owned()); + self.entries = OnceLock::new(); + self.index = OnceLock::new(); + } + + /// Tools in path order (by UTF-16 code units, as the reference sorts), for the catalog and search. + pub fn entries(&self) -> &[Entry] { + self.entries.get_or_init(|| { + let mut entries: Vec = self + .tools + .iter() + .map(|(path, tool)| { + let mut namespaces = Vec::new(); + let mut prefix = String::new(); + for (i, segment) in path.split('.').enumerate() { + if i > 0 { + prefix.push('.'); + } + prefix.push_str(segment); + if let Some(d) = self.namespaces.get(&prefix) { + namespaces.push(d.clone()); + } + } + Entry::new(path.clone(), (**tool).clone(), namespaces) + }) + .collect(); + entries.sort_by(|a, b| compare_text(&a.path, &b.path)); + entries + }) + } + + pub fn get(&self, path: &str) -> Option<&Arc> { + self.tools.get(path) + } + + /// Whether some tool lives under `path`, which makes it a namespace. + pub fn is_namespace(&self, path: &str) -> bool { + if path.is_empty() { + return true; + } + let under = format!("{path}."); + self.tools + .range(under.clone()..) + .next() + .is_some_and(|(k, _)| k.starts_with(&under)) + } + + /// Whether `path` names a tool or a namespace. + pub fn exists(&self, path: &str) -> bool { + self.tools.contains_key(path) || self.is_namespace(path) + } + + /// The child segments under a namespace, in the order the reference's trie holds them: first insertion. + pub fn children(&self, path: &str) -> Vec { + let under = if path.is_empty() { + String::new() + } else { + format!("{path}.") + }; + let mut out: Vec = Vec::new(); + for k in &self.order { + if let Some(rest) = k.strip_prefix(&under) { + let child = rest.split('.').next().unwrap_or(rest); + if !out.iter().any(|c| c == child) { + out.push(child.to_owned()); + } + } + } + out + } +} + +/// String order by UTF-16 code units, like JavaScript's `<`. +pub fn compare_text(a: &str, b: &str) -> std::cmp::Ordering { + a.encode_utf16().cmp(b.encode_utf16()) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/vm.rs b/packages/codemode-rust/crates/psychoscript/src/vm.rs index 486578d12a9a..5a9883df22ed 100644 --- a/packages/codemode-rust/crates/psychoscript/src/vm.rs +++ b/packages/codemode-rust/crates/psychoscript/src/vm.rs @@ -1,6 +1,6 @@ //! The stack machine: frames, calls, exceptions, suspension and the run loop. -use std::collections::{BTreeMap, VecDeque}; +use std::collections::VecDeque; use std::rc::Rc; use std::time::Instant; @@ -10,11 +10,11 @@ use crate::bytecode::{Arith, Capture, FuncProto, Op, Program}; use crate::object::*; use crate::strings::{StrId, Strings}; use crate::value::{Id, Slot, Value}; -use crate::{DiagnosticKind, Json, Limits, ToolCall, ToolFn}; +use crate::{DiagnosticKind, Limits, ToolCall}; pub type Res = Result; -/// A tool call's result as it waits to settle its promise. -pub type ToolOutcome = Result; +/// A host call's result as it waits to settle its promise. +pub type ToolOutcome = crate::host::Settlement; pub type NativeFn = fn(&mut Vm, Value, &[Value], Id) -> Res; pub const MAX_DEPTH: usize = 10_000; @@ -165,7 +165,7 @@ pub struct Vm<'rt> { pub coroutines: Vec, pub logs: Vec, pub tool_calls: Vec, - pub tools: &'rt BTreeMap, + pub host: Box>, pub tool_refs: FxHashMap, Id>, pub limits: Limits, pub start: Instant, @@ -182,7 +182,7 @@ pub struct Vm<'rt> { } impl<'rt> Vm<'rt> { - pub fn new(tools: &'rt BTreeMap, limits: Limits, atoms: Strings) -> Self { + pub fn new(host: crate::host::RunHost<'rt>, limits: Limits, atoms: Strings) -> Self { let mut atoms = atoms; let names = Names { length: atoms.intern_static("length"), @@ -230,7 +230,7 @@ impl<'rt> Vm<'rt> { coroutines: Vec::new(), logs: Vec::new(), tool_calls: Vec::new(), - tools, + host: Box::new(host), tool_refs: FxHashMap::default(), limits, start: Instant::now(), @@ -635,59 +635,7 @@ impl<'rt> Vm<'rt> { } pub fn call_tool(&mut self, path: &str, args: &[Value]) -> Res { - let p = self.new_promise(); - let outcome = self.invoke_tool(path, args); - self.inbox.push_back((p, outcome)); - Ok(Value::Obj(p)) - } - - fn invoke_tool( - &mut self, - path: &str, - args: &[Value], - ) -> Result { - if args.len() > 1 { - return Err(( - DiagnosticKind::InvalidDataValue, - format!("Tool '{path}' expects at most one input object."), - )); - } - let tools = self.tools; - let Some(tool) = tools.get(path) else { - let under = format!("{path}."); - let message = if tools.keys().any(|k| k.starts_with(&under)) { - format!("Tool '{path}' is not callable, it is a namespace.") - } else { - format!("Unknown tool '{path}'.") - }; - return Err((DiagnosticKind::UnknownTool, message)); - }; - let input = match args.first() { - None => Json::Object(serde_json::Map::new()), - Some(v) => match crate::convert::to_json(self, v) { - Ok(j) => j, - Err(e) => { - let msg = self.error_text(&e); - return Err(( - DiagnosticKind::InvalidDataValue, - format!("Invalid input for tool '{path}': {msg}"), - )); - } - }, - }; - if let Some(max) = self.limits.max_tool_calls - && self.tool_calls.len() as u64 >= max - { - return Err(( - DiagnosticKind::ToolCallLimitExceeded, - format!("Execution exceeded its tool-call limit of {max}."), - )); - } - self.tool_calls.push(ToolCall { - path: path.to_owned(), - input: input.clone(), - }); - tool(&input).map_err(|m| (DiagnosticKind::ToolFailure, m)) + crate::host::call_tool(self, path, args) } pub fn tool_ref(&mut self, path: &str) -> Value { @@ -1860,26 +1808,12 @@ impl<'rt> Vm<'rt> { } if let Some((p, outcome)) = self.inbox.pop_front() { self.check_time()?; - match outcome { - Ok(json) => { - let v = crate::convert::from_json(self, &json); - self.fulfill(p, v); - } - Err((kind, message)) => { - let proto = self.realm.error_proto; - let e = self.make_error(proto, &message); - if let Value::Obj(id) = e { - self.heap[id as usize].kind = Kind::Error(Some(Box::new(Failure { - kind, - message, - offset: None, - }))); - } - self.reject(p, e); - } - } + crate::host::settle(self, p, outcome); continue; } + if self.host.waiting() { + return Ok(()); + } let e = self.make_error( self.realm.error_proto, "The program is waiting on a promise that can never settle: nothing else is running, so nothing can resolve it.", diff --git a/packages/codemode-rust/crates/psychoscript/tests/catalog.rs b/packages/codemode-rust/crates/psychoscript/tests/catalog.rs new file mode 100644 index 000000000000..a4e9e9a6b7f9 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/tests/catalog.rs @@ -0,0 +1,140 @@ +//! The catalog, signatures, search and tool-call diagnostics against the reference, from +//! `conformance/catalog.json`, which `bun conformance/catalog.ts` generates from the reference. + +use psychoscript::{Json, Runtime, Schema, Tool, search_signature, tool_expression}; + +fn fixture() -> Json { + let path = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../conformance/catalog.json" + ); + serde_json::from_str(&std::fs::read_to_string(path).expect("catalog.json")).expect("JSON") +} + +fn schema(spec: &Json) -> Schema { + if spec["validated"] == Json::Bool(true) { + Schema::validated(spec["schema"].clone()) + } else { + Schema::render_only(spec["schema"].clone()) + } +} + +fn runtime(fixture: &Json) -> Runtime { + let results = serde_json::json!({ + "orders.lookup": { "id": "o1", "status": "open" }, + "orders.list": [{ "id": "o1", "total": 3 }], + "util.now": null, + "fetchPage": "page", + "context7.resolve-library-id": "/lib", + }); + let mut rt = Runtime::new(); + for spec in fixture["tools"].as_array().unwrap() { + let path = spec["path"].as_str().unwrap(); + let result = results.get(path).cloned(); + let mut tool = Tool::new(spec["description"].as_str().unwrap(), move |input, _| { + Ok(result.clone().unwrap_or(input)) + }) + .input(schema(&spec["input"])); + if let Some(output) = spec.get("output") { + tool = tool.output(schema(output)); + } + if spec["freeform"] == Json::Bool(true) { + tool = tool.freeform(); + } + rt = rt.with_tool(path, tool); + } + for ns in fixture["namespaces"].as_array().unwrap() { + rt = rt.namespace( + ns["path"].as_str().unwrap(), + ns["description"].as_str().unwrap(), + ); + } + rt +} + +#[test] +fn catalog_signatures_match_the_reference() { + let fixture = fixture(); + let rt = runtime(&fixture); + let catalog: Vec = rt + .catalog() + .into_iter() + .map(|t| serde_json::json!({ "path": t.path, "description": t.description, "signature": t.signature })) + .collect(); + let expected = fixture["catalog"].as_array().unwrap(); + assert_eq!(catalog.len(), expected.len()); + for (actual, expected) in catalog.iter().zip(expected) { + assert_eq!( + actual, expected, + "\n{}\n---\n{}", + actual["signature"], expected["signature"] + ); + } +} + +#[test] +fn search_signature_and_tool_expressions_match_the_reference() { + let fixture = fixture(); + assert_eq!( + search_signature(), + fixture["searchSignature"].as_str().unwrap() + ); + for pair in fixture["expressions"].as_array().unwrap() { + assert_eq!( + tool_expression(pair[0].as_str().unwrap()), + pair[1].as_str().unwrap() + ); + } +} + +#[test] +fn search_and_tool_call_diagnostics_match_the_reference() { + let fixture = fixture(); + let rt = runtime(&fixture); + let mut failures = Vec::new(); + for case in fixture["programs"].as_array().unwrap() { + let code = case["code"].as_str().unwrap(); + let outcome = rt.execute(code, &serde_json::Map::new()); + let actual = match &outcome.result { + Ok(value) => { + serde_json::json!({ "ok": true, "value": value, "toolCalls": outcome.tool_calls.len() }) + } + Err(d) => { + let mut error = serde_json::json!({ "kind": d.kind.name(), "message": d.message }); + if !d.suggestions.is_empty() { + error["suggestions"] = d.suggestions.clone().into(); + } + serde_json::json!({ "ok": false, "error": error, "toolCalls": outcome.tool_calls.len() }) + } + }; + let mut expected = case.clone(); + expected.as_object_mut().unwrap().remove("code"); + if let Some(e) = expected.get_mut("error") { + e.as_object_mut().unwrap().remove("location"); + } + if !same(&actual, &expected) { + failures.push(format!( + "{code}\n expected: {expected}\n actual: {actual}" + )); + } + } + assert!( + failures.is_empty(), + "{} mismatches:\n{}", + failures.len(), + failures.join("\n") + ); +} + +fn same(a: &Json, b: &Json) -> bool { + match (a, b) { + (Json::Number(x), Json::Number(y)) => x.as_f64() == y.as_f64(), + (Json::Array(x), Json::Array(y)) => { + x.len() == y.len() && x.iter().zip(y).all(|(x, y)| same(x, y)) + } + (Json::Object(x), Json::Object(y)) => { + x.len() == y.len() && x.iter().all(|(k, v)| y.get(k).is_some_and(|w| same(v, w))) + } + _ => a == b, + } +} diff --git a/packages/codemode-rust/crates/psychoscript/tests/hooks.rs b/packages/codemode-rust/crates/psychoscript/tests/hooks.rs new file mode 100644 index 000000000000..3ec1771a2a25 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/tests/hooks.rs @@ -0,0 +1,480 @@ +//! Asynchronous tools, hooks, interruption and time slicing, mirroring the reference's `codemode.test.ts` call hooks +//! and `limits.test.ts`. + +use std::future::Future; +use std::pin::Pin; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex}; +use std::task::{Context, Poll, Waker}; +use std::time::{Duration, Instant}; + +use psychoscript::{ + CallResult, DiagnosticKind, Extension, Hooks, HostError, HostFunction, HostValue, Json, Limits, + Outcome, Runtime, Schema, Tool, ToolError, +}; +use serde_json::json; + +/// A value that arrives after `ms` from another thread: an asynchronous host operation without an executor. +struct Later { + state: Arc, Option)>>, +} + +fn later(ms: u64, value: T) -> Later { + let state = Arc::new(Mutex::new((None, None::))); + let shared = state.clone(); + std::thread::spawn(move || { + std::thread::sleep(Duration::from_millis(ms)); + let mut s = shared.lock().unwrap(); + s.0 = Some(value); + if let Some(w) = s.1.take() { + w.wake(); + } + }); + Later { state } +} + +impl Future for Later { + type Output = T; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let mut s = self.state.lock().unwrap(); + match s.0.take() { + Some(v) => Poll::Ready(v), + None => { + s.1 = Some(cx.waker().clone()); + Poll::Pending + } + } + } +} + +fn run(rt: &Runtime, code: &str) -> Outcome { + rt.execute(code, &serde_json::Map::new()) +} + +fn empty() -> Schema { + Schema::validated(json!({ "type": "object", "properties": {}, "additionalProperties": false })) +} + +fn any() -> Schema { + Schema::render_only(json!({})) +} + +fn ended(result: &CallResult<'_, V>) -> String { + match result { + CallResult::Failure(message) => format!("failure:{message}"), + other => other.status().to_owned(), + } +} + +/// Hooks that log every event, so the order across tools and extensions is visible. +fn observe(events: &Arc>>) -> Hooks { + let (a, b, c, d) = ( + events.clone(), + events.clone(), + events.clone(), + events.clone(), + ); + Hooks::new() + .tool_before(move |call| { + a.lock().unwrap().push(format!( + "tool.before {}", + json!({ "name": call.name, "input": call.input }) + )); + Ok(()) + }) + .tool_after(move |call, result| { + b.lock() + .unwrap() + .push(format!("tool.after {} {}", call.name, ended(&result))); + }) + .extension_before(move |call| { + let args: Vec = call + .args + .iter() + .map(|a| a.to_json().unwrap_or(Json::Null)) + .collect(); + c.lock().unwrap().push(format!( + "extension.before {}", + json!({ "extension": call.extension, "name": call.name, "args": args }) + )); + Ok(()) + }) + .extension_after(move |call, result| { + d.lock() + .unwrap() + .push(format!("extension.after {} {}", call.name, ended(&result))); + }) +} + +#[test] +fn async_tools_run_concurrently() { + let rt = Runtime::new().with_tool( + "slow", + Tool::new_async("Slow", |input, _| async move { + Ok(later(50, input["n"].clone()).await) + }) + .output(any()), + ); + let started = Instant::now(); + let outcome = run( + &rt, + "const all = await Promise.all(Array.from({ length: 40 }, (_, n) => tools.slow({ n }))); return all.reduce((a, b) => a + b, 0)", + ); + assert_eq!(outcome.result.unwrap(), json!(780)); + assert!( + started.elapsed() < Duration::from_millis(1500), + "{:?}", + started.elapsed() + ); + assert_eq!(outcome.tool_calls.len(), 40); +} + +#[test] +fn hooks_surround_the_tools_invoked_with_decoded_input() { + let events = Arc::new(Mutex::new(Vec::new())); + let lookup = Tool::new("Look up a value", |input, _| { + let query = input["query"].as_str().unwrap_or_default().to_owned(); + if query == "boom" { + return Err(ToolError::new("Lookup refused")); + } + Ok(Json::String(query)) + }) + .output(any()) + .input(Schema::validated(json!({ + "type": "object", + "properties": { "query": { "type": "string" } }, + "required": ["query"], + "additionalProperties": false + }))); + let rt = Runtime::new() + .with_tool("context.lookup", lookup) + .hooks(observe(&events)); + let ok = run( + &rt, + r#"if (false) await tools.context.lookup({ query: "not called" }) + return await tools.context.lookup({ query: "deployment failure", extra: 1 })"#, + ); + assert_eq!(ok.result.unwrap(), json!("deployment failure")); + assert!( + run( + &rt, + r#"return await tools.context.lookup({ query: "boom" })"# + ) + .result + .is_err() + ); + assert_eq!( + *events.lock().unwrap(), + [ + r#"tool.before {"name":"context.lookup","input":{"query":"deployment failure"}}"#, + "tool.after context.lookup success", + r#"tool.before {"name":"context.lookup","input":{"query":"boom"}}"#, + "tool.after context.lookup failure:Lookup refused", + ] + ); +} + +#[test] +fn hooks_surround_extension_globals_but_not_functions_inside_results() { + let events = Arc::new(Mutex::new(Vec::new())); + let fetch = HostFunction::new_async("fetch", 2, |args| async move { + let url = args.first().cloned().unwrap_or_default(); + let method = args + .get(1) + .and_then(|i| i.get("method")) + .cloned() + .unwrap_or("GET".into()); + Ok(HostValue::object([ + ("url", url), + ("method", method), + ( + "json", + HostFunction::new("json", 0, |_| Ok(1.0.into())).into(), + ), + ])) + }); + let fail = HostFunction::new("fail", 0, |_| { + Err(HostError::named("RangeError", "nope").into()) + }); + let rt = Runtime::new() + .extension( + Extension::new("web") + .function("fetch", fetch) + .function("fail", fail), + ) + .hooks(observe(&events)); + let outcome = run( + &rt, + r#"const res = await fetch("https://a.test/", { method: "POST" }) + res.json() + try { fail() } catch {} + return res.url"#, + ); + assert_eq!(outcome.result.unwrap(), json!("https://a.test/")); + assert!(outcome.tool_calls.is_empty()); + assert_eq!( + *events.lock().unwrap(), + [ + r#"extension.before {"extension":"web","name":"fetch","args":["https://a.test/",{"method":"POST"}]}"#, + "extension.after fetch success", + r#"extension.before {"extension":"web","name":"fail","args":[]}"#, + "extension.after fail failure:nope", + ] + ); +} + +#[test] +fn a_failing_before_hook_denies_the_call() { + let called = Arc::new(AtomicUsize::new(0)); + let hits = called.clone(); + let lookup = Tool::new("Look up", move |_, _| { + hits.fetch_add(1, Ordering::SeqCst); + Ok(json!("ok")) + }) + .input(empty()) + .output(any()); + let fetch = HostFunction::new_async("fetch", 1, |args| async move { + Ok(args.into_iter().next().unwrap_or_default()) + }); + let rt = + Runtime::new() + .with_tool("lookup", lookup.clone()) + .extension(Extension::new("web").function("fetch", fetch)) + .hooks(Hooks::new().extension_before(|call| { + Err(HostError::new(format!("{} is not allowed", call.name))) + })); + assert_eq!( + run( + &rt, + r#"const denied = await fetch("https://a.test/").catch((e) => [e instanceof Error, e.message]) + return [denied, await tools.lookup({})]"# + ) + .result + .unwrap(), + json!([[true, "fetch is not allowed"], "ok"]) + ); + let d = run(&rt, r#"await fetch("https://a.test/")"#) + .result + .unwrap_err(); + assert_eq!(d.kind, DiagnosticKind::ExecutionFailure); + assert_eq!(d.message, "Error: fetch is not allowed"); + + let refused = Runtime::new() + .with_tool("lookup", lookup) + .hooks(Hooks::new().tool_before(|_| Err(ToolError::new("lookup is not allowed")))); + let outcome = run( + &refused, + "try { await tools.lookup({}) } catch (e) { return [e.name, e.message] }", + ); + assert_eq!( + outcome.result.unwrap(), + json!(["Error", "lookup is not allowed"]) + ); + assert_eq!(outcome.tool_calls.len(), 1); + let d = run(&refused, "await tools.lookup({})").result.unwrap_err(); + assert_eq!(d.kind, DiagnosticKind::ToolFailure); + assert_eq!(d.message, "lookup is not allowed"); + assert_eq!(called.load(Ordering::SeqCst), 1); +} + +#[test] +fn a_denied_call_fails_the_way_the_global_would() { + let called = Arc::new(Mutex::new(Vec::new())); + let (a, b) = (called.clone(), called.clone()); + let rt = + Runtime::new() + .extension( + Extension::new("host") + .function( + "value", + HostFunction::new("value", 0, move |_| { + a.lock().unwrap().push("value"); + Ok(1.0.into()) + }), + ) + .function( + "asyncFn", + HostFunction::new_async("asyncFn", 0, move |_| { + b.lock().unwrap().push("asyncFn"); + async { Ok(1.0.into()) } + }), + ), + ) + .hooks(Hooks::new().extension_before(|call| { + Err(HostError::new(format!("{} is not allowed", call.name))) + })); + assert_eq!( + run( + &rt, + "return (await Promise.allSettled([asyncFn()])).map((r) => r.reason.message)" + ) + .result + .unwrap(), + json!(["asyncFn is not allowed"]) + ); + assert_eq!( + run(&rt, "try { value() } catch (e) { return e.message }") + .result + .unwrap(), + json!("value is not allowed") + ); + assert!(called.lock().unwrap().is_empty()); +} + +#[test] +fn calls_left_running_are_interrupted_when_the_program_returns() { + let events = Arc::new(Mutex::new(Vec::new())); + let pending = Tool::new_async("Pending", |_, _| std::future::pending()).input(empty()); + let forever = HostFunction::new_async("forever", 0, |_| std::future::pending()); + let rt = Runtime::new() + .with_tool("host.call", pending) + .extension(Extension::new("slow").function("forever", forever)) + .hooks(observe(&events)); + assert_eq!( + run(&rt, r#"tools.host.call({}); forever(); return "done""#) + .result + .unwrap(), + json!("done") + ); + assert_eq!( + *events.lock().unwrap(), + [ + r#"tool.before {"name":"host.call","input":{}}"#, + r#"extension.before {"extension":"slow","name":"forever","args":[]}"#, + "tool.after host.call interrupted", + "extension.after forever interrupted", + ] + ); +} + +#[test] +fn the_timeout_interrupts_calls_in_flight() { + let events = Arc::new(Mutex::new(Vec::new())); + let pending = Tool::new_async("Pending", |_, _| std::future::pending()).input(empty()); + let rt = Runtime::new() + .with_tool("host.call", pending) + .limits(Limits { + timeout_ms: Some(30), + ..Limits::default() + }) + .hooks(observe(&events)); + let started = Instant::now(); + let d = run(&rt, "return await tools.host.call({})") + .result + .unwrap_err(); + assert_eq!(d.kind, DiagnosticKind::TimeoutExceeded); + assert!(started.elapsed() < Duration::from_secs(2)); + assert_eq!( + *events.lock().unwrap(), + [ + r#"tool.before {"name":"host.call","input":{}}"#, + "tool.after host.call interrupted" + ] + ); +} + +#[test] +fn an_async_before_hook_can_wait() { + let rt = Runtime::new() + .with_tool( + "lookup", + Tool::new("Look up", |_, _| Ok(json!("ok"))) + .input(empty()) + .output(any()), + ) + .hooks(Hooks::new().tool_before_async(|_| async { + later(20, ()).await; + Ok(()) + })); + assert_eq!( + run( + &rt, + "return [await tools.lookup(), search({}).items.length]" + ) + .result + .unwrap(), + json!(["ok", 1]) + ); +} + +/// A minimal executor, standing in for whatever the host runs futures on. +fn drive(future: F) -> F::Output { + struct Flag(std::sync::atomic::AtomicBool, std::thread::Thread); + impl std::task::Wake for Flag { + fn wake(self: Arc) { + self.0.store(true, Ordering::SeqCst); + self.1.unpark(); + } + } + let flag = Arc::new(Flag(false.into(), std::thread::current())); + let waker = Waker::from(flag.clone()); + let mut cx = Context::from_waker(&waker); + let mut future = std::pin::pin!(future); + loop { + if let Poll::Ready(v) = future.as_mut().poll(&mut cx) { + return v; + } + while !flag.0.swap(false, Ordering::SeqCst) { + std::thread::park(); + } + } +} + +#[test] +fn execute_async_runs_on_any_executor() { + let rt = Runtime::new() + .with_tool( + "slow", + Tool::new_async("Slow", |_, _| async { Ok(later(10, json!(2)).await) }).output(any()), + ) + .limits(Limits { + timeout_ms: Some(5_000), + ..Limits::default() + }); + let outcome = + drive(rt.execute_async("return (await tools.slow()) * 21", &serde_json::Map::new())); + assert_eq!(outcome.result.unwrap(), json!(42)); + let timeout = Runtime::new() + .with_tool( + "never", + Tool::new_async("Never", |_, _| std::future::pending()), + ) + .limits(Limits { + timeout_ms: Some(20), + ..Limits::default() + }); + let outcome = + drive(timeout.execute_async("return await tools.never()", &serde_json::Map::new())); + assert_eq!( + outcome.result.unwrap_err().kind, + DiagnosticKind::TimeoutExceeded + ); +} + +#[test] +fn dropping_a_run_cancels_its_calls() { + let events = Arc::new(Mutex::new(Vec::new())); + let rt = Runtime::new() + .with_tool( + "never", + Tool::new_async("Never", |_, _| std::future::pending()).input(empty()), + ) + .hooks(observe(&events)); + let bindings = serde_json::Map::new(); + let mut run = Box::pin(rt.execute_async("return await tools.never({})", &bindings)); + let waker = Waker::noop(); + assert!( + run.as_mut() + .poll(&mut Context::from_waker(waker)) + .is_pending() + ); + drop(run); + assert_eq!( + *events.lock().unwrap(), + [ + r#"tool.before {"name":"never","input":{}}"#, + "tool.after never interrupted" + ] + ); +} diff --git a/packages/codemode-rust/crates/psychoscript/tests/tools.rs b/packages/codemode-rust/crates/psychoscript/tests/tools.rs new file mode 100644 index 000000000000..654c2077b014 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/tests/tools.rs @@ -0,0 +1,496 @@ +//! Tools, schemas, paths and search, mirroring the reference's `codemode.test.ts` and `tool-paths.test.ts`. + +use std::sync::{Arc, Mutex}; + +use psychoscript::{DiagnosticKind, Json, Limits, Outcome, Runtime, Schema, Tool, ToolError}; +use serde_json::json; + +fn run(rt: &Runtime, code: &str) -> Outcome { + rt.execute(code, &serde_json::Map::new()) +} + +fn value(rt: &Runtime, code: &str) -> Json { + match run(rt, code).result { + Ok(v) => v, + Err(d) => panic!("expected success, got {:?}: {}", d.kind, d.message), + } +} + +fn failure(rt: &Runtime, code: &str) -> psychoscript::Diagnostic { + match run(rt, code).result { + Ok(v) => panic!("expected failure, got {v}"), + Err(d) => d, + } +} + +fn empty() -> Schema { + Schema::validated(json!({ "type": "object", "properties": {}, "additionalProperties": false })) +} + +fn echo(description: &str, result: &str) -> Tool { + let result = result.to_owned(); + Tool::new(description, move |_, _| Ok(Json::String(result.clone()))) + .input(empty()) + .output(Schema::validated(json!({ "type": "string" }))) +} + +fn struct_of(fields: Json, required: &[&str]) -> Schema { + Schema::validated(json!({ + "type": "object", + "properties": fields, + "required": required, + "additionalProperties": false + })) +} + +#[test] +fn explicit_tool_failures_are_preserved() { + let rt = Runtime::new().with_tool( + "host.call", + Tool::new("Fail", |_, _| { + Err(ToolError::new("Authorized request was refused")) + }) + .input(empty()), + ); + let d = failure(&rt, "return await tools.host.call({})"); + assert_eq!(d.kind, DiagnosticKind::ToolFailure); + assert_eq!(d.message, "Authorized request was refused"); +} + +#[test] +fn invalid_output_is_reported_with_the_schema_error() { + let rt = Runtime::new().with_tool( + "host.call", + Tool::new("Return invalid output", |_, _| Ok(json!({ "value": 1 }))) + .input(empty()) + .output(struct_of( + json!({ "value": { "type": "string" } }), + &["value"], + )), + ); + let d = failure(&rt, "return await tools.host.call({})"); + assert_eq!(d.kind, DiagnosticKind::InvalidToolOutput); + assert_eq!( + d.message, + "Invalid output from tool 'host.call': SchemaError(Expected string\n at [\"value\"])" + ); +} + +#[test] +fn caught_tool_failures_are_error_values() { + let rt = Runtime::new().with_tool( + "host.call", + Tool::new("Refuse", |_, _| Err("Refused".into())).input(empty()), + ); + assert_eq!( + value( + &rt, + r#"try { await tools.host.call({}); return "no" } catch (e) { return { isError: e instanceof Error, message: e.message } }"# + ), + json!({ "isError": true, "message": "Refused" }) + ); +} + +#[test] +fn render_only_input_passes_through_and_omitted_output_is_void() { + let observed = Arc::new(Mutex::new(Vec::new())); + let seen = observed.clone(); + let call = Tool::new("Call an adapter-described tool", move |input, _| { + seen.lock().unwrap().push(input.clone()); + Ok(json!({ "echoed": input })) + }) + .input(Schema::render_only(json!({ + "type": "object", + "properties": { "id": { "type": "string" }, "count": { "type": "number" } }, + "required": ["id"] + }))); + let rt = Runtime::new().with_tool("adapter.call", call); + assert_eq!( + rt.catalog()[0].signature, + "tools.adapter.call({\n id: string,\n count?: number,\n}): Promise" + ); + assert_eq!( + value(&rt, "return await tools.adapter.call({ id: 42 })"), + Json::Null + ); + assert_eq!(*observed.lock().unwrap(), vec![json!({ "id": 42 })]); +} + +#[test] +fn arguments_follow_json_serialization_and_drop_undefined() { + let observed = Arc::new(Mutex::new(Vec::new())); + let seen = observed.clone(); + let rt = Runtime::new().with_tool( + "things.find", + Tool::new("Find things", move |input, _| { + seen.lock().unwrap().push(input); + Ok(json!("ok")) + }) + .input(Schema::validated(json!({ + "type": "object", + "properties": { "query": { "type": "string" }, "limit": { "type": "number" } }, + "additionalProperties": false + }))), + ); + value( + &rt, + "return await tools.things.find({ query: undefined, limit: 5 })", + ); + // NaN crosses as `null`, which a number field refuses, as Effect's `Schema.Number` does. + let d = failure(&rt, "return await tools.things.find({ limit: 0 / 0 })"); + assert_eq!(d.kind, DiagnosticKind::InvalidToolInput); + assert_eq!(*observed.lock().unwrap(), vec![json!({ "limit": 5 })]); +} + +#[test] +fn validated_input_drops_excess_properties_before_the_tool_sees_it() { + let observed = Arc::new(Mutex::new(Vec::new())); + let seen = observed.clone(); + let rt = Runtime::new().with_tool( + "echo", + Tool::new("Echo", move |input, _| { + seen.lock().unwrap().push(input.clone()); + Ok(input) + }) + .output(Schema::render_only(json!({}))) + .input(struct_of( + json!({ "text": { "type": "string" } }), + &["text"], + )), + ); + assert_eq!( + value(&rt, r#"return await tools.echo({ text: "a", extra: 1 })"#), + json!({ "text": "a" }) + ); + let d = failure(&rt, r#"return await tools.echo({ message: "hello" })"#); + assert_eq!(d.kind, DiagnosticKind::InvalidToolInput); + assert_eq!( + d.suggestions, + ["The signature may have changed. Use search to get the current signature."] + ); + let d = failure(&rt, "return await tools.echo({}, {})"); + assert_eq!(d.kind, DiagnosticKind::InvalidToolInput); + assert!(d.suggestions.is_empty()); + assert_eq!(observed.lock().unwrap().len(), 1); +} + +#[test] +fn a_freeform_tool_takes_its_string_directly_and_still_accepts_the_object() { + let input = struct_of( + json!({ "url": { "type": "string", "description": "Page URL" } }), + &["url"], + ); + let fetch = |freeform: bool| { + let t = Tool::new("Fetch a page", |input, _| Ok(input["url"].clone())) + .input(input.clone()) + .output(Schema::validated(json!({ "type": "string" }))); + if freeform { t.freeform() } else { t } + }; + let rt = Runtime::new() + .with_tool("fetchPage", fetch(true)) + .with_tool("plain", fetch(false)); + let signatures: Vec = rt.catalog().into_iter().map(|t| t.signature).collect(); + assert_eq!( + signatures, + [ + "tools.fetchPage(/** Page URL */ url: string): Promise", + "tools.plain({\n /** Page URL */\n url: string,\n}): Promise" + ] + ); + assert_eq!( + value( + &rt, + r#"return [await tools.fetchPage("a"), await tools.fetchPage({ url: "b" })]"# + ), + json!(["a", "b"]) + ); + assert!(run(&rt, r#"return await tools.plain("a")"#).result.is_err()); +} + +#[test] +fn catalogs_are_sorted_whatever_the_insertion_order() { + let make = |order: &[&str]| { + order + .iter() + .fold(Runtime::new(), |rt, p| rt.with_tool(p, echo(p, p))) + .catalog() + }; + let first = make(&["zeta.zeta", "zeta.alpha", "alpha.zeta", "alpha.alpha"]); + let second = make(&["alpha.alpha", "alpha.zeta", "zeta.alpha", "zeta.zeta"]); + assert_eq!(first, second); + let paths: Vec = first.into_iter().map(|t| t.path).collect(); + assert_eq!( + paths, + ["alpha.alpha", "alpha.zeta", "zeta.alpha", "zeta.zeta"] + ); +} + +#[test] +fn dotted_names_nest_and_bracket_access_spells_the_same_path() { + let rt = Runtime::new().with_tool("api.issues.list", echo("List issues", "listed")); + assert_eq!(rt.catalog()[0].path, "api.issues.list"); + assert_eq!( + value(&rt, "return await tools.api.issues.list({})"), + json!("listed") + ); + assert_eq!( + value(&rt, r#"return await tools.api["issues"].list({})"#), + json!("listed") + ); + assert_eq!( + value( + &rt, + "return [Object.keys(tools.api), Object.keys(tools.api.issues)]" + ), + json!([["issues"], ["list"]]) + ); +} + +#[test] +fn a_path_can_hold_a_tool_and_child_tools() { + let rt = Runtime::new() + .with_tool("issues", echo("All issues", "all")) + .with_tool("issues.list", echo("List issues", "list")); + assert_eq!(value(&rt, "return await tools.issues({})"), json!("all")); + assert_eq!( + value(&rt, "return await tools.issues.list({})"), + json!("list") + ); + assert_eq!( + value(&rt, "return Object.keys(tools.issues)"), + json!(["list"]) + ); + let d = failure(&rt, "return await tools.issues.missing({})"); + assert_eq!(d.kind, DiagnosticKind::UnknownTool); + assert!(d.message.contains("Unknown tool 'issues.missing'")); + assert_eq!(d.suggestions, ["Use search to find available tools."]); + assert_eq!( + failure(&rt, r#"return await tools.issues["get-list"]({})"#).message, + "Unknown tool 'issues.get-list'. Did you mean tools.issues.list?" + ); +} + +#[test] +fn calling_a_namespace_names_a_few_tools_and_counts_the_rest() { + let rt = ["archive", "create", "get", "issues", "list"] + .iter() + .fold(Runtime::new(), |rt, n| { + rt.with_tool(&format!("issues.{n}"), echo(&format!("Issue {n}"), n)) + }); + let d = failure(&rt, "return await tools.issues({})"); + assert_eq!( + d.message, + "Tool 'issues' is not callable, it is a namespace. Did you mean tools.issues.issues, tools.issues.archive, or tools.issues.create?" + ); + assert_eq!( + d.suggestions, + [r#"2 more under 'issues'. Use search({ namespace: "issues" }) to list them."#] + ); +} + +#[test] +fn tools_may_use_blocked_member_names() { + let rt = Runtime::new() + .with_tool("prototype", echo("Prototype tool", "proto")) + .with_tool("issues.constructor", echo("Constructor tool", "ctor")) + .with_tool("nested.__proto__", echo("Proto tool", "dunder")); + let paths: Vec = rt.catalog().into_iter().map(|t| t.path).collect(); + assert_eq!( + paths, + ["issues.constructor", "nested.__proto__", "prototype"] + ); + assert_eq!( + value(&rt, "return await tools.prototype({})"), + json!("proto") + ); + assert_eq!( + value(&rt, "return await tools.issues.constructor({})"), + json!("ctor") + ); + assert_eq!( + value(&rt, "return await tools.nested.__proto__({})"), + json!("dunder") + ); +} + +#[test] +fn empty_segments_are_refused() { + for name in ["", "a..b", "trail.", ".lead"] { + let err = Runtime::new() + .try_with_tool(name, echo("Bad", "bad")) + .err() + .unwrap(); + assert!(err.0.contains("empty segment"), "{name}"); + } +} + +#[test] +fn the_last_tool_for_a_canonical_path_wins() { + let rt = Runtime::new() + .with_tool("issues.list", echo("First", "first")) + .with_tool("issues.list", echo("Second", "second")) + .with_tool("issues.get", echo("Get issue", "got")); + assert_eq!( + value(&rt, "return await tools.issues.list({})"), + json!("second") + ); + assert_eq!(rt.catalog().len(), 2); + assert_eq!(rt.catalog()[1].description, "Second"); +} + +#[test] +fn a_proto_key_never_reaches_tool_code() { + let rt = Runtime::new().with_tool( + "inspect", + Tool::new("Inspect", |input, _| Ok(input)).output(Schema::render_only(json!({}))), + ); + assert_eq!( + value( + &rt, + "return await tools.inspect({ v: { __proto__: { polluted: true }, a: 1 } })" + ), + json!({ "v": { "a": 1 } }) + ); +} + +#[test] +fn search_is_a_counted_tool_call_and_is_observed() { + let observed = Arc::new(Mutex::new(Vec::new())); + let seen = observed.clone(); + let rt = Runtime::new() + .with_tool("orders.lookup", echo("Look up an order", "o")) + .limits(Limits { + max_tool_calls: Some(1), + ..Limits::default() + }) + .hooks(psychoscript::Hooks::new().tool_before(move |call| { + seen.lock() + .unwrap() + .push((call.name.clone(), call.input.clone())); + Ok(()) + })); + let outcome = run(&rt, "search({}); return search({})"); + assert_eq!( + outcome.result.unwrap_err().kind, + DiagnosticKind::ToolCallLimitExceeded + ); + assert_eq!( + *observed.lock().unwrap(), + vec![("search".to_owned(), json!({}))] + ); + assert_eq!(outcome.tool_calls.len(), 1); +} + +#[test] +fn search_is_an_opaque_shadowable_global() { + let rt = Runtime::new().with_tool("api.list", echo("List things", "listed")); + assert_eq!(value(&rt, "return typeof search"), json!("function")); + assert_eq!( + value(&rt, r#"const search = () => "local"; return search()"#), + json!("local") + ); + assert_eq!(value(&rt, "return { search }"), json!({})); +} + +#[test] +fn search_results_can_be_read_awaited_or_chained() { + let rt = Runtime::new().with_tool("api.list", echo("List things", "listed")); + assert_eq!( + value( + &rt, + r#"const query = { query: "list" } + return [ + search(query).items[0].path, + (await search(query)).items[0].path, + await search(query).then((result) => result.items[0].path), + (await search(query).catch(() => "unused")).items[0].path, + (await search(query).finally(() => "ignored")).items[0].path, + (await Promise.all([search(query), search({})])).map((result) => result.items.length), + (await tools.search("list")).items[0].path, + ]"# + ), + json!([ + "tools.api.list", + "tools.api.list", + "tools.api.list", + "tools.api.list", + "tools.api.list", + [1, 1], + "tools.api.list" + ]) + ); + assert_eq!( + value( + &rt, + r#"const result = search({ query: "list" }) + const forIn = [] + for (const key in result) forIn.push(key) + return [Object.keys(result), Object.keys({ ...result }), forIn, JSON.parse(JSON.stringify(result)).remaining]"# + ), + json!([ + ["items", "remaining", "next"], + ["items", "remaining", "next"], + ["items", "remaining", "next"], + 0 + ]) + ); + assert!( + value( + &rt, + r#"try { await search({ limit: "ten" }) } catch (error) { return error.message }"# + ) + .as_str() + .unwrap() + .contains("Invalid input for tool 'search'") + ); +} + +#[test] +fn a_registered_root_search_tool_takes_precedence() { + let rt = Runtime::new().with_tool("search", echo("Custom search", "custom")); + assert_eq!(value(&rt, "return await tools.search({})"), json!("custom")); +} + +#[test] +fn tool_context_carries_the_run_key() { + let rt = Runtime::new().with_tool( + "key", + Tool::new("Key", |_, ctx| Ok(Json::String(ctx.key()))) + .output(Schema::render_only(json!({}))), + ); + let program = rt.program( + "return [await tools.key(), await tools.key()]", + &serde_json::Map::new(), + Some("run-1"), + ); + assert_eq!(program.run().result.unwrap(), json!(["run-1:0", "run-1:1"])); + let generated = value(&rt, "return await tools.key()"); + assert_eq!( + generated.as_str().unwrap().len(), + "00000000-0000-0000-0000-000000000000:0".len() + ); +} + +#[test] +fn reruns_start_from_a_clean_slate() { + let rt = Runtime::new() + .with_tool( + "host.echo", + Tool::new("echo", |_, _| Ok(json!(1))) + .input(empty()) + .output(Schema::validated(json!({ "type": "number" }))), + ) + .limits(Limits { + max_tool_calls: Some(1), + ..Limits::default() + }); + for _ in 0..2 { + let outcome = run( + &rt, + r#"console.log("hi"); return await tools.host.echo({})"#, + ); + assert_eq!(outcome.result.unwrap(), json!(1)); + assert_eq!(outcome.logs, ["hi"]); + assert_eq!(outcome.tool_calls.len(), 1); + } +} From 9f8c722ceccfc5ea2fed1746fd605cf37815d54a Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:02:32 +0000 Subject: [PATCH 011/100] chore(codemode): run the Rust checks in check-test's unit job --- .github/workflows/check-test.yml | 91 ++++++++++++++++++++ .github/workflows/codemode-rust.yml | 125 ---------------------------- packages/codemode-rust/AGENTS.md | 1 + 3 files changed, 92 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/codemode-rust.yml diff --git a/.github/workflows/check-test.yml b/.github/workflows/check-test.yml index 8b2751cb2eec..5c60dc9fc750 100644 --- a/.github/workflows/check-test.yml +++ b/.github/workflows/check-test.yml @@ -97,6 +97,23 @@ jobs: # Pull requests diff against the merge's first parent; pushes diff against the previous dev head. fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + # The Rust port of codemode is checked in this job, on Linux, only when it or its TypeScript reference changed. + # Runs without a base to diff against (manual runs, the release gate, a new branch) check it always. + - name: Decide whether the codemode Rust checks run + id: codemode-rust + if: runner.os == 'Linux' + run: | + paths=(packages/codemode packages/codemode-rust .github/workflows/check-test.yml) + if [ "$AFFECTED" != "true" ] || ! git cat-file -e "${TURBO_SCM_BASE}^{commit}" 2>/dev/null; then + run=true + elif git diff --quiet "$TURBO_SCM_BASE" "$TURBO_SCM_HEAD" -- "${paths[@]}"; then + run=false + else + run=true + fi + echo "run=$run" >> "$GITHUB_OUTPUT" + echo "codemode Rust checks: $run" + - name: Setup Node uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: @@ -155,6 +172,80 @@ jobs: working-directory: packages/protocol run: bun run check:generated + # The toolchain, profile and components come from packages/codemode-rust/rust-toolchain.toml. + - name: Install Rust for codemode + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + working-directory: packages/codemode-rust + run: rustup toolchain install --no-self-update + + # One cache for the debug and release builds below. + - name: Cache codemode Rust builds + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 + with: + shared-key: codemode-rust + key: ${{ hashFiles('packages/codemode-rust/rust-toolchain.toml') }} + workspaces: packages/codemode-rust -> target + + - name: Check codemode Rust formatting, Clippy and tests + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + timeout-minutes: 15 + working-directory: packages/codemode-rust + run: | + cargo fmt --check + cargo clippy --locked --workspace --all-targets -- -D warnings + # Includes bench/tests/conformance.rs, which checks every conformance case against the reference outcome. + cargo test --locked --workspace + + # A change to the reference fails here until the Rust side is updated and the expectations regenerated. + - name: Check codemode Rust conformance expectations match the reference + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + working-directory: packages/codemode-rust + run: | + bun conformance/generate.ts + git status --porcelain -- conformance + git diff --exit-code -- conformance + test -z "$(git status --porcelain -- conformance)" + + - name: Read the pinned test262 revision + id: test262 + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + run: | + revision=$(jq -r .revision packages/codemode/test/test262/manifest.json) + echo "revision=$revision" >> "$GITHUB_OUTPUT" + echo "checkout=$HOME/.cache/test262-$revision" >> "$GITHUB_OUTPUT" + + - name: Cache the test262 checkout + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: ${{ steps.test262.outputs.checkout }} + key: test262-${{ steps.test262.outputs.revision }} + + # Parity both ways, against test262/rust-skipped.txt and test262/reference-gaps.txt; see test262/README.md. + - name: Check codemode Rust test262 parity + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + timeout-minutes: 10 + working-directory: packages/codemode-rust + env: + TEST262_CHECKOUT: ${{ steps.test262.outputs.checkout }} + run: bash test262/run.sh + + # Shared runners are too noisy for a performance gate; the numbers go to the job summary only. + - name: Benchmark codemode Rust against the reference (informational) + if: runner.os == 'Linux' && steps.codemode-rust.outputs.run == 'true' + continue-on-error: true + timeout-minutes: 10 + working-directory: packages/codemode-rust + env: + ITERATIONS: "5" + COLD_RUNS: "5" + PLUGIN_RUNS: "2000" + run: | + [ -x /usr/bin/time ] || (sudo apt-get update && sudo apt-get install -y time) + bash bench/compare.sh + cat bench/RESULTS.md >> "$GITHUB_STEP_SUMMARY" + build: name: build (${{ matrix.settings.name }}) # Compiling the CLI and smoke-testing its service lifecycle is part of the full tier. diff --git a/.github/workflows/codemode-rust.yml b/.github/workflows/codemode-rust.yml deleted file mode 100644 index fc8b296f116c..000000000000 --- a/.github/workflows/codemode-rust.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: Codemode Rust - -on: - pull_request: - paths: - - packages/codemode-rust/** - - packages/codemode/** - - .github/workflows/codemode-rust.yml - push: - branches: [dev] - paths: - - packages/codemode-rust/** - - packages/codemode/** - - .github/workflows/codemode-rust.yml - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -defaults: - run: - working-directory: packages/codemode-rust - -env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: "0" - -jobs: - check: - name: Format, Clippy and tests - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 20 - steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - # The toolchain, profile and components come from packages/codemode-rust/rust-toolchain.toml. - - name: Install Rust - run: rustup toolchain install --no-self-update - - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - with: - shared-key: codemode-rust-dev - workspaces: packages/codemode-rust -> target - - run: cargo fmt --check - - run: cargo clippy --locked --workspace --all-targets -- -D warnings - # Includes bench/tests/conformance.rs, which checks every conformance case against the reference outcome. - - run: cargo test --locked --workspace - - conformance-fresh: - name: Conformance expectations match the reference - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 10 - steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - - uses: ./.github/actions/setup-bun - # A change to the reference fails here until the Rust side is updated and the expectations regenerated. - - name: Regenerate every expectation from ../codemode - run: bun conformance/generate.ts - - name: Check nothing changed - run: | - git status --porcelain -- conformance - git diff --exit-code -- conformance - test -z "$(git status --porcelain -- conformance)" - - test262: - name: test262 parity - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 20 - steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - # The reference runs the listed reference gaps, so its dependencies are installed too. - - uses: ./.github/actions/setup-bun - - name: Install Rust - run: rustup toolchain install --no-self-update - - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - with: - shared-key: codemode-rust-release - workspaces: packages/codemode-rust -> target - - name: Read the pinned test262 revision - id: test262 - run: | - revision=$(jq -r .revision ../codemode/test/test262/manifest.json) - echo "revision=$revision" >> "$GITHUB_OUTPUT" - echo "checkout=$HOME/.cache/test262-$revision" >> "$GITHUB_OUTPUT" - - name: Cache the test262 checkout - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 - with: - path: ${{ steps.test262.outputs.checkout }} - key: test262-${{ steps.test262.outputs.revision }} - # Parity both ways. Fails when a file fails that test262/rust-skipped.txt does not list, or a listed file - # passes; and when a file the reference skips passes but test262/reference-gaps.txt does not list it, or a - # listed file fails here, leaves the reference's skipped.txt, or passes in the reference. - - name: Run test262 against rust-skipped.txt and reference-gaps.txt - env: - TEST262_CHECKOUT: ${{ steps.test262.outputs.checkout }} - run: bash test262/run.sh - - bench: - name: Benchmarks (informational) - runs-on: blacksmith-4vcpu-ubuntu-2404 - timeout-minutes: 20 - # Shared runners are too noisy for a performance gate; the numbers go to the job summary only. - continue-on-error: true - steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - - uses: ./.github/actions/setup-bun - - name: Install Rust - run: rustup toolchain install --no-self-update - - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - with: - shared-key: codemode-rust-release - workspaces: packages/codemode-rust -> target - - name: Install GNU time - run: "[ -x /usr/bin/time ] || (sudo apt-get update && sudo apt-get install -y time)" - - run: cargo build --release --locked -p psychoscript-bench --bin psychoscript-bench --example embed - - name: Compare with the reference - env: - ITERATIONS: "5" - COLD_RUNS: "5" - PLUGIN_RUNS: "2000" - run: bash bench/compare.sh - - name: Write the results to the job summary - run: cat bench/RESULTS.md >> "$GITHUB_STEP_SUMMARY" diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index 30c606f5cd10..1613dc351854 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -29,4 +29,5 @@ Out of scope: classes (rejected, like the reference), `export`/modules/`import`, - test262 parity runs both ways: `bash test262/run.sh` must pass, and `test262/rust-skipped.txt` and `test262/reference-gaps.txt` may only shrink. - `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` must pass. - Benchmark claims need the command, machine and numbers in `bench/RESULTS.md`. +- CI: the `unit` job of `.github/workflows/check-test.yml` runs these checks, conformance freshness, test262 and the informational bench on Linux, whenever `packages/codemode`, `packages/codemode-rust` or that workflow changed. - Nothing in the repo mentions internal tooling, private chats, home paths, hostnames or secrets. From f0d11200ae75e8e6df25e65eedc8abc995075a78 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:11:25 +0000 Subject: [PATCH 012/100] perf(codemode): compile tool schemas once and keep host calls off the copy path Schema::validated compiles its document into a validator once, so checking a value does no keyword lookups and builds a path only when it fails. A failed host call is boxed, so a successful one stays small in the inbox; synchronous tools share one context; a program compiles when it is made and borrows its source; the run id is made on first use. The benchmark tools now declare the reference's schemas, so tool fan-out also validates each input and output, as the reference does. --- packages/codemode-rust/bench/src/main.rs | 35 ++- .../crates/psychoscript/src/host.rs | 131 +++++---- .../crates/psychoscript/src/lib.rs | 8 +- .../crates/psychoscript/src/program.rs | 58 ++-- .../crates/psychoscript/src/run.rs | 18 +- .../crates/psychoscript/src/schema.rs | 276 ++++++++++-------- .../crates/psychoscript/src/test262.rs | 6 +- .../crates/psychoscript/src/vm.rs | 4 +- 8 files changed, 302 insertions(+), 234 deletions(-) diff --git a/packages/codemode-rust/bench/src/main.rs b/packages/codemode-rust/bench/src/main.rs index e0cc585b5e99..5ca400ae5ddc 100644 --- a/packages/codemode-rust/bench/src/main.rs +++ b/packages/codemode-rust/bench/src/main.rs @@ -9,7 +9,7 @@ use std::path::PathBuf; use std::time::Instant; -use psychoscript::{Json, Runtime}; +use psychoscript::{Json, Runtime, Schema, Tool}; use serde_json::json; /// Case files and reference names, in the reference order. @@ -30,13 +30,34 @@ const CASES: [(&str, &str); 9] = [ /// `{ branch: string, dirty: boolean }` out); these Rust tools do not validate yet. Once `Runtime` takes tool schemas, /// register both with the equivalent validating schemas here, so each side pays for validation. fn tools(runtime: Runtime) -> Runtime { + // The reference's Effect Schemas, as the JSON Schema documents they render to. runtime - .tool("echo", |input| { - Ok(input.get("id").cloned().unwrap_or(Json::Null)) - }) - .tool("git.status", |_| { - Ok(json!({ "branch": "main", "dirty": true })) - }) + .with_tool( + "echo", + Tool::new("Echo an id", |input, _| Ok(input["id"].clone())) + .input(Schema::validated(json!({ + "type": "object", + "properties": { "id": { "type": "number" } }, + "required": ["id"], + "additionalProperties": false + }))) + .output(Schema::validated(json!({ "type": "number" }))), + ) + .with_tool( + "git.status", + Tool::new("Working tree status", |_, _| { + Ok(json!({ "branch": "main", "dirty": true })) + }) + .input(Schema::validated( + json!({ "type": "object", "properties": {}, "additionalProperties": false }), + )) + .output(Schema::validated(json!({ + "type": "object", + "properties": { "branch": { "type": "string" }, "dirty": { "type": "boolean" } }, + "required": ["branch", "dirty"], + "additionalProperties": false + }))), + ) } fn main() { diff --git a/packages/codemode-rust/crates/psychoscript/src/host.rs b/packages/codemode-rust/crates/psychoscript/src/host.rs index 480d9ab956df..cee675dd3c27 100644 --- a/packages/codemode-rust/crates/psychoscript/src/host.rs +++ b/packages/codemode-rust/crates/psychoscript/src/host.rs @@ -95,11 +95,18 @@ pub struct Failed { impl Settlement { fn failure(kind: DiagnosticKind, message: String) -> Self { - Settlement::Failure(Box::new(Failed { + Settlement::Failure(Failed::new(kind, message)) + } +} + +impl Failed { + #[cold] + fn new(kind: DiagnosticKind, message: String) -> Box { + Box::new(Failed { kind, message, suggestions: Vec::new(), - })) + }) } } @@ -115,10 +122,11 @@ pub struct FnEntry { /// The host state of one run. pub struct RunHost<'rt> { pub setup: &'rt Setup, - pub run_id: Arc, + /// Names the run's host calls; made on first use when the host gave none. + run_id: Option>, next_call: u64, /// The context handed to synchronous tools, its call id set for each call. - ctx: ToolContext, + ctx: Option, pub tasks: Tasks<'rt, Settlement>, functions: Vec, /// Suggestions attached to failure values, by error object. @@ -129,11 +137,11 @@ pub struct RunHost<'rt> { } impl<'rt> RunHost<'rt> { - pub fn new(setup: &'rt Setup, run_id: String) -> Self { + pub fn new(setup: &'rt Setup, run_id: Option) -> Self { Self { setup, - ctx: ToolContext::new(Arc::from(run_id.as_str()), 0), - run_id: Arc::from(run_id), + ctx: None, + run_id: run_id.map(Arc::from), next_call: 0, tasks: Tasks::default(), functions: Vec::new(), @@ -155,9 +163,25 @@ impl<'rt> RunHost<'rt> { id } + pub fn run_id(&mut self) -> Arc { + self.run_id + .get_or_insert_with(|| Arc::from(crate::run::random_run_id())) + .clone() + } + fn context(&mut self) -> ToolContext { let id = self.next_call(); - ToolContext::new(self.run_id.clone(), id) + ToolContext::new(self.run_id(), id) + } + + /// The shared context for a synchronous call, without a reference count change per call. + fn sync_context(&mut self, call: u64) -> &ToolContext { + if self.ctx.is_none() { + self.ctx = Some(ToolContext::new(self.run_id(), 0)); + } + let ctx = self.ctx.as_mut().expect("context"); + ctx.call = call; + ctx } } @@ -206,22 +230,10 @@ fn native(vm: &mut Vm, name: &str, length: u8, f: crate::vm::NativeFn, data: Val /// `tools.(...args)`: returns a promise at once; the call starts now and settles it later. pub fn call_tool(vm: &mut Vm, path: &str, args: &[Value]) -> Res { let p = vm.new_promise(); - match start_tool(vm, path, args) { - Started::Now(s) => vm.inbox.push_back((p, s)), - Started::Later(future) => { - if let Poll::Ready(s) = vm.host.tasks.spawn(p, future) { - vm.inbox.push_back((p, s)); - } - } - } + start_tool(vm, p, path, args); Ok(Value::Obj(p)) } -enum Started<'rt> { - Now(Settlement), - Later(BoxFuture<'rt, Settlement>), -} - /// Everything about a call that happens before its tool runs: the reference's `decode` and `admit`. struct Admitted<'rt> { tool: &'rt Tool, @@ -229,42 +241,54 @@ struct Admitted<'rt> { call: u64, } -fn start_tool<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Started<'rt> { +/// Starts a call whose promise is `p`. A call that ends at once queues its outcome; the rest become tasks. +fn start_tool<'rt>(vm: &mut Vm<'rt>, p: Id, path: &str, args: &[Value]) { let setup = vm.host.setup; // Models often write `tools.search(...)` for the bare `search(...)`; honor it unless a tool owns that path. if path == "search" && !setup.registry.exists("search") { - return match run_search(vm, args) { - Ok(json) => Started::Now(Settlement::Json(json)), - Err(s) => Started::Now(s), + let s = match run_search(vm, args) { + Ok(json) => Settlement::Json(json), + Err(f) => Settlement::Failure(f), }; + vm.inbox.push_back((p, s)); + return; } let admitted = match admit(vm, path, args) { Ok(a) => a, - Err(s) => return Started::Now(s), + Err(f) => { + vm.inbox.push_back((p, Settlement::Failure(f))); + return; + } }; let hooks = &setup.hooks; if hooks.tool_before.is_none() && hooks.tool_after.is_none() && let Execute::Sync(f) = &admitted.tool.execute { - vm.host.ctx.call = admitted.call; - let raw = f(admitted.input, &vm.host.ctx); - return Started::Now(finish(path, admitted.tool, raw)); + let raw = f(admitted.input, vm.host.sync_context(admitted.call)); + let s = finish(path, admitted.tool, raw); + vm.inbox.push_back((p, s)); + return; + } + let ctx = ToolContext::new(vm.host.run_id(), admitted.call); + let future = Box::pin(hooked_tool(hooks, path.to_owned(), admitted, ctx)); + if let Poll::Ready(s) = vm.host.tasks.spawn(p, future) { + vm.inbox.push_back((p, s)); } - let ctx = ToolContext::new(vm.host.run_id.clone(), admitted.call); - Started::Later(Box::pin(hooked_tool(hooks, path.to_owned(), admitted, ctx))) } -fn admit<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Result, Settlement> { +#[inline] +fn admit<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Result, Box> { let setup = vm.host.setup; let Some(tool) = setup.registry.get(path) else { return Err(unknown_tool(setup, path)); }; let tool: &'rt Tool = tool; - let entry_field = tool - .freeform - .then(|| schema::string_parameter(tool.input.document()).map(|(name, _)| name)) - .flatten(); + let entry_field = if tool.freeform { + schema::string_parameter(tool.input.document()).map(|(name, _)| name) + } else { + None + }; let input = decode(vm, path, &tool.input, entry_field.as_deref(), args, false)?; admit_call(vm, path, &input)?; let call = vm.host.next_call(); @@ -272,6 +296,7 @@ fn admit<'rt>(vm: &mut Vm<'rt>, path: &str, args: &[Value]) -> Result, args: &[Value], search: bool, -) -> Result { +) -> Result> { if args.len() > 1 { - return Err(Settlement::failure( + return Err(Failed::new( DiagnosticKind::InvalidToolInput, format!("Tool '{name}' expects at most one input object."), )); @@ -292,7 +317,7 @@ fn decode( Ok(j) => j, Err(e) => { let msg = vm.error_text(&e); - return Err(Settlement::failure( + return Err(Failed::new( DiagnosticKind::InvalidDataValue, format!("Invalid input for tool '{name}': {msg}"), )); @@ -309,7 +334,7 @@ fn decode( }; schema .validate(input) - .map_err(|e| Settlement::Failure(Box::new(Failed { + .map_err(|e| Box::new(Failed { kind: DiagnosticKind::InvalidToolInput, message: format!("Invalid input for tool '{name}': {e}"), suggestions: vec![if search { @@ -317,15 +342,16 @@ fn decode( } else { "The signature may have changed. Use search to get the current signature.".into() }], - }))) + })) } /// Counts a call against `max_tool_calls` and records it. -fn admit_call(vm: &mut Vm, path: &str, input: &Json) -> Result<(), Settlement> { +#[inline] +fn admit_call(vm: &mut Vm, path: &str, input: &Json) -> Result<(), Box> { if let Some(max) = vm.limits.max_tool_calls && vm.tool_calls.len() as u64 >= max { - return Err(Settlement::failure( + return Err(Failed::new( DiagnosticKind::ToolCallLimitExceeded, format!("Execution exceeded its tool-call limit of {max}."), )); @@ -338,6 +364,7 @@ fn admit_call(vm: &mut Vm, path: &str, input: &Json) -> Result<(), Settlement> { } /// A tool's raw result as the program receives it. +#[inline] fn finish(name: &str, tool: &Tool, raw: Result) -> Settlement { match raw { Err(e) => Settlement::failure(DiagnosticKind::ToolFailure, e.message), @@ -407,7 +434,8 @@ async fn hooked_tool(hooks: &Hooks, name: String, a: Admitted<'_>, ctx: ToolCont s } -fn unknown_tool(setup: &Setup, path: &str) -> Settlement { +#[cold] +fn unknown_tool(setup: &Setup, path: &str) -> Box { let registry = &setup.registry; let entries = registry.entries(); let index = registry.word_index(); @@ -437,11 +465,11 @@ fn unknown_tool(setup: &Setup, path: &str) -> Settlement { ), None => format!("Unknown tool '{path}'."), }; - return Settlement::Failure(Box::new(Failed { + return Box::new(Failed { kind: DiagnosticKind::UnknownTool, message, suggestions: vec!["Use search to find available tools.".into()], - })); + }); } let under = format!("{path}."); let scope: Vec = (0..entries.len()) @@ -480,11 +508,11 @@ fn unknown_tool(setup: &Setup, path: &str) -> Settlement { } else { "Use search to find available tools.".into() }; - Settlement::Failure(Box::new(Failed { + Box::new(Failed { kind: DiagnosticKind::UnknownTool, message, suggestions: vec![suggestion], - })) + }) } /// `Intl.ListFormat("en", { type: "disjunction" })`. @@ -550,13 +578,12 @@ fn search_native(vm: &mut Vm, _this: Value, args: &[Value], _callee: Id) -> Res } Ok(v) } - Err(Settlement::Failure(f)) => Err(failure_value(vm, f.kind, f.message, f.suggestions)), - Err(_) => Ok(Value::Undef), + Err(f) => Err(failure_value(vm, f.kind, f.message, f.suggestions)), } } /// The built-in search, blocking: decode, admit, the hooks, then the ranking. -fn run_search(vm: &mut Vm, args: &[Value]) -> Result { +fn run_search(vm: &mut Vm, args: &[Value]) -> Result> { let setup = vm.host.setup; let args: Vec = match args.first() { Some(Value::Str(s)) => { @@ -583,7 +610,7 @@ fn run_search(vm: &mut Vm, args: &[Value]) -> Result { if let Some(before) = &hooks.tool_before && let Err(e) = block_on(before(&call)) { - return Err(Settlement::failure(DiagnosticKind::ToolFailure, e.message)); + return Err(Failed::new(DiagnosticKind::ToolFailure, e.message)); } let registry = &setup.registry; let result = search::search(registry.entries(), registry.word_index(), &input); diff --git a/packages/codemode-rust/crates/psychoscript/src/lib.rs b/packages/codemode-rust/crates/psychoscript/src/lib.rs index 237a1d195329..300632b5bfd5 100644 --- a/packages/codemode-rust/crates/psychoscript/src/lib.rs +++ b/packages/codemode-rust/crates/psychoscript/src/lib.rs @@ -257,12 +257,12 @@ impl Runtime { } /// A program ready to run once; nothing runs until [`Program::run`] or [`Program::run_async`]. Host calls get the keys `:`; a random run id by default. - pub fn program( - &self, - code: &str, + pub fn program<'a>( + &'a self, + code: &'a str, bindings: &serde_json::Map, run_id: Option<&str>, - ) -> Program<'_> { + ) -> Program<'a> { Program::new(self, code, bindings, run_id) } diff --git a/packages/codemode-rust/crates/psychoscript/src/program.rs b/packages/codemode-rust/crates/psychoscript/src/program.rs index 2e5731c2d9fa..6ff164aa5457 100644 --- a/packages/codemode-rust/crates/psychoscript/src/program.rs +++ b/packages/codemode-rust/crates/psychoscript/src/program.rs @@ -9,45 +9,41 @@ use crate::run; use crate::vm::Vm; use crate::{Json, Outcome, Runtime}; -enum State<'rt> { - Ready { - code: String, - bindings: serde_json::Map, - run_id: String, - }, - Running(Box>), +enum State<'a> { + Running(Box>), + /// It ended before running: the program did not compile. + Failed(Box), Done, } -pub(crate) struct Running<'rt> { - pub vm: Vm<'rt>, - pub code: String, +pub(crate) struct Running<'a> { + pub vm: Vm<'a>, + pub code: &'a str, started: bool, timer_armed: bool, } /// A program ready to run once. Dropping it interrupts the run and cancels every host call in flight. -pub struct Program<'rt> { - rt: &'rt Runtime, - state: State<'rt>, +pub struct Program<'a> { + state: State<'a>, /// How much of the native stack below the point it is driven from the run may use. pub(crate) stack_budget: usize, } -impl<'rt> Program<'rt> { +impl<'a> Program<'a> { + /// Compiles the program and sets up its globals; nothing runs yet. pub(crate) fn new( - rt: &'rt Runtime, - code: &str, + rt: &'a Runtime, + code: &'a str, bindings: &serde_json::Map, run_id: Option<&str>, ) -> Self { + let state = match run::start(rt, code, bindings, run_id.map(str::to_owned)) { + Ok(r) => State::Running(r), + Err(outcome) => State::Failed(outcome), + }; Self { - rt, - state: State::Ready { - code: code.to_owned(), - bindings: bindings.clone(), - run_id: run_id.map_or_else(run::random_run_id, str::to_owned), - }, + state, stack_budget: run::INLINE_STACK_BUDGET, } } @@ -65,19 +61,11 @@ impl<'rt> Program<'rt> { fn advance(&mut self, cx: &mut Context<'_>) -> Poll { let probe = 0u8; - if let State::Ready { .. } = self.state { - let State::Ready { - code, - bindings, - run_id, - } = std::mem::replace(&mut self.state, State::Done) - else { + if let State::Failed(_) = self.state { + let State::Failed(outcome) = std::mem::replace(&mut self.state, State::Done) else { unreachable!() }; - match run::start(self.rt, code, &bindings, run_id) { - Ok(vm) => self.state = State::Running(vm), - Err(outcome) => return Poll::Ready(*outcome), - } + return Poll::Ready(*outcome); } let State::Running(r) = &mut self.state else { return Poll::Pending; @@ -126,8 +114,8 @@ impl<'rt> Program<'rt> { } } -impl<'rt> Running<'rt> { - pub fn new(vm: Vm<'rt>, code: String) -> Self { +impl<'a> Running<'a> { + pub fn new(vm: Vm<'a>, code: &'a str) -> Self { Self { vm, code, diff --git a/packages/codemode-rust/crates/psychoscript/src/run.rs b/packages/codemode-rust/crates/psychoscript/src/run.rs index 230d68184373..48b853f6d838 100644 --- a/packages/codemode-rust/crates/psychoscript/src/run.rs +++ b/packages/codemode-rust/crates/psychoscript/src/run.rs @@ -24,8 +24,7 @@ const THREAD_STACK_BUDGET: usize = 64 << 20; pub fn execute(rt: &Runtime, code: &str, bindings: &serde_json::Map) -> Outcome { if code.len() <= INLINE_SOURCE_BYTES && bracket_depth(code) <= INLINE_BRACKET_DEPTH { - let program = rt.program(code, bindings, None); - let run = AssertUnwindSafe(|| program.run()); + let run = AssertUnwindSafe(|| rt.program(code, bindings, None).run()); return std::panic::catch_unwind(run).unwrap_or_else(|_| internal_error()); } std::thread::scope(|s| { @@ -105,17 +104,17 @@ pub fn random_run_id() -> String { } /// Compiles a program and sets up its run, or the outcome when it does not compile. -pub fn start<'rt>( - rt: &'rt Runtime, - code: String, +pub fn start<'a>( + rt: &'a Runtime, + code: &'a str, bindings: &serde_json::Map, - run_id: String, -) -> Result>, Box> { + run_id: Option, +) -> Result>, Box> { let mut atoms = Strings::new(); - let program = match compiler::compile(&code, &mut atoms) { + let program = match compiler::compile(code, &mut atoms) { Ok(p) => p, Err(e) => { - let location = e.offset.map(|o| line_col(&code, o)); + let location = e.offset.map(|o| line_col(code, o)); let message = format!("{}{}", e.message, suffix(location)); return Err(Box::new(failed(Diagnostic { kind: e.kind, @@ -162,7 +161,6 @@ pub fn finish(r: Running<'_>) -> Outcome { let Running { mut vm, code, .. } = r; vm.host.tasks.clear(); let vm = &mut vm; - let code = code.as_str(); let result = match (vm.fatal.clone(), vm.outcome.take()) { (Some((kind, message)), _) => Err(diagnostic(kind, message)), (None, Some(Ok(v))) => match convert::to_json(vm, &v) { diff --git a/packages/codemode-rust/crates/psychoscript/src/schema.rs b/packages/codemode-rust/crates/psychoscript/src/schema.rs index 0c142370e151..472d1f83d8ae 100644 --- a/packages/codemode-rust/crates/psychoscript/src/schema.rs +++ b/packages/codemode-rust/crates/psychoscript/src/schema.rs @@ -47,12 +47,19 @@ impl Schema { /// `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`, `minLength`, `maxLength`, `minItems`, `maxItems` and /// `uniqueItems`: the constraints an Effect Schema's JSON Schema document is made of. `pattern` and `format` only /// render: the crate has no regular-expression engine, and Effect's `format` is an annotation. + #[inline] pub fn validate(&self, value: Json) -> Result { - let Some(v) = &self.validator else { - return Ok(value); - }; - let mut path = Vec::new(); - check(&v.root, value, v, &mut path, 0) + match &self.validator { + None => Ok(value), + Some(v) => v.validate(value), + } + } +} + +impl Validator { + #[inline(never)] + fn validate(&self, value: Json) -> Result { + check(&self.root, value, self, 0) .map_err(|(message, path)| format!("SchemaError({message}{})", render_path(&path))) } } @@ -754,8 +761,8 @@ struct Node { enumeration: Option>, any_of: Vec, all_of: Vec, - /// Type names, or empty for any type. - types: Vec, + /// Type bits, or 0 for any type. + types: u8, expected: String, minimum: Option, maximum: Option, @@ -768,8 +775,10 @@ struct Node { max_items: Option, unique_items: bool, items: Option>, - properties: Vec<(String, Node)>, - required: Vec, + /// Each property with whether it is required, in schema order. + properties: Vec<(String, Node, bool)>, + /// Required keys that are not among the properties. + required_only: Vec, additional: Additional, } @@ -852,7 +861,7 @@ fn compile(s: &Json, index: &dyn Fn(&str) -> Option, depth: usize) -> Nod if let Some(Json::Array(all)) = field(s, "allOf") { n.all_of = all.iter().map(sub).collect(); } - n.types = types_of(s); + n.types = type_bits(&types_of(s)); n.expected = expected(s); n.minimum = number(s, "minimum"); n.maximum = number(s, "maximum"); @@ -865,15 +874,23 @@ fn compile(s: &Json, index: &dyn Fn(&str) -> Option, depth: usize) -> Nod n.max_items = number(s, "maxItems"); n.unique_items = s.get("uniqueItems") == Some(&Json::Bool(true)); n.items = field(s, "items").map(|i| Box::new(sub(i))); - if let Some(Json::Object(props)) = s.get("properties") { - n.properties = props.iter().map(|(k, v)| (k.clone(), sub(v))).collect(); - } - if let Some(Json::Array(r)) = s.get("required") { - n.required = r + let required: Vec = match s.get("required") { + Some(Json::Array(r)) => r .iter() .filter_map(|v| v.as_str().map(str::to_owned)) + .collect(), + _ => Vec::new(), + }; + if let Some(Json::Object(props)) = s.get("properties") { + n.properties = props + .iter() + .map(|(k, v)| (k.clone(), sub(v), required.contains(k))) .collect(); } + n.required_only = required + .into_iter() + .filter(|r| !n.properties.iter().any(|(k, _, _)| k == r)) + .collect(); n.additional = match s.get("additionalProperties") { Some(Json::Bool(false)) => Additional::Drop, Some(extra @ Json::Object(_)) => Additional::Check(Box::new(sub(extra))), @@ -882,9 +899,10 @@ fn compile(s: &Json, index: &dyn Fn(&str) -> Option, depth: usize) -> Nod n } +/// A failure's message and where it happened, innermost segment first: each level adds its own on the way out, +/// so checking a valid value builds no path at all. type Failure = (String, Vec); -#[derive(Clone)] enum PathPart { Key(String), Index(usize), @@ -895,7 +913,7 @@ fn render_path(path: &[PathPart]) -> String { return String::new(); } let mut out = String::from("\n at "); - for p in path { + for p in path.iter().rev() { match p { PathPart::Key(k) => { out.push('['); @@ -908,22 +926,48 @@ fn render_path(path: &[PathPart]) -> String { out } -fn json_type(v: &Json) -> &'static str { - match v { - Json::Null => "null", - Json::Bool(_) => "boolean", - Json::Number(_) => "number", - Json::String(_) => "string", - Json::Array(_) => "array", - Json::Object(_) => "object", - } +fn at(r: Result, part: impl FnOnce() -> PathPart) -> Result { + r.map_err(|(message, mut path)| { + path.push(part()); + (message, path) + }) } -fn matches_type(t: &str, v: &Json) -> bool { - match t { - "integer" | "number" => v.is_number(), - other => json_type(v) == other, - } +const T_NULL: u8 = 1; +const T_BOOLEAN: u8 = 2; +const T_NUMBER: u8 = 4; +const T_INTEGER: u8 = 8; +const T_STRING: u8 = 16; +const T_ARRAY: u8 = 32; +const T_OBJECT: u8 = 64; + +fn type_bits(types: &[String]) -> u8 { + types + .iter() + .map(|t| match t.as_str() { + "null" => T_NULL, + "boolean" => T_BOOLEAN, + "number" => T_NUMBER, + "integer" => T_INTEGER, + "string" => T_STRING, + "array" => T_ARRAY, + "object" => T_OBJECT, + _ => 0, + }) + .fold(0, |a, b| a | b) +} + +/// Whether a value is of one of the types; an `integer` type accepts any number here and is checked after. +fn type_matches(bits: u8, v: &Json) -> bool { + let bit = match v { + Json::Null => T_NULL, + Json::Bool(_) => T_BOOLEAN, + Json::Number(_) => T_NUMBER | T_INTEGER, + Json::String(_) => T_STRING, + Json::Array(_) => T_ARRAY, + Json::Object(_) => T_OBJECT, + }; + bits & bit != 0 } /// What a schema accepts, for an `Expected ...` message. @@ -958,92 +1002,81 @@ fn expected(s: &Json) -> String { .join(" | ") } -fn fail(message: impl Into, path: &[PathPart]) -> Result { - Err((message.into(), path.to_vec())) +#[cold] +fn fail(message: impl Into) -> Result { + Err((message.into(), Vec::new())) } -fn check( - n: &Node, - mut value: Json, - v: &Validator, - path: &mut Vec, - depth: usize, -) -> Result { +fn check(n: &Node, mut value: Json, v: &Validator, depth: usize) -> Result { if depth > 64 { - return fail("Schema nesting is too deep", path); + return fail("Schema nesting is too deep"); } if n.never { - return fail("Expected never", path); + return fail("Expected never"); } if let Some(r) = n.reference { - value = check(&v.defs[r], value, v, path, depth + 1)?; + value = check(&v.defs[r], value, v, depth + 1)?; } if let Some(c) = &n.constant && !json_eq(c, &value) { - return fail(format!("Expected {}", js_stringify(c)), path); + return fail(format!("Expected {}", js_stringify(c))); } if let Some(values) = &n.enumeration && !values.iter().any(|c| json_eq(c, &value)) { - return fail(format!("Expected {}", n.expected), path); + return fail(format!("Expected {}", n.expected)); } if !n.any_of.is_empty() { - value = check_union(n, value, v, path, depth)?; + value = check_union(n, value, v, depth)?; } for part in &n.all_of { - value = check(part, value, v, path, depth + 1)?; + value = check(part, value, v, depth + 1)?; } - if !n.types.is_empty() { - if !n.types.iter().any(|t| matches_type(t, &value)) { - return fail(format!("Expected {}", n.expected), path); + if n.types != 0 { + if !type_matches(n.types, &value) { + return fail(format!("Expected {}", n.expected)); } - if n.types.iter().all(|t| t == "integer") - && value.as_f64().is_some_and(|x| x.fract() != 0.0) - { - return fail("Expected an integer", path); + if n.types == T_INTEGER && value.as_f64().is_some_and(|x| x.fract() != 0.0) { + return fail("Expected an integer"); } } match &mut value { - Json::Number(x) => check_number(n, x.as_f64().unwrap_or(f64::NAN), path)?, - Json::String(text) => check_length(utf16_len(text), n.min_length, n.max_length, path)?, + Json::Number(x) => check_number(n, x.as_f64().unwrap_or(f64::NAN))?, + Json::String(text) if n.min_length.is_some() || n.max_length.is_some() => { + check_length(utf16_len(text), n.min_length, n.max_length)? + } Json::Array(items) => { - check_length(items.len(), n.min_items, n.max_items, path)?; + check_length(items.len(), n.min_items, n.max_items)?; if n.unique_items { for i in 0..items.len() { if items[..i].iter().any(|prev| json_eq(prev, &items[i])) { - return fail("Expected an array of unique items", path); + return fail("Expected an array of unique items"); } } } if let Some(item_node) = &n.items { for (i, item) in items.iter_mut().enumerate() { - path.push(PathPart::Index(i)); - *item = check(item_node, std::mem::take(item), v, path, depth + 1)?; - path.pop(); + *item = at(check(item_node, std::mem::take(item), v, depth + 1), || { + PathPart::Index(i) + })?; } } } - Json::Object(map) => check_object(n, map, v, path, depth)?, + Json::Object(map) => check_object(n, map, v, depth)?, _ => {} } Ok(value) } -fn check_union( - n: &Node, - value: Json, - v: &Validator, - path: &mut Vec, - depth: usize, -) -> Result { +fn check_union(n: &Node, value: Json, v: &Validator, depth: usize) -> Result { let mut candidate = None; let mut same_type = 0; for alt in &n.any_of { - match check(alt, value.clone(), v, path, depth + 1) { + match check(alt, value.clone(), v, depth + 1) { Ok(decoded) => return Ok(decoded), Err(e) => { - if alt.types.iter().any(|t| matches_type(t, &value)) { + if type_matches(alt.types, &value) { same_type += 1; candidate = Some(e); } @@ -1053,69 +1086,64 @@ fn check_union( // Like Effect, a single member of the value's own type explains the failure; otherwise the union does. match candidate { Some(e) if same_type == 1 => Err(e), - _ => fail(format!("Expected {}", n.expected), path), + _ => fail(format!("Expected {}", n.expected)), } } -fn check_number(n: &Node, x: f64, path: &[PathPart]) -> Result<(), Failure> { +fn check_number(n: &Node, x: f64) -> Result<(), Failure> { if let Some(m) = n.minimum && x < m { - return fail( - format!("Expected a value greater than or equal to {}", js_num(m)), - path, - ); + return fail(format!( + "Expected a value greater than or equal to {}", + js_num(m) + )); } if let Some(m) = n.maximum && x > m { - return fail( - format!("Expected a value less than or equal to {}", js_num(m)), - path, - ); + return fail(format!( + "Expected a value less than or equal to {}", + js_num(m) + )); } if let Some(m) = n.exclusive_minimum && x <= m { - return fail(format!("Expected a value greater than {}", js_num(m)), path); + return fail(format!("Expected a value greater than {}", js_num(m))); } if let Some(m) = n.exclusive_maximum && x >= m { - return fail(format!("Expected a value less than {}", js_num(m)), path); + return fail(format!("Expected a value less than {}", js_num(m))); } if let Some(m) = n.multiple_of && (x / m).fract() != 0.0 { - return fail( - format!("Expected a value that is a multiple of {}", js_num(m)), - path, - ); + return fail(format!( + "Expected a value that is a multiple of {}", + js_num(m) + )); } Ok(()) } -fn check_length( - len: usize, - min: Option, - max: Option, - path: &[PathPart], -) -> Result<(), Failure> { +fn check_length(len: usize, min: Option, max: Option) -> Result<(), Failure> { if let Some(m) = min && (len as f64) < m { - return fail( - format!("Expected a value with a length of at least {}", js_num(m)), - path, - ); + return fail(format!( + "Expected a value with a length of at least {}", + js_num(m) + )); } if let Some(m) = max && (len as f64) > m { - return fail( - format!("Expected a value with a length of at most {}", js_num(m)), - path, - ); + return fail(format!( + "Expected a value with a length of at most {}", + js_num(m) + )); } Ok(()) } @@ -1124,38 +1152,48 @@ fn check_object( n: &Node, map: &mut serde_json::Map, v: &Validator, - path: &mut Vec, depth: usize, ) -> Result<(), Failure> { - for name in &n.required { + for name in &n.required_only { if !map.contains_key(name) { - path.push(PathPart::Key(name.clone())); - return fail("Missing key", path); + return at(fail("Missing key"), || PathPart::Key(name.clone())); } } - for (name, prop) in &n.properties { - if let Some(item) = map.get_mut(name) { - path.push(PathPart::Key(name.clone())); - *item = check(prop, std::mem::take(item), v, path, depth + 1)?; - path.pop(); + let mut present = 0; + // Tool inputs are small objects, where a scan beats hashing every key. + let small = map.len() <= 8; + for (name, prop, required) in &n.properties { + let item = if small { + map.iter_mut().find(|(k, _)| *k == name).map(|(_, v)| v) + } else { + map.get_mut(name) + }; + match item { + Some(item) => { + present += 1; + *item = at(check(prop, std::mem::take(item), v, depth + 1), || { + PathPart::Key(name.clone()) + })?; + } + None if *required => return at(fail("Missing key"), || PathPart::Key(name.clone())), + None => {} } } - let known = |k: &str| n.properties.iter().any(|(p, _)| p == k); + if map.len() == present { + return Ok(()); + } + let known = |k: &str| n.properties.iter().any(|(p, _, _)| p == k); match &n.additional { Additional::Keep => {} - Additional::Drop => { - if map.len() > n.properties.len() || map.keys().any(|k| !known(k)) { - map.retain(|k, _| known(k)); - } - } + Additional::Drop => map.retain(|k, _| known(k)), Additional::Check(extra) => { for (name, item) in map.iter_mut() { if known(name) { continue; } - path.push(PathPart::Key(name.clone())); - *item = check(extra, std::mem::take(item), v, path, depth + 1)?; - path.pop(); + *item = at(check(extra, std::mem::take(item), v, depth + 1), || { + PathPart::Key(name.clone()) + })?; } } } diff --git a/packages/codemode-rust/crates/psychoscript/src/test262.rs b/packages/codemode-rust/crates/psychoscript/src/test262.rs index f34c274fcdd5..b823be776eeb 100644 --- a/packages/codemode-rust/crates/psychoscript/src/test262.rs +++ b/packages/codemode-rust/crates/psychoscript/src/test262.rs @@ -73,11 +73,7 @@ fn run_here(code: &str, timeout_ms: u64) -> Run { ..Limits::default() }; let rt = crate::Runtime::new(); - let mut vm = Vm::new( - crate::host::RunHost::new(rt.setup(), String::new()), - limits, - atoms, - ); + let mut vm = Vm::new(crate::host::RunHost::new(rt.setup(), None), limits, atoms); vm.stack_base = &probe as *const u8 as usize; vm.stack_budget = STACK_BUDGET; vm.setup(); diff --git a/packages/codemode-rust/crates/psychoscript/src/vm.rs b/packages/codemode-rust/crates/psychoscript/src/vm.rs index 5a9883df22ed..29eccb34d0eb 100644 --- a/packages/codemode-rust/crates/psychoscript/src/vm.rs +++ b/packages/codemode-rust/crates/psychoscript/src/vm.rs @@ -165,7 +165,7 @@ pub struct Vm<'rt> { pub coroutines: Vec, pub logs: Vec, pub tool_calls: Vec, - pub host: Box>, + pub host: crate::host::RunHost<'rt>, pub tool_refs: FxHashMap, Id>, pub limits: Limits, pub start: Instant, @@ -230,7 +230,7 @@ impl<'rt> Vm<'rt> { coroutines: Vec::new(), logs: Vec::new(), tool_calls: Vec::new(), - host: Box::new(host), + host, tool_refs: FxHashMap::default(), limits, start: Instant::now(), From 2ebbab5ce470d9557e7212e7f46316d7c85b6f01 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:13:18 +0000 Subject: [PATCH 013/100] test(codemode): cover extensions and tool calls against the reference Adds host- conformance cases for invalid input, unknown tools, namespaces, search browsing, chaining, validation and counting, and missing modules, with expectations generated from the reference, and Rust tests mirroring the reference's extension tests. HostValue::to_json keeps integral numbers as integers. --- .../conformance/cases/host-import-missing.js | 2 + .../cases/host-import-missing.json | 6 + .../cases/host-input-excess-dropped.js | 1 + .../cases/host-input-excess-dropped.json | 12 + .../cases/host-invalid-input-arity.js | 1 + .../cases/host-invalid-input-arity.json | 6 + .../cases/host-invalid-input-missing.js | 1 + .../cases/host-invalid-input-missing.json | 6 + .../cases/host-invalid-input-type.js | 1 + .../cases/host-invalid-input-type.json | 9 + .../cases/host-namespace-not-callable.js | 1 + .../cases/host-namespace-not-callable.json | 6 + .../cases/host-require-dynamic-import.js | 5 + .../cases/host-require-dynamic-import.json | 10 + .../conformance/cases/host-search-browse.js | 4 + .../conformance/cases/host-search-browse.json | 69 +++ .../conformance/cases/host-search-chained.js | 4 + .../cases/host-search-chained.json | 16 + .../conformance/cases/host-search-counts.js | 4 + .../conformance/cases/host-search-counts.json | 9 + .../conformance/cases/host-search-invalid.js | 5 + .../cases/host-search-invalid.json | 13 + .../conformance/cases/host-tool-keys.js | 1 + .../conformance/cases/host-tool-keys.json | 18 + .../cases/host-unknown-tool-message.js | 5 + .../cases/host-unknown-tool-message.json | 11 + .../crates/psychoscript/src/extension.rs | 1 + .../crates/psychoscript/tests/extensions.rs | 408 ++++++++++++++++++ 28 files changed, 635 insertions(+) create mode 100644 packages/codemode-rust/conformance/cases/host-import-missing.js create mode 100644 packages/codemode-rust/conformance/cases/host-import-missing.json create mode 100644 packages/codemode-rust/conformance/cases/host-input-excess-dropped.js create mode 100644 packages/codemode-rust/conformance/cases/host-input-excess-dropped.json create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-arity.js create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-arity.json create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-missing.js create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-missing.json create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-type.js create mode 100644 packages/codemode-rust/conformance/cases/host-invalid-input-type.json create mode 100644 packages/codemode-rust/conformance/cases/host-namespace-not-callable.js create mode 100644 packages/codemode-rust/conformance/cases/host-namespace-not-callable.json create mode 100644 packages/codemode-rust/conformance/cases/host-require-dynamic-import.js create mode 100644 packages/codemode-rust/conformance/cases/host-require-dynamic-import.json create mode 100644 packages/codemode-rust/conformance/cases/host-search-browse.js create mode 100644 packages/codemode-rust/conformance/cases/host-search-browse.json create mode 100644 packages/codemode-rust/conformance/cases/host-search-chained.js create mode 100644 packages/codemode-rust/conformance/cases/host-search-chained.json create mode 100644 packages/codemode-rust/conformance/cases/host-search-counts.js create mode 100644 packages/codemode-rust/conformance/cases/host-search-counts.json create mode 100644 packages/codemode-rust/conformance/cases/host-search-invalid.js create mode 100644 packages/codemode-rust/conformance/cases/host-search-invalid.json create mode 100644 packages/codemode-rust/conformance/cases/host-tool-keys.js create mode 100644 packages/codemode-rust/conformance/cases/host-tool-keys.json create mode 100644 packages/codemode-rust/conformance/cases/host-unknown-tool-message.js create mode 100644 packages/codemode-rust/conformance/cases/host-unknown-tool-message.json create mode 100644 packages/codemode-rust/crates/psychoscript/tests/extensions.rs diff --git a/packages/codemode-rust/conformance/cases/host-import-missing.js b/packages/codemode-rust/conformance/cases/host-import-missing.js new file mode 100644 index 000000000000..66ecc3ca40ed --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-import-missing.js @@ -0,0 +1,2 @@ +import fs from "node:fs" +return fs diff --git a/packages/codemode-rust/conformance/cases/host-import-missing.json b/packages/codemode-rust/conformance/cases/host-import-missing.json new file mode 100644 index 000000000000..d67f74bc1c8e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-import-missing.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "ExecutionFailure", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-input-excess-dropped.js b/packages/codemode-rust/conformance/cases/host-input-excess-dropped.js new file mode 100644 index 000000000000..99cbfb360a5d --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-input-excess-dropped.js @@ -0,0 +1 @@ +return [await tools.echo({ id: 3, extra: true }), await tools.git.status({ anything: 1 })] diff --git a/packages/codemode-rust/conformance/cases/host-input-excess-dropped.json b/packages/codemode-rust/conformance/cases/host-input-excess-dropped.json new file mode 100644 index 000000000000..f30d164ee56a --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-input-excess-dropped.json @@ -0,0 +1,12 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + 3, + { + "branch": "main", + "dirty": true + } + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-arity.js b/packages/codemode-rust/conformance/cases/host-invalid-input-arity.js new file mode 100644 index 000000000000..3e139fa30cb6 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-arity.js @@ -0,0 +1 @@ +return await tools.echo({ id: 1 }, { id: 2 }) diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-arity.json b/packages/codemode-rust/conformance/cases/host-invalid-input-arity.json new file mode 100644 index 000000000000..2aed171e56ba --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-arity.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "InvalidToolInput", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-missing.js b/packages/codemode-rust/conformance/cases/host-invalid-input-missing.js new file mode 100644 index 000000000000..51cd7da40fa4 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-missing.js @@ -0,0 +1 @@ +return await tools.echo({}) diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-missing.json b/packages/codemode-rust/conformance/cases/host-invalid-input-missing.json new file mode 100644 index 000000000000..2aed171e56ba --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-missing.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "InvalidToolInput", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-type.js b/packages/codemode-rust/conformance/cases/host-invalid-input-type.js new file mode 100644 index 000000000000..00fa6e0e0baf --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-type.js @@ -0,0 +1 @@ +try { await tools.echo({ id: "7" }) } catch (e) { return [e.name, e.message] } diff --git a/packages/codemode-rust/conformance/cases/host-invalid-input-type.json b/packages/codemode-rust/conformance/cases/host-invalid-input-type.json new file mode 100644 index 000000000000..84b5d80b731e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-invalid-input-type.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "Error", + "Invalid input for tool 'echo': SchemaError(Expected number\n at [\"id\"])" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-namespace-not-callable.js b/packages/codemode-rust/conformance/cases/host-namespace-not-callable.js new file mode 100644 index 000000000000..bde1c1d27186 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-namespace-not-callable.js @@ -0,0 +1 @@ +return await tools.git({}) diff --git a/packages/codemode-rust/conformance/cases/host-namespace-not-callable.json b/packages/codemode-rust/conformance/cases/host-namespace-not-callable.json new file mode 100644 index 000000000000..95f92b51f8fa --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-namespace-not-callable.json @@ -0,0 +1,6 @@ +{ + "bindings": {}, + "ok": false, + "kind": "UnknownTool", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-require-dynamic-import.js b/packages/codemode-rust/conformance/cases/host-require-dynamic-import.js new file mode 100644 index 000000000000..1a94cd7ce8e0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-require-dynamic-import.js @@ -0,0 +1,5 @@ +const errors = [] +try { require("fs") } catch (e) { errors.push(e.message) } +try { await import("child_process") } catch (e) { errors.push(e.message) } +try { require(1) } catch (e) { errors.push(e.name) } +return errors diff --git a/packages/codemode-rust/conformance/cases/host-require-dynamic-import.json b/packages/codemode-rust/conformance/cases/host-require-dynamic-import.json new file mode 100644 index 000000000000..d70d48cb9b3d --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-require-dynamic-import.json @@ -0,0 +1,10 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "Cannot import \"fs\": it isn't available in Code Mode, which can't load packages or files. Use the provided globals, or call tools through `tools`.", + "Cannot import \"child_process\": it isn't available in Code Mode, which can't load packages or files. Use the provided globals, or call tools through `tools`.", + "TypeError" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-search-browse.js b/packages/codemode-rust/conformance/cases/host-search-browse.js new file mode 100644 index 000000000000..dca49668f062 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-browse.js @@ -0,0 +1,4 @@ +const all = search({}) +const page = search({ limit: 1, offset: 1 }) +const done = search({ limit: 1, offset: 3 }) +return [all, page, done, search("status"), search({ query: "", namespace: "git" }), search("tools.git.status").items.length] diff --git a/packages/codemode-rust/conformance/cases/host-search-browse.json b/packages/codemode-rust/conformance/cases/host-search-browse.json new file mode 100644 index 000000000000..b9e49dd7789f --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-browse.json @@ -0,0 +1,69 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + { + "items": [ + { + "path": "tools.echo", + "description": "Echo an id", + "signature": "tools.echo({\n id: number,\n}): Promise" + }, + { + "path": "tools.fail", + "description": "Always fails", + "signature": "tools.fail(): Promise" + }, + { + "path": "tools.git.status", + "description": "Working tree status", + "signature": "tools.git.status(): Promise<{\n branch: string,\n dirty: boolean,\n}>" + } + ], + "remaining": 0, + "next": null + }, + { + "items": [ + { + "path": "tools.fail", + "description": "Always fails", + "signature": "tools.fail(): Promise" + } + ], + "remaining": 1, + "next": { + "offset": 2 + } + }, + { + "items": [], + "remaining": 0, + "next": null + }, + { + "items": [ + { + "path": "tools.git.status", + "description": "Working tree status", + "signature": "tools.git.status(): Promise<{\n branch: string,\n dirty: boolean,\n}>" + } + ], + "remaining": 0, + "next": null + }, + { + "items": [ + { + "path": "tools.git.status", + "description": "Working tree status", + "signature": "tools.git.status(): Promise<{\n branch: string,\n dirty: boolean,\n}>" + } + ], + "remaining": 0, + "next": null + }, + 1 + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-search-chained.js b/packages/codemode-rust/conformance/cases/host-search-chained.js new file mode 100644 index 000000000000..62a71fb39905 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-chained.js @@ -0,0 +1,4 @@ +const viaThen = await search("echo").then((r) => r.items[0].path) +const viaAwait = (await search("echo")).items[0].path +const alias = (await tools.search({ query: "echo" })).items[0].path +return [viaThen, viaAwait, alias, Object.keys(search("echo")), JSON.stringify(search({ limit: 1 })).length > 10] diff --git a/packages/codemode-rust/conformance/cases/host-search-chained.json b/packages/codemode-rust/conformance/cases/host-search-chained.json new file mode 100644 index 000000000000..e9f18e6d9601 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-chained.json @@ -0,0 +1,16 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "tools.echo", + "tools.echo", + "tools.echo", + [ + "items", + "remaining", + "next" + ], + true + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-search-counts.js b/packages/codemode-rust/conformance/cases/host-search-counts.js new file mode 100644 index 000000000000..d0c5d9b2a753 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-counts.js @@ -0,0 +1,4 @@ +// @limits {"max_tool_calls": 2} +search({}) +await tools.echo({ id: 1 }) +return search("echo") diff --git a/packages/codemode-rust/conformance/cases/host-search-counts.json b/packages/codemode-rust/conformance/cases/host-search-counts.json new file mode 100644 index 000000000000..65a9c31b4a1b --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-counts.json @@ -0,0 +1,9 @@ +{ + "bindings": {}, + "limits": { + "max_tool_calls": 2 + }, + "ok": false, + "kind": "ToolCallLimitExceeded", + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-search-invalid.js b/packages/codemode-rust/conformance/cases/host-search-invalid.js new file mode 100644 index 000000000000..c571d27de841 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-invalid.js @@ -0,0 +1,5 @@ +const errors = [] +for (const input of [{ limit: 0 }, { limit: 0.5 }, { offset: -1 }, { namespace: 7 }, 42, null]) { + try { search(input) } catch (e) { errors.push(e.message) } +} +return errors diff --git a/packages/codemode-rust/conformance/cases/host-search-invalid.json b/packages/codemode-rust/conformance/cases/host-search-invalid.json new file mode 100644 index 000000000000..f3b278faadd0 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-search-invalid.json @@ -0,0 +1,13 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "Invalid input for tool 'search': SchemaError(Expected a value greater than 0\n at [\"limit\"])", + "Invalid input for tool 'search': SchemaError(Expected an integer\n at [\"limit\"])", + "Invalid input for tool 'search': SchemaError(Expected a value greater than or equal to 0\n at [\"offset\"])", + "Invalid input for tool 'search': SchemaError(Expected string\n at [\"namespace\"])", + "Invalid input for tool 'search': SchemaError(Expected object)", + "Invalid input for tool 'search': SchemaError(Expected object)" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-tool-keys.js b/packages/codemode-rust/conformance/cases/host-tool-keys.js new file mode 100644 index 000000000000..4b9375539605 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-tool-keys.js @@ -0,0 +1 @@ +return [Object.keys(tools), Object.keys(tools.git), typeof tools.git, typeof tools.git.status, typeof search] diff --git a/packages/codemode-rust/conformance/cases/host-tool-keys.json b/packages/codemode-rust/conformance/cases/host-tool-keys.json new file mode 100644 index 000000000000..9e15df4e2d8e --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-tool-keys.json @@ -0,0 +1,18 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + [ + "echo", + "fail", + "git" + ], + [ + "status" + ], + "function", + "function", + "function" + ], + "logs": [] +} diff --git a/packages/codemode-rust/conformance/cases/host-unknown-tool-message.js b/packages/codemode-rust/conformance/cases/host-unknown-tool-message.js new file mode 100644 index 000000000000..157e98952d9d --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-unknown-tool-message.js @@ -0,0 +1,5 @@ +const messages = [] +for (const call of [() => tools.ech({ id: 1 }), () => tools.git.stat({}), () => tools.git({}), () => tools.nothing.here({})]) { + try { await call() } catch (e) { messages.push(e.message) } +} +return messages diff --git a/packages/codemode-rust/conformance/cases/host-unknown-tool-message.json b/packages/codemode-rust/conformance/cases/host-unknown-tool-message.json new file mode 100644 index 000000000000..0fa518e8a948 --- /dev/null +++ b/packages/codemode-rust/conformance/cases/host-unknown-tool-message.json @@ -0,0 +1,11 @@ +{ + "bindings": {}, + "ok": true, + "value": [ + "Unknown tool 'ech'.", + "Unknown tool 'git.stat'. Did you mean tools.git.status?", + "Tool 'git' is not callable, it is a namespace. Did you mean tools.git.status?", + "Unknown tool 'nothing.here'." + ], + "logs": [] +} diff --git a/packages/codemode-rust/crates/psychoscript/src/extension.rs b/packages/codemode-rust/crates/psychoscript/src/extension.rs index c296add71e62..1028bc38a833 100644 --- a/packages/codemode-rust/crates/psychoscript/src/extension.rs +++ b/packages/codemode-rust/crates/psychoscript/src/extension.rs @@ -83,6 +83,7 @@ impl HostValue { HostValue::Undefined | HostValue::Function(_) => return None, HostValue::Null => Json::Null, HostValue::Bool(b) => Json::Bool(*b), + HostValue::Number(n) if n.fract() == 0.0 && n.abs() < 9.0e15 => Json::from(*n as i64), HostValue::Number(n) => { serde_json::Number::from_f64(*n).map_or(Json::Null, Json::Number) } diff --git a/packages/codemode-rust/crates/psychoscript/tests/extensions.rs b/packages/codemode-rust/crates/psychoscript/tests/extensions.rs new file mode 100644 index 000000000000..c5379c14eb4d --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/tests/extensions.rs @@ -0,0 +1,408 @@ +//! Extension globals, the copying boundary, host errors and imports, mirroring the reference's +//! `extensions.test.ts`. + +use std::sync::{Arc, Mutex}; + +use psychoscript::{ + ConfigError, Extension, Hooks, HostError, HostFunction, HostValue, Json, Limits, Runtime, +}; +use serde_json::json; + +type Held = Arc>>; + +fn web(held: &Held) -> Extension { + let keep = held.clone(); + let fetch = HostFunction::new_async("fetch", 2, |args| async move { + let url = args + .first() + .and_then(HostValue::as_str) + .unwrap_or_default() + .to_owned(); + let body = format!(r#"{{"url":"{url}"}}"#); + let text = body.clone(); + Ok(HostValue::object([ + ("status", HostValue::Number(200.0)), + ("ok", HostValue::Bool(true)), + ( + "headers", + HostValue::object([( + "get", + HostFunction::new("get", 1, |args| { + Ok(match args.first().and_then(HostValue::as_str) { + Some("content-type") => "application/json".into(), + _ => HostValue::Null, + }) + }) + .into(), + )]), + ), + ( + "text", + HostFunction::new("text", 0, move |_| Ok(text.clone().into())).into(), + ), + ( + "json", + HostFunction::new("json", 0, move |_| { + Ok(HostValue::from_json(&serde_json::from_str(&body).unwrap())) + }) + .into(), + ), + ( + "handlers", + HostValue::array([HostFunction::new("step", 1, |args| { + Ok(HostValue::Number(args[0].as_f64().unwrap_or(0.0) + 1.0)) + }) + .into()]), + ), + ])) + }); + Extension::new("web") + .function( + "keep", + HostFunction::new("keep", 1, move |args| { + let v = args.into_iter().next().unwrap_or_default(); + keep.lock().unwrap().push(v.clone()); + Ok(v) + }), + ) + .function( + "settings", + HostFunction::new("settings", 0, |_| { + Ok(HostValue::from_json( + &json!({ "retries": 3, "nested": { "deep": true } }), + )) + }), + ) + .function( + "later", + HostFunction::new_async("later", 1, |args| async move { + Ok(HostValue::Number(args[0].as_f64().unwrap_or(0.0) + 1.0)) + }), + ) + .function( + "first", + HostFunction::new("first", 1, |args| match args.into_iter().next() { + Some(HostValue::Map(entries)) => Ok(entries + .into_iter() + .find(|(k, _)| k.as_str() == Some("k")) + .map(|(_, v)| v) + .unwrap_or_default()), + _ => Ok(HostValue::Undefined), + }), + ) + .function("fetch", fetch) +} + +fn value(rt: &Runtime, code: &str) -> Json { + match rt.execute(code, &serde_json::Map::new()).result { + Ok(v) => v, + Err(d) => panic!("expected success, got {:?}: {}", d.kind, d.message), + } +} + +fn failure(rt: &Runtime, code: &str) -> String { + match rt.execute(code, &serde_json::Map::new()).result { + Ok(v) => panic!("expected failure, got {v}"), + Err(d) => d.message, + } +} + +#[test] +fn a_global_is_callable_awaitable_and_named() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)); + assert_eq!(value(&rt, "return await later(1)"), json!(2)); + assert_eq!( + value(&rt, "return [typeof later, later.name, later.length]"), + json!(["function", "later", 1]) + ); + assert!( + rt.execute("new later()", &serde_json::Map::new()) + .result + .is_err() + ); +} + +#[test] +fn a_function_inside_a_result_is_callable_and_crosses_the_same_way() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)); + assert_eq!( + value( + &rt, + r#"const res = await fetch("https://a.test/", { method: "GET" }) + return [res.status, res.ok, res.headers.get("content-type"), res.text(), res.json(), typeof res.json, res.json.name, res.handlers[0](1)]"# + ), + json!([200, true, "application/json", r#"{"url":"https://a.test/"}"#, { "url": "https://a.test/" }, "function", "json", 2]) + ); + assert!( + failure( + &rt, + r#"const res = await fetch("https://a.test/"); res.handlers[0](() => 1)"# + ) + .contains("Argument 1 to fetch.handlers[0] contains a function") + ); + assert_eq!( + value(&rt, r#"return await fetch("https://a.test/")"#), + json!({ "status": 200, "ok": true, "headers": {}, "handlers": [null] }) + ); +} + +#[test] +fn values_are_copies_both_ways() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)); + value( + &rt, + "const o = { n: 1, list: [1] }; keep(o); o.n = 2; o.list.push(2)", + ); + assert_eq!( + held.lock().unwrap()[0].to_json(), + Some(json!({ "n": 1, "list": [1] })) + ); + assert_eq!( + value( + &rt, + "const s = settings(); s.retries = 0; s.nested.deep = false; return [s, settings()]" + ), + json!([{ "retries": 0, "nested": { "deep": false } }, { "retries": 3, "nested": { "deep": true } }]) + ); + assert_eq!(value(&rt, "return settings() === settings()"), json!(false)); + assert_eq!( + value(&rt, r#"return first(new Map([["k", { z: 1 }]]))"#), + json!({ "z": 1 }) + ); + held.lock().unwrap().clear(); + value(&rt, "keep({ __proto__: { polluted: true }, a: 1 })"); + assert_eq!(held.lock().unwrap()[0].to_json(), Some(json!({ "a": 1 }))); +} + +#[test] +fn a_program_error_crosses_with_its_name_message_cause_and_data() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)); + value( + &rt, + r#"const e = new Error("m", { cause: new RangeError("root") }) + e.code = "ENOENT"; e.detail = { path: "x" }; e.fn = () => 1 + keep(e)"#, + ); + let HostValue::Error(e) = &held.lock().unwrap()[0] else { + panic!("not an error"); + }; + assert_eq!((e.name.as_str(), e.message.as_str()), ("Error", "m")); + let Some(HostValue::Error(cause)) = e.cause.as_deref() else { + panic!("no cause"); + }; + assert_eq!( + (cause.name.as_str(), cause.message.as_str()), + ("RangeError", "root") + ); + let keys: Vec<&str> = e.fields.iter().map(|(k, _)| k.as_str()).collect(); + assert_eq!(keys, ["code", "detail"]); +} + +#[test] +fn functions_promises_iterators_and_symbols_cannot_be_passed_in() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)); + assert!(failure(&rt, "keep(() => 1)").contains("Argument 1 to keep contains a function")); + assert!(failure(&rt, "keep([1].keys())").contains("Argument 1 to keep contains an iterator")); + assert!(failure(&rt, "keep(later(1))").contains("un-awaited Promise")); + assert!(failure(&rt, "keep(Symbol.iterator)").contains("Argument 1 to keep contains a symbol")); +} + +#[test] +fn host_errors_become_program_errors() { + let rt = Runtime::new().extension( + Extension::new("odd") + .function( + "fail", + HostFunction::new("fail", 0, |_| { + Err(HostError::named("RangeError", "boom").into()) + }), + ) + .function( + "open", + HostFunction::new("open", 0, |_| { + let cause = HostError::new("ENOENT: no such file or directory, open 'x'") + .with_field("code", "ENOENT") + .with_field("errno", -2.0) + .with_field("path", "x") + .with_field("detail", HostValue::from_json(&json!({ "retried": true }))) + .with_field("retry", HostFunction::new("retry", 0, |_| Ok(1.0.into()))); + Err(HostError::new("open failed").with_cause(cause).into()) + }), + ) + .function( + "reject", + HostFunction::new_async("reject", 1, |args| async move { + Err(args.into_iter().next().unwrap_or_default()) + }), + ) + .function( + "boom", + HostFunction::new("boom", 0, |_| { + Err(HostValue::from_json( + &json!({ "status": 404, "nested": { "a": 1 } }), + )) + }), + ), + ); + assert_eq!( + value( + &rt, + "try { fail() } catch (e) { return [e instanceof RangeError, e.message] }" + ), + json!([true, "boom"]) + ); + assert_eq!( + value( + &rt, + r#"try { open() } catch (e) { + const c = e.cause + return [e.message, Object.keys(e), c instanceof Error, c.code, c.errno, c.path, c.detail, Object.keys(c), "stack" in c] + }"# + ), + json!(["open failed", [], true, "ENOENT", -2, "x", { "retried": true }, ["code", "errno", "path", "detail"], false]) + ); + assert_eq!( + value( + &rt, + r#"try { await reject(new TypeError("bad")) } catch (e) { return [e instanceof TypeError, e.message] }"# + ), + json!([true, "bad"]) + ); + assert_eq!( + value( + &rt, + r#"try { await reject("plain") } catch (e) { return e }"# + ), + json!("plain") + ); + assert_eq!( + value(&rt, "try { boom() } catch (e) { return e.status }"), + json!(404) + ); + assert_eq!( + failure(&rt, "boom()"), + r#"Uncaught: {"status":404,"nested":{"a":1}}"# + ); +} + +#[test] +fn extension_calls_are_not_tool_calls() { + let held = Held::default(); + let rt = Runtime::new().extension(web(&held)).limits(Limits { + max_tool_calls: Some(0), + ..Limits::default() + }); + let outcome = rt.execute( + r#"(await fetch("https://a.test/")).json(); return await later(1)"#, + &serde_json::Map::new(), + ); + assert_eq!(outcome.result.unwrap(), json!(2)); + assert!(outcome.tool_calls.is_empty()); +} + +#[test] +fn a_global_may_not_shadow_a_built_in_or_another_extension() { + let url = + Extension::new("web").function("URL", HostFunction::new("URL", 0, |_| Ok(1.0.into()))); + assert_eq!( + Runtime::new().try_extension(url).err(), + Some(ConfigError( + "Extension \"web\" global \"URL\" is already defined.".into() + )) + ); + let held = Held::default(); + let again = Extension::new("again") + .function("fetch", HostFunction::new("fetch", 0, |_| Ok(1.0.into()))); + assert_eq!( + Runtime::new() + .extension(web(&held)) + .try_extension(again) + .err(), + Some(ConfigError( + "Extension \"again\" global \"fetch\" is already defined.".into() + )) + ); +} + +fn files() -> Extension { + Extension::new("files").object( + "fs", + HostValue::object([ + ( + "readFile", + HostFunction::new("readFile", 1, |args| { + Ok(format!("text of {}", args[0].as_str().unwrap_or_default()).into()) + }) + .into(), + ), + ( + "promises", + HostValue::object([( + "readFile", + HostFunction::new_async("readFile", 1, |args| async move { + Ok(args.into_iter().next().unwrap_or_default()) + }) + .into(), + )]), + ), + ]), + ) +} + +#[test] +fn import_require_and_dynamic_import_load_globals_and_fire_the_hooks() { + let calls = Arc::new(Mutex::new(Vec::new())); + let seen = calls.clone(); + let rt = Runtime::new() + .extension(files()) + .hooks(Hooks::new().extension_before(move |call| { + seen.lock() + .unwrap() + .push(format!("{}:{}", call.extension, call.name)); + Ok(()) + })); + assert_eq!( + value( + &rt, + r#"import fs, { readFile } from "node:fs" + import * as ns from "fs" + import { readFile as readAsync } from "fs/promises" + const dynamic = await import("fs") + return [readFile("a"), fs === require("fs"), ns.default === fs, dynamic === ns, await readAsync("b")]"# + ), + json!(["text of a", true, true, true, "b"]) + ); + assert_eq!( + *calls.lock().unwrap(), + ["files:fs.readFile", "files:fs.promises.readFile"] + ); +} + +#[test] +fn a_module_that_is_not_provided_or_a_missing_export_fails_at_the_import() { + let rt = Runtime::new().extension(files()); + assert!(failure(&rt, r#"import yaml from "yaml""#).starts_with( + r#"Error: Cannot import "yaml": it isn't available in Code Mode, which can't load packages or files."# + )); + assert!( + value( + &rt, + r#"try { await import("child_process") } catch (e) { return e.message }"# + ) + .as_str() + .unwrap() + .starts_with(r#"Cannot import "child_process""#) + ); + assert!( + failure(&rt, r#"import { writeFile } from "fs""#) + .starts_with(r#"SyntaxError: "fs" has no export named "writeFile"."#) + ); + assert!( + failure(&Runtime::new(), r#"require("fs")"#).starts_with(r#"Error: Cannot import "fs""#) + ); +} From b58381cf1b1ac5521641f55ea6575d1f365de2af Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:17:15 +0000 Subject: [PATCH 014/100] perf(codemode): make host globals and run ids only when a run uses them A run defines search, require, the import hook and extension globals only for the names its program refers to, and a module import makes the one it asks for. The run id is made the first time a call's key is read. --- .../crates/psychoscript/src/host.rs | 59 ++++++++++++------- .../crates/psychoscript/src/run.rs | 2 +- .../crates/psychoscript/src/tool.rs | 15 +++-- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/packages/codemode-rust/crates/psychoscript/src/host.rs b/packages/codemode-rust/crates/psychoscript/src/host.rs index cee675dd3c27..a02a91434ce3 100644 --- a/packages/codemode-rust/crates/psychoscript/src/host.rs +++ b/packages/codemode-rust/crates/psychoscript/src/host.rs @@ -123,7 +123,7 @@ pub struct FnEntry { pub struct RunHost<'rt> { pub setup: &'rt Setup, /// Names the run's host calls; made on first use when the host gave none. - run_id: Option>, + run_id: crate::tool::RunId, next_call: u64, /// The context handed to synchronous tools, its call id set for each call. ctx: Option, @@ -141,7 +141,7 @@ impl<'rt> RunHost<'rt> { Self { setup, ctx: None, - run_id: run_id.map(Arc::from), + run_id: Arc::new(run_id.map(std::sync::OnceLock::from).unwrap_or_default()), next_call: 0, tasks: Tasks::default(), functions: Vec::new(), @@ -163,10 +163,8 @@ impl<'rt> RunHost<'rt> { id } - pub fn run_id(&mut self) -> Arc { - self.run_id - .get_or_insert_with(|| Arc::from(crate::run::random_run_id())) - .clone() + pub fn run_id(&mut self) -> crate::tool::RunId { + self.run_id.clone() } fn context(&mut self) -> ToolContext { @@ -187,24 +185,40 @@ impl<'rt> RunHost<'rt> { // ---------- setup ---------- -/// Defines `search`, `require`, the import hook and the extensions' globals. -pub fn install(vm: &mut Vm) { - let search = native(vm, "search", 0, search_native, Value::Undef); - global(vm, "search", search); - let require = native(vm, "require", 1, require_native, Value::Undef); - global(vm, "require", require); - let import = native(vm, "import", 2, import_native, Value::Undef); - global(vm, IMPORT_GLOBAL, import); - let setup = vm.host.setup; - for extension in &setup.extensions { - for (name, value) in extension.globals() { - let v = from_host(vm, value, name, Some((extension.name(), true)), 0) - .unwrap_or(Value::Undef); - global(vm, name, v); - } +/// Defines the host globals the program refers to: `search`, `require`, the import hook, and extension globals. +/// The rest are made only if a module import asks for them, so a run pays only for the globals it uses. +pub fn install(vm: &mut Vm, referenced: &[Atom]) { + for &a in referenced { + let name = vm.atoms.text(a).to_owned(); + define_host_global(vm, &name); } } +/// Defines one host global by name; false when there is none. +fn define_host_global(vm: &mut Vm, name: &str) -> bool { + let v = match name { + "search" => native(vm, "search", 0, search_native, Value::Undef), + "require" => native(vm, "require", 1, require_native, Value::Undef), + IMPORT_GLOBAL => native(vm, "import", 2, import_native, Value::Undef), + _ => { + let setup = vm.host.setup; + let found = setup.extensions.iter().find_map(|extension| { + extension + .globals() + .iter() + .find(|(n, _)| n == name) + .map(|(_, value)| (extension.name(), value)) + }); + let Some((extension, value)) = found else { + return false; + }; + from_host(vm, value, name, Some((extension, true)), 0).unwrap_or(Value::Undef) + } + }; + global(vm, name, v); + true +} + fn global(vm: &mut Vm, name: &str, v: Value) { let a = vm.atoms.intern(name); vm.global_map.insert(a, v); @@ -1056,6 +1070,9 @@ fn module_name(specifier: &str) -> &str { fn global_value(vm: &mut Vm, name: &str) -> Option { let a = vm.atoms.intern(name); + if !vm.global_map.contains_key(&a) { + define_host_global(vm, name); + } match vm.global_map.get(&a) { Some(Value::Undef) | None => None, Some(v) => Some(*v), diff --git a/packages/codemode-rust/crates/psychoscript/src/run.rs b/packages/codemode-rust/crates/psychoscript/src/run.rs index 48b853f6d838..1a231c2acf22 100644 --- a/packages/codemode-rust/crates/psychoscript/src/run.rs +++ b/packages/codemode-rust/crates/psychoscript/src/run.rs @@ -127,7 +127,7 @@ pub fn start<'a>( let setup = rt.setup(); let mut vm = Vm::new(RunHost::new(setup, run_id), setup.limits, atoms); vm.setup(); - host::install(&mut vm); + host::install(&mut vm, &program.globals); for (k, v) in bindings { let val = convert::from_json(&mut vm, v); let a = vm.atoms.intern(k); diff --git a/packages/codemode-rust/crates/psychoscript/src/tool.rs b/packages/codemode-rust/crates/psychoscript/src/tool.rs index 56c9673215ad..a500b2e1983e 100644 --- a/packages/codemode-rust/crates/psychoscript/src/tool.rs +++ b/packages/codemode-rust/crates/psychoscript/src/tool.rs @@ -13,20 +13,27 @@ use crate::schema::{self, Schema}; pub type BoxFuture<'a, T> = Pin + Send + 'a>>; /// What a tool call knows about itself: its stable idempotency key, `:`. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug)] pub struct ToolContext { - run_id: Arc, + run_id: RunId, pub(crate) call: u64, } +/// A run's id, shared by its calls and made the first time a key is read, when the host gave none. +pub(crate) type RunId = Arc>; + impl ToolContext { - pub(crate) fn new(run_id: Arc, call: u64) -> Self { + pub(crate) fn new(run_id: RunId, call: u64) -> Self { Self { run_id, call } } /// `:`, the same at every hook. pub fn key(&self) -> String { - format!("{}:{}", self.run_id, self.call) + format!( + "{}:{}", + self.run_id.get_or_init(crate::run::random_run_id), + self.call + ) } } From f356df00dbd6102f65e44daf2d29ad33c748a36b Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:15 +0000 Subject: [PATCH 015/100] fix(codemode): convert functions, generators and iterators through ToPrimitive Operators and built-in arguments now call their valueOf/toString like any other object, as JS does: fn + 1 is "[object Function]1" and -fn is NaN. Promises and tool references still reject, so a missing await cannot hide. --- .../codemode-rust/test262/reference-gaps.txt | 28 ---------- packages/codemode/interpreter-support.md | 17 +++--- packages/codemode/src/internal-prelude.ts | 4 +- packages/codemode/src/prelude/bytecode.json | 2 +- packages/codemode/src/runtime/operations.ts | 4 +- packages/codemode/src/vm.ts | 12 ++--- packages/codemode/test/errors.test.ts | 2 +- packages/codemode/test/parity.test.ts | 53 +++++++++++-------- packages/codemode/test/stdlib.test.ts | 2 +- packages/codemode/test/test262/skipped.txt | 28 ---------- 10 files changed, 55 insertions(+), 97 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index 559d86b759f4..6d892a47a8fb 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -43,25 +43,10 @@ built-ins/String/fromCharCode/S9.7_A3.1_T4.js # real: ToPrimitive and ToInteger built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -language/expressions/addition/S11.6.1_A2.2_T3.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/addition/S11.6.1_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) language/expressions/assignment/target-member-identifier-reference-null.js # real: assignment to a member of null or undefined evaluates the right side first language/expressions/assignment/target-member-identifier-reference-undefined.js # real: assignment to a member of null or undefined evaluates the right side first -language/expressions/bitwise-and/S11.10.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/bitwise-not/S11.4.8_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/bitwise-or/S11.10.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/bitwise-xor/S11.10.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) language/expressions/delete/non-reference-return-true.js # real: delete of a non-reference unary chain is true -language/expressions/division/S11.5.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/greater-than-or-equal/S11.8.4_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/greater-than/S11.8.2_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/left-shift/S11.7.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/less-than-or-equal/S11.8.3_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/less-than/S11.8.1_A3.2_T1.2.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/modulus/S11.5.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/multiplication/S11.5.1_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) language/expressions/new/ctorExpr-isCtor-after-args-eval-fn-wrapup.js # real: new evaluates its arguments before the constructor check language/expressions/new/ctorExpr-isCtor-after-args-eval.js # real: new evaluates its arguments before the constructor check language/expressions/new/spread-err-mult-err-expr-throws.js # real: new evaluates its arguments before the constructor check @@ -74,19 +59,6 @@ language/expressions/new/spread-err-sngl-err-itr-get-call.js # real: new evalua language/expressions/new/spread-err-sngl-err-itr-step.js # real: new evaluates its arguments before the constructor check language/expressions/new/spread-err-sngl-err-obj-unresolvable.js # real: new evaluates its arguments before the constructor check language/expressions/new/spread-err-sngl-err-unresolvable.js # real: new evaluates its arguments before the constructor check -language/expressions/postfix-decrement/S11.3.2_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/postfix-decrement/S11.3.2_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/postfix-increment/S11.3.1_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/postfix-increment/S11.3.1_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/prefix-decrement/S11.4.5_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/prefix-decrement/S11.4.5_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/prefix-increment/S11.4.4_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/prefix-increment/S11.4.4_A4_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/right-shift/S11.7.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/subtraction/S11.6.2_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/unary-minus/S11.4.7_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/unary-plus/S11.4.6_A3_T5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) -language/expressions/unsigned-right-shift/S11.7.3_A3_T1.5.js # real: coercing a function or other non-data value in an operator or argument (TS gap, interpreter-support.md) language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 993f5276ce9a..303de00ef2d6 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -233,7 +233,8 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. assigning a read-only one (`Math.PI`, `fn.name`) throws a `TypeError`, as in strict mode. `delete` of a non-reference (`delete 0`, `delete f()`) evaluates the operand and is `true`; `delete x` on a variable throws. - [x] Coercion helpers and template interpolation accept functions and namespaces: `String(fn)` and `${fn}` give - `"[object Function]"` rather than the source text, `isNaN(fn)` is `true`. + `"[object Function]"` rather than the source text (unless the function has its own `toString` or `valueOf`), + `isNaN(fn)` is `true`. - [x] `==` and `!=` follow IsLooselyEqual: objects (including functions and tool references) compare by identity, a nullish operand never coerces the other side, and a data object facing a primitive converts through its own `valueOf`/`toString` (default hint) (`fn == null` is `false`, `fn == fn` is `true`, `[1] == 1` and `[1, 2] == "1,2"` are `true`). @@ -241,9 +242,11 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. values. Operators inspect only their direct operands, so `rows == null` on a large array costs the same as `rows === null`, and an object merely holding a function inside (`[fn] + ""`, `-[fn]`) coerces like any other data object (`"[object Function]"`, `NaN`). -- [ ] Coercing a function, promise, generator, or tool reference itself: `fn + ""`, `-fn`, `fn++`, and `fn == 1` - throw `TypeError: Binary operators require data values.` (or the unary/update form) where JavaScript would use - the source text or `NaN`. +- [x] Functions, generators, and iterators convert through ToPrimitive like any other object, in operators and in + built-in arguments: `fn + ""` is `"[object Function]"` (not the source text), `-fn` and `fn++` give `NaN`, + `fn == 1` is `false`, and an own `valueOf` or `toString` is used. A promise or tool reference is never + converted, so a missing `await` cannot hide: `promise + 1`, `-promise`, and `promise == 1` throw + `TypeError: Binary operators require data values.` (or the unary/update form). - [x] ToPrimitive on program objects: `+ - * / % **`, the relational and bitwise operators, unary `+ - ~`, `++`/`--`, compound assignment, `${x}`, `Number`/`String`/`isNaN`/`isFinite`, `parseInt`/`parseFloat` (text and radix), `Math.*` arguments, `Error(message)`, and `Array.prototype.join`/`toString` elements call the object's own @@ -263,7 +266,7 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. converts through its own `toString`/`valueOf` (string hint) exactly once per access, in reads, writes, compound assignment, `++`, `delete`, `in`, object literals, and destructuring: `o[{ toString() { return "id" } }] += 1` updates `o.id`. A nullish base throws before the key converts, as - in JS. Opaque values (functions, promises, tool references) keep their built-in string form. + in JS. Promises and tool references keep their built-in string form. ## Promises and tools @@ -422,7 +425,7 @@ reject }` object. - [x] Native argument coercion for supported String methods; for example, `includes(1)` and `slice("1")` coerce like native JS, `split(undefined)` returns the whole string, and `includes`/`startsWith`/`endsWith` reject regular expressions with a native-style `TypeError`. Data objects convert through their own `toString`/`valueOf` (see - ToPrimitive above). Opaque runtime references still reject as data errors, and `repeat` still requires a finite + ToPrimitive above). Promises and tool references still reject as data errors, and `repeat` still requires a finite non-negative count. - [x] Native no-argument parity for `match()`, `matchAll()`, and `search()`; all behave as an empty pattern. - [x] `String.raw`, on a template object or any `{ raw }` object; raw strings and substitutions coerce through their own @@ -449,7 +452,7 @@ reject }` object. - [x] Native zero-argument behavior for `Number()` and `String()`: they produce `0` and `""`, while `Number(undefined)` stays `NaN` and `String(undefined)` stays `"undefined"`. - [x] `++` and `--` use CodeMode numeric coercion (numeric strings increment, plain data objects become `NaN`, Dates - use their epoch time) and reject opaque runtime references as data errors. + use their epoch time, functions become `NaN`) and reject promises and tool references as data errors. - [x] Unknown static members on global namespaces and on `Number`/`String`/the coercion functions read as `undefined` for feature detection. Calling any undefined value reports a native-style `TypeError` naming the callee, for example `Math.sum is not a function.` or `search(...).catch is not a function.` Unknown `Promise` statics keep diff --git a/packages/codemode/src/internal-prelude.ts b/packages/codemode/src/internal-prelude.ts index 305fc669d951..6a17d482cdc6 100644 --- a/packages/codemode/src/internal-prelude.ts +++ b/packages/codemode/src/internal-prelude.ts @@ -42,8 +42,9 @@ export class VmIntrinsic { } export const INTERNAL_SOURCE = String.raw` +// A promise stays as it is, so that the operator or built-in it reaches rejects it as an un-awaited value. function $vmToPrimitive(v, hint) { - if (!$IsDataObj(v)) return v + if (!$IsObj(v) || $IsPromise(v)) return v const first = hint === "string" || (hint === "default" && $IsDate(v)) ? "toString" : "valueOf" const second = first === "toString" ? "valueOf" : "toString" const m1 = $GetMethod(v, first) @@ -265,7 +266,6 @@ export const registerVmIntrinsics = (map: Map, vm: Vm): void => } add("$IsObj", ([v]) => v instanceof Obj) - add("$IsDataObj", ([v]) => v instanceof Obj && !isOpaque(v)) add("$IsDate", ([v]) => v instanceof DateObj) add("$IsPromise", ([v]) => v instanceof PromiseObj) add("$IsArray", ([v]) => v instanceof Arr) diff --git a/packages/codemode/src/prelude/bytecode.json b/packages/codemode/src/prelude/bytecode.json index 086ea5d6e5c6..8f91df36f3ad 100644 --- a/packages/codemode/src/prelude/bytecode.json +++ b/packages/codemode/src/prelude/bytecode.json @@ -1 +1 @@ -{"@prelude":{"text":"f135511dc7fc0839","codes":[{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65352,65546,328,262411,3,327947,327690,65546,46,1900605,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,458812,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,52,2,54,3,52,4,50,5,58,6,56,7,61,8,62,9,60,10,59,11,67,12,68,13,66,14,68,15,66,16,72,17,71,18,74,19,75,20,73,21,76,22,69,23,66,24,65,25,79,26,78,27,79,28,59,29,81,30,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,65352,262154,328,327947,3,393483,393226,262154,46,2818109,393226,10,33,2555965,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,1048636,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,149,11,151,12,149,13,147,14,155,15,153,16,158,17,159,18,157,19,156,20,163,21,164,22,162,23,161,24,168,25,169,26,167,27,169,28,167,29,173,30,172,31,175,32,176,33,174,34,177,35,178,36,170,37,167,38,166,39,181,40,180,41,181,42,156,43,183,44,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":33,"name":"sortDefault","flags":72,"length":5,"params":5,"locals":6,"maxStack":9,"code":[0,20,196618,326,327947,0,65556,327690,326,720957,327740,0,131092,10,65546,131082,0,196628,327690,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1221,1,1222,2,1223,3,1221,4,1219,5,1225,6,1226,7,1227,8,1225,9,1224,11,1230,12,1231,13,1232,14,1233,15,1234,16,1235,17,1236,18,1237,19,1238,20,1235,21,1239,22,1230,23,1229],"localNames":["target","into","holes","values","undefs","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1240,2,1246,3,1247,4,1248,5,1249,6,1250,7,1246,8,1244,9,1254,10,1252,11,1258,12,1256,13,1260,15,1264,16,1266,17,1265,18,1263,19,1262,20,1271,21,1272,22,1270,23,1269,24,1275,25,1276,26,1274,27,1275,28,1281,29,1282,30,1280,31,1279,32,1286,33,1287,34,1285,35,1284,36,1289,37,1290,38,1288,39,1283,40,1293,41,1294,42,1295,43,1298,44,1297,45,1296,46,1294,47,1292,48,1293,49,1302,50,1301,51,1302,52,1262,53,1304,54,1303],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1316,1,1317,2,1315,3,1314,4,1319,5,1320,6,1318,7,1312,9,1325,10,1321,16,1322,17,1329,18,1328,19,1327,20,1331,21,1332,22,1333,23,1334,24,1335,25,1331,27,1327,28,1338,29,1339,30,1340,31,1338,32,1337,33,1336,34,1342,35,1343,36,1344,37,1347,38,1348,39,1346,40,1349,41,1345,42,1342,44,1336,45,1351,46,1352,47,1353,48,1354,49,1356,50,1357,51,1355,52,1359,53,1360,54,1358,55,1351,57,1321,72,1362,73,1361],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1369,1,1370,2,1371,3,1372,4,1373,5,1369,6,1368],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1380,1,1381,2,1382,3,1383,4,1384,5,1380,6,1379],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1394,1,1395,2,1393,3,1392,4,1397,5,1398,6,1396,7,1391,8,1400,9,1401,10,1402,11,1404,12,1405,13,1403,14,1400,16,1407,17,1408,18,1409,19,1411,20,1412,21,1410,22,1407,24,1416,25,1417,26,1418,27,1419,28,1416,29,1414,30,1423,31,1421,32,1425,35,1431,36,1427,42,1428,43,1436,44,1437,45,1438,46,1440,48,1439,50,1440,51,1436,52,1435,53,1443,54,1444,55,1442,56,1441,57,1448,58,1449,59,1450,60,1451,61,1452,62,1453,63,1450,64,1448,65,1447,66,1455,67,1456,68,1457,69,1458,70,1459,71,1460,72,1455,74,1427,89,1462,90,1461],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1472,1,1473,2,1474,3,1472,4,1470,5,1476,6,1477,7,1478,8,1479,9,1480,10,1481,11,1476,13,1483,14,1482],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1484,2,1486,4,1487,6,1489,7,1487,8,1492,9,1493,10,1494,11,1495,12,1496,13,1497,14,1498,15,1494,16,1499,17,1500,18,1501,19,1492,21,1490],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1502,2,1504,4,1505,6,1507,7,1505,8,1510,9,1511,10,1512,11,1513,12,1514,13,1515,14,1516,15,1512,16,1517,17,1518,18,1519,19,1510,21,1508],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1528,1,1529,2,1530,3,1531,4,1528,7,1536,8,1537,9,1538,10,1539,11,1536,12,1532,18,1533,19,1544,20,1543,21,1546,22,1547,23,1545,24,1549,25,1550,26,1548,27,1551,28,1541,30,1532,45,1526],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1552,2,1557,3,1558,4,1559,5,1560,6,1561,7,1562,8,1563,9,1559,10,1564,11,1565,12,1557,13,1556],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1566,2,1571,3,1572,4,1573,5,1574,6,1575,7,1576,8,1577,9,1573,10,1578,11,1579,12,1571,13,1570],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1580,2,1585,3,1586,4,1587,5,1588,6,1589,7,1590,8,1591,9,1587,10,1592,11,1593,12,1585,13,1584],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1594,2,1599,3,1600,4,1601,5,1602,6,1603,7,1604,8,1605,9,1601,10,1606,11,1607,12,1599,13,1598],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1608,2,1613,3,1614,4,1615,5,1616,6,1617,7,1618,8,1619,9,1615,10,1620,11,1621,12,1613,13,1612],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1622,2,1627,3,1628,4,1629,5,1630,6,1631,7,1632,8,1633,9,1629,10,1634,11,1635,12,1627,13,1626],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1636,2,1641,3,1642,4,1643,5,1644,6,1645,7,1646,8,1647,9,1643,10,1648,11,1649,12,1641,13,1640],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7209021,1114132,65352,72,8454203,131082,1179652,50,7667775,131082,1245188,50,7929919,131082,1310724,50,8388669,0,851988,1376260,10,582,8454203,0,459019,131082,917508,50,9764927,131082,1048580,50,9240639,131082,1245188,50,9502783,131082,1441796,50,9765183,393226,196618,47,524555,0,590091,524298,16056381,720908,0,851988,1507332,131082,1245188,50,10747965,458762,10813499,10,582,14614602,14614587,852235,15535436,14811195,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12714045,589834,12648509,0,851988,1572868,458762,720906,838,5,14549051,131082,1245188,50,13631549,589834,13566013,0,851988,1638404,458762,720906,838,5,14549051,589834,131082,1441796,50,50,14549053,2,983307,14421326,70,1611,5,983050,67,11075644,70,75,11010107,70,15535437,11206715,917771,15273294,70,5,917514,64,5,15269947,458762,0,50,15925309,258,15990843,458762,67,65546,327690,70,655627,0,20,655370,326,54,17367101,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23199818,23199803,1048843,24121420,23396411,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19464253,0,851988,1572868,458762,786442,838,5,23134267,131082,1048580,50,20381757,589834,20316221,0,851988,1572868,458762,786442,838,5,23134267,131082,1245188,50,21168189,0,851988,1638404,458762,786442,838,5,23134267,131082,1310724,50,22216765,0,851988,589834,21823549,1638404,21889083,1572868,458762,786442,838,5,23134267,589834,131082,1441796,50,50,23134269,2,983307,23007310,70,1611,5,983050,67,17956924,70,75,17891387,70,24121421,18087995,1114379,23859278,70,5,1114122,64,5,23855163,458762,0,50,24510525,258,24576059,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[171,223,229,0,230,233,235,0,276,354,360,0,361,364,366,0],"finallies":[],"finallyOffsets":[],"sites":[0,1658,1,1659,2,1660,3,1658,4,1657,5,1656,6,1662,7,1663,8,1664,9,1667,10,1668,11,1666,12,1669,13,1665,14,1662,16,1675,17,1674,18,1673,19,1671,20,1679,21,1680,22,1678,23,1677,24,1682,25,1683,26,1684,27,1687,28,1688,29,1686,30,1689,31,1685,32,1682,34,1692,35,1693,36,1691,37,1690,38,1695,39,1696,40,1697,41,1700,42,1701,43,1699,44,1702,45,1698,46,1695,48,1707,49,1706,50,1704,51,1713,52,1712,53,1710,54,1718,55,1719,56,1720,57,1718,58,1717,59,1716,60,1722,61,1723,62,1724,63,1722,64,1721,65,1715,66,1726,67,1727,68,1728,69,1731,70,1732,71,1730,72,1733,73,1729,74,1726,76,1737,77,1738,78,1739,79,1740,80,1737,81,1735,82,1744,83,1745,84,1743,85,1742,86,1747,87,1748,88,1746,89,1741,90,1750,91,1749,92,1754,93,1755,94,1753,95,1752,96,1757,97,1758,98,1756,99,1751,100,1760,101,1759,102,1766,103,1767,104,1765,105,1764,106,1769,107,1768,109,1764,110,1774,111,1775,112,1773,113,1772,114,1777,115,1778,116,1776,117,1771,118,1780,119,1781,120,1779,121,1770,122,1782,123,1783,124,1784,125,1785,126,1782,127,1770,128,1786,129,1762,130,1792,131,1793,132,1791,133,1790,134,1798,135,1799,136,1797,137,1796,138,1801,139,1802,140,1800,141,1795,142,1804,143,1805,144,1803,145,1794,146,1807,147,1808,148,1806,149,1788,150,1810,152,1813,153,1812,155,1819,156,1820,157,1821,158,1824,159,1825,160,1823,161,1822,162,1826,163,1822,164,1827,165,1819,166,1815,172,1816,173,1837,174,1836,175,1838,176,1834,177,1833,178,1832,179,1831,180,1841,181,1842,182,1840,183,1839,184,1845,185,1844,186,1847,187,1848,188,1849,189,1850,190,1851,191,1847,193,1839,194,1854,195,1855,196,1853,197,1852,198,1858,199,1857,200,1860,201,1861,202,1862,203,1863,204,1864,205,1860,207,1852,208,1867,209,1869,210,1870,211,1868,212,1866,213,1865,214,1872,215,1871,222,1815,237,1876,238,1877,239,1875,240,1874,241,1878,242,1874,243,1879,244,1873,245,1886,246,1885,247,1883,248,1881,249,1889,250,1890,251,1891,252,1889,253,1888,254,1887,255,1893,256,1894,257,1895,258,1898,259,1899,260,1897,261,1900,262,1896,263,1893,266,1905,267,1906,268,1907,269,1908,270,1905,271,1901,277,1902,278,1913,279,1914,280,1915,281,1916,282,1917,283,1913,284,1912,285,1920,286,1921,287,1919,288,1918,289,1923,290,1924,291,1925,292,1926,293,1927,294,1923,296,1918,297,1930,298,1931,299,1929,300,1928,301,1934,302,1933,303,1936,304,1937,305,1938,306,1939,307,1940,308,1936,310,1928,311,1943,312,1944,313,1942,314,1941,315,1946,316,1947,317,1948,318,1949,319,1950,320,1946,322,1941,323,1953,324,1954,325,1952,326,1951,327,1956,328,1957,329,1959,330,1958,331,1960,332,1958,333,1961,334,1962,335,1963,336,1956,338,1951,339,1966,340,1968,341,1969,342,1967,343,1965,344,1964,345,1971,346,1970,353,1901,368,1975,369,1976,370,1974,371,1973,372,1977,373,1973,374,1978,375,1972],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1986,1,1984,3,1991,4,1987,10,1988,11,1995,12,1996,13,1997,14,1998,15,1995,16,1994,17,1993,18,2000,19,2001,20,2002,21,2003,22,2000,24,2005,25,2006,26,2007,27,2008,28,2009,29,2011,30,2012,31,2010,32,2008,33,2014,34,2015,35,2013,36,2016,37,2005,39,1987,54,2018,55,2017],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2026,1,2024,3,2031,4,2027,10,2028,11,2036,12,2035,13,2037,14,2034,15,2033,16,2039,17,2040,18,2041,19,2042,20,2039,22,2046,23,2048,24,2047,25,2045,26,2047,27,2045,28,2050,29,2045,30,2044,31,2027,46,2052,47,2053,48,2054,49,2052,50,2051],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2063,1,2061,3,2068,4,2064,10,2065,11,2072,12,2074,13,2073,14,2071,15,2073,16,2071,17,2076,18,2071,19,2070,20,2064,35,2078,36,2079,37,2080,38,2081,39,2082,40,2083,41,2078,42,2077],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2095,1,2096,2,2097,3,2095,4,2094,5,2093,6,2099,7,2100,8,2101,9,2105,10,2106,11,2104,12,2107,13,2108,14,2109,15,2107,16,2103,17,2110,18,2102,19,2099,21,2114,22,2112,24,2119,25,2115,31,2116,32,2123,33,2125,34,2124,35,2122,36,2124,37,2122,38,2127,39,2122,40,2121,41,2115,56,2131,57,2129,58,2134,59,2135,60,2133,61,2132,62,2139,63,2141,64,2140,65,2138,66,2137,67,2147,68,2148,69,2146,70,2148,71,2146,72,2152,73,2151,74,2154,75,2155,76,2153,77,2156,78,2149,79,2146,80,2145,81,2159,82,2158,83,2159,84,2137,85,2161,86,2162,87,2163,88,2164,89,2165,90,2161,91,2160],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2175,1,2176,2,2177,3,2175,4,2174,5,2173,6,2179,7,2180,8,2181,9,2182,10,2183,11,2184,12,2179,13,2178,14,2188,15,2186,16,2190,19,2196,20,2192,26,2193,27,2200,28,2201,29,2202,30,2200,31,2199,32,2198,33,2204,34,2205,35,2206,36,2208,37,2209,38,2207,39,2204,41,2213,42,2212,44,2218,45,2214,51,2215,52,2222,53,2224,54,2223,55,2221,56,2223,57,2221,58,2226,59,2227,60,2228,61,2226,62,2221,63,2220,64,2214,79,2232,80,2234,81,2233,82,2231,83,2233,84,2231,85,2236,86,2231,87,2230,88,2192,103,2238,104,2239,105,2240,106,2241,107,2242,108,2243,109,2238,110,2237],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2254,1,2252,2,2257,3,2259,4,2258,5,2256,6,2255,7,2266,8,2265,9,2269,10,2270,11,2268,12,2271,13,2267,14,2274,15,2275,16,2273,17,2276,18,2272,19,2277,20,2263,22,2280,23,2279,24,2280,25,2255,26,2250],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2287,1,2288,2,2289,3,2287,4,2286,5,2290,6,2291,7,2292,8,2294,9,2293,10,2290,11,2285,12,2297,13,2296,14,2299,15,2300,16,2301,17,2302,18,2303,19,2304,20,2305,21,2306,22,2307,23,2308,24,2304,25,2301,26,2299,27,2298],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2309,1,2317,2,2315,3,2321,13,2325,14,2324,16,2330,17,2326,23,2327,24,2333,25,2332,38,2326,53,2318,59,2337,60,2336,61,2335,62,2339,63,2340,64,2341,65,2339,67,2318,70,2313],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2342,2,2349,3,2350,4,2351,5,2352,6,2349,7,2347,8,2354,9,2355,10,2356,11,2357,12,2354,14,2359,15,2360,16,2361,17,2362,18,2363,19,2364,20,2365,21,2361,22,2359,23,2358],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2366,1,2375,2,2373,4,2379,14,2383,15,2382,16,2387,17,2385,19,2392,20,2388,26,2389,27,2395,28,2396,29,2397,30,2399,32,2398,34,2399,35,2395,36,2394,49,2388,64,2376,70,2403,71,2402,72,2401,73,2405,74,2406,75,2407,76,2405,78,2376,81,2371],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2408,2,2415,3,2416,4,2417,5,2418,6,2415,7,2413,8,2420,9,2421,10,2422,11,2423,12,2420,14,2425,15,2426,16,2427,17,2428,18,2429,19,2430,20,2431,21,2427,22,2425,23,2424],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2432,1,2441,2,2439,4,2445,14,2449,15,2448,16,2453,17,2451,19,2458,20,2454,26,2455,27,2460,28,2461,29,2462,30,2464,32,2463,34,2464,35,2460,36,2459,37,2467,38,2466,51,2454,66,2442,72,2471,73,2470,74,2469,75,2473,76,2474,77,2475,78,2473,80,2442,83,2437],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2476,2,2483,3,2484,4,2485,5,2486,6,2483,7,2481,8,2488,9,2489,10,2490,11,2491,12,2492,13,2493,14,2494,15,2495,16,2496,17,2497,18,2494,19,2490,20,2488,21,2487],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2498,1,2507,2,2505,3,2511,13,2515,14,2514,15,2518,16,2519,17,2517,18,2516,19,2521,20,2522,21,2523,22,2521,23,2520,30,2528,31,2524,37,2525,38,2532,39,2531,40,2532,41,2535,42,2534,55,2538,56,2539,57,2537,58,2536,59,2540,64,2524,79,2508,85,2544,86,2543,87,2542,88,2546,89,2547,90,2548,91,2546,93,2508,96,2503],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2549,2,2556,3,2557,4,2558,5,2559,6,2556,7,2554,8,2561,9,2562,10,2563,11,2564,12,2565,13,2566,14,2567,15,2568,16,2569,17,2570,18,2567,19,2563,20,2561,21,2560],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2571,1,2580,2,2578,3,2584,13,2588,14,2587,16,2593,17,2589,23,2590,24,2597,25,2598,26,2596,27,2595,28,2601,29,2600,30,2601,31,2595,32,2604,33,2603,46,2589,61,2581,67,2608,68,2607,69,2606,70,2610,71,2611,72,2612,73,2610,75,2581,78,2576],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2613,2,2620,3,2621,4,2622,5,2623,6,2620,7,2618,8,2625,9,2626,10,2627,11,2628,12,2625,14,2630,15,2631,16,2632,17,2633,18,2634,19,2635,20,2636,21,2632,22,2630,23,2629],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2637,1,2646,2,2644,4,2650,14,2654,15,2653,16,2658,17,2656,19,2663,20,2659,26,2660,28,2669,29,2670,30,2671,31,2672,32,2673,33,2675,35,2674,37,2675,38,2671,39,2676,40,2677,41,2669,42,2665,48,2666,49,2680,50,2679,67,2665,82,2659,97,2647,103,2684,104,2683,105,2682,106,2686,107,2687,108,2688,109,2686,111,2647,114,2642],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2696,1,2695,2,2694,4,2699,5,2698],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2709,1,2708,2,2706,3,2716,4,2717,5,2715,6,2714,7,2719,8,2721,9,2720,10,2718,11,2713,12,2722,13,2713,14,2724,15,2726,16,2727,17,2725,18,2723,19,2711,20,2731,21,2732,22,2730,23,2729,24,2734,25,2735,26,2733,27,2728,28,2737,29,2738,30,2739,31,2744,32,2745,33,2743,34,2746,35,2742,36,2747,37,2741,38,2748,39,2740,40,2737,42,2750,43,2749],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2761,1,2760,2,2762,3,2759,4,2758,5,2764,6,2763,7,2758,8,2766,9,2767,10,2768,11,2766,12,2765,13,2757,14,2770,15,2771,16,2772,17,2776,18,2777,19,2775,20,2778,21,2779,22,2780,23,2778,24,2774,25,2781,26,2773,27,2770,29,2786,30,2788,31,2787,32,2785,33,2783,34,2791,35,2792,36,2796,37,2797,38,2795,39,2794,40,2799,41,2800,42,2798,43,2793,44,2801,45,2793,46,2805,47,2804,48,2802,49,2806,50,2791,51,2790],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2815,1,2814,2,2812,3,2821,4,2822,5,2820,6,2819,7,2824,8,2825,9,2823,10,2818,11,2827,12,2828,13,2832,14,2831,15,2829,16,2827,17,2826,18,2817,19,2834,20,2835,21,2836,22,2837,23,2834,25,2810],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2838,2,2844,3,2842,5,2849,6,2850,7,2851,8,2852,9,2849,10,2845,16,2846,17,2856,18,2858,19,2857,20,2855,21,2857,22,2855,23,2860,24,2855,25,2854,26,2845,41,2862,42,2861],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2863,2,2865,4,2866,6,2872,7,2873,8,2874,9,2875,10,2872,11,2870,12,2877,13,2878,14,2879,15,2880,16,2877,18,2885,19,2886,20,2884,21,2882,22,2892,23,2891,24,2894,25,2890,26,2888,27,2898,28,2896,30,2903,31,2899,37,2900,38,2906,39,2905,40,2910,41,2911,42,2912,43,2913,44,2914,45,2910,46,2909,47,2905,48,2918,49,2917,50,2922,51,2921,52,2925,53,2924,54,2925,55,2899,70,2928,71,2927,72,2926,73,2930,74,2931,75,2932,76,2933,77,2930,79,2935,80,2934],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2936,2,2941,3,2942,4,2943,5,2944,6,2945,7,2941,9,2939],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2946,2,2951,3,2952,4,2953,5,2954,6,2955,7,2951,8,2950],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2956,2,2961,3,2962,4,2963,5,2964,6,2965,7,2961,8,2960],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2966,2,2971,3,2972,4,2973,5,2974,6,2975,7,2971,8,2970],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2985,1,2986,2,2987,3,2988,4,2985,5,2983,6,2990,7,2991,8,2992,9,2994,10,2995,11,2993,12,2990,14,2999,15,2997,16,3001,19,3007,20,3003,26,3004,27,3012,28,3013,29,3014,30,3016,32,3015,34,3016,35,3012,36,3011,37,3020,38,3021,39,3019,40,3018,41,3022,42,3017,43,3024,44,3023,51,3028,52,3029,53,3027,54,3026,55,3031,56,3030,57,3025,58,3033,59,3032,66,3037,67,3038,68,3036,69,3035,70,3039,71,3034,72,3041,73,3040,80,3003,95,3045,96,3046,97,3044,98,3043,99,3047,100,3043,101,3050,102,3051,103,3049,104,3048,105,3052,106,3048,107,3053,108,3042],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3064,1,3065,2,3063,3,3061,4,3067,5,3068,6,3069,7,3067,8,3066,12,3074,13,3075,14,3076,15,3074,16,3072,17,3080,18,3078,19,3082,21,3086,22,3088,23,3087,24,3085,25,3084,26,3094,27,3095,28,3096,29,3098,30,3099,31,3097,32,3100,33,3094,34,3093,35,3103,36,3104,37,3102,38,3101,39,3108,40,3110,41,3111,42,3109,43,3107,44,3106,45,3101,46,3115,47,3117,48,3118,49,3116,50,3114,51,3116,52,3114,53,3119,54,3114,55,3113,56,3122,57,3121,58,3122,59,3084,60,3127,61,3126,62,3128,63,3129,64,3124,65,3123],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3139,1,3137,2,3143,3,3141,4,3146,5,3148,6,3147,7,3145,8,3144,9,3153,10,3157,11,3158,12,3156,13,3159,14,3155,15,3160,16,3161,17,3162,18,3163,19,3162,20,3167,21,3168,22,3166,23,3169,24,3165,25,3164,40,3162,41,3160,42,3154,43,3152,44,3153,45,3172,46,3171,47,3172,48,3144,49,3175,50,3176,51,3174,52,3173],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"8cec7c4116877903","codes":[{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,524349,10,67,65546,65540,50,1310783,65546,131076,50,1311039,0,196628,10,326,1507389,262148,1572923,327684,131339,131082,262148,50,2031677,327684,2097211,262148,196875,0,393236,10,131082,582,262411,262154,0,51,3670077,393228,10,262154,70,393483,0,458772,393226,326,54,3670077,393226,67,0,393236,10,196618,582,327947,327690,0,51,5177405,458764,10,327690,70,459019,0,458772,458762,326,54,5177405,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsDataObj","string","default","$IsDate","toString","valueOf","$GetMethod","$IsObj","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,8,1,9,2,10,3,8,4,7,5,6,6,12,7,11,8,19,9,20,10,18,11,17,12,23,13,24,14,22,15,21,16,25,17,26,18,27,19,25,20,16,21,28,22,16,23,29,24,14,25,35,26,36,27,34,28,33,29,37,30,33,31,38,32,31,33,42,34,43,35,44,36,45,37,42,38,40,39,48,40,49,41,47,42,46,44,57,45,56,46,54,47,52,48,60,49,61,50,62,51,60,52,59,53,58,54,64,55,63,56,68,57,69,58,70,59,71,60,68,61,66,62,74,63,75,64,73,65,72,67,83,68,82,69,80,70,78,71,86,72,87,73,88,74,86,75,85,76,84,77,90,78,89,79,92,80,93,81,94,82,95,83,92,85,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,101,1,102,2,103,3,104,4,105,5,106,6,103,7,101,8,100],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,112,1,113,2,114,3,115,4,116,5,117,6,114,7,112,8,111],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,124,1,125,2,126,3,127,4,128,5,129,6,130,7,127,8,124,9,123],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,139,1,140,2,141,3,142,4,143,5,144,6,145,7,142,8,139,9,137,10,149,11,150,12,148,13,147,14,152,15,153,16,151,17,147,18,155,19,156,20,154,21,146],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,163,1,164,2,165,3,166,4,167,5,168,6,169,7,166,8,163,9,162],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,179,1,180,2,181,3,182,4,183,5,179,6,177,7,186,8,187,9,185,10,184,11,189,12,190,13,191,14,192,15,193,16,189,17,188,18,196,19,197,20,195,21,194,23,202,24,203,25,204,26,205,27,202,28,200,29,207,30,208,31,209,32,210,33,211,34,207,35,206,36,217,37,218,38,216,39,215,40,219,41,215,42,220,43,213,44,224,45,225,46,226,47,227,48,224,49,222,50,231,51,232,52,233,53,234,54,231,55,229,56,236,57,237,58,238,59,239,60,240,61,236,62,235],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":8,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,248,1,249,2,250,3,251,4,249,5,247,6,246],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":9,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,260,1,261,2,262,3,263,4,261,5,259,6,257],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":10,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,274,1,273,9,279,10,280,11,281,12,279,13,277,14,285,15,286,16,287,17,288,18,285,19,283,20,292,21,293,22,294,23,295,24,292,25,290,26,300,27,299,28,297,29,305,30,303,31,309,32,307,33,312,34,313,35,311,36,310,40,319,41,320,42,318,43,316,44,324,45,325,46,326,47,327,48,324,49,322,50,332,51,333,52,334,53,332,54,331,55,335,56,336,57,337,58,338,59,335,60,331,61,339,62,329,63,343,64,344,65,342,66,344,67,342,68,346,69,345,70,347,71,348,72,349,73,350,74,347,75,345,76,351,77,342,78,341,79,354,80,353,81,354,82,310,83,358,84,359,85,357,86,359,87,357,88,360,89,357,90,356,91,364,92,365,93,366,94,367,95,368,96,369,97,370,98,364,99,362,100,373,101,374,102,375,103,373,104,372,105,371,106,377,107,376,108,381,109,380,110,273,111,272],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":11,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,786454,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,382,5,392,7,391,8,389,9,639,10,638],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":12,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,392,1,400,2,401,3,399,4,398,5,403,6,404,7,405,8,406,9,403,11,411,12,412,13,410,14,408,15,414,16,415,17,416,18,414,19,413,20,420,21,419,22,418,23,423,24,424,25,425,26,426,27,423,29,431,30,430,33,429,34,433,35,434,36,435,37,433,38,432,40,441,41,440,42,438,43,444,44,445,45,446,46,444,47,443,48,453,49,452,50,454,51,450,52,449,53,457,54,458,55,456,56,455,57,465,58,464,59,466,60,467,61,462,62,461,63,471,64,472,65,473,66,474,67,475,68,471,69,469,70,478,71,479,72,477,73,476,74,481,75,480,76,484,77,485,78,483,79,482,80,487,81,486,82,490,83,491,84,489,85,488,86,493,87,492,88,496,89,497,90,495,91,494,92,499,93,500,94,501,95,502,96,499,97,498,98,508,99,509,100,507,101,506,102,510,103,511,104,512,105,510,106,506,107,513,108,504,109,517,110,519,111,518,112,516,113,518,114,516,115,521,116,516,117,515,118,523,120,526,121,527,122,528,123,526,124,525,127,533,128,532,129,538,130,537,131,535,132,543,133,541,134,546,135,547,136,545,137,544,139,553,140,554,141,555,142,556,143,557,144,558,145,556,146,560,147,561,148,559,149,553,150,552,181,550,182,565,183,566,184,564,185,566,186,564,187,569,188,570,189,568,190,567,191,571,192,567,193,572,194,564,195,563,196,575,197,574,198,575,199,544,200,525,203,580,204,581,205,580,206,579,207,585,208,586,209,587,210,588,211,589,212,585,213,583,214,593,215,591,216,596,217,598,218,597,219,595,220,594,223,605,224,606,225,604,226,602,227,611,228,612,229,613,230,614,231,616,232,617,233,615,234,611,235,610,266,608,267,620,268,621,269,619,270,618,271,623,272,624,273,625,274,626,275,627,276,628,277,623,279,631,280,630,281,631,282,594,283,633,284,634,285,635,286,633,288,637,289,636],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":13,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,653,1,654,2,655,3,656,4,657,5,658,6,654,7,659,8,662,9,660,10,663,11,664,12,653,13,652,14,651,15,650,16,648,17,668,18,669,19,670,20,671,21,672,22,673,23,668,24,667],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":14,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,681,1,682,2,683,3,684,4,685,5,681,6,680],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":15,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,694,1,695,2,696,3,697,4,694,5,692,7,702,8,698,14,699,15,705,16,706,17,707,18,708,19,705,21,698,36,710,37,711,38,712,39,710,41,690],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":16,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,719,1,720,2,724,3,723,4,721,5,719,6,718],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":17,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,735,1,736,2,737,3,735,4,733,5,743,6,744,7,742,8,741,9,745,10,746,11,747,12,745,13,741,14,748,15,749,16,750,17,751,18,752,19,748,20,739,21,756,22,757,23,755,24,754,25,759,26,760,27,758,28,753,30,764,31,765,32,763,33,762,34,768,35,769,36,770,37,768,39,771,41,775,42,776,43,777,44,778,45,779,46,775,47,773,48,783,49,784,50,782,51,781,52,786,53,787,54,785,55,780,56,790,57,791,58,792,59,796,60,795,61,793,62,797,63,790,65,799,66,800,67,801,68,799,70,802,72,807,73,806,74,811,75,810,76,812,77,808,78,806,79,816,80,815,81,813,82,804,83,818,84,819,85,820,86,821,87,822,88,818,90,829,91,828,92,827,93,826,94,824,95,835,96,834,97,832,98,838,99,839,100,840,101,841,102,842,103,844,104,845,105,843,106,838,108,731],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":18,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,854,1,853,2,851,3,859,4,860,5,858,6,857,7,862,8,863,9,861,10,856,11,868,12,867,13,865,15,849],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"0d2b321257a5648b"},"index":19,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,878,1,876,2,882,3,880,4,885,5,887,6,886,7,884,8,883,12,894,13,895,14,893,15,891,16,899,17,900,18,898,19,897,20,901,21,902,22,903,23,901,24,896,25,908,26,907,27,906,28,912,29,913,30,914,31,915,32,916,33,917,34,913,35,918,36,921,37,919,38,922,39,923,40,912,41,910,42,929,43,928,44,927,45,925,46,934,47,933,48,932,49,931,50,941,51,940,52,945,53,944,54,943,55,939,56,938,57,931,58,950,59,951,60,949,61,951,62,949,63,952,64,953,65,954,66,956,67,955,68,958,69,959,70,952,71,949,72,948,73,962,74,961,75,962,76,883,77,965,78,966,79,964,80,963,81,969,82,970,83,968,84,967,85,973,86,974,87,972,88,971,89,976,90,977,91,978,92,976,93,975,94,980,95,981,96,982,97,983,98,984,99,980,101,874],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} +{"@prelude":{"text":"f135511dc7fc0839","codes":[{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65352,65546,328,262411,3,327947,327690,65546,46,1900605,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,458812,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,52,2,54,3,52,4,50,5,58,6,56,7,61,8,62,9,60,10,59,11,67,12,68,13,66,14,68,15,66,16,72,17,71,18,74,19,75,20,73,21,76,22,69,23,66,24,65,25,79,26,78,27,79,28,59,29,81,30,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,65352,262154,328,327947,3,393483,393226,262154,46,2818109,393226,10,33,2555965,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,1048636,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,149,11,151,12,149,13,147,14,155,15,153,16,158,17,159,18,157,19,156,20,163,21,164,22,162,23,161,24,168,25,169,26,167,27,169,28,167,29,173,30,172,31,175,32,176,33,174,34,177,35,178,36,170,37,167,38,166,39,181,40,180,41,181,42,156,43,183,44,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":33,"name":"sortDefault","flags":72,"length":5,"params":5,"locals":6,"maxStack":9,"code":[0,20,196618,326,327947,0,65556,327690,326,720957,327740,0,131092,10,65546,131082,0,196628,327690,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1221,1,1222,2,1223,3,1221,4,1219,5,1225,6,1226,7,1227,8,1225,9,1224,11,1230,12,1231,13,1232,14,1233,15,1234,16,1235,17,1236,18,1237,19,1238,20,1235,21,1239,22,1230,23,1229],"localNames":["target","into","holes","values","undefs","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1240,2,1246,3,1247,4,1248,5,1249,6,1250,7,1246,8,1244,9,1254,10,1252,11,1258,12,1256,13,1260,15,1264,16,1266,17,1265,18,1263,19,1262,20,1271,21,1272,22,1270,23,1269,24,1275,25,1276,26,1274,27,1275,28,1281,29,1282,30,1280,31,1279,32,1286,33,1287,34,1285,35,1284,36,1289,37,1290,38,1288,39,1283,40,1293,41,1294,42,1295,43,1298,44,1297,45,1296,46,1294,47,1292,48,1293,49,1302,50,1301,51,1302,52,1262,53,1304,54,1303],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1316,1,1317,2,1315,3,1314,4,1319,5,1320,6,1318,7,1312,9,1325,10,1321,16,1322,17,1329,18,1328,19,1327,20,1331,21,1332,22,1333,23,1334,24,1335,25,1331,27,1327,28,1338,29,1339,30,1340,31,1338,32,1337,33,1336,34,1342,35,1343,36,1344,37,1347,38,1348,39,1346,40,1349,41,1345,42,1342,44,1336,45,1351,46,1352,47,1353,48,1354,49,1356,50,1357,51,1355,52,1359,53,1360,54,1358,55,1351,57,1321,72,1362,73,1361],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1369,1,1370,2,1371,3,1372,4,1373,5,1369,6,1368],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1380,1,1381,2,1382,3,1383,4,1384,5,1380,6,1379],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1394,1,1395,2,1393,3,1392,4,1397,5,1398,6,1396,7,1391,8,1400,9,1401,10,1402,11,1404,12,1405,13,1403,14,1400,16,1407,17,1408,18,1409,19,1411,20,1412,21,1410,22,1407,24,1416,25,1417,26,1418,27,1419,28,1416,29,1414,30,1423,31,1421,32,1425,35,1431,36,1427,42,1428,43,1436,44,1437,45,1438,46,1440,48,1439,50,1440,51,1436,52,1435,53,1443,54,1444,55,1442,56,1441,57,1448,58,1449,59,1450,60,1451,61,1452,62,1453,63,1450,64,1448,65,1447,66,1455,67,1456,68,1457,69,1458,70,1459,71,1460,72,1455,74,1427,89,1462,90,1461],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1472,1,1473,2,1474,3,1472,4,1470,5,1476,6,1477,7,1478,8,1479,9,1480,10,1481,11,1476,13,1483,14,1482],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1484,2,1486,4,1487,6,1489,7,1487,8,1492,9,1493,10,1494,11,1495,12,1496,13,1497,14,1498,15,1494,16,1499,17,1500,18,1501,19,1492,21,1490],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1502,2,1504,4,1505,6,1507,7,1505,8,1510,9,1511,10,1512,11,1513,12,1514,13,1515,14,1516,15,1512,16,1517,17,1518,18,1519,19,1510,21,1508],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1528,1,1529,2,1530,3,1531,4,1528,7,1536,8,1537,9,1538,10,1539,11,1536,12,1532,18,1533,19,1544,20,1543,21,1546,22,1547,23,1545,24,1549,25,1550,26,1548,27,1551,28,1541,30,1532,45,1526],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1552,2,1557,3,1558,4,1559,5,1560,6,1561,7,1562,8,1563,9,1559,10,1564,11,1565,12,1557,13,1556],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1566,2,1571,3,1572,4,1573,5,1574,6,1575,7,1576,8,1577,9,1573,10,1578,11,1579,12,1571,13,1570],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1580,2,1585,3,1586,4,1587,5,1588,6,1589,7,1590,8,1591,9,1587,10,1592,11,1593,12,1585,13,1584],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1594,2,1599,3,1600,4,1601,5,1602,6,1603,7,1604,8,1605,9,1601,10,1606,11,1607,12,1599,13,1598],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1608,2,1613,3,1614,4,1615,5,1616,6,1617,7,1618,8,1619,9,1615,10,1620,11,1621,12,1613,13,1612],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1622,2,1627,3,1628,4,1629,5,1630,6,1631,7,1632,8,1633,9,1629,10,1634,11,1635,12,1627,13,1626],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1636,2,1641,3,1642,4,1643,5,1644,6,1645,7,1646,8,1647,9,1643,10,1648,11,1649,12,1641,13,1640],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7209021,1114132,65352,72,8454203,131082,1179652,50,7667775,131082,1245188,50,7929919,131082,1310724,50,8388669,0,851988,1376260,10,582,8454203,0,459019,131082,917508,50,9764927,131082,1048580,50,9240639,131082,1245188,50,9502783,131082,1441796,50,9765183,393226,196618,47,524555,0,590091,524298,16056381,720908,0,851988,1507332,131082,1245188,50,10747965,458762,10813499,10,582,14614602,14614587,852235,15535436,14811195,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12714045,589834,12648509,0,851988,1572868,458762,720906,838,5,14549051,131082,1245188,50,13631549,589834,13566013,0,851988,1638404,458762,720906,838,5,14549051,589834,131082,1441796,50,50,14549053,2,983307,14421326,70,1611,5,983050,67,11075644,70,75,11010107,70,15535437,11206715,917771,15273294,70,5,917514,64,5,15269947,458762,0,50,15925309,258,15990843,458762,67,65546,327690,70,655627,0,20,655370,326,54,17367101,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23199818,23199803,1048843,24121420,23396411,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19464253,0,851988,1572868,458762,786442,838,5,23134267,131082,1048580,50,20381757,589834,20316221,0,851988,1572868,458762,786442,838,5,23134267,131082,1245188,50,21168189,0,851988,1638404,458762,786442,838,5,23134267,131082,1310724,50,22216765,0,851988,589834,21823549,1638404,21889083,1572868,458762,786442,838,5,23134267,589834,131082,1441796,50,50,23134269,2,983307,23007310,70,1611,5,983050,67,17956924,70,75,17891387,70,24121421,18087995,1114379,23859278,70,5,1114122,64,5,23855163,458762,0,50,24510525,258,24576059,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[171,223,229,0,230,233,235,0,276,354,360,0,361,364,366,0],"finallies":[],"finallyOffsets":[],"sites":[0,1658,1,1659,2,1660,3,1658,4,1657,5,1656,6,1662,7,1663,8,1664,9,1667,10,1668,11,1666,12,1669,13,1665,14,1662,16,1675,17,1674,18,1673,19,1671,20,1679,21,1680,22,1678,23,1677,24,1682,25,1683,26,1684,27,1687,28,1688,29,1686,30,1689,31,1685,32,1682,34,1692,35,1693,36,1691,37,1690,38,1695,39,1696,40,1697,41,1700,42,1701,43,1699,44,1702,45,1698,46,1695,48,1707,49,1706,50,1704,51,1713,52,1712,53,1710,54,1718,55,1719,56,1720,57,1718,58,1717,59,1716,60,1722,61,1723,62,1724,63,1722,64,1721,65,1715,66,1726,67,1727,68,1728,69,1731,70,1732,71,1730,72,1733,73,1729,74,1726,76,1737,77,1738,78,1739,79,1740,80,1737,81,1735,82,1744,83,1745,84,1743,85,1742,86,1747,87,1748,88,1746,89,1741,90,1750,91,1749,92,1754,93,1755,94,1753,95,1752,96,1757,97,1758,98,1756,99,1751,100,1760,101,1759,102,1766,103,1767,104,1765,105,1764,106,1769,107,1768,109,1764,110,1774,111,1775,112,1773,113,1772,114,1777,115,1778,116,1776,117,1771,118,1780,119,1781,120,1779,121,1770,122,1782,123,1783,124,1784,125,1785,126,1782,127,1770,128,1786,129,1762,130,1792,131,1793,132,1791,133,1790,134,1798,135,1799,136,1797,137,1796,138,1801,139,1802,140,1800,141,1795,142,1804,143,1805,144,1803,145,1794,146,1807,147,1808,148,1806,149,1788,150,1810,152,1813,153,1812,155,1819,156,1820,157,1821,158,1824,159,1825,160,1823,161,1822,162,1826,163,1822,164,1827,165,1819,166,1815,172,1816,173,1837,174,1836,175,1838,176,1834,177,1833,178,1832,179,1831,180,1841,181,1842,182,1840,183,1839,184,1845,185,1844,186,1847,187,1848,188,1849,189,1850,190,1851,191,1847,193,1839,194,1854,195,1855,196,1853,197,1852,198,1858,199,1857,200,1860,201,1861,202,1862,203,1863,204,1864,205,1860,207,1852,208,1867,209,1869,210,1870,211,1868,212,1866,213,1865,214,1872,215,1871,222,1815,237,1876,238,1877,239,1875,240,1874,241,1878,242,1874,243,1879,244,1873,245,1886,246,1885,247,1883,248,1881,249,1889,250,1890,251,1891,252,1889,253,1888,254,1887,255,1893,256,1894,257,1895,258,1898,259,1899,260,1897,261,1900,262,1896,263,1893,266,1905,267,1906,268,1907,269,1908,270,1905,271,1901,277,1902,278,1913,279,1914,280,1915,281,1916,282,1917,283,1913,284,1912,285,1920,286,1921,287,1919,288,1918,289,1923,290,1924,291,1925,292,1926,293,1927,294,1923,296,1918,297,1930,298,1931,299,1929,300,1928,301,1934,302,1933,303,1936,304,1937,305,1938,306,1939,307,1940,308,1936,310,1928,311,1943,312,1944,313,1942,314,1941,315,1946,316,1947,317,1948,318,1949,319,1950,320,1946,322,1941,323,1953,324,1954,325,1952,326,1951,327,1956,328,1957,329,1959,330,1958,331,1960,332,1958,333,1961,334,1962,335,1963,336,1956,338,1951,339,1966,340,1968,341,1969,342,1967,343,1965,344,1964,345,1971,346,1970,353,1901,368,1975,369,1976,370,1974,371,1973,372,1977,373,1973,374,1978,375,1972],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1986,1,1984,3,1991,4,1987,10,1988,11,1995,12,1996,13,1997,14,1998,15,1995,16,1994,17,1993,18,2000,19,2001,20,2002,21,2003,22,2000,24,2005,25,2006,26,2007,27,2008,28,2009,29,2011,30,2012,31,2010,32,2008,33,2014,34,2015,35,2013,36,2016,37,2005,39,1987,54,2018,55,2017],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2026,1,2024,3,2031,4,2027,10,2028,11,2036,12,2035,13,2037,14,2034,15,2033,16,2039,17,2040,18,2041,19,2042,20,2039,22,2046,23,2048,24,2047,25,2045,26,2047,27,2045,28,2050,29,2045,30,2044,31,2027,46,2052,47,2053,48,2054,49,2052,50,2051],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2063,1,2061,3,2068,4,2064,10,2065,11,2072,12,2074,13,2073,14,2071,15,2073,16,2071,17,2076,18,2071,19,2070,20,2064,35,2078,36,2079,37,2080,38,2081,39,2082,40,2083,41,2078,42,2077],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2095,1,2096,2,2097,3,2095,4,2094,5,2093,6,2099,7,2100,8,2101,9,2105,10,2106,11,2104,12,2107,13,2108,14,2109,15,2107,16,2103,17,2110,18,2102,19,2099,21,2114,22,2112,24,2119,25,2115,31,2116,32,2123,33,2125,34,2124,35,2122,36,2124,37,2122,38,2127,39,2122,40,2121,41,2115,56,2131,57,2129,58,2134,59,2135,60,2133,61,2132,62,2139,63,2141,64,2140,65,2138,66,2137,67,2147,68,2148,69,2146,70,2148,71,2146,72,2152,73,2151,74,2154,75,2155,76,2153,77,2156,78,2149,79,2146,80,2145,81,2159,82,2158,83,2159,84,2137,85,2161,86,2162,87,2163,88,2164,89,2165,90,2161,91,2160],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2175,1,2176,2,2177,3,2175,4,2174,5,2173,6,2179,7,2180,8,2181,9,2182,10,2183,11,2184,12,2179,13,2178,14,2188,15,2186,16,2190,19,2196,20,2192,26,2193,27,2200,28,2201,29,2202,30,2200,31,2199,32,2198,33,2204,34,2205,35,2206,36,2208,37,2209,38,2207,39,2204,41,2213,42,2212,44,2218,45,2214,51,2215,52,2222,53,2224,54,2223,55,2221,56,2223,57,2221,58,2226,59,2227,60,2228,61,2226,62,2221,63,2220,64,2214,79,2232,80,2234,81,2233,82,2231,83,2233,84,2231,85,2236,86,2231,87,2230,88,2192,103,2238,104,2239,105,2240,106,2241,107,2242,108,2243,109,2238,110,2237],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2254,1,2252,2,2257,3,2259,4,2258,5,2256,6,2255,7,2266,8,2265,9,2269,10,2270,11,2268,12,2271,13,2267,14,2274,15,2275,16,2273,17,2276,18,2272,19,2277,20,2263,22,2280,23,2279,24,2280,25,2255,26,2250],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2287,1,2288,2,2289,3,2287,4,2286,5,2290,6,2291,7,2292,8,2294,9,2293,10,2290,11,2285,12,2297,13,2296,14,2299,15,2300,16,2301,17,2302,18,2303,19,2304,20,2305,21,2306,22,2307,23,2308,24,2304,25,2301,26,2299,27,2298],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2309,1,2317,2,2315,3,2321,13,2325,14,2324,16,2330,17,2326,23,2327,24,2333,25,2332,38,2326,53,2318,59,2337,60,2336,61,2335,62,2339,63,2340,64,2341,65,2339,67,2318,70,2313],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2342,2,2349,3,2350,4,2351,5,2352,6,2349,7,2347,8,2354,9,2355,10,2356,11,2357,12,2354,14,2359,15,2360,16,2361,17,2362,18,2363,19,2364,20,2365,21,2361,22,2359,23,2358],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2366,1,2375,2,2373,4,2379,14,2383,15,2382,16,2387,17,2385,19,2392,20,2388,26,2389,27,2395,28,2396,29,2397,30,2399,32,2398,34,2399,35,2395,36,2394,49,2388,64,2376,70,2403,71,2402,72,2401,73,2405,74,2406,75,2407,76,2405,78,2376,81,2371],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2408,2,2415,3,2416,4,2417,5,2418,6,2415,7,2413,8,2420,9,2421,10,2422,11,2423,12,2420,14,2425,15,2426,16,2427,17,2428,18,2429,19,2430,20,2431,21,2427,22,2425,23,2424],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2432,1,2441,2,2439,4,2445,14,2449,15,2448,16,2453,17,2451,19,2458,20,2454,26,2455,27,2460,28,2461,29,2462,30,2464,32,2463,34,2464,35,2460,36,2459,37,2467,38,2466,51,2454,66,2442,72,2471,73,2470,74,2469,75,2473,76,2474,77,2475,78,2473,80,2442,83,2437],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2476,2,2483,3,2484,4,2485,5,2486,6,2483,7,2481,8,2488,9,2489,10,2490,11,2491,12,2492,13,2493,14,2494,15,2495,16,2496,17,2497,18,2494,19,2490,20,2488,21,2487],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2498,1,2507,2,2505,3,2511,13,2515,14,2514,15,2518,16,2519,17,2517,18,2516,19,2521,20,2522,21,2523,22,2521,23,2520,30,2528,31,2524,37,2525,38,2532,39,2531,40,2532,41,2535,42,2534,55,2538,56,2539,57,2537,58,2536,59,2540,64,2524,79,2508,85,2544,86,2543,87,2542,88,2546,89,2547,90,2548,91,2546,93,2508,96,2503],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2549,2,2556,3,2557,4,2558,5,2559,6,2556,7,2554,8,2561,9,2562,10,2563,11,2564,12,2565,13,2566,14,2567,15,2568,16,2569,17,2570,18,2567,19,2563,20,2561,21,2560],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2571,1,2580,2,2578,3,2584,13,2588,14,2587,16,2593,17,2589,23,2590,24,2597,25,2598,26,2596,27,2595,28,2601,29,2600,30,2601,31,2595,32,2604,33,2603,46,2589,61,2581,67,2608,68,2607,69,2606,70,2610,71,2611,72,2612,73,2610,75,2581,78,2576],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2613,2,2620,3,2621,4,2622,5,2623,6,2620,7,2618,8,2625,9,2626,10,2627,11,2628,12,2625,14,2630,15,2631,16,2632,17,2633,18,2634,19,2635,20,2636,21,2632,22,2630,23,2629],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2637,1,2646,2,2644,4,2650,14,2654,15,2653,16,2658,17,2656,19,2663,20,2659,26,2660,28,2669,29,2670,30,2671,31,2672,32,2673,33,2675,35,2674,37,2675,38,2671,39,2676,40,2677,41,2669,42,2665,48,2666,49,2680,50,2679,67,2665,82,2659,97,2647,103,2684,104,2683,105,2682,106,2686,107,2687,108,2688,109,2686,111,2647,114,2642],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2696,1,2695,2,2694,4,2699,5,2698],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2709,1,2708,2,2706,3,2716,4,2717,5,2715,6,2714,7,2719,8,2721,9,2720,10,2718,11,2713,12,2722,13,2713,14,2724,15,2726,16,2727,17,2725,18,2723,19,2711,20,2731,21,2732,22,2730,23,2729,24,2734,25,2735,26,2733,27,2728,28,2737,29,2738,30,2739,31,2744,32,2745,33,2743,34,2746,35,2742,36,2747,37,2741,38,2748,39,2740,40,2737,42,2750,43,2749],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2761,1,2760,2,2762,3,2759,4,2758,5,2764,6,2763,7,2758,8,2766,9,2767,10,2768,11,2766,12,2765,13,2757,14,2770,15,2771,16,2772,17,2776,18,2777,19,2775,20,2778,21,2779,22,2780,23,2778,24,2774,25,2781,26,2773,27,2770,29,2786,30,2788,31,2787,32,2785,33,2783,34,2791,35,2792,36,2796,37,2797,38,2795,39,2794,40,2799,41,2800,42,2798,43,2793,44,2801,45,2793,46,2805,47,2804,48,2802,49,2806,50,2791,51,2790],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2815,1,2814,2,2812,3,2821,4,2822,5,2820,6,2819,7,2824,8,2825,9,2823,10,2818,11,2827,12,2828,13,2832,14,2831,15,2829,16,2827,17,2826,18,2817,19,2834,20,2835,21,2836,22,2837,23,2834,25,2810],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2838,2,2844,3,2842,5,2849,6,2850,7,2851,8,2852,9,2849,10,2845,16,2846,17,2856,18,2858,19,2857,20,2855,21,2857,22,2855,23,2860,24,2855,25,2854,26,2845,41,2862,42,2861],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2863,2,2865,4,2866,6,2872,7,2873,8,2874,9,2875,10,2872,11,2870,12,2877,13,2878,14,2879,15,2880,16,2877,18,2885,19,2886,20,2884,21,2882,22,2892,23,2891,24,2894,25,2890,26,2888,27,2898,28,2896,30,2903,31,2899,37,2900,38,2906,39,2905,40,2910,41,2911,42,2912,43,2913,44,2914,45,2910,46,2909,47,2905,48,2918,49,2917,50,2922,51,2921,52,2925,53,2924,54,2925,55,2899,70,2928,71,2927,72,2926,73,2930,74,2931,75,2932,76,2933,77,2930,79,2935,80,2934],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2936,2,2941,3,2942,4,2943,5,2944,6,2945,7,2941,9,2939],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2946,2,2951,3,2952,4,2953,5,2954,6,2955,7,2951,8,2950],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2956,2,2961,3,2962,4,2963,5,2964,6,2965,7,2961,8,2960],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2966,2,2971,3,2972,4,2973,5,2974,6,2975,7,2971,8,2970],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2985,1,2986,2,2987,3,2988,4,2985,5,2983,6,2990,7,2991,8,2992,9,2994,10,2995,11,2993,12,2990,14,2999,15,2997,16,3001,19,3007,20,3003,26,3004,27,3012,28,3013,29,3014,30,3016,32,3015,34,3016,35,3012,36,3011,37,3020,38,3021,39,3019,40,3018,41,3022,42,3017,43,3024,44,3023,51,3028,52,3029,53,3027,54,3026,55,3031,56,3030,57,3025,58,3033,59,3032,66,3037,67,3038,68,3036,69,3035,70,3039,71,3034,72,3041,73,3040,80,3003,95,3045,96,3046,97,3044,98,3043,99,3047,100,3043,101,3050,102,3051,103,3049,104,3048,105,3052,106,3048,107,3053,108,3042],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3064,1,3065,2,3063,3,3061,4,3067,5,3068,6,3069,7,3067,8,3066,12,3074,13,3075,14,3076,15,3074,16,3072,17,3080,18,3078,19,3082,21,3086,22,3088,23,3087,24,3085,25,3084,26,3094,27,3095,28,3096,29,3098,30,3099,31,3097,32,3100,33,3094,34,3093,35,3103,36,3104,37,3102,38,3101,39,3108,40,3110,41,3111,42,3109,43,3107,44,3106,45,3101,46,3115,47,3117,48,3118,49,3116,50,3114,51,3116,52,3114,53,3119,54,3114,55,3113,56,3122,57,3121,58,3122,59,3084,60,3127,61,3126,62,3128,63,3129,64,3124,65,3123],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3139,1,3137,2,3143,3,3141,4,3146,5,3148,6,3147,7,3145,8,3144,9,3153,10,3157,11,3158,12,3156,13,3159,14,3155,15,3160,16,3161,17,3162,18,3163,19,3162,20,3167,21,3168,22,3166,23,3169,24,3165,25,3164,40,3162,41,3160,42,3154,43,3152,44,3153,45,3172,46,3171,47,3172,48,3144,49,3175,50,3176,51,3174,52,3173],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"dedf05ab29c415d3","codes":[{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,655423,0,65556,10,326,852029,10,67,65546,131076,50,1638463,65546,196612,50,1638719,0,262164,10,326,1835069,327684,1900603,393220,131339,131082,327684,50,2359357,393220,2424891,327684,196875,0,458772,10,131082,582,262411,262154,0,51,3997757,393228,10,262154,70,393483,0,20,393226,326,54,3997757,393226,67,0,458772,10,196618,582,327947,327690,0,51,5505085,458764,10,327690,70,459019,0,20,458762,326,54,5505085,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsObj","$IsPromise","string","default","$IsDate","toString","valueOf","$GetMethod","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,9,1,10,2,11,3,9,4,8,5,7,6,12,7,13,8,14,9,12,10,6,11,16,12,15,13,23,14,24,15,22,16,21,17,27,18,28,19,26,20,25,21,29,22,30,23,31,24,29,25,20,26,32,27,20,28,33,29,18,30,39,31,40,32,38,33,37,34,41,35,37,36,42,37,35,38,46,39,47,40,48,41,49,42,46,43,44,44,52,45,53,46,51,47,50,49,61,50,60,51,58,52,56,53,64,54,65,55,66,56,64,57,63,58,62,59,68,60,67,61,72,62,73,63,74,64,75,65,72,66,70,67,78,68,79,69,77,70,76,72,87,73,86,74,84,75,82,76,90,77,91,78,92,79,90,80,89,81,88,82,94,83,93,84,96,85,97,86,98,87,99,88,96,90,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,105,1,106,2,107,3,108,4,109,5,110,6,107,7,105,8,104],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,116,1,117,2,118,3,119,4,120,5,121,6,118,7,116,8,115],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,128,1,129,2,130,3,131,4,132,5,133,6,134,7,131,8,128,9,127],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,143,1,144,2,145,3,146,4,147,5,148,6,149,7,146,8,143,9,141,10,153,11,154,12,152,13,151,14,156,15,157,16,155,17,151,18,159,19,160,20,158,21,150],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,167,1,168,2,169,3,170,4,171,5,172,6,173,7,170,8,167,9,166],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,183,1,184,2,185,3,186,4,187,5,183,6,181,7,190,8,191,9,189,10,188,11,193,12,194,13,195,14,196,15,197,16,193,17,192,18,200,19,201,20,199,21,198,23,206,24,207,25,208,26,209,27,206,28,204,29,211,30,212,31,213,32,214,33,215,34,211,35,210,36,221,37,222,38,220,39,219,40,223,41,219,42,224,43,217,44,228,45,229,46,230,47,231,48,228,49,226,50,235,51,236,52,237,53,238,54,235,55,233,56,240,57,241,58,242,59,243,60,244,61,240,62,239],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":8,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,252,1,253,2,254,3,255,4,253,5,251,6,250],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":9,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,264,1,265,2,266,3,267,4,265,5,263,6,261],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":10,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,278,1,277,9,283,10,284,11,285,12,283,13,281,14,289,15,290,16,291,17,292,18,289,19,287,20,296,21,297,22,298,23,299,24,296,25,294,26,304,27,303,28,301,29,309,30,307,31,313,32,311,33,316,34,317,35,315,36,314,40,323,41,324,42,322,43,320,44,328,45,329,46,330,47,331,48,328,49,326,50,336,51,337,52,338,53,336,54,335,55,339,56,340,57,341,58,342,59,339,60,335,61,343,62,333,63,347,64,348,65,346,66,348,67,346,68,350,69,349,70,351,71,352,72,353,73,354,74,351,75,349,76,355,77,346,78,345,79,358,80,357,81,358,82,314,83,362,84,363,85,361,86,363,87,361,88,364,89,361,90,360,91,368,92,369,93,370,94,371,95,372,96,373,97,374,98,368,99,366,100,377,101,378,102,379,103,377,104,376,105,375,106,381,107,380,108,385,109,384,110,277,111,276],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":11,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,786454,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,386,5,396,7,395,8,393,9,643,10,642],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":12,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,396,1,404,2,405,3,403,4,402,5,407,6,408,7,409,8,410,9,407,11,415,12,416,13,414,14,412,15,418,16,419,17,420,18,418,19,417,20,424,21,423,22,422,23,427,24,428,25,429,26,430,27,427,29,435,30,434,33,433,34,437,35,438,36,439,37,437,38,436,40,445,41,444,42,442,43,448,44,449,45,450,46,448,47,447,48,457,49,456,50,458,51,454,52,453,53,461,54,462,55,460,56,459,57,469,58,468,59,470,60,471,61,466,62,465,63,475,64,476,65,477,66,478,67,479,68,475,69,473,70,482,71,483,72,481,73,480,74,485,75,484,76,488,77,489,78,487,79,486,80,491,81,490,82,494,83,495,84,493,85,492,86,497,87,496,88,500,89,501,90,499,91,498,92,503,93,504,94,505,95,506,96,503,97,502,98,512,99,513,100,511,101,510,102,514,103,515,104,516,105,514,106,510,107,517,108,508,109,521,110,523,111,522,112,520,113,522,114,520,115,525,116,520,117,519,118,527,120,530,121,531,122,532,123,530,124,529,127,537,128,536,129,542,130,541,131,539,132,547,133,545,134,550,135,551,136,549,137,548,139,557,140,558,141,559,142,560,143,561,144,562,145,560,146,564,147,565,148,563,149,557,150,556,181,554,182,569,183,570,184,568,185,570,186,568,187,573,188,574,189,572,190,571,191,575,192,571,193,576,194,568,195,567,196,579,197,578,198,579,199,548,200,529,203,584,204,585,205,584,206,583,207,589,208,590,209,591,210,592,211,593,212,589,213,587,214,597,215,595,216,600,217,602,218,601,219,599,220,598,223,609,224,610,225,608,226,606,227,615,228,616,229,617,230,618,231,620,232,621,233,619,234,615,235,614,266,612,267,624,268,625,269,623,270,622,271,627,272,628,273,629,274,630,275,631,276,632,277,627,279,635,280,634,281,635,282,598,283,637,284,638,285,639,286,637,288,641,289,640],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":13,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,657,1,658,2,659,3,660,4,661,5,662,6,658,7,663,8,666,9,664,10,667,11,668,12,657,13,656,14,655,15,654,16,652,17,672,18,673,19,674,20,675,21,676,22,677,23,672,24,671],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":14,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,685,1,686,2,687,3,688,4,689,5,685,6,684],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":15,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,698,1,699,2,700,3,701,4,698,5,696,7,706,8,702,14,703,15,709,16,710,17,711,18,712,19,709,21,702,36,714,37,715,38,716,39,714,41,694],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":16,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,723,1,724,2,728,3,727,4,725,5,723,6,722],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":17,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,739,1,740,2,741,3,739,4,737,5,747,6,748,7,746,8,745,9,749,10,750,11,751,12,749,13,745,14,752,15,753,16,754,17,755,18,756,19,752,20,743,21,760,22,761,23,759,24,758,25,763,26,764,27,762,28,757,30,768,31,769,32,767,33,766,34,772,35,773,36,774,37,772,39,775,41,779,42,780,43,781,44,782,45,783,46,779,47,777,48,787,49,788,50,786,51,785,52,790,53,791,54,789,55,784,56,794,57,795,58,796,59,800,60,799,61,797,62,801,63,794,65,803,66,804,67,805,68,803,70,806,72,811,73,810,74,815,75,814,76,816,77,812,78,810,79,820,80,819,81,817,82,808,83,822,84,823,85,824,86,825,87,826,88,822,90,833,91,832,92,831,93,830,94,828,95,839,96,838,97,836,98,842,99,843,100,844,101,845,102,846,103,848,104,849,105,847,106,842,108,735],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":18,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,858,1,857,2,855,3,863,4,864,5,862,6,861,7,866,8,867,9,865,10,860,11,872,12,871,13,869,15,853],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":19,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,882,1,880,2,886,3,884,4,889,5,891,6,890,7,888,8,887,12,898,13,899,14,897,15,895,16,903,17,904,18,902,19,901,20,905,21,906,22,907,23,905,24,900,25,912,26,911,27,910,28,916,29,917,30,918,31,919,32,920,33,921,34,917,35,922,36,925,37,923,38,926,39,927,40,916,41,914,42,933,43,932,44,931,45,929,46,938,47,937,48,936,49,935,50,945,51,944,52,949,53,948,54,947,55,943,56,942,57,935,58,954,59,955,60,953,61,955,62,953,63,956,64,957,65,958,66,960,67,959,68,962,69,963,70,956,71,953,72,952,73,966,74,965,75,966,76,887,77,969,78,970,79,968,80,967,81,973,82,974,83,972,84,971,85,977,86,978,87,976,88,975,89,980,90,981,91,982,92,980,93,979,94,984,95,985,96,986,97,987,98,988,99,984,101,878],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} diff --git a/packages/codemode/src/runtime/operations.ts b/packages/codemode/src/runtime/operations.ts index 93d772b72e84..106173304d89 100644 --- a/packages/codemode/src/runtime/operations.ts +++ b/packages/codemode/src/runtime/operations.ts @@ -112,7 +112,7 @@ export const applyBinaryOperator = (operator: string, lhs: Value, rhs: Value, no if (operator === "!==") return lhs !== rhs if (operator === "==") return looselyEqual(lhs, rhs, node) if (operator === "!=") return !looselyEqual(lhs, rhs, node) - if (operator === "in" && rhs instanceof Obj && !isOpaque(lhs)) return has(rhs, propertyKey(lhs)) + if (operator === "in" && rhs instanceof Obj && !(lhs instanceof ToolReference)) return has(rhs, propertyKey(lhs)) if (isOpaque(lhs) || isOpaque(rhs)) { throw invalidData("Binary operators require data values.", node) } @@ -182,7 +182,7 @@ export const operatorConversion = ( rhs: Value, ): { readonly kind: "key" } | { readonly kind: "primitive"; readonly hint: "default" | "number" } | undefined => { // `in` checks the right operand before ToPropertyKey on the left, so a bad right side wins over a bad key. - if (operator === "in" && lhs instanceof Obj && !isOpaque(lhs) && rhs instanceof Obj) return { kind: "key" } + if (operator === "in" && lhs instanceof Obj && rhs instanceof Obj) return { kind: "key" } // IsLooselyEqual converts only an object facing a non-nullish primitive; two objects (including tool // references, which are not Obj) compare by identity. const equality = operator === "==" || operator === "!=" diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index fc6003ed8d12..af7c0dd93df9 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -1495,7 +1495,7 @@ export class Vm { } private execToKey(frame: Frame, v: Value, pc: number, sp: number): boolean { - if (!(v instanceof Obj) || isOpaque(v)) { + if (!(v instanceof Obj)) { frame.regs[sp - 1] = coerceToString(v) return false } @@ -1614,7 +1614,7 @@ export class Vm { const fcode = frame.code frame.pc = pc frame.sp = sp - if (v instanceof Obj && !isOpaque(v)) { + if (v instanceof Obj) { frame.sp = sp - 1 this.pushInternalCall(helper, [flag, v], fcode.siteAt(pc) ?? frame.origin) return true @@ -1634,7 +1634,7 @@ export class Vm { } private execToStringSlow(frame: Frame, flag: number, v: Value, pc: number, sp: number): boolean { - if (flag === 1 || !(v instanceof Obj) || isOpaque(v)) { + if (flag === 1 || !(v instanceof Obj)) { frame.regs[sp - 1] = coerceToString(v) return false } @@ -2046,7 +2046,7 @@ export class Vm { const site = frame.code.siteAt(pc)! const memberNode = site as MemberExpression if (mode !== 2) requireMemberBase(memberNode, o, keyVal) - if (keyVal instanceof Obj && !isOpaque(keyVal)) { + if (keyVal instanceof Obj) { frame.sp = sp - 2 this.pushInternalCall("$vmGetElem", [o, keyVal], memberNode.property ?? site) return true @@ -2113,7 +2113,7 @@ export class Vm { private execDeleteElem(frame: Frame, o: Value, keyVal: Value, pc: number, sp: number): boolean { const site = frame.code.siteAt(pc)! requireMemberBase(site as MemberExpression, o, keyVal) - if (keyVal instanceof Obj && !isOpaque(keyVal)) { + if (keyVal instanceof Obj) { frame.sp = sp - 1 this.pushInternalCall("$vmDeleteElem", [o, keyVal], site) return true @@ -2168,7 +2168,7 @@ export class Vm { } const fcode = frame.code const site = fcode.siteAt(pc) ?? frame.origin - if (v instanceof Obj && !isOpaque(v)) { + if (v instanceof Obj) { frame.sp = sp - 1 this.pushInternalCall("$vmUnary", [sub, v], site) return true diff --git a/packages/codemode/test/errors.test.ts b/packages/codemode/test/errors.test.ts index 8cbb483c247a..a78063c0ca96 100644 --- a/packages/codemode/test/errors.test.ts +++ b/packages/codemode/test/errors.test.ts @@ -100,7 +100,7 @@ describe("error identity", () => { describe("rethrown interpreter failures", () => { test("keep their diagnostic kind and source location", async () => { - const failure = await error(`try { Symbol + 1 } catch (e) { throw e }`) + const failure = await error(`try { Promise.resolve(1) + 1 } catch (e) { throw e }`) expect(failure.kind).toBe("InvalidDataValue") expect(failure.message).toStartWith("TypeError: Binary operators require data values. (line ") expect(failure.location).toBeDefined() diff --git a/packages/codemode/test/parity.test.ts b/packages/codemode/test/parity.test.ts index 72b00a447a53..ad4a0edfde4f 100644 --- a/packages/codemode/test/parity.test.ts +++ b/packages/codemode/test/parity.test.ts @@ -919,11 +919,12 @@ describe("coercion parity: String method arguments coerce like native JS", () => expect(await value(`try { "abc".endsWith(/a/) } catch (e) { return e.name }`)).toBe("TypeError") }) - test("opaque runtime references still reject as data errors", async () => { - const err = await error(`const f = () => 1; return "abc".includes(f)`) - expect(err.message).toContain("data value") - const replacerErr = await error(`const f = () => 1; return "a".replace(f, () => "x")`) - expect(replacerErr.message).toContain("data value") + test("functions convert like other objects, while promises and tool references still reject", async () => { + expect( + await value(`const f = () => 1; f.toString = () => "b"; return ["abc".includes(f), "a".replace(f, "x")]`), + ).toEqual([true, "a"]) + expect((await error(`return "abc".includes(Promise.resolve("b"))`)).message).toContain("data value") + expect((await error(`return "a".replace(tools.nowhere, () => "x")`)).message).toContain("data value") }) }) @@ -953,8 +954,9 @@ describe("coercion parity: ++ and -- use CodeMode numeric coercion", () => { expect(await value(`const o = { a: {} }; o.a++; return Number.isNaN(o.a)`)).toBe(true) }) - test("opaque runtime references reject with a clear error", async () => { - const err = await error(`let f = () => 1; f++`) + test("functions become NaN, and promises reject with a clear error", async () => { + expect(await value(`let f = () => 1; f++; return Number.isNaN(f)`)).toBe(true) + const err = await error(`let p = Promise.resolve(1); p++`) expect(err.message).toContain("data value") }) }) @@ -1199,15 +1201,23 @@ describe("loose equality and operator gates on opaque references", () => { ).toEqual([false, true, false, true, false, false, false, false, false, true]) }) - test("coercing an opaque reference against a non-nullish primitive still rejects", async () => { - expect((await error(`const fn = () => 1; return fn == 1`)).message).toContain( - "Binary operators require data values", - ) - expect((await error(`const fn = () => 1; return fn + ""`)).message).toContain( + test("a function facing a primitive converts; a promise or tool reference still rejects", async () => { + expect( + await value(` + const fn = () => 1 + const one = () => 2 + one.valueOf = () => 1 + let inc = fn + inc++ + return [fn == 1, fn + "", -fn, Number.isNaN(inc), one == 1, fn == "[object Function]"] + `), + ).toEqual([false, "[object Function]", null, true, true, true]) + expect((await error(`const p = Promise.resolve(1); return p == 1`)).message).toContain( "Binary operators require data values", ) - expect((await error(`const fn = () => 1; return -fn`)).message).toContain("Unary operators require data values") - expect((await error(`let fn = () => 1; fn++`)).message).toContain("'++' requires a data value") + expect((await error(`return tools.nowhere + ""`)).message).toContain("Binary operators require data values") + expect((await error(`return -Promise.resolve(1)`)).message).toContain("Unary operators require data values") + expect((await error(`let p = Promise.resolve(1); p++`)).message).toContain("'++' requires a data value") }) test("switch and Object.is match opaque references by identity", async () => { @@ -1573,15 +1583,15 @@ describe("this, arguments, and Function.prototype.call/apply/bind", () => { }) describe("ToPrimitive: operators and conversions honor program valueOf and toString", () => { - test("program-installed valueOf and toString on opaque values are ignored at every site", async () => { + test("program-installed valueOf and toString on functions are honored at every site", async () => { expect( await value(` const f = () => 1 f.toString = () => "custom" f.valueOf = () => 5 - return [String(f), \`\${f}\`, [f].join(), new Error(f).message, isNaN(Number(f)), isNaN(Math.abs(f))] + return [String(f), \`\${f}\`, [f].join(), new Error(f).message, Number(f), Math.abs(f), f + 1, ({ custom: 2 })[f]] `), - ).toEqual(["[object Function]", "[object Function]", "[object Function]", "[object Function]", true, true]) + ).toEqual(["custom", "custom", "custom", "custom", 5, 5, 6, 2]) }) test("== converts an object facing a non-nullish primitive through its own valueOf", async () => { @@ -1591,7 +1601,7 @@ describe("ToPrimitive: operators and conversions honor program valueOf and toStr return [one == 1, 1 == one, one == true, one == "1", one == null, one == one, one == { valueOf() { return 1 } }, [1] == 1] `), ).toEqual([true, true, true, true, false, true, false, true]) - expect((await error(`(() => 1) == 1`)).message).toContain("Binary operators require data values") + expect((await error(`Promise.resolve(1) == 1`)).message).toContain("Binary operators require data values") }) test("operators, unary, template literals, and conversion functions use the object's own methods", async () => { @@ -1681,9 +1691,10 @@ describe("ToPrimitive: operators and conversions honor program valueOf and toStr ).toEqual([5, 6, 6, 6]) }) - test("functions and other opaque values still reject arithmetic, and an object without a primitive form throws", async () => { - expect((await error(`const f = () => 1; return f + 1`)).message).toContain("Binary operators require data values") - expect((await error(`return -(() => 1)`)).message).toContain("Unary operators require data values") + test("promises and tool references still reject arithmetic, and an object without a primitive form throws", async () => { + expect(await value(`const f = () => 1; return [f + 1, -(() => 1)]`)).toEqual(["[object Function]1", null]) + expect((await error(`return Promise.resolve(1) + 1`)).message).toContain("Binary operators require data values") + expect((await error(`return -tools.nowhere`)).message).toContain("Unary operators require data values") const failure = await error(`return { valueOf() { return {} }, toString() { return [] } } + 1`) expect(failure.message).toContain("Cannot convert object to primitive value") }) diff --git a/packages/codemode/test/stdlib.test.ts b/packages/codemode/test/stdlib.test.ts index ef09e2d3303b..8021db9041b1 100644 --- a/packages/codemode/test/stdlib.test.ts +++ b/packages/codemode/test/stdlib.test.ts @@ -1554,7 +1554,7 @@ describe("built-in iterators", () => { ]) const logged = await run(`console.log([1].keys()); return null`) expect(logged.logs?.[0]).toBe("[opaque reference]") - expect((await error(`return [1].keys() + ""`)).message).toContain("Binary operators require data values") + expect(await value(`return [1].keys() + ""`)).toBe("[object Iterator]") expect((await error(`return [1].keys().next.call({})`)).message).toContain( "Iterator.prototype.next called on incompatible receiver a data object", ) diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index cd1d318a046e..f2b2be524e44 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1324,7 +1324,6 @@ built-ins/String/prototype/S15.5.4_A1.js # #1: delete String.prototype.toString built-ins/String/prototype/S15.5.4_A2.js # #1: String.prototype =="". Actual: String.prototype ==[object Object] built-ins/String/prototype/S15.5.4_A3.js # #2: delete String.prototype.toString; String.prototype.toString() == "[object "+"String"+"]". Actual built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # Expected a Test262Error to be thrown but no exception was thrown at all -built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js # TypeError: String.at expects argument 1 to be a data value. built-ins/String/prototype/charAt/S15.5.4.4_A2.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/String/prototype/constructor/S15.5.4.1_A1_T2.js # TypeError: new __constr(...) is not supported; call __constr(...) without new instead. @@ -1354,8 +1353,6 @@ language/arguments-object/10.6-2gs.js # Expected a TypeError to be thrown but n language/arguments-object/S10.6_A3_T1.js # #1: arguments object doesn't exists language/comments/S7.4_A1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). language/comments/S7.4_A2_T1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/addition/S11.6.1_A2.2_T3.js # TypeError: Binary operators require data values. -language/expressions/addition/S11.6.1_A3.2_T1.2.js # TypeError: Binary operators require data values. language/expressions/arrow-function/ArrowFunction_restricted-properties.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/arrow-function/dstr/ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true @@ -1395,10 +1392,6 @@ language/expressions/async-generator/dstr/named-dflt-ary-ptrn-elem-id-iter-val-a language/expressions/await/await-in-global.js # Unexpected token (13:22) language/expressions/await/await-in-nested-function.js # Unexpected token (21:22) language/expressions/await/await-in-nested-generator.js # Unexpected token (22:22) -language/expressions/bitwise-and/S11.10.1_A3_T1.5.js # TypeError: Binary operators require data values. -language/expressions/bitwise-not/S11.4.8_A3_T5.js # TypeError: Unary operators require data values. -language/expressions/bitwise-or/S11.10.3_A3_T1.5.js # TypeError: Binary operators require data values. -language/expressions/bitwise-xor/S11.10.2_A3_T1.5.js # TypeError: Binary operators require data values. language/expressions/compound-assignment/S11.13.2_A7.10_T1.js # Expected a DummyError but got a TypeError language/expressions/compound-assignment/S11.13.2_A7.10_T2.js # Expected a DummyError but got a TypeError language/expressions/compound-assignment/S11.13.2_A7.10_T3.js # Expected a DummyError but got a Test262Error @@ -1439,7 +1432,6 @@ language/expressions/delete/S11.4.1_A3.3_T3.js # TypeError: MyFunction cannot b language/expressions/delete/S8.12.7_A2_T2.js # TypeError: Palette cannot be constructed: user-defined constructors and classes are not supported. C language/expressions/delete/non-reference-return-true.js # TypeError: Only data fields may be deleted. language/expressions/delete/super-property-topropertykey.js # Expected a ReferenceError but got a SyntaxError -language/expressions/division/S11.5.2_A3_T1.5.js # TypeError: Binary operators require data values. language/expressions/function/dstr/ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true language/expressions/function/dstr/dflt-ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all @@ -1450,17 +1442,10 @@ language/expressions/generators/dstr/ary-ptrn-elem-id-iter-val-array-prototype.j language/expressions/generators/dstr/dflt-ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/generators/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true language/expressions/generators/prototype-relation-to-function.js # Expected SameValue(«object», «») to be true -language/expressions/greater-than-or-equal/S11.8.4_A3.2_T1.2.js # TypeError: Binary operators require data values. -language/expressions/greater-than/S11.8.2_A3.2_T1.2.js # TypeError: Binary operators require data values. language/expressions/in/S8.12.6_A2_T2.js # TypeError: Robin cannot be constructed: user-defined constructors and classes are not supported. Cal -language/expressions/left-shift/S11.7.1_A3_T1.5.js # TypeError: Binary operators require data values. -language/expressions/less-than-or-equal/S11.8.3_A3.2_T1.2.js # TypeError: Binary operators require data values. -language/expressions/less-than/S11.8.1_A3.2_T1.2.js # TypeError: Binary operators require data values. language/expressions/logical-assignment/lgcl-and-assignment-operator-lhs-before-rhs.js # Expected a DummyError but got a TypeError language/expressions/logical-assignment/lgcl-nullish-assignment-operator-lhs-before-rhs.js # Expected a DummyError but got a TypeError language/expressions/logical-assignment/lgcl-or-assignment-operator-lhs-before-rhs.js # Expected a DummyError but got a TypeError -language/expressions/modulus/S11.5.3_A3_T1.5.js # TypeError: Binary operators require data values. -language/expressions/multiplication/S11.5.1_A3_T1.5.js # TypeError: Binary operators require data values. language/expressions/new/ctorExpr-fn-ref-before-args-eval-fn-wrapup.js # TypeError: x cannot be constructed: user-defined constructors and classes are not supported. Call it language/expressions/new/ctorExpr-fn-ref-before-args-eval.js # TypeError: x cannot be constructed: user-defined constructors and classes are not supported. Call it language/expressions/new/ctorExpr-isCtor-after-args-eval-fn-wrapup.js # arguments evaluated before checking valid ctor Expected SameValue(«undefined», «39») to be true @@ -1506,29 +1491,19 @@ language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-proto language/expressions/object/method-definition/generator-super-prop-body.js # unsupported syntax Super language/expressions/optional-chaining/optional-call-preserves-this.js # TypeError: Cannot read properties of undefined (reading '…'). language/expressions/postfix-decrement/S11.3.2_A2.1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/postfix-decrement/S11.3.2_A3_T5.js # TypeError: '…' requires a data value. -language/expressions/postfix-decrement/S11.3.2_A4_T5.js # TypeError: '…' requires a data value. language/expressions/postfix-decrement/S11.3.2_A6_T1.js # Expected a DummyError but got a TypeError language/expressions/postfix-decrement/S11.3.2_A6_T2.js # Expected a DummyError but got a TypeError language/expressions/postfix-increment/S11.3.1_A2.1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/postfix-increment/S11.3.1_A3_T5.js # TypeError: '…' requires a data value. -language/expressions/postfix-increment/S11.3.1_A4_T5.js # TypeError: '…' requires a data value. language/expressions/postfix-increment/S11.3.1_A6_T1.js # Expected a DummyError but got a TypeError language/expressions/postfix-increment/S11.3.1_A6_T2.js # Expected a DummyError but got a TypeError language/expressions/prefix-decrement/S11.4.5_A2.1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/prefix-decrement/S11.4.5_A3_T5.js # TypeError: '…' requires a data value. -language/expressions/prefix-decrement/S11.4.5_A4_T5.js # TypeError: '…' requires a data value. language/expressions/prefix-decrement/S11.4.5_A6_T1.js # Expected a DummyError but got a TypeError language/expressions/prefix-decrement/S11.4.5_A6_T2.js # Expected a DummyError but got a TypeError language/expressions/prefix-increment/S11.4.4_A2.1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/prefix-increment/S11.4.4_A3_T5.js # TypeError: '…' requires a data value. -language/expressions/prefix-increment/S11.4.4_A4_T5.js # TypeError: '…' requires a data value. language/expressions/prefix-increment/S11.4.4_A6_T1.js # Expected a DummyError but got a TypeError language/expressions/prefix-increment/S11.4.4_A6_T2.js # Expected a DummyError but got a TypeError language/expressions/property-accessors/S11.2.1_A4_T5.js # #27: typeof String.prototype.length === "number". Actual: undefined language/expressions/property-accessors/S8.12.3_A1.js # TypeError: Cannot read properties of undefined (reading '…'). -language/expressions/right-shift/S11.7.2_A3_T1.5.js # TypeError: Binary operators require data values. -language/expressions/subtraction/S11.6.2_A3_T1.5.js # TypeError: Binary operators require data values. language/expressions/super/prop-dot-obj-ref-strict.js # unsupported syntax Super language/expressions/super/prop-expr-obj-err.js # unsupported syntax Super language/expressions/super/prop-expr-obj-key-err.js # unsupported syntax Super @@ -1537,9 +1512,6 @@ language/expressions/super/prop-expr-obj-unresolvable.js # Expected SameValue( language/expressions/tagged-template/constructor-invocation.js # The called value cannot be constructed: user-defined constructors and classes are not supported. language/expressions/tagged-template/template-object-frozen-strict.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/this/11.1.1-1.js # Expected SameValue(«undefined», «undefined») to be false -language/expressions/unary-minus/S11.4.7_A3_T5.js # TypeError: Unary operators require data values. -language/expressions/unary-plus/S11.4.6_A3_T5.js # TypeError: Unary operators require data values. -language/expressions/unsigned-right-shift/S11.7.3_A3_T1.5.js # TypeError: Binary operators require data values. language/expressions/yield/star-in-rltn-expr.js # TypeError: yield* requires a compatible iterable value. language/expressions/yield/star-iterable.js # First result `done` flag Expected SameValue(«false», «undefined») to be true language/function-code/10.4.3-1-21-s.js # TypeError: f cannot be constructed: user-defined constructors and classes are not supported. Call it From b2ba869a6ec81d03adac9f377271fbef30e3c0d9 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 016/100] fix(codemode): evaluate new arguments before checking the constructor EvaluateNew evaluates the callee and its arguments before IsConstructor, so an argument's side effects and throws come first. Bumps the compiler version, since NEW no longer emits a separate check. --- .../codemode-rust/test262/reference-gaps.txt | 12 --------- packages/codemode/interpreter-support.md | 3 ++- packages/codemode/script/disasm.ts | 3 +-- packages/codemode/src/compiler/compile.ts | 5 ++-- packages/codemode/src/prelude/bytecode.json | 2 +- packages/codemode/src/vm.ts | 26 ++++++++----------- packages/codemode/test/new-expression.test.ts | 12 +++++++++ packages/codemode/test/test262/skipped.txt | 12 --------- packages/codemode/test/verify-bytecode.ts | 9 ++----- 9 files changed, 31 insertions(+), 53 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index 6d892a47a8fb..62558317f3be 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -47,18 +47,6 @@ built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js language/expressions/assignment/target-member-identifier-reference-null.js # real: assignment to a member of null or undefined evaluates the right side first language/expressions/assignment/target-member-identifier-reference-undefined.js # real: assignment to a member of null or undefined evaluates the right side first language/expressions/delete/non-reference-return-true.js # real: delete of a non-reference unary chain is true -language/expressions/new/ctorExpr-isCtor-after-args-eval-fn-wrapup.js # real: new evaluates its arguments before the constructor check -language/expressions/new/ctorExpr-isCtor-after-args-eval.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-mult-err-expr-throws.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-mult-err-itr-get-call.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-mult-err-itr-step.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-mult-err-obj-unresolvable.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-mult-err-unresolvable.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-sngl-err-expr-throws.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-sngl-err-itr-get-call.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-sngl-err-itr-step.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-sngl-err-obj-unresolvable.js # real: new evaluates its arguments before the constructor check -language/expressions/new/spread-err-sngl-err-unresolvable.js # real: new evaluates its arguments before the constructor check language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 303de00ef2d6..374639ea305d 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -326,7 +326,8 @@ reject }` object. - [x] Own-field reads and writes on plain data objects. - [x] `new` dispatches on the evaluated constructor value, so aliases (`const D = Date; new D()`), constructors held in objects, and constructors passed as arguments work, while a shadowed name (`const Date = 5; new Date()`) does - not construct. + not construct. The arguments are evaluated before the callee is checked, so `new x(x = Date)` with `x = 1` + throws its `TypeError` after the assignment. - [x] `Object()` and `new Object()` return `{}` for nullish arguments and pass objects through unchanged; primitive wrapper objects (`Object(1)`) are rejected explicitly. - [x] Computed property names and object spread. Any value works as a key (ToPropertyKey): strings, numbers, and the diff --git a/packages/codemode/script/disasm.ts b/packages/codemode/script/disasm.ts index d3e114270ff5..27446deaa890 100644 --- a/packages/codemode/script/disasm.ts +++ b/packages/codemode/script/disasm.ts @@ -142,9 +142,8 @@ const formatOperand = (c: Code, op: number, a: number, bx: number, sbx: number): case Op.PICK: case Op.ROT: case Op.CALL: - return String(a) case Op.NEW: - return a === 255 ? "check" : String(a) + return String(a) case Op.GET_LOCAL: case Op.HOLE_LOCAL: case Op.COPY_CELL: diff --git a/packages/codemode/src/compiler/compile.ts b/packages/codemode/src/compiler/compile.ts index f74cb3f4bda9..8a01228caafb 100644 --- a/packages/codemode/src/compiler/compile.ts +++ b/packages/codemode/src/compiler/compile.ts @@ -144,7 +144,7 @@ type ControlEntry = const idx = (node: AstNode | undefined | null): number => (node ? (nodeId(node)?.index ?? -1) : -1) /** Bump when the compiler emits different bytecode for the same source; it is part of the snapshot build id. */ -export const COMPILER_VERSION = 1 +export const COMPILER_VERSION = 2 const compileCache = new Map>() const MAX_CACHE_SIZE = 64 @@ -1348,9 +1348,8 @@ const compileFunctionBody = ( } const compileNewExpression = (node: NewExpression): void => { + // The callee, then the arguments, and only then the constructibility check, as in EvaluateNew. compileExpression(node.callee as Expression) - // Check constructibility before evaluating arguments - builder.emit(Op.NEW, 255, 0, idx(node), 0) const args = node.arguments if (emitArguments(args, node)) builder.emit(Op.NEW_SPREAD, 0, 0, idx(node), -1) else builder.emit(Op.NEW, args.length, 0, idx(node), -args.length) diff --git a/packages/codemode/src/prelude/bytecode.json b/packages/codemode/src/prelude/bytecode.json index 8f91df36f3ad..667be7156c7a 100644 --- a/packages/codemode/src/prelude/bytecode.json +++ b/packages/codemode/src/prelude/bytecode.json @@ -1 +1 @@ -{"@prelude":{"text":"f135511dc7fc0839","codes":[{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65352,65546,328,262411,3,327947,327690,65546,46,1900605,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,458812,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,52,2,54,3,52,4,50,5,58,6,56,7,61,8,62,9,60,10,59,11,67,12,68,13,66,14,68,15,66,16,72,17,71,18,74,19,75,20,73,21,76,22,69,23,66,24,65,25,79,26,78,27,79,28,59,29,81,30,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,65352,262154,328,327947,3,393483,393226,262154,46,2818109,393226,10,33,2555965,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,1048636,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,149,11,151,12,149,13,147,14,155,15,153,16,158,17,159,18,157,19,156,20,163,21,164,22,162,23,161,24,168,25,169,26,167,27,169,28,167,29,173,30,172,31,175,32,176,33,174,34,177,35,178,36,170,37,167,38,166,39,181,40,180,41,181,42,156,43,183,44,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":33,"name":"sortDefault","flags":72,"length":5,"params":5,"locals":6,"maxStack":9,"code":[0,20,196618,326,327947,0,65556,327690,326,720957,327740,0,131092,10,65546,131082,0,196628,327690,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1221,1,1222,2,1223,3,1221,4,1219,5,1225,6,1226,7,1227,8,1225,9,1224,11,1230,12,1231,13,1232,14,1233,15,1234,16,1235,17,1236,18,1237,19,1238,20,1235,21,1239,22,1230,23,1229],"localNames":["target","into","holes","values","undefs","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1240,2,1246,3,1247,4,1248,5,1249,6,1250,7,1246,8,1244,9,1254,10,1252,11,1258,12,1256,13,1260,15,1264,16,1266,17,1265,18,1263,19,1262,20,1271,21,1272,22,1270,23,1269,24,1275,25,1276,26,1274,27,1275,28,1281,29,1282,30,1280,31,1279,32,1286,33,1287,34,1285,35,1284,36,1289,37,1290,38,1288,39,1283,40,1293,41,1294,42,1295,43,1298,44,1297,45,1296,46,1294,47,1292,48,1293,49,1302,50,1301,51,1302,52,1262,53,1304,54,1303],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1316,1,1317,2,1315,3,1314,4,1319,5,1320,6,1318,7,1312,9,1325,10,1321,16,1322,17,1329,18,1328,19,1327,20,1331,21,1332,22,1333,23,1334,24,1335,25,1331,27,1327,28,1338,29,1339,30,1340,31,1338,32,1337,33,1336,34,1342,35,1343,36,1344,37,1347,38,1348,39,1346,40,1349,41,1345,42,1342,44,1336,45,1351,46,1352,47,1353,48,1354,49,1356,50,1357,51,1355,52,1359,53,1360,54,1358,55,1351,57,1321,72,1362,73,1361],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1369,1,1370,2,1371,3,1372,4,1373,5,1369,6,1368],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1380,1,1381,2,1382,3,1383,4,1384,5,1380,6,1379],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1394,1,1395,2,1393,3,1392,4,1397,5,1398,6,1396,7,1391,8,1400,9,1401,10,1402,11,1404,12,1405,13,1403,14,1400,16,1407,17,1408,18,1409,19,1411,20,1412,21,1410,22,1407,24,1416,25,1417,26,1418,27,1419,28,1416,29,1414,30,1423,31,1421,32,1425,35,1431,36,1427,42,1428,43,1436,44,1437,45,1438,46,1440,48,1439,50,1440,51,1436,52,1435,53,1443,54,1444,55,1442,56,1441,57,1448,58,1449,59,1450,60,1451,61,1452,62,1453,63,1450,64,1448,65,1447,66,1455,67,1456,68,1457,69,1458,70,1459,71,1460,72,1455,74,1427,89,1462,90,1461],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1472,1,1473,2,1474,3,1472,4,1470,5,1476,6,1477,7,1478,8,1479,9,1480,10,1481,11,1476,13,1483,14,1482],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1484,2,1486,4,1487,6,1489,7,1487,8,1492,9,1493,10,1494,11,1495,12,1496,13,1497,14,1498,15,1494,16,1499,17,1500,18,1501,19,1492,21,1490],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1502,2,1504,4,1505,6,1507,7,1505,8,1510,9,1511,10,1512,11,1513,12,1514,13,1515,14,1516,15,1512,16,1517,17,1518,18,1519,19,1510,21,1508],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1528,1,1529,2,1530,3,1531,4,1528,7,1536,8,1537,9,1538,10,1539,11,1536,12,1532,18,1533,19,1544,20,1543,21,1546,22,1547,23,1545,24,1549,25,1550,26,1548,27,1551,28,1541,30,1532,45,1526],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1552,2,1557,3,1558,4,1559,5,1560,6,1561,7,1562,8,1563,9,1559,10,1564,11,1565,12,1557,13,1556],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1566,2,1571,3,1572,4,1573,5,1574,6,1575,7,1576,8,1577,9,1573,10,1578,11,1579,12,1571,13,1570],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1580,2,1585,3,1586,4,1587,5,1588,6,1589,7,1590,8,1591,9,1587,10,1592,11,1593,12,1585,13,1584],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1594,2,1599,3,1600,4,1601,5,1602,6,1603,7,1604,8,1605,9,1601,10,1606,11,1607,12,1599,13,1598],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1608,2,1613,3,1614,4,1615,5,1616,6,1617,7,1618,8,1619,9,1615,10,1620,11,1621,12,1613,13,1612],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1622,2,1627,3,1628,4,1629,5,1630,6,1631,7,1632,8,1633,9,1629,10,1634,11,1635,12,1627,13,1626],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1636,2,1641,3,1642,4,1643,5,1644,6,1645,7,1646,8,1647,9,1643,10,1648,11,1649,12,1641,13,1640],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7209021,1114132,65352,72,8454203,131082,1179652,50,7667775,131082,1245188,50,7929919,131082,1310724,50,8388669,0,851988,1376260,10,582,8454203,0,459019,131082,917508,50,9764927,131082,1048580,50,9240639,131082,1245188,50,9502783,131082,1441796,50,9765183,393226,196618,47,524555,0,590091,524298,16056381,720908,0,851988,1507332,131082,1245188,50,10747965,458762,10813499,10,582,14614602,14614587,852235,15535436,14811195,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12714045,589834,12648509,0,851988,1572868,458762,720906,838,5,14549051,131082,1245188,50,13631549,589834,13566013,0,851988,1638404,458762,720906,838,5,14549051,589834,131082,1441796,50,50,14549053,2,983307,14421326,70,1611,5,983050,67,11075644,70,75,11010107,70,15535437,11206715,917771,15273294,70,5,917514,64,5,15269947,458762,0,50,15925309,258,15990843,458762,67,65546,327690,70,655627,0,20,655370,326,54,17367101,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23199818,23199803,1048843,24121420,23396411,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19464253,0,851988,1572868,458762,786442,838,5,23134267,131082,1048580,50,20381757,589834,20316221,0,851988,1572868,458762,786442,838,5,23134267,131082,1245188,50,21168189,0,851988,1638404,458762,786442,838,5,23134267,131082,1310724,50,22216765,0,851988,589834,21823549,1638404,21889083,1572868,458762,786442,838,5,23134267,589834,131082,1441796,50,50,23134269,2,983307,23007310,70,1611,5,983050,67,17956924,70,75,17891387,70,24121421,18087995,1114379,23859278,70,5,1114122,64,5,23855163,458762,0,50,24510525,258,24576059,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[171,223,229,0,230,233,235,0,276,354,360,0,361,364,366,0],"finallies":[],"finallyOffsets":[],"sites":[0,1658,1,1659,2,1660,3,1658,4,1657,5,1656,6,1662,7,1663,8,1664,9,1667,10,1668,11,1666,12,1669,13,1665,14,1662,16,1675,17,1674,18,1673,19,1671,20,1679,21,1680,22,1678,23,1677,24,1682,25,1683,26,1684,27,1687,28,1688,29,1686,30,1689,31,1685,32,1682,34,1692,35,1693,36,1691,37,1690,38,1695,39,1696,40,1697,41,1700,42,1701,43,1699,44,1702,45,1698,46,1695,48,1707,49,1706,50,1704,51,1713,52,1712,53,1710,54,1718,55,1719,56,1720,57,1718,58,1717,59,1716,60,1722,61,1723,62,1724,63,1722,64,1721,65,1715,66,1726,67,1727,68,1728,69,1731,70,1732,71,1730,72,1733,73,1729,74,1726,76,1737,77,1738,78,1739,79,1740,80,1737,81,1735,82,1744,83,1745,84,1743,85,1742,86,1747,87,1748,88,1746,89,1741,90,1750,91,1749,92,1754,93,1755,94,1753,95,1752,96,1757,97,1758,98,1756,99,1751,100,1760,101,1759,102,1766,103,1767,104,1765,105,1764,106,1769,107,1768,109,1764,110,1774,111,1775,112,1773,113,1772,114,1777,115,1778,116,1776,117,1771,118,1780,119,1781,120,1779,121,1770,122,1782,123,1783,124,1784,125,1785,126,1782,127,1770,128,1786,129,1762,130,1792,131,1793,132,1791,133,1790,134,1798,135,1799,136,1797,137,1796,138,1801,139,1802,140,1800,141,1795,142,1804,143,1805,144,1803,145,1794,146,1807,147,1808,148,1806,149,1788,150,1810,152,1813,153,1812,155,1819,156,1820,157,1821,158,1824,159,1825,160,1823,161,1822,162,1826,163,1822,164,1827,165,1819,166,1815,172,1816,173,1837,174,1836,175,1838,176,1834,177,1833,178,1832,179,1831,180,1841,181,1842,182,1840,183,1839,184,1845,185,1844,186,1847,187,1848,188,1849,189,1850,190,1851,191,1847,193,1839,194,1854,195,1855,196,1853,197,1852,198,1858,199,1857,200,1860,201,1861,202,1862,203,1863,204,1864,205,1860,207,1852,208,1867,209,1869,210,1870,211,1868,212,1866,213,1865,214,1872,215,1871,222,1815,237,1876,238,1877,239,1875,240,1874,241,1878,242,1874,243,1879,244,1873,245,1886,246,1885,247,1883,248,1881,249,1889,250,1890,251,1891,252,1889,253,1888,254,1887,255,1893,256,1894,257,1895,258,1898,259,1899,260,1897,261,1900,262,1896,263,1893,266,1905,267,1906,268,1907,269,1908,270,1905,271,1901,277,1902,278,1913,279,1914,280,1915,281,1916,282,1917,283,1913,284,1912,285,1920,286,1921,287,1919,288,1918,289,1923,290,1924,291,1925,292,1926,293,1927,294,1923,296,1918,297,1930,298,1931,299,1929,300,1928,301,1934,302,1933,303,1936,304,1937,305,1938,306,1939,307,1940,308,1936,310,1928,311,1943,312,1944,313,1942,314,1941,315,1946,316,1947,317,1948,318,1949,319,1950,320,1946,322,1941,323,1953,324,1954,325,1952,326,1951,327,1956,328,1957,329,1959,330,1958,331,1960,332,1958,333,1961,334,1962,335,1963,336,1956,338,1951,339,1966,340,1968,341,1969,342,1967,343,1965,344,1964,345,1971,346,1970,353,1901,368,1975,369,1976,370,1974,371,1973,372,1977,373,1973,374,1978,375,1972],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1986,1,1984,3,1991,4,1987,10,1988,11,1995,12,1996,13,1997,14,1998,15,1995,16,1994,17,1993,18,2000,19,2001,20,2002,21,2003,22,2000,24,2005,25,2006,26,2007,27,2008,28,2009,29,2011,30,2012,31,2010,32,2008,33,2014,34,2015,35,2013,36,2016,37,2005,39,1987,54,2018,55,2017],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2026,1,2024,3,2031,4,2027,10,2028,11,2036,12,2035,13,2037,14,2034,15,2033,16,2039,17,2040,18,2041,19,2042,20,2039,22,2046,23,2048,24,2047,25,2045,26,2047,27,2045,28,2050,29,2045,30,2044,31,2027,46,2052,47,2053,48,2054,49,2052,50,2051],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2063,1,2061,3,2068,4,2064,10,2065,11,2072,12,2074,13,2073,14,2071,15,2073,16,2071,17,2076,18,2071,19,2070,20,2064,35,2078,36,2079,37,2080,38,2081,39,2082,40,2083,41,2078,42,2077],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2095,1,2096,2,2097,3,2095,4,2094,5,2093,6,2099,7,2100,8,2101,9,2105,10,2106,11,2104,12,2107,13,2108,14,2109,15,2107,16,2103,17,2110,18,2102,19,2099,21,2114,22,2112,24,2119,25,2115,31,2116,32,2123,33,2125,34,2124,35,2122,36,2124,37,2122,38,2127,39,2122,40,2121,41,2115,56,2131,57,2129,58,2134,59,2135,60,2133,61,2132,62,2139,63,2141,64,2140,65,2138,66,2137,67,2147,68,2148,69,2146,70,2148,71,2146,72,2152,73,2151,74,2154,75,2155,76,2153,77,2156,78,2149,79,2146,80,2145,81,2159,82,2158,83,2159,84,2137,85,2161,86,2162,87,2163,88,2164,89,2165,90,2161,91,2160],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2175,1,2176,2,2177,3,2175,4,2174,5,2173,6,2179,7,2180,8,2181,9,2182,10,2183,11,2184,12,2179,13,2178,14,2188,15,2186,16,2190,19,2196,20,2192,26,2193,27,2200,28,2201,29,2202,30,2200,31,2199,32,2198,33,2204,34,2205,35,2206,36,2208,37,2209,38,2207,39,2204,41,2213,42,2212,44,2218,45,2214,51,2215,52,2222,53,2224,54,2223,55,2221,56,2223,57,2221,58,2226,59,2227,60,2228,61,2226,62,2221,63,2220,64,2214,79,2232,80,2234,81,2233,82,2231,83,2233,84,2231,85,2236,86,2231,87,2230,88,2192,103,2238,104,2239,105,2240,106,2241,107,2242,108,2243,109,2238,110,2237],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2254,1,2252,2,2257,3,2259,4,2258,5,2256,6,2255,7,2266,8,2265,9,2269,10,2270,11,2268,12,2271,13,2267,14,2274,15,2275,16,2273,17,2276,18,2272,19,2277,20,2263,22,2280,23,2279,24,2280,25,2255,26,2250],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2287,1,2288,2,2289,3,2287,4,2286,5,2290,6,2291,7,2292,8,2294,9,2293,10,2290,11,2285,12,2297,13,2296,14,2299,15,2300,16,2301,17,2302,18,2303,19,2304,20,2305,21,2306,22,2307,23,2308,24,2304,25,2301,26,2299,27,2298],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2309,1,2317,2,2315,3,2321,13,2325,14,2324,16,2330,17,2326,23,2327,24,2333,25,2332,38,2326,53,2318,59,2337,60,2336,61,2335,62,2339,63,2340,64,2341,65,2339,67,2318,70,2313],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2342,2,2349,3,2350,4,2351,5,2352,6,2349,7,2347,8,2354,9,2355,10,2356,11,2357,12,2354,14,2359,15,2360,16,2361,17,2362,18,2363,19,2364,20,2365,21,2361,22,2359,23,2358],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2366,1,2375,2,2373,4,2379,14,2383,15,2382,16,2387,17,2385,19,2392,20,2388,26,2389,27,2395,28,2396,29,2397,30,2399,32,2398,34,2399,35,2395,36,2394,49,2388,64,2376,70,2403,71,2402,72,2401,73,2405,74,2406,75,2407,76,2405,78,2376,81,2371],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2408,2,2415,3,2416,4,2417,5,2418,6,2415,7,2413,8,2420,9,2421,10,2422,11,2423,12,2420,14,2425,15,2426,16,2427,17,2428,18,2429,19,2430,20,2431,21,2427,22,2425,23,2424],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2432,1,2441,2,2439,4,2445,14,2449,15,2448,16,2453,17,2451,19,2458,20,2454,26,2455,27,2460,28,2461,29,2462,30,2464,32,2463,34,2464,35,2460,36,2459,37,2467,38,2466,51,2454,66,2442,72,2471,73,2470,74,2469,75,2473,76,2474,77,2475,78,2473,80,2442,83,2437],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2476,2,2483,3,2484,4,2485,5,2486,6,2483,7,2481,8,2488,9,2489,10,2490,11,2491,12,2492,13,2493,14,2494,15,2495,16,2496,17,2497,18,2494,19,2490,20,2488,21,2487],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2498,1,2507,2,2505,3,2511,13,2515,14,2514,15,2518,16,2519,17,2517,18,2516,19,2521,20,2522,21,2523,22,2521,23,2520,30,2528,31,2524,37,2525,38,2532,39,2531,40,2532,41,2535,42,2534,55,2538,56,2539,57,2537,58,2536,59,2540,64,2524,79,2508,85,2544,86,2543,87,2542,88,2546,89,2547,90,2548,91,2546,93,2508,96,2503],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2549,2,2556,3,2557,4,2558,5,2559,6,2556,7,2554,8,2561,9,2562,10,2563,11,2564,12,2565,13,2566,14,2567,15,2568,16,2569,17,2570,18,2567,19,2563,20,2561,21,2560],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2571,1,2580,2,2578,3,2584,13,2588,14,2587,16,2593,17,2589,23,2590,24,2597,25,2598,26,2596,27,2595,28,2601,29,2600,30,2601,31,2595,32,2604,33,2603,46,2589,61,2581,67,2608,68,2607,69,2606,70,2610,71,2611,72,2612,73,2610,75,2581,78,2576],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2613,2,2620,3,2621,4,2622,5,2623,6,2620,7,2618,8,2625,9,2626,10,2627,11,2628,12,2625,14,2630,15,2631,16,2632,17,2633,18,2634,19,2635,20,2636,21,2632,22,2630,23,2629],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2637,1,2646,2,2644,4,2650,14,2654,15,2653,16,2658,17,2656,19,2663,20,2659,26,2660,28,2669,29,2670,30,2671,31,2672,32,2673,33,2675,35,2674,37,2675,38,2671,39,2676,40,2677,41,2669,42,2665,48,2666,49,2680,50,2679,67,2665,82,2659,97,2647,103,2684,104,2683,105,2682,106,2686,107,2687,108,2688,109,2686,111,2647,114,2642],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2696,1,2695,2,2694,4,2699,5,2698],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2709,1,2708,2,2706,3,2716,4,2717,5,2715,6,2714,7,2719,8,2721,9,2720,10,2718,11,2713,12,2722,13,2713,14,2724,15,2726,16,2727,17,2725,18,2723,19,2711,20,2731,21,2732,22,2730,23,2729,24,2734,25,2735,26,2733,27,2728,28,2737,29,2738,30,2739,31,2744,32,2745,33,2743,34,2746,35,2742,36,2747,37,2741,38,2748,39,2740,40,2737,42,2750,43,2749],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2761,1,2760,2,2762,3,2759,4,2758,5,2764,6,2763,7,2758,8,2766,9,2767,10,2768,11,2766,12,2765,13,2757,14,2770,15,2771,16,2772,17,2776,18,2777,19,2775,20,2778,21,2779,22,2780,23,2778,24,2774,25,2781,26,2773,27,2770,29,2786,30,2788,31,2787,32,2785,33,2783,34,2791,35,2792,36,2796,37,2797,38,2795,39,2794,40,2799,41,2800,42,2798,43,2793,44,2801,45,2793,46,2805,47,2804,48,2802,49,2806,50,2791,51,2790],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2815,1,2814,2,2812,3,2821,4,2822,5,2820,6,2819,7,2824,8,2825,9,2823,10,2818,11,2827,12,2828,13,2832,14,2831,15,2829,16,2827,17,2826,18,2817,19,2834,20,2835,21,2836,22,2837,23,2834,25,2810],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2838,2,2844,3,2842,5,2849,6,2850,7,2851,8,2852,9,2849,10,2845,16,2846,17,2856,18,2858,19,2857,20,2855,21,2857,22,2855,23,2860,24,2855,25,2854,26,2845,41,2862,42,2861],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2863,2,2865,4,2866,6,2872,7,2873,8,2874,9,2875,10,2872,11,2870,12,2877,13,2878,14,2879,15,2880,16,2877,18,2885,19,2886,20,2884,21,2882,22,2892,23,2891,24,2894,25,2890,26,2888,27,2898,28,2896,30,2903,31,2899,37,2900,38,2906,39,2905,40,2910,41,2911,42,2912,43,2913,44,2914,45,2910,46,2909,47,2905,48,2918,49,2917,50,2922,51,2921,52,2925,53,2924,54,2925,55,2899,70,2928,71,2927,72,2926,73,2930,74,2931,75,2932,76,2933,77,2930,79,2935,80,2934],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2936,2,2941,3,2942,4,2943,5,2944,6,2945,7,2941,9,2939],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2946,2,2951,3,2952,4,2953,5,2954,6,2955,7,2951,8,2950],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2956,2,2961,3,2962,4,2963,5,2964,6,2965,7,2961,8,2960],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2966,2,2971,3,2972,4,2973,5,2974,6,2975,7,2971,8,2970],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2985,1,2986,2,2987,3,2988,4,2985,5,2983,6,2990,7,2991,8,2992,9,2994,10,2995,11,2993,12,2990,14,2999,15,2997,16,3001,19,3007,20,3003,26,3004,27,3012,28,3013,29,3014,30,3016,32,3015,34,3016,35,3012,36,3011,37,3020,38,3021,39,3019,40,3018,41,3022,42,3017,43,3024,44,3023,51,3028,52,3029,53,3027,54,3026,55,3031,56,3030,57,3025,58,3033,59,3032,66,3037,67,3038,68,3036,69,3035,70,3039,71,3034,72,3041,73,3040,80,3003,95,3045,96,3046,97,3044,98,3043,99,3047,100,3043,101,3050,102,3051,103,3049,104,3048,105,3052,106,3048,107,3053,108,3042],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3064,1,3065,2,3063,3,3061,4,3067,5,3068,6,3069,7,3067,8,3066,12,3074,13,3075,14,3076,15,3074,16,3072,17,3080,18,3078,19,3082,21,3086,22,3088,23,3087,24,3085,25,3084,26,3094,27,3095,28,3096,29,3098,30,3099,31,3097,32,3100,33,3094,34,3093,35,3103,36,3104,37,3102,38,3101,39,3108,40,3110,41,3111,42,3109,43,3107,44,3106,45,3101,46,3115,47,3117,48,3118,49,3116,50,3114,51,3116,52,3114,53,3119,54,3114,55,3113,56,3122,57,3121,58,3122,59,3084,60,3127,61,3126,62,3128,63,3129,64,3124,65,3123],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"a7f6f842e15eb031"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3139,1,3137,2,3143,3,3141,4,3146,5,3148,6,3147,7,3145,8,3144,9,3153,10,3157,11,3158,12,3156,13,3159,14,3155,15,3160,16,3161,17,3162,18,3163,19,3162,20,3167,21,3168,22,3166,23,3169,24,3165,25,3164,40,3162,41,3160,42,3154,43,3152,44,3153,45,3172,46,3171,47,3172,48,3144,49,3175,50,3176,51,3174,52,3173],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"dedf05ab29c415d3","codes":[{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,655423,0,65556,10,326,852029,10,67,65546,131076,50,1638463,65546,196612,50,1638719,0,262164,10,326,1835069,327684,1900603,393220,131339,131082,327684,50,2359357,393220,2424891,327684,196875,0,458772,10,131082,582,262411,262154,0,51,3997757,393228,10,262154,70,393483,0,20,393226,326,54,3997757,393226,67,0,458772,10,196618,582,327947,327690,0,51,5505085,458764,10,327690,70,459019,0,20,458762,326,54,5505085,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsObj","$IsPromise","string","default","$IsDate","toString","valueOf","$GetMethod","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,9,1,10,2,11,3,9,4,8,5,7,6,12,7,13,8,14,9,12,10,6,11,16,12,15,13,23,14,24,15,22,16,21,17,27,18,28,19,26,20,25,21,29,22,30,23,31,24,29,25,20,26,32,27,20,28,33,29,18,30,39,31,40,32,38,33,37,34,41,35,37,36,42,37,35,38,46,39,47,40,48,41,49,42,46,43,44,44,52,45,53,46,51,47,50,49,61,50,60,51,58,52,56,53,64,54,65,55,66,56,64,57,63,58,62,59,68,60,67,61,72,62,73,63,74,64,75,65,72,66,70,67,78,68,79,69,77,70,76,72,87,73,86,74,84,75,82,76,90,77,91,78,92,79,90,80,89,81,88,82,94,83,93,84,96,85,97,86,98,87,99,88,96,90,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,105,1,106,2,107,3,108,4,109,5,110,6,107,7,105,8,104],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,116,1,117,2,118,3,119,4,120,5,121,6,118,7,116,8,115],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,128,1,129,2,130,3,131,4,132,5,133,6,134,7,131,8,128,9,127],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,143,1,144,2,145,3,146,4,147,5,148,6,149,7,146,8,143,9,141,10,153,11,154,12,152,13,151,14,156,15,157,16,155,17,151,18,159,19,160,20,158,21,150],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,167,1,168,2,169,3,170,4,171,5,172,6,173,7,170,8,167,9,166],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,183,1,184,2,185,3,186,4,187,5,183,6,181,7,190,8,191,9,189,10,188,11,193,12,194,13,195,14,196,15,197,16,193,17,192,18,200,19,201,20,199,21,198,23,206,24,207,25,208,26,209,27,206,28,204,29,211,30,212,31,213,32,214,33,215,34,211,35,210,36,221,37,222,38,220,39,219,40,223,41,219,42,224,43,217,44,228,45,229,46,230,47,231,48,228,49,226,50,235,51,236,52,237,53,238,54,235,55,233,56,240,57,241,58,242,59,243,60,244,61,240,62,239],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":8,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,252,1,253,2,254,3,255,4,253,5,251,6,250],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":9,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,264,1,265,2,266,3,267,4,265,5,263,6,261],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":10,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,278,1,277,9,283,10,284,11,285,12,283,13,281,14,289,15,290,16,291,17,292,18,289,19,287,20,296,21,297,22,298,23,299,24,296,25,294,26,304,27,303,28,301,29,309,30,307,31,313,32,311,33,316,34,317,35,315,36,314,40,323,41,324,42,322,43,320,44,328,45,329,46,330,47,331,48,328,49,326,50,336,51,337,52,338,53,336,54,335,55,339,56,340,57,341,58,342,59,339,60,335,61,343,62,333,63,347,64,348,65,346,66,348,67,346,68,350,69,349,70,351,71,352,72,353,73,354,74,351,75,349,76,355,77,346,78,345,79,358,80,357,81,358,82,314,83,362,84,363,85,361,86,363,87,361,88,364,89,361,90,360,91,368,92,369,93,370,94,371,95,372,96,373,97,374,98,368,99,366,100,377,101,378,102,379,103,377,104,376,105,375,106,381,107,380,108,385,109,384,110,277,111,276],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":11,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,786454,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,386,5,396,7,395,8,393,9,643,10,642],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":12,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,396,1,404,2,405,3,403,4,402,5,407,6,408,7,409,8,410,9,407,11,415,12,416,13,414,14,412,15,418,16,419,17,420,18,418,19,417,20,424,21,423,22,422,23,427,24,428,25,429,26,430,27,427,29,435,30,434,33,433,34,437,35,438,36,439,37,437,38,436,40,445,41,444,42,442,43,448,44,449,45,450,46,448,47,447,48,457,49,456,50,458,51,454,52,453,53,461,54,462,55,460,56,459,57,469,58,468,59,470,60,471,61,466,62,465,63,475,64,476,65,477,66,478,67,479,68,475,69,473,70,482,71,483,72,481,73,480,74,485,75,484,76,488,77,489,78,487,79,486,80,491,81,490,82,494,83,495,84,493,85,492,86,497,87,496,88,500,89,501,90,499,91,498,92,503,93,504,94,505,95,506,96,503,97,502,98,512,99,513,100,511,101,510,102,514,103,515,104,516,105,514,106,510,107,517,108,508,109,521,110,523,111,522,112,520,113,522,114,520,115,525,116,520,117,519,118,527,120,530,121,531,122,532,123,530,124,529,127,537,128,536,129,542,130,541,131,539,132,547,133,545,134,550,135,551,136,549,137,548,139,557,140,558,141,559,142,560,143,561,144,562,145,560,146,564,147,565,148,563,149,557,150,556,181,554,182,569,183,570,184,568,185,570,186,568,187,573,188,574,189,572,190,571,191,575,192,571,193,576,194,568,195,567,196,579,197,578,198,579,199,548,200,529,203,584,204,585,205,584,206,583,207,589,208,590,209,591,210,592,211,593,212,589,213,587,214,597,215,595,216,600,217,602,218,601,219,599,220,598,223,609,224,610,225,608,226,606,227,615,228,616,229,617,230,618,231,620,232,621,233,619,234,615,235,614,266,612,267,624,268,625,269,623,270,622,271,627,272,628,273,629,274,630,275,631,276,632,277,627,279,635,280,634,281,635,282,598,283,637,284,638,285,639,286,637,288,641,289,640],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":13,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,657,1,658,2,659,3,660,4,661,5,662,6,658,7,663,8,666,9,664,10,667,11,668,12,657,13,656,14,655,15,654,16,652,17,672,18,673,19,674,20,675,21,676,22,677,23,672,24,671],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":14,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,685,1,686,2,687,3,688,4,689,5,685,6,684],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":15,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,698,1,699,2,700,3,701,4,698,5,696,7,706,8,702,14,703,15,709,16,710,17,711,18,712,19,709,21,702,36,714,37,715,38,716,39,714,41,694],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":16,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,723,1,724,2,728,3,727,4,725,5,723,6,722],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":17,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,739,1,740,2,741,3,739,4,737,5,747,6,748,7,746,8,745,9,749,10,750,11,751,12,749,13,745,14,752,15,753,16,754,17,755,18,756,19,752,20,743,21,760,22,761,23,759,24,758,25,763,26,764,27,762,28,757,30,768,31,769,32,767,33,766,34,772,35,773,36,774,37,772,39,775,41,779,42,780,43,781,44,782,45,783,46,779,47,777,48,787,49,788,50,786,51,785,52,790,53,791,54,789,55,784,56,794,57,795,58,796,59,800,60,799,61,797,62,801,63,794,65,803,66,804,67,805,68,803,70,806,72,811,73,810,74,815,75,814,76,816,77,812,78,810,79,820,80,819,81,817,82,808,83,822,84,823,85,824,86,825,87,826,88,822,90,833,91,832,92,831,93,830,94,828,95,839,96,838,97,836,98,842,99,843,100,844,101,845,102,846,103,848,104,849,105,847,106,842,108,735],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":18,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,858,1,857,2,855,3,863,4,864,5,862,6,861,7,866,8,867,9,865,10,860,11,872,12,871,13,869,15,853],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":19,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,882,1,880,2,886,3,884,4,889,5,891,6,890,7,888,8,887,12,898,13,899,14,897,15,895,16,903,17,904,18,902,19,901,20,905,21,906,22,907,23,905,24,900,25,912,26,911,27,910,28,916,29,917,30,918,31,919,32,920,33,921,34,917,35,922,36,925,37,923,38,926,39,927,40,916,41,914,42,933,43,932,44,931,45,929,46,938,47,937,48,936,49,935,50,945,51,944,52,949,53,948,54,947,55,943,56,942,57,935,58,954,59,955,60,953,61,955,62,953,63,956,64,957,65,958,66,960,67,959,68,962,69,963,70,956,71,953,72,952,73,966,74,965,75,966,76,887,77,969,78,970,79,968,80,967,81,973,82,974,83,972,84,971,85,977,86,978,87,976,88,975,89,980,90,981,91,982,92,980,93,979,94,984,95,985,96,986,97,987,98,988,99,984,101,878],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} +{"@prelude":{"text":"f135511dc7fc0839","codes":[{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65546,328,262411,3,327947,327690,65546,46,1835069,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,393276,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,54,2,52,3,50,4,58,5,56,6,61,7,62,8,60,9,59,10,67,11,68,12,66,13,68,14,66,15,72,16,71,17,74,18,75,19,73,20,76,21,69,22,66,23,65,24,79,25,78,26,79,27,59,28,81,29,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,262154,328,327947,3,393483,393226,262154,46,2752573,393226,10,33,2490429,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,983100,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,151,11,149,12,147,13,155,14,153,15,158,16,159,17,157,18,156,19,163,20,164,21,162,22,161,23,168,24,169,25,167,26,169,27,167,28,173,29,172,30,175,31,176,32,174,33,177,34,178,35,170,36,167,37,166,38,181,39,180,40,181,41,156,42,183,43,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":33,"name":"sortDefault","flags":72,"length":5,"params":5,"locals":6,"maxStack":9,"code":[0,20,196618,326,327947,0,65556,327690,326,720957,327740,0,131092,10,65546,131082,0,196628,327690,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1221,1,1222,2,1223,3,1221,4,1219,5,1225,6,1226,7,1227,8,1225,9,1224,11,1230,12,1231,13,1232,14,1233,15,1234,16,1235,17,1236,18,1237,19,1238,20,1235,21,1239,22,1230,23,1229],"localNames":["target","into","holes","values","undefs","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1240,2,1246,3,1247,4,1248,5,1249,6,1250,7,1246,8,1244,9,1254,10,1252,11,1258,12,1256,13,1260,15,1264,16,1266,17,1265,18,1263,19,1262,20,1271,21,1272,22,1270,23,1269,24,1275,25,1276,26,1274,27,1275,28,1281,29,1282,30,1280,31,1279,32,1286,33,1287,34,1285,35,1284,36,1289,37,1290,38,1288,39,1283,40,1293,41,1294,42,1295,43,1298,44,1297,45,1296,46,1294,47,1292,48,1293,49,1302,50,1301,51,1302,52,1262,53,1304,54,1303],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1316,1,1317,2,1315,3,1314,4,1319,5,1320,6,1318,7,1312,9,1325,10,1321,16,1322,17,1329,18,1328,19,1327,20,1331,21,1332,22,1333,23,1334,24,1335,25,1331,27,1327,28,1338,29,1339,30,1340,31,1338,32,1337,33,1336,34,1342,35,1343,36,1344,37,1347,38,1348,39,1346,40,1349,41,1345,42,1342,44,1336,45,1351,46,1352,47,1353,48,1354,49,1356,50,1357,51,1355,52,1359,53,1360,54,1358,55,1351,57,1321,72,1362,73,1361],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1369,1,1370,2,1371,3,1372,4,1373,5,1369,6,1368],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1380,1,1381,2,1382,3,1383,4,1384,5,1380,6,1379],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1394,1,1395,2,1393,3,1392,4,1397,5,1398,6,1396,7,1391,8,1400,9,1401,10,1402,11,1404,12,1405,13,1403,14,1400,16,1407,17,1408,18,1409,19,1411,20,1412,21,1410,22,1407,24,1416,25,1417,26,1418,27,1419,28,1416,29,1414,30,1423,31,1421,32,1425,35,1431,36,1427,42,1428,43,1436,44,1437,45,1438,46,1440,48,1439,50,1440,51,1436,52,1435,53,1443,54,1444,55,1442,56,1441,57,1448,58,1449,59,1450,60,1451,61,1452,62,1453,63,1450,64,1448,65,1447,66,1455,67,1456,68,1457,69,1458,70,1459,71,1460,72,1455,74,1427,89,1462,90,1461],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1472,1,1473,2,1474,3,1472,4,1470,5,1476,6,1477,7,1478,8,1479,9,1480,10,1481,11,1476,13,1483,14,1482],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1484,2,1486,4,1487,6,1489,7,1487,8,1492,9,1493,10,1494,11,1495,12,1496,13,1497,14,1498,15,1494,16,1499,17,1500,18,1501,19,1492,21,1490],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1502,2,1504,4,1505,6,1507,7,1505,8,1510,9,1511,10,1512,11,1513,12,1514,13,1515,14,1516,15,1512,16,1517,17,1518,18,1519,19,1510,21,1508],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1528,1,1529,2,1530,3,1531,4,1528,7,1536,8,1537,9,1538,10,1539,11,1536,12,1532,18,1533,19,1544,20,1543,21,1546,22,1547,23,1545,24,1549,25,1550,26,1548,27,1551,28,1541,30,1532,45,1526],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1552,2,1557,3,1558,4,1559,5,1560,6,1561,7,1562,8,1563,9,1559,10,1564,11,1565,12,1557,13,1556],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1566,2,1571,3,1572,4,1573,5,1574,6,1575,7,1576,8,1577,9,1573,10,1578,11,1579,12,1571,13,1570],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1580,2,1585,3,1586,4,1587,5,1588,6,1589,7,1590,8,1591,9,1587,10,1592,11,1593,12,1585,13,1584],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1594,2,1599,3,1600,4,1601,5,1602,6,1603,7,1604,8,1605,9,1601,10,1606,11,1607,12,1599,13,1598],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1608,2,1613,3,1614,4,1615,5,1616,6,1617,7,1618,8,1619,9,1615,10,1620,11,1621,12,1613,13,1612],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1622,2,1627,3,1628,4,1629,5,1630,6,1631,7,1632,8,1633,9,1629,10,1634,11,1635,12,1627,13,1626],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1636,2,1641,3,1642,4,1643,5,1644,6,1645,7,1646,8,1647,9,1643,10,1648,11,1649,12,1641,13,1640],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7143485,1114132,72,8388667,131082,1179652,50,7602239,131082,1245188,50,7864383,131082,1310724,50,8323133,0,851988,1376260,10,582,8388667,0,459019,131082,917508,50,9699391,131082,1048580,50,9175103,131082,1245188,50,9437247,131082,1441796,50,9699647,393226,196618,47,524555,0,590091,524298,15990845,720908,0,851988,1507332,131082,1245188,50,10682429,458762,10747963,10,582,14549066,14549051,852235,15469900,14745659,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12648509,589834,12582973,0,851988,1572868,458762,720906,838,5,14483515,131082,1245188,50,13566013,589834,13500477,0,851988,1638404,458762,720906,838,5,14483515,589834,131082,1441796,50,50,14483517,2,983307,14355790,70,1611,5,983050,67,11010108,70,75,10944571,70,15469901,11141179,917771,15207758,70,5,917514,64,5,15204411,458762,0,50,15859773,258,15925307,458762,67,65546,327690,70,655627,0,20,655370,326,54,17301565,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23134282,23134267,1048843,24055884,23330875,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19398717,0,851988,1572868,458762,786442,838,5,23068731,131082,1048580,50,20316221,589834,20250685,0,851988,1572868,458762,786442,838,5,23068731,131082,1245188,50,21102653,0,851988,1638404,458762,786442,838,5,23068731,131082,1310724,50,22151229,0,851988,589834,21758013,1638404,21823547,1572868,458762,786442,838,5,23068731,589834,131082,1441796,50,50,23068733,2,983307,22941774,70,1611,5,983050,67,17891388,70,75,17825851,70,24055885,18022459,1114379,23793742,70,5,1114122,64,5,23789627,458762,0,50,24444989,258,24510523,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[170,222,228,0,229,232,234,0,275,353,359,0,360,363,365,0],"finallies":[],"finallyOffsets":[],"sites":[0,1658,1,1659,2,1660,3,1658,4,1657,5,1656,6,1662,7,1663,8,1664,9,1667,10,1668,11,1666,12,1669,13,1665,14,1662,16,1675,17,1674,18,1673,19,1671,20,1679,21,1680,22,1678,23,1677,24,1682,25,1683,26,1684,27,1687,28,1688,29,1686,30,1689,31,1685,32,1682,34,1692,35,1693,36,1691,37,1690,38,1695,39,1696,40,1697,41,1700,42,1701,43,1699,44,1702,45,1698,46,1695,48,1707,49,1706,50,1704,51,1713,52,1712,53,1710,54,1718,55,1719,56,1720,57,1718,58,1717,59,1716,60,1722,61,1723,62,1724,63,1722,64,1721,65,1715,66,1726,67,1727,68,1728,69,1731,70,1732,71,1730,72,1733,73,1729,74,1726,76,1737,77,1738,78,1739,79,1740,80,1737,81,1735,82,1744,83,1745,84,1743,85,1742,86,1747,87,1748,88,1746,89,1741,90,1750,91,1749,92,1754,93,1755,94,1753,95,1752,96,1757,97,1758,98,1756,99,1751,100,1760,101,1759,102,1766,103,1767,104,1765,105,1764,106,1769,107,1768,108,1764,109,1774,110,1775,111,1773,112,1772,113,1777,114,1778,115,1776,116,1771,117,1780,118,1781,119,1779,120,1770,121,1782,122,1783,123,1784,124,1785,125,1782,126,1770,127,1786,128,1762,129,1792,130,1793,131,1791,132,1790,133,1798,134,1799,135,1797,136,1796,137,1801,138,1802,139,1800,140,1795,141,1804,142,1805,143,1803,144,1794,145,1807,146,1808,147,1806,148,1788,149,1810,151,1813,152,1812,154,1819,155,1820,156,1821,157,1824,158,1825,159,1823,160,1822,161,1826,162,1822,163,1827,164,1819,165,1815,171,1816,172,1837,173,1836,174,1838,175,1834,176,1833,177,1832,178,1831,179,1841,180,1842,181,1840,182,1839,183,1845,184,1844,185,1847,186,1848,187,1849,188,1850,189,1851,190,1847,192,1839,193,1854,194,1855,195,1853,196,1852,197,1858,198,1857,199,1860,200,1861,201,1862,202,1863,203,1864,204,1860,206,1852,207,1867,208,1869,209,1870,210,1868,211,1866,212,1865,213,1872,214,1871,221,1815,236,1876,237,1877,238,1875,239,1874,240,1878,241,1874,242,1879,243,1873,244,1886,245,1885,246,1883,247,1881,248,1889,249,1890,250,1891,251,1889,252,1888,253,1887,254,1893,255,1894,256,1895,257,1898,258,1899,259,1897,260,1900,261,1896,262,1893,265,1905,266,1906,267,1907,268,1908,269,1905,270,1901,276,1902,277,1913,278,1914,279,1915,280,1916,281,1917,282,1913,283,1912,284,1920,285,1921,286,1919,287,1918,288,1923,289,1924,290,1925,291,1926,292,1927,293,1923,295,1918,296,1930,297,1931,298,1929,299,1928,300,1934,301,1933,302,1936,303,1937,304,1938,305,1939,306,1940,307,1936,309,1928,310,1943,311,1944,312,1942,313,1941,314,1946,315,1947,316,1948,317,1949,318,1950,319,1946,321,1941,322,1953,323,1954,324,1952,325,1951,326,1956,327,1957,328,1959,329,1958,330,1960,331,1958,332,1961,333,1962,334,1963,335,1956,337,1951,338,1966,339,1968,340,1969,341,1967,342,1965,343,1964,344,1971,345,1970,352,1901,367,1975,368,1976,369,1974,370,1973,371,1977,372,1973,373,1978,374,1972],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1986,1,1984,3,1991,4,1987,10,1988,11,1995,12,1996,13,1997,14,1998,15,1995,16,1994,17,1993,18,2000,19,2001,20,2002,21,2003,22,2000,24,2005,25,2006,26,2007,27,2008,28,2009,29,2011,30,2012,31,2010,32,2008,33,2014,34,2015,35,2013,36,2016,37,2005,39,1987,54,2018,55,2017],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2026,1,2024,3,2031,4,2027,10,2028,11,2036,12,2035,13,2037,14,2034,15,2033,16,2039,17,2040,18,2041,19,2042,20,2039,22,2046,23,2048,24,2047,25,2045,26,2047,27,2045,28,2050,29,2045,30,2044,31,2027,46,2052,47,2053,48,2054,49,2052,50,2051],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2063,1,2061,3,2068,4,2064,10,2065,11,2072,12,2074,13,2073,14,2071,15,2073,16,2071,17,2076,18,2071,19,2070,20,2064,35,2078,36,2079,37,2080,38,2081,39,2082,40,2083,41,2078,42,2077],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2095,1,2096,2,2097,3,2095,4,2094,5,2093,6,2099,7,2100,8,2101,9,2105,10,2106,11,2104,12,2107,13,2108,14,2109,15,2107,16,2103,17,2110,18,2102,19,2099,21,2114,22,2112,24,2119,25,2115,31,2116,32,2123,33,2125,34,2124,35,2122,36,2124,37,2122,38,2127,39,2122,40,2121,41,2115,56,2131,57,2129,58,2134,59,2135,60,2133,61,2132,62,2139,63,2141,64,2140,65,2138,66,2137,67,2147,68,2148,69,2146,70,2148,71,2146,72,2152,73,2151,74,2154,75,2155,76,2153,77,2156,78,2149,79,2146,80,2145,81,2159,82,2158,83,2159,84,2137,85,2161,86,2162,87,2163,88,2164,89,2165,90,2161,91,2160],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2175,1,2176,2,2177,3,2175,4,2174,5,2173,6,2179,7,2180,8,2181,9,2182,10,2183,11,2184,12,2179,13,2178,14,2188,15,2186,16,2190,19,2196,20,2192,26,2193,27,2200,28,2201,29,2202,30,2200,31,2199,32,2198,33,2204,34,2205,35,2206,36,2208,37,2209,38,2207,39,2204,41,2213,42,2212,44,2218,45,2214,51,2215,52,2222,53,2224,54,2223,55,2221,56,2223,57,2221,58,2226,59,2227,60,2228,61,2226,62,2221,63,2220,64,2214,79,2232,80,2234,81,2233,82,2231,83,2233,84,2231,85,2236,86,2231,87,2230,88,2192,103,2238,104,2239,105,2240,106,2241,107,2242,108,2243,109,2238,110,2237],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2254,1,2252,2,2257,3,2259,4,2258,5,2256,6,2255,7,2266,8,2265,9,2269,10,2270,11,2268,12,2271,13,2267,14,2274,15,2275,16,2273,17,2276,18,2272,19,2277,20,2263,22,2280,23,2279,24,2280,25,2255,26,2250],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2287,1,2288,2,2289,3,2287,4,2286,5,2290,6,2291,7,2292,8,2294,9,2293,10,2290,11,2285,12,2297,13,2296,14,2299,15,2300,16,2301,17,2302,18,2303,19,2304,20,2305,21,2306,22,2307,23,2308,24,2304,25,2301,26,2299,27,2298],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2309,1,2317,2,2315,3,2321,13,2325,14,2324,16,2330,17,2326,23,2327,24,2333,25,2332,38,2326,53,2318,59,2337,60,2336,61,2335,62,2339,63,2340,64,2341,65,2339,67,2318,70,2313],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2342,2,2349,3,2350,4,2351,5,2352,6,2349,7,2347,8,2354,9,2355,10,2356,11,2357,12,2354,14,2359,15,2360,16,2361,17,2362,18,2363,19,2364,20,2365,21,2361,22,2359,23,2358],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2366,1,2375,2,2373,4,2379,14,2383,15,2382,16,2387,17,2385,19,2392,20,2388,26,2389,27,2395,28,2396,29,2397,30,2399,32,2398,34,2399,35,2395,36,2394,49,2388,64,2376,70,2403,71,2402,72,2401,73,2405,74,2406,75,2407,76,2405,78,2376,81,2371],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2408,2,2415,3,2416,4,2417,5,2418,6,2415,7,2413,8,2420,9,2421,10,2422,11,2423,12,2420,14,2425,15,2426,16,2427,17,2428,18,2429,19,2430,20,2431,21,2427,22,2425,23,2424],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2432,1,2441,2,2439,4,2445,14,2449,15,2448,16,2453,17,2451,19,2458,20,2454,26,2455,27,2460,28,2461,29,2462,30,2464,32,2463,34,2464,35,2460,36,2459,37,2467,38,2466,51,2454,66,2442,72,2471,73,2470,74,2469,75,2473,76,2474,77,2475,78,2473,80,2442,83,2437],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2476,2,2483,3,2484,4,2485,5,2486,6,2483,7,2481,8,2488,9,2489,10,2490,11,2491,12,2492,13,2493,14,2494,15,2495,16,2496,17,2497,18,2494,19,2490,20,2488,21,2487],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2498,1,2507,2,2505,3,2511,13,2515,14,2514,15,2518,16,2519,17,2517,18,2516,19,2521,20,2522,21,2523,22,2521,23,2520,30,2528,31,2524,37,2525,38,2532,39,2531,40,2532,41,2535,42,2534,55,2538,56,2539,57,2537,58,2536,59,2540,64,2524,79,2508,85,2544,86,2543,87,2542,88,2546,89,2547,90,2548,91,2546,93,2508,96,2503],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2549,2,2556,3,2557,4,2558,5,2559,6,2556,7,2554,8,2561,9,2562,10,2563,11,2564,12,2565,13,2566,14,2567,15,2568,16,2569,17,2570,18,2567,19,2563,20,2561,21,2560],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2571,1,2580,2,2578,3,2584,13,2588,14,2587,16,2593,17,2589,23,2590,24,2597,25,2598,26,2596,27,2595,28,2601,29,2600,30,2601,31,2595,32,2604,33,2603,46,2589,61,2581,67,2608,68,2607,69,2606,70,2610,71,2611,72,2612,73,2610,75,2581,78,2576],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2613,2,2620,3,2621,4,2622,5,2623,6,2620,7,2618,8,2625,9,2626,10,2627,11,2628,12,2625,14,2630,15,2631,16,2632,17,2633,18,2634,19,2635,20,2636,21,2632,22,2630,23,2629],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2637,1,2646,2,2644,4,2650,14,2654,15,2653,16,2658,17,2656,19,2663,20,2659,26,2660,28,2669,29,2670,30,2671,31,2672,32,2673,33,2675,35,2674,37,2675,38,2671,39,2676,40,2677,41,2669,42,2665,48,2666,49,2680,50,2679,67,2665,82,2659,97,2647,103,2684,104,2683,105,2682,106,2686,107,2687,108,2688,109,2686,111,2647,114,2642],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2696,1,2695,2,2694,4,2699,5,2698],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2709,1,2708,2,2706,3,2716,4,2717,5,2715,6,2714,7,2719,8,2721,9,2720,10,2718,11,2713,12,2722,13,2713,14,2724,15,2726,16,2727,17,2725,18,2723,19,2711,20,2731,21,2732,22,2730,23,2729,24,2734,25,2735,26,2733,27,2728,28,2737,29,2738,30,2739,31,2744,32,2745,33,2743,34,2746,35,2742,36,2747,37,2741,38,2748,39,2740,40,2737,42,2750,43,2749],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2761,1,2760,2,2762,3,2759,4,2758,5,2764,6,2763,7,2758,8,2766,9,2767,10,2768,11,2766,12,2765,13,2757,14,2770,15,2771,16,2772,17,2776,18,2777,19,2775,20,2778,21,2779,22,2780,23,2778,24,2774,25,2781,26,2773,27,2770,29,2786,30,2788,31,2787,32,2785,33,2783,34,2791,35,2792,36,2796,37,2797,38,2795,39,2794,40,2799,41,2800,42,2798,43,2793,44,2801,45,2793,46,2805,47,2804,48,2802,49,2806,50,2791,51,2790],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2815,1,2814,2,2812,3,2821,4,2822,5,2820,6,2819,7,2824,8,2825,9,2823,10,2818,11,2827,12,2828,13,2832,14,2831,15,2829,16,2827,17,2826,18,2817,19,2834,20,2835,21,2836,22,2837,23,2834,25,2810],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2838,2,2844,3,2842,5,2849,6,2850,7,2851,8,2852,9,2849,10,2845,16,2846,17,2856,18,2858,19,2857,20,2855,21,2857,22,2855,23,2860,24,2855,25,2854,26,2845,41,2862,42,2861],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2863,2,2865,4,2866,6,2872,7,2873,8,2874,9,2875,10,2872,11,2870,12,2877,13,2878,14,2879,15,2880,16,2877,18,2885,19,2886,20,2884,21,2882,22,2892,23,2891,24,2894,25,2890,26,2888,27,2898,28,2896,30,2903,31,2899,37,2900,38,2906,39,2905,40,2910,41,2911,42,2912,43,2913,44,2914,45,2910,46,2909,47,2905,48,2918,49,2917,50,2922,51,2921,52,2925,53,2924,54,2925,55,2899,70,2928,71,2927,72,2926,73,2930,74,2931,75,2932,76,2933,77,2930,79,2935,80,2934],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2936,2,2941,3,2942,4,2943,5,2944,6,2945,7,2941,9,2939],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2946,2,2951,3,2952,4,2953,5,2954,6,2955,7,2951,8,2950],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2956,2,2961,3,2962,4,2963,5,2964,6,2965,7,2961,8,2960],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2966,2,2971,3,2972,4,2973,5,2974,6,2975,7,2971,8,2970],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2985,1,2986,2,2987,3,2988,4,2985,5,2983,6,2990,7,2991,8,2992,9,2994,10,2995,11,2993,12,2990,14,2999,15,2997,16,3001,19,3007,20,3003,26,3004,27,3012,28,3013,29,3014,30,3016,32,3015,34,3016,35,3012,36,3011,37,3020,38,3021,39,3019,40,3018,41,3022,42,3017,43,3024,44,3023,51,3028,52,3029,53,3027,54,3026,55,3031,56,3030,57,3025,58,3033,59,3032,66,3037,67,3038,68,3036,69,3035,70,3039,71,3034,72,3041,73,3040,80,3003,95,3045,96,3046,97,3044,98,3043,99,3047,100,3043,101,3050,102,3051,103,3049,104,3048,105,3052,106,3048,107,3053,108,3042],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3064,1,3065,2,3063,3,3061,4,3067,5,3068,6,3069,7,3067,8,3066,12,3074,13,3075,14,3076,15,3074,16,3072,17,3080,18,3078,19,3082,21,3086,22,3088,23,3087,24,3085,25,3084,26,3094,27,3095,28,3096,29,3098,30,3099,31,3097,32,3100,33,3094,34,3093,35,3103,36,3104,37,3102,38,3101,39,3108,40,3110,41,3111,42,3109,43,3107,44,3106,45,3101,46,3115,47,3117,48,3118,49,3116,50,3114,51,3116,52,3114,53,3119,54,3114,55,3113,56,3122,57,3121,58,3122,59,3084,60,3127,61,3126,62,3128,63,3129,64,3124,65,3123],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3139,1,3137,2,3143,3,3141,4,3146,5,3148,6,3147,7,3145,8,3144,9,3153,10,3157,11,3158,12,3156,13,3159,14,3155,15,3160,16,3161,17,3162,18,3163,19,3162,20,3167,21,3168,22,3166,23,3169,24,3165,25,3164,40,3162,41,3160,42,3154,43,3152,44,3153,45,3172,46,3171,47,3172,48,3144,49,3175,50,3176,51,3174,52,3173],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"dedf05ab29c415d3","codes":[{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,655423,0,65556,10,326,852029,10,67,65546,131076,50,1638463,65546,196612,50,1638719,0,262164,10,326,1835069,327684,1900603,393220,131339,131082,327684,50,2359357,393220,2424891,327684,196875,0,458772,10,131082,582,262411,262154,0,51,3997757,393228,10,262154,70,393483,0,20,393226,326,54,3997757,393226,67,0,458772,10,196618,582,327947,327690,0,51,5505085,458764,10,327690,70,459019,0,20,458762,326,54,5505085,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsObj","$IsPromise","string","default","$IsDate","toString","valueOf","$GetMethod","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,9,1,10,2,11,3,9,4,8,5,7,6,12,7,13,8,14,9,12,10,6,11,16,12,15,13,23,14,24,15,22,16,21,17,27,18,28,19,26,20,25,21,29,22,30,23,31,24,29,25,20,26,32,27,20,28,33,29,18,30,39,31,40,32,38,33,37,34,41,35,37,36,42,37,35,38,46,39,47,40,48,41,49,42,46,43,44,44,52,45,53,46,51,47,50,49,61,50,60,51,58,52,56,53,64,54,65,55,66,56,64,57,63,58,62,59,68,60,67,61,72,62,73,63,74,64,75,65,72,66,70,67,78,68,79,69,77,70,76,72,87,73,86,74,84,75,82,76,90,77,91,78,92,79,90,80,89,81,88,82,94,83,93,84,96,85,97,86,98,87,99,88,96,90,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,105,1,106,2,107,3,108,4,109,5,110,6,107,7,105,8,104],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,116,1,117,2,118,3,119,4,120,5,121,6,118,7,116,8,115],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,128,1,129,2,130,3,131,4,132,5,133,6,134,7,131,8,128,9,127],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,143,1,144,2,145,3,146,4,147,5,148,6,149,7,146,8,143,9,141,10,153,11,154,12,152,13,151,14,156,15,157,16,155,17,151,18,159,19,160,20,158,21,150],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,167,1,168,2,169,3,170,4,171,5,172,6,173,7,170,8,167,9,166],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,183,1,184,2,185,3,186,4,187,5,183,6,181,7,190,8,191,9,189,10,188,11,193,12,194,13,195,14,196,15,197,16,193,17,192,18,200,19,201,20,199,21,198,23,206,24,207,25,208,26,209,27,206,28,204,29,211,30,212,31,213,32,214,33,215,34,211,35,210,36,221,37,222,38,220,39,219,40,223,41,219,42,224,43,217,44,228,45,229,46,230,47,231,48,228,49,226,50,235,51,236,52,237,53,238,54,235,55,233,56,240,57,241,58,242,59,243,60,244,61,240,62,239],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":8,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,252,1,253,2,254,3,255,4,253,5,251,6,250],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":9,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,264,1,265,2,266,3,267,4,265,5,263,6,261],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":10,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,278,1,277,9,283,10,284,11,285,12,283,13,281,14,289,15,290,16,291,17,292,18,289,19,287,20,296,21,297,22,298,23,299,24,296,25,294,26,304,27,303,28,301,29,309,30,307,31,313,32,311,33,316,34,317,35,315,36,314,40,323,41,324,42,322,43,320,44,328,45,329,46,330,47,331,48,328,49,326,50,336,51,337,52,338,53,336,54,335,55,339,56,340,57,341,58,342,59,339,60,335,61,343,62,333,63,347,64,348,65,346,66,348,67,346,68,350,69,349,70,351,71,352,72,353,73,354,74,351,75,349,76,355,77,346,78,345,79,358,80,357,81,358,82,314,83,362,84,363,85,361,86,363,87,361,88,364,89,361,90,360,91,368,92,369,93,370,94,371,95,372,96,373,97,374,98,368,99,366,100,377,101,378,102,379,103,377,104,376,105,375,106,381,107,380,108,385,109,384,110,277,111,276],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":11,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,786454,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,386,5,396,7,395,8,393,9,643,10,642],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":12,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,396,1,404,2,405,3,403,4,402,5,407,6,408,7,409,8,410,9,407,11,415,12,416,13,414,14,412,15,418,16,419,17,420,18,418,19,417,20,424,21,423,22,422,23,427,24,428,25,429,26,430,27,427,29,435,30,434,33,433,34,437,35,438,36,439,37,437,38,436,40,445,41,444,42,442,43,448,44,449,45,450,46,448,47,447,48,457,49,456,50,458,51,454,52,453,53,461,54,462,55,460,56,459,57,469,58,468,59,470,60,471,61,466,62,465,63,475,64,476,65,477,66,478,67,479,68,475,69,473,70,482,71,483,72,481,73,480,74,485,75,484,76,488,77,489,78,487,79,486,80,491,81,490,82,494,83,495,84,493,85,492,86,497,87,496,88,500,89,501,90,499,91,498,92,503,93,504,94,505,95,506,96,503,97,502,98,512,99,513,100,511,101,510,102,514,103,515,104,516,105,514,106,510,107,517,108,508,109,521,110,523,111,522,112,520,113,522,114,520,115,525,116,520,117,519,118,527,120,530,121,531,122,532,123,530,124,529,127,537,128,536,129,542,130,541,131,539,132,547,133,545,134,550,135,551,136,549,137,548,139,557,140,558,141,559,142,560,143,561,144,562,145,560,146,564,147,565,148,563,149,557,150,556,181,554,182,569,183,570,184,568,185,570,186,568,187,573,188,574,189,572,190,571,191,575,192,571,193,576,194,568,195,567,196,579,197,578,198,579,199,548,200,529,203,584,204,585,205,584,206,583,207,589,208,590,209,591,210,592,211,593,212,589,213,587,214,597,215,595,216,600,217,602,218,601,219,599,220,598,223,609,224,610,225,608,226,606,227,615,228,616,229,617,230,618,231,620,232,621,233,619,234,615,235,614,266,612,267,624,268,625,269,623,270,622,271,627,272,628,273,629,274,630,275,631,276,632,277,627,279,635,280,634,281,635,282,598,283,637,284,638,285,639,286,637,288,641,289,640],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":13,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,657,1,658,2,659,3,660,4,661,5,662,6,658,7,663,8,666,9,664,10,667,11,668,12,657,13,656,14,655,15,654,16,652,17,672,18,673,19,674,20,675,21,676,22,677,23,672,24,671],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":14,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,685,1,686,2,687,3,688,4,689,5,685,6,684],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":15,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,698,1,699,2,700,3,701,4,698,5,696,7,706,8,702,14,703,15,709,16,710,17,711,18,712,19,709,21,702,36,714,37,715,38,716,39,714,41,694],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":16,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,723,1,724,2,728,3,727,4,725,5,723,6,722],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":17,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,739,1,740,2,741,3,739,4,737,5,747,6,748,7,746,8,745,9,749,10,750,11,751,12,749,13,745,14,752,15,753,16,754,17,755,18,756,19,752,20,743,21,760,22,761,23,759,24,758,25,763,26,764,27,762,28,757,30,768,31,769,32,767,33,766,34,772,35,773,36,774,37,772,39,775,41,779,42,780,43,781,44,782,45,783,46,779,47,777,48,787,49,788,50,786,51,785,52,790,53,791,54,789,55,784,56,794,57,795,58,796,59,800,60,799,61,797,62,801,63,794,65,803,66,804,67,805,68,803,70,806,72,811,73,810,74,815,75,814,76,816,77,812,78,810,79,820,80,819,81,817,82,808,83,822,84,823,85,824,86,825,87,826,88,822,90,833,91,832,92,831,93,830,94,828,95,839,96,838,97,836,98,842,99,843,100,844,101,845,102,846,103,848,104,849,105,847,106,842,108,735],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":18,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,858,1,857,2,855,3,863,4,864,5,862,6,861,7,866,8,867,9,865,10,860,11,872,12,871,13,869,15,853],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":19,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,882,1,880,2,886,3,884,4,889,5,891,6,890,7,888,8,887,12,898,13,899,14,897,15,895,16,903,17,904,18,902,19,901,20,905,21,906,22,907,23,905,24,900,25,912,26,911,27,910,28,916,29,917,30,918,31,919,32,920,33,921,34,917,35,922,36,925,37,923,38,926,39,927,40,916,41,914,42,933,43,932,44,931,45,929,46,938,47,937,48,936,49,935,50,945,51,944,52,949,53,948,54,947,55,943,56,942,57,935,58,954,59,955,60,953,61,955,62,953,63,956,64,957,65,958,66,960,67,959,68,962,69,963,70,956,71,953,72,952,73,966,74,965,75,966,76,887,77,969,78,970,79,968,80,967,81,973,82,974,83,972,84,971,85,977,86,978,87,976,88,975,89,980,90,981,91,982,92,980,93,979,94,984,95,985,96,986,97,987,98,988,99,984,101,878],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index af7c0dd93df9..0e7d5d0971fa 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -1722,21 +1722,10 @@ export class Vm { } private execNew(frame: Frame, n: number, pc: number, sp: number): boolean { - const fcode = frame.code const regs = frame.regs - if (n === 255) { - const callee = regs[sp - 1] as Value - if (!(callee instanceof Builtin) || callee.construct === undefined) { - frame.pc = pc - frame.sp = sp - throw notConstructible(callee, fcode.siteAt(pc) as NewExpression) - } - frame.sp = sp - return false - } frame.pc = pc const base = sp - n - const callee = regs[base - 1] as Builtin + const callee = this.constructible(frame, regs[base - 1] as Value, pc, sp) const args = regs.slice(base, sp) as Array frame.sp = base - 1 return this.execConstruct(frame, callee, args, callSiteOf(frame, pc)) @@ -1744,13 +1733,20 @@ export class Vm { private execNewSpread(frame: Frame, pc: number, sp: number): boolean { const regs = frame.regs - const argsArr = regs[--sp] as Arr - const callee = regs[--sp] as Builtin frame.pc = pc - frame.sp = sp + const callee = this.constructible(frame, regs[sp - 2] as Value, pc, sp) + const argsArr = regs[--sp] as Arr + frame.sp = --sp return this.execConstruct(frame, callee, [...argsArr.items], callSiteOf(frame, pc)) } + // IsConstructor, checked once the arguments are evaluated. + private constructible(frame: Frame, callee: Value, pc: number, sp: number): Builtin { + if (callee instanceof Builtin && callee.construct !== undefined) return callee + frame.sp = sp + throw notConstructible(callee, frame.code.siteAt(pc) as NewExpression) + } + private execIterStepSlow(frame: Frame, custom: CustomIter, bx: number, pc: number, sp: number): boolean { const regs = frame.regs custom.done = true diff --git a/packages/codemode/test/new-expression.test.ts b/packages/codemode/test/new-expression.test.ts index 0beafad48fba..4040bc2a0513 100644 --- a/packages/codemode/test/new-expression.test.ts +++ b/packages/codemode/test/new-expression.test.ts @@ -58,6 +58,18 @@ describe("new on a non-constructible callee", () => { ) }) + test("the arguments are evaluated before the callee is checked", async () => { + expect( + await value(` + let x = 1 + const seen = [] + try { new x(x = Date, seen.push("argument")) } catch (error) { seen.push(error.name) } + try { new Number(...missing) } catch (error) { seen.push(error.name) } + return [seen, x === Date] + `), + ).toEqual([["argument", "TypeError", "ReferenceError"], true]) + }) + test("the failure is a catchable TypeError", async () => { expect( await value(` diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index f2b2be524e44..e55174b446ff 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1448,18 +1448,6 @@ language/expressions/logical-assignment/lgcl-nullish-assignment-operator-lhs-bef language/expressions/logical-assignment/lgcl-or-assignment-operator-lhs-before-rhs.js # Expected a DummyError but got a TypeError language/expressions/new/ctorExpr-fn-ref-before-args-eval-fn-wrapup.js # TypeError: x cannot be constructed: user-defined constructors and classes are not supported. Call it language/expressions/new/ctorExpr-fn-ref-before-args-eval.js # TypeError: x cannot be constructed: user-defined constructors and classes are not supported. Call it -language/expressions/new/ctorExpr-isCtor-after-args-eval-fn-wrapup.js # arguments evaluated before checking valid ctor Expected SameValue(«undefined», «39») to be true -language/expressions/new/ctorExpr-isCtor-after-args-eval.js # Expected SameValue(«object», «Array») to be true -language/expressions/new/spread-err-mult-err-expr-throws.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-mult-err-itr-get-call.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-mult-err-itr-step.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-mult-err-obj-unresolvable.js # Expected a ReferenceError but got a TypeError -language/expressions/new/spread-err-mult-err-unresolvable.js # Expected a ReferenceError but got a TypeError -language/expressions/new/spread-err-sngl-err-expr-throws.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-sngl-err-itr-get-call.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-sngl-err-itr-step.js # Expected a Test262Error but got a TypeError -language/expressions/new/spread-err-sngl-err-obj-unresolvable.js # Expected a ReferenceError but got a TypeError -language/expressions/new/spread-err-sngl-err-unresolvable.js # Expected a ReferenceError but got a TypeError language/expressions/new/spread-mult-empty.js # TypeError: The called value cannot be constructed: user-defined constructors and classes are not sup language/expressions/new/spread-mult-expr.js # TypeError: The called value cannot be constructed: user-defined constructors and classes are not sup language/expressions/new/spread-mult-iter.js # TypeError: The called value cannot be constructed: user-defined constructors and classes are not sup diff --git a/packages/codemode/test/verify-bytecode.ts b/packages/codemode/test/verify-bytecode.ts index 9babd65dbc43..0ffb3be8b447 100644 --- a/packages/codemode/test/verify-bytecode.ts +++ b/packages/codemode/test/verify-bytecode.ts @@ -263,13 +263,8 @@ export const verifyCode = (c: Code): Array => { next(-(a + 1)) break case Op.NEW: - if (a === 255) { - if (d < 1) errors.push(`${label}: NEW.check at depth ${d} (pc ${pc})`) - next(0) - } else { - if (d < a + 1) errors.push(`${label}: NEW ${a} at depth ${d} (pc ${pc})`) - next(-a) - } + if (d < a + 1) errors.push(`${label}: NEW ${a} at depth ${d} (pc ${pc})`) + next(-a) break case Op.ITER_OPEN: { const jumpPc = pc + stride From 82bdea7677a410b5715b18d3fcc218c9a9fd3b99 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 017/100] fix(codemode): evaluate the right side of o.x = v before checking o PutValue checks the base, so null.x = f() calls f before it throws, and (1).x = f() surfaces f's throw. --- packages/codemode-rust/test262/reference-gaps.txt | 2 -- packages/codemode/interpreter-support.md | 2 +- packages/codemode/script/disasm.ts | 4 +++- packages/codemode/src/compiler/compile.ts | 6 ++++++ packages/codemode/src/opcodes.ts | 2 ++ packages/codemode/src/vm.ts | 8 ++++++-- packages/codemode/test/parity.test.ts | 11 +++++++++++ packages/codemode/test/test262/skipped.txt | 2 -- packages/codemode/test/verify-bytecode.ts | 6 ++++-- packages/codemode/test/vm.test.ts | 7 +++---- 10 files changed, 36 insertions(+), 14 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index 62558317f3be..4330bf8379b2 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -44,8 +44,6 @@ built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPri built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -language/expressions/assignment/target-member-identifier-reference-null.js # real: assignment to a member of null or undefined evaluates the right side first -language/expressions/assignment/target-member-identifier-reference-undefined.js # real: assignment to a member of null or undefined evaluates the right side first language/expressions/delete/non-reference-return-true.js # real: delete of a non-reference unary chain is true language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 374639ea305d..91791c52471b 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -76,7 +76,7 @@ the ultimate source of truth. Upstream test262 files run verbatim from `test/tes - [x] Object and array destructuring in declarations, parameters, assignment expressions, and `for...of` bindings. - [x] Nested patterns, defaults, elisions, and rest elements. - [x] Assignment to identifiers, plain-object fields, non-negative integer array indexes, and writable URL - fields. + fields. `o.x = v` evaluates `v` before checking `o`, so `null.x = f()` calls `f` and then throws. - [x] Direct function declarations are hoisted in program and block statement lists. - [x] Parameter defaults observe a temporal dead zone for later parameters. - [x] `var` is function-scoped and hoisted: names declared anywhere in a function or program body, including loop diff --git a/packages/codemode/script/disasm.ts b/packages/codemode/script/disasm.ts index 27446deaa890..7e45c5102458 100644 --- a/packages/codemode/script/disasm.ts +++ b/packages/codemode/script/disasm.ts @@ -192,7 +192,9 @@ const formatOperand = (c: Code, op: number, a: number, bx: number, sbx: number): ? `.writeProp ${JSON.stringify(c.consts[bx])}` : a === CheckBaseKind.WRITE_ELEM ? ".writeElem" - : ".destructure" + : a === CheckBaseKind.ASSIGN_PROP + ? `.assignProp ${JSON.stringify(c.consts[bx])}` + : ".destructure" case Op.BINOP: return BinOpSymbols[a] ?? String(a) case Op.UNARY: diff --git a/packages/codemode/src/compiler/compile.ts b/packages/codemode/src/compiler/compile.ts index 8a01228caafb..29982d0b0ec3 100644 --- a/packages/codemode/src/compiler/compile.ts +++ b/packages/codemode/src/compiler/compile.ts @@ -1257,6 +1257,12 @@ const compileFunctionBody = ( if (left.computed) { compileExpression(left.property as Expression) emitWritableKey(left) + } else if (op === "=") { + // PutValue checks the base, so the right side is evaluated first: `null.x = f()` calls `f`. + compileExpression(node.right) + builder.emit(Op.CHECK_BASE, CheckBaseKind.ASSIGN_PROP, k, idx(left), 0) + put() + return } else builder.emit(Op.CHECK_BASE, CheckBaseKind.WRITE_PROP, k, idx(left), 0) if (op === "=") { compileExpression(node.right) diff --git a/packages/codemode/src/opcodes.ts b/packages/codemode/src/opcodes.ts index d81ef7a6f9fc..cf2523997ccd 100644 --- a/packages/codemode/src/opcodes.ts +++ b/packages/codemode/src/opcodes.ts @@ -218,6 +218,8 @@ export const CheckBaseKind = { WRITE_ELEM: 2, /** Destructuring target check: throws if top is null or undefined (`[v] -> [v]`). */ DESTRUCTURE: 3, + /** `o.x = v`: the `WRITE_PROP` check, made once the right side is evaluated (`[o, v] -> [o, v]`, `bx = k`). */ + ASSIGN_PROP: 4, } as const /** Sub-ops for `Op.ITER_OPEN` and `Op.ITER_INIT` (`a` operand). */ diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index 0e7d5d0971fa..f8b5f7992579 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -2120,7 +2120,11 @@ export class Vm { } private execCheckBase(fcode: Code, kind: number, bx: number, regs: Array, sp: number, pc: number): void { - const base = regs[kind === CheckBaseKind.READ || kind === CheckBaseKind.WRITE_ELEM ? sp - 2 : sp - 1] as Value + const base = regs[ + kind === CheckBaseKind.READ || kind === CheckBaseKind.WRITE_ELEM || kind === CheckBaseKind.ASSIGN_PROP + ? sp - 2 + : sp - 1 + ] as Value if (base instanceof Obj && !(base instanceof PromiseObj)) return const site = fcode.siteAt(pc)! if (kind === CheckBaseKind.DESTRUCTURE) { @@ -2134,7 +2138,7 @@ export class Vm { requireMemberBase(memberNode, base, regs[sp - 1] as Value) return } - const key = kind === CheckBaseKind.WRITE_PROP ? (fcode.consts[bx] as string) : propertyKey(regs[sp - 1] as Value) + const key = kind === CheckBaseKind.WRITE_ELEM ? propertyKey(regs[sp - 1] as Value) : (fcode.consts[bx] as string) readReference(writableReference(this.resolveMember(base, key, site), memberNode), memberNode) } diff --git a/packages/codemode/test/parity.test.ts b/packages/codemode/test/parity.test.ts index ad4a0edfde4f..7daf6818041a 100644 --- a/packages/codemode/test/parity.test.ts +++ b/packages/codemode/test/parity.test.ts @@ -1836,6 +1836,17 @@ describe("computed property keys convert through the object's own toString", () ) }) + test("a nullish base in o.x = v throws once the right side is evaluated, as PutValue checks it", async () => { + expect( + await value(` + let count = 0 + let failure + try { const base = null; base.prop = count += 1 } catch (error) { failure = error.name } + return [count, failure] + `), + ).toEqual([1, "TypeError"]) + }) + test("a nullish base throws before the key converts, as ToObject precedes ToPropertyKey", async () => { const failure = await error(`const base = null; base[{ toString() { throw new RangeError("key evaluated") } }]`) expect(failure.message).toContain("Cannot read properties of null") diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index e55174b446ff..51a04e78fbc6 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1378,8 +1378,6 @@ language/expressions/assignment/dstr/array-rest-lref-err.js # Expected SameValu language/expressions/assignment/target-member-computed-reference-null.js # Expected a DummyError but got a TypeError language/expressions/assignment/target-member-computed-reference-undefined.js # Expected a DummyError but got a TypeError language/expressions/assignment/target-member-computed-reference.js # Expected a DummyError but got a TypeError -language/expressions/assignment/target-member-identifier-reference-null.js # Expected SameValue(«0», «1») to be true -language/expressions/assignment/target-member-identifier-reference-undefined.js # Expected SameValue(«0», «1») to be true language/expressions/assignmenttargettype/simple-basic-identifierreference-await.js # Unexpected token (12:6) language/expressions/async-generator/dstr/ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true diff --git a/packages/codemode/test/verify-bytecode.ts b/packages/codemode/test/verify-bytecode.ts index 0ffb3be8b447..d133e7c9f6cc 100644 --- a/packages/codemode/test/verify-bytecode.ts +++ b/packages/codemode/test/verify-bytecode.ts @@ -183,8 +183,10 @@ export const verifyCode = (c: Code): Array => { case Op.FOR_IN: case Op.ITER_INIT: case Op.GENERATOR_START: - if (op === Op.CHECK_BASE && a === CheckBaseKind.READ && d < 2) { - errors.push(`${label}: CHECK_BASE.read at depth ${d} (pc ${pc})`) + if (op === Op.CHECK_BASE && (a === CheckBaseKind.READ || a === CheckBaseKind.ASSIGN_PROP) && d < 2) { + errors.push( + `${label}: CHECK_BASE.${a === CheckBaseKind.READ ? "read" : "assignProp"} at depth ${d} (pc ${pc})`, + ) } next(0) break diff --git a/packages/codemode/test/vm.test.ts b/packages/codemode/test/vm.test.ts index b33c1cfb2c90..62688a54cf95 100644 --- a/packages/codemode/test/vm.test.ts +++ b/packages/codemode/test/vm.test.ts @@ -162,13 +162,12 @@ describe("scopes, TDZ, hoisting, and closures", () => { }) describe("expressions, evaluation order, and destructuring", () => { - test("member evaluation order: nullish base before key conversion, base check before rhs", () => { + test("member evaluation order: nullish base before key conversion, rhs before the base check", () => { expect(err(`const base = null; base[{ toString() { throw new RangeError("boom") } }]`).message).toContain( "Cannot read properties of null", ) - expect(err(`(1).x = (() => { throw new RangeError("rhs ran") })()`).message).toContain( - "Cannot create property 'x' on number '1'", - ) + expect(err(`(1).x = (() => { throw new RangeError("rhs ran") })()`).message).toContain("rhs ran") + expect(err(`(1).x = 2`).message).toContain("Cannot create property 'x' on number '1'") expect( val(` const log = [] From aa304b8b6f8b8c1558e3e8dc7308b7462898cd10 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 018/100] fix(codemode): delete on a primitive base is true unless the wrapper owns the key delete "abc"[5] and delete (1).x are true, as they delete from the wrapper; a string's own index or length still throws in strict mode. --- packages/codemode-rust/test262/reference-gaps.txt | 1 - packages/codemode/interpreter-support.md | 2 ++ packages/codemode/src/vm.ts | 8 ++++++++ packages/codemode/test/parity.test.ts | 12 ++++++++++++ packages/codemode/test/test262/skipped.txt | 1 - 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index 4330bf8379b2..88b3812c4c5c 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -44,7 +44,6 @@ built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPri built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -language/expressions/delete/non-reference-return-true.js # real: delete of a non-reference unary chain is true language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 91791c52471b..3b5d3becdf13 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -232,6 +232,8 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. creates a hole without changing its length. Deleting a non-configurable property (`length`) or assigning a read-only one (`Math.PI`, `fn.name`) throws a `TypeError`, as in strict mode. `delete` of a non-reference (`delete 0`, `delete f()`) evaluates the operand and is `true`; `delete x` on a variable throws. + A primitive base deletes from its wrapper: `delete "abc"[5]` and `delete (1).x` are `true`, while a string's + own index or `length` throws. - [x] Coercion helpers and template interpolation accept functions and namespaces: `String(fn)` and `${fn}` give `"[object Function]"` rather than the source text (unless the function has its own `toString` or `valueOf`), `isNaN(fn)` is `true`. diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index f8b5f7992579..7c7061b2b1e6 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -36,6 +36,7 @@ import { Native, type NativeResult, Obj, + parseArrayIndex, Position, PromiseObj, readonly, @@ -2099,6 +2100,13 @@ export class Vm { private execDeleteProp(fcode: Code, o: Value, key: PropertyKey, pc: number): boolean { const site = fcode.siteAt(pc)! const ref = this.resolveMember(o, key, site) + // A primitive base deletes from its wrapper, whose only own properties are a string's indexes and length. + if (!(ref instanceof ToolReference) && !(o instanceof Obj)) { + const index = typeof key === "symbol" ? undefined : parseArrayIndex(key) + const own = typeof o === "string" && (key === "length" || (index !== undefined && index < o.length)) + if (own) throw typeError(`Cannot delete property '${String(key)}' of ${JSON.stringify(o)}.`, site) + return true + } if (ref instanceof ToolReference || "value" in ref || ref.receiver !== ref.target) { throw invalidData("Only data fields may be deleted.", site) } diff --git a/packages/codemode/test/parity.test.ts b/packages/codemode/test/parity.test.ts index 7daf6818041a..b15e9abeadfc 100644 --- a/packages/codemode/test/parity.test.ts +++ b/packages/codemode/test/parity.test.ts @@ -231,6 +231,18 @@ describe("property deletion", () => { ).toEqual([[true, true, true, true, true], true, "TypeError"]) }) + test("a primitive base deletes from its wrapper: only a string's indexes and length are own", async () => { + expect( + await value(` + const failures = [] + for (const remove of [() => delete "abc"[0], () => delete "abc".length]) { + try { remove() } catch (error) { failures.push(error.name) } + } + return [delete "abc"[3], delete "abc".foo, delete (1).x, delete true.y, delete void typeof 0, failures] + `), + ).toEqual([true, true, true, true, true, ["TypeError", "TypeError"]]) + }) + test("evaluates computed object and key expressions once", async () => { expect( await value(` diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index 51a04e78fbc6..e0aa73d02482 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1428,7 +1428,6 @@ language/expressions/delete/S11.4.1_A2.2_T3.js # TypeError: Cannot read propert language/expressions/delete/S11.4.1_A3.2_T3.js # TypeError: MyFunction cannot be constructed: user-defined constructors and classes are not supported language/expressions/delete/S11.4.1_A3.3_T3.js # TypeError: MyFunction cannot be constructed: user-defined constructors and classes are not supported language/expressions/delete/S8.12.7_A2_T2.js # TypeError: Palette cannot be constructed: user-defined constructors and classes are not supported. C -language/expressions/delete/non-reference-return-true.js # TypeError: Only data fields may be deleted. language/expressions/delete/super-property-topropertykey.js # Expected a ReferenceError but got a SyntaxError language/expressions/function/dstr/ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/expressions/function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true From 223bff4cea0897569f6e29f4c214c3ab14930540 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 019/100] fix(codemode): match JS in built-in object details Resolving functions are anonymous, Set.prototype.keys is values, built-in iterators report their kind (Array Iterator, Map Iterator, ...), AggregateError has no own message unless given one, and generator and async functions inherit from their own non-callable function prototypes. --- .../codemode-rust/test262/reference-gaps.txt | 6 ----- packages/codemode/interpreter-support.md | 16 +++++++++----- packages/codemode/src/runtime/errors.ts | 5 ++++- packages/codemode/src/runtime/intrinsics.ts | 22 ++++++++++++++++--- packages/codemode/src/runtime/objects.ts | 13 ++++++++++- packages/codemode/src/runtime/promises.ts | 4 ++-- packages/codemode/src/snapshot/codec.ts | 2 +- packages/codemode/src/stdlib/collections.ts | 4 +++- packages/codemode/src/vm.ts | 10 +++++---- packages/codemode/test/errors.test.ts | 11 ++++++++++ packages/codemode/test/promise.test.ts | 8 +++++++ packages/codemode/test/resumable.test.ts | 4 ++-- packages/codemode/test/stdlib.test.ts | 22 +++++++++++++++++-- packages/codemode/test/test262/skipped.txt | 6 ----- .../test/var-hoisting-test262.test.ts | 14 ++++++++++++ 15 files changed, 112 insertions(+), 35 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index 88b3812c4c5c..e3c3e9be85df 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -2,7 +2,6 @@ # with "real" (Rust has the behaviour and TypeScript lacks it) or "accident" (Rust passes through a looser check, # where the reference is deliberately strict). Generated by `bash test262/run.sh --write`, which keeps the categories; # CI fails when an unlisted file passes, a listed file fails here, or the reference passes a listed file. -built-ins/AggregateError/message-undefined-no-prop.js # real: built-in object model details (names, prototypes, toStringTag, own message) built-ins/Array/length/S15.4.5.1_A1.3_T2.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/at/index-argument-tointeger.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/fill/return-abrupt-from-end.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) @@ -27,9 +26,6 @@ built-ins/Array/prototype/some/15.4.4.17-7-6.js # real: array holes read inheri built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/sort/bug_596_1.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/ArrayIteratorPrototype/Symbol.toStringTag/value-from-to-string.js # real: built-in object model details (names, prototypes, toStringTag, own message) -built-ins/AsyncFunction/AsyncFunctionPrototype-is-not-callable.js # real: built-in object model details (names, prototypes, toStringTag, own message) -built-ins/GeneratorFunction/prototype/not-callable.js # real: built-in object model details (names, prototypes, toStringTag, own message) built-ins/JSON/parse/text-object.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/JSON/stringify/value-array-circular.js # accident: circular values are allowed; the reference rejects them on purpose when created built-ins/Promise/all/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does @@ -37,8 +33,6 @@ built-ins/Promise/allSettled/reject-element-function-nonconstructor.js # accide built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/any/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/race/S25.4.4.3_A5.1_T1.js # accident: Promise.race([]) never settles; the reference rejects it on purpose with a hint -built-ins/Promise/withResolvers/resolvers.js # real: built-in object model details (names, prototypes, toStringTag, own message) -built-ins/Set/prototype/keys/keys.js # real: built-in object model details (names, prototypes, toStringTag, own message) built-ins/String/fromCharCode/S9.7_A3.1_T4.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 3b5d3becdf13..8c769c5ce042 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -179,8 +179,10 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. - [x] Redeclaring a function in the same scope, or alongside a `var`, is allowed: the last declaration wins. - [x] Generator functions have their own `prototype` (inheriting the shared generator prototype), so `g() instanceof g` holds. Plain functions have none, since they cannot construct. -- [ ] `GeneratorFunction.prototype`: every function, generator or not, inherits directly from `Function.prototype`, - and a generator whose `prototype` was replaced by a non-object still creates from the shared generator prototype. +- [x] `GeneratorFunction.prototype`, `AsyncGeneratorFunction.prototype`, and `AsyncFunction.prototype`: generator, + async generator, and async functions (arrows included) inherit from these non-callable objects, which inherit + `Function.prototype`; the generator ones link to the shared generator prototypes through `prototype` and + `constructor`. A generator whose `prototype` was replaced by a non-object creates from the shared one. - [x] Generator and async generator functions bind parameters (defaults, destructuring) at the call and defer only the body to the first `next()`, so a bad argument throws synchronously from the call site, as in JS. - [x] Synchronous and async generator declarations/expressions, `yield`, and `yield*`, including lazy bodies, @@ -308,7 +310,7 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. accepted, including `.then`/`.catch` handlers and collection callbacks, and vanish at the data boundary like any function. - [x] `Promise.withResolvers()`: the same promise and resolver callables as the constructor, as a `{ promise, resolve, -reject }` object. +reject }` object. The resolvers are anonymous (`name` is `""`) with `length` 1, as every resolving function is. - [x] `Promise.try(fn, ...args)`: calls `fn` synchronously; a throw rejects, a return fulfils, and a returned promise or thenable is adopted. - [x] Recursive assimilation of objects with an own callable `then` field across `Promise.resolve`, combinators, @@ -394,7 +396,8 @@ reject }` object. with `next()` and `[Symbol.iterator]`, as in JS. Iterator objects are opaque references: they print as `[opaque reference]`, serialize to `{}`, and cannot be passed to extensions. Every built-in collection iterator shares one prototype, where JavaScript gives each collection its own; `Object.getPrototypeOf` shows the - difference. + difference. `Object.prototype.toString` still reports each one's kind: `[object Array Iterator]`, + `[object Map Iterator]`, `[object String Iterator]`, and so on. - [x] `length`, numeric indexing, index assignment, spread, and `for...of`. - [x] `Array.prototype.toSpliced`. - [x] Canonical array/string index parsing: keys such as `"01"` are ordinary properties rather than aliases of index @@ -541,7 +544,7 @@ reject }` object. - [x] `new Set()` from synchronous iterables. - [x] Set `add`, `has`, `delete`, `clear`, `size`, and `forEach`. - [x] Live `keys`, `values`, `entries`, and `[Symbol.iterator]` iterators for Map and Set; a Set-like operand's `keys()` - may return any iterator or an array. + may return any iterator or an array. `Set.prototype.keys` is the same function as `values`. - [x] Spread, `for...of`, `Array.from`, and `Object.fromEntries` integration. - [x] Map and Set values serialize to `{}` at host/JSON boundaries. - [x] Set composition and relation methods: `union`, `intersection`, `difference`, `symmetricDifference`, `isSubsetOf`, @@ -666,7 +669,8 @@ Nothing is exposed unless a host provides it; extension calls are not tool calls - [x] `Error`, `TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, and `URIError`, callable with or without `new`. - [x] `AggregateError` with the `(errors, message?)` signature and an own `errors` array, constructed directly or by - an all-rejected `Promise.any`; direct construction accepts custom synchronous iterators and generators. + an all-rejected `Promise.any`; direct construction accepts custom synchronous iterators and generators. Without + a message it has no own `message`, as in JS, and inherits `""`. - [x] Error `name`/`message`, error inheritance through `instanceof`, and plain-data serialization. `message` is an own non-enumerable property and `name` is inherited, as in JS, so `Object.keys(err)` is `[]` for a plain error. The result boundary still emits `{ name, message, ...own enumerable }`, so a field such as `code` crosses. `cause` is diff --git a/packages/codemode/src/runtime/errors.ts b/packages/codemode/src/runtime/errors.ts index 4e9ce352fc26..019a6c8090de 100644 --- a/packages/codemode/src/runtime/errors.ts +++ b/packages/codemode/src/runtime/errors.ts @@ -175,7 +175,10 @@ export const errorGlobal = (type: ErrorType, ctx: Interpreter) => { "string", message === undefined ? [] : [message], ([text]) => { - const created = withCause(createErrorValue(proto, message === undefined ? "" : coerceToString(text)), args[2]) + const created = withCause( + createErrorValue(proto, message === undefined ? undefined : coerceToString(text)), + args[2], + ) return new Invoke(ctx.prelude.fn("aggregateError"), undefined, [created, args[0]], undefined) }, true, diff --git a/packages/codemode/src/runtime/intrinsics.ts b/packages/codemode/src/runtime/intrinsics.ts index 89b80d75735e..6540241569d1 100644 --- a/packages/codemode/src/runtime/intrinsics.ts +++ b/packages/codemode/src/runtime/intrinsics.ts @@ -1,4 +1,4 @@ -import { define, hidden, Native, Arr, ErrorObj, Obj, type Value } from "./objects.js" +import { define, hidden, Native, Arr, ErrorObj, Obj, readonly, type Value } from "./objects.js" export const errorTypes = [ "Error", @@ -43,6 +43,9 @@ const builtins = [ "Generator", "AsyncGenerator", "AsyncFromSyncIterator", + "GeneratorFunction", + "AsyncGeneratorFunction", + "AsyncFunction", ] as const /** @@ -82,6 +85,16 @@ export const createBuiltins = (): Builtins => { const iterator = plain() const asyncIterator = plain() const uint8Array = plain() + const generator = new Obj(iterator) + const asyncGenerator = new Obj(asyncIterator) + // What generator and async functions inherit: plain objects, not callable, linked to the prototype of what they make. + const functionKind = (made?: Obj) => { + const proto = new Obj(fn) + if (made === undefined) return proto + define(proto, "prototype", made, readonly) + define(made, "constructor", proto, readonly) + return proto + } return { Object: object, Function: fn, @@ -109,10 +122,13 @@ export const createBuiltins = (): Builtins => { Iterator: iterator, IteratorHelper: new Obj(iterator), AsyncIterator: asyncIterator, - Generator: new Obj(iterator), - AsyncGenerator: new Obj(asyncIterator), + Generator: generator, + AsyncGenerator: asyncGenerator, /** CreateAsyncFromSyncIterator's objects; programs never see them. */ AsyncFromSyncIterator: new Obj(asyncIterator), + GeneratorFunction: functionKind(generator), + AsyncGeneratorFunction: functionKind(asyncGenerator), + AsyncFunction: functionKind(), Error: error, TypeError: derived("TypeError"), RangeError: derived("RangeError"), diff --git a/packages/codemode/src/runtime/objects.ts b/packages/codemode/src/runtime/objects.ts index ad09b37256bd..4c97ae6d1602 100644 --- a/packages/codemode/src/runtime/objects.ts +++ b/packages/codemode/src/runtime/objects.ts @@ -485,18 +485,29 @@ export class Position implements TableCursor { /** A built-in iterator: a live cursor over a host collection or an iterator helper, yielding program values. */ export class IteratorObj extends Opaque { - override readonly tag = "Iterator" + /** The `@@toStringTag` of what it walks: `[object Array Iterator]`, or `[object Iterator]` for a helper. */ + override readonly tag: string constructor( proto: Obj, readonly cursor: Cursor, ) { super(proto) + this.tag = cursor instanceof Position ? `${iteratedKind(cursor.source)} Iterator` : "Iterator" } override get describe() { return "an iterator" } } +const iteratedKind = (source: PositionSource): string => { + if (typeof source === "string") return "String" + if (source instanceof MapObj) return "Map" + if (source instanceof SetObj) return "Set" + if (source instanceof HeadersObj) return "Headers" + if (source instanceof URLSearchParamsObj) return "URLSearchParams" + return "Array" +} + /** A built-in iterator over a collection, e.g. `array.values()`. */ export const positionIterator = (builtins: Builtins, source: PositionSource, kind: IterationKind): IteratorObj => new IteratorObj(builtins.Iterator, new Position(source, kind, builtins.Array)) diff --git a/packages/codemode/src/runtime/promises.ts b/packages/codemode/src/runtime/promises.ts index 0b91eebb91d0..3acd7e1661de 100644 --- a/packages/codemode/src/runtime/promises.ts +++ b/packages/codemode/src/runtime/promises.ts @@ -11,8 +11,8 @@ import { finishAwaitReturn } from "../generators.js" // A `resolve`/`reject` handed to an executor or thenable: calling it settles the capability. const resolvingFunctions = (ctx: Interpreter, resolving: Resolving) => ({ - resolve: new Resolver(ctx.builtins.Function, "resolve", resolving, "resolve"), - reject: new Resolver(ctx.builtins.Function, "reject", resolving, "reject"), + resolve: new Resolver(ctx.builtins.Function, "", resolving, "resolve"), + reject: new Resolver(ctx.builtins.Function, "", resolving, "reject"), }) /** diff --git a/packages/codemode/src/snapshot/codec.ts b/packages/codemode/src/snapshot/codec.ts index 1af62f67aa91..1713b0287796 100644 --- a/packages/codemode/src/snapshot/codec.ts +++ b/packages/codemode/src/snapshot/codec.ts @@ -199,7 +199,7 @@ const builtinSpecs = (): ReadonlyArray => [ obj: true, constants: { tag: "Generator" }, }, - { name: "IteratorObj", ctor: IteratorObj, fields: ["cursor"], obj: true, constants: { tag: "Iterator" } }, + { name: "IteratorObj", ctor: IteratorObj, fields: ["cursor", "tag"], obj: true }, { name: "DateObj", ctor: DateObj, fields: ["time"], obj: true, constants: { tag: "Date" } }, { name: "RegExpObj", diff --git a/packages/codemode/src/stdlib/collections.ts b/packages/codemode/src/stdlib/collections.ts index 7458be075291..e8f8c18b14fb 100644 --- a/packages/codemode/src/stdlib/collections.ts +++ b/packages/codemode/src/stdlib/collections.ts @@ -120,8 +120,10 @@ export const setGlobal = (ctx: Interpreter) => { return undefined }, ], - ...iteratorMethods(builtins, self), + // Set.prototype.keys is the same function as values. + ...iteratorMethods(builtins, self).filter(([name]) => name !== "keys"), ]) + define(proto, "keys", get(proto, "values"), hidden) define(proto, IteratorSymbol, get(proto, "values"), hidden) return set } diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index 7c7061b2b1e6..c6b342d75c70 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -1938,11 +1938,13 @@ export class Vm { } childCells = arr } - const fn = new Fn(this.ctx.builtins.Function, childCode, childCells) - if ((childCode.flags & CodeFlags.GENERATOR) !== 0) { - const isAsync = (childCode.flags & CodeFlags.ASYNC) !== 0 - define(fn, "prototype", new Obj(isAsync ? this.ctx.builtins.AsyncGenerator : this.ctx.builtins.Generator), hidden) + const builtins = this.ctx.builtins + const isAsync = (childCode.flags & CodeFlags.ASYNC) !== 0 + if ((childCode.flags & CodeFlags.GENERATOR) === 0) { + return new Fn(isAsync ? builtins.AsyncFunction : builtins.Function, childCode, childCells) } + const fn = new Fn(isAsync ? builtins.AsyncGeneratorFunction : builtins.GeneratorFunction, childCode, childCells) + define(fn, "prototype", new Obj(isAsync ? builtins.AsyncGenerator : builtins.Generator), hidden) return fn } diff --git a/packages/codemode/test/errors.test.ts b/packages/codemode/test/errors.test.ts index a78063c0ca96..b45194df3139 100644 --- a/packages/codemode/test/errors.test.ts +++ b/packages/codemode/test/errors.test.ts @@ -98,6 +98,17 @@ describe("error identity", () => { }) }) +describe("AggregateError", () => { + test("has an own message only when one is given", async () => { + expect( + await value(` + const own = (error) => Object.hasOwn(error, "message") + return [own(new AggregateError([])), own(new AggregateError([], undefined)), own(new AggregateError([], "m")), new AggregateError([]).message] + `), + ).toEqual([false, false, true, ""]) + }) +}) + describe("rethrown interpreter failures", () => { test("keep their diagnostic kind and source location", async () => { const failure = await error(`try { Promise.resolve(1) + 1 } catch (e) { throw e }`) diff --git a/packages/codemode/test/promise.test.ts b/packages/codemode/test/promise.test.ts index 947e3a50d69d..075af2bc8884 100644 --- a/packages/codemode/test/promise.test.ts +++ b/packages/codemode/test/promise.test.ts @@ -1169,6 +1169,14 @@ describe("Promise.withResolvers", () => { `), ).toEqual([["promise", "resolve", "reject"], true, "adopted", "no"]) }) + + test("its resolving functions are anonymous, with length 1", async () => { + expect( + await value( + `const { resolve, reject } = Promise.withResolvers(); return [resolve.name, resolve.length, reject.name]`, + ), + ).toEqual(["", 1, ""]) + }) }) describe("Promise.any", () => { diff --git a/packages/codemode/test/resumable.test.ts b/packages/codemode/test/resumable.test.ts index 8bc794f4e3f2..34e0c1ad6884 100644 --- a/packages/codemode/test/resumable.test.ts +++ b/packages/codemode/test/resumable.test.ts @@ -173,9 +173,9 @@ describe("natives only at intrinsic creation", () => { "function", [1, 2, 3, 4], "bound bound add", - "resolve", + "", 1, - "reject", + "", "function", 5, ["", 1, "function"], diff --git a/packages/codemode/test/stdlib.test.ts b/packages/codemode/test/stdlib.test.ts index 8021db9041b1..8be03d36f590 100644 --- a/packages/codemode/test/stdlib.test.ts +++ b/packages/codemode/test/stdlib.test.ts @@ -969,6 +969,13 @@ describe("Map", () => { }) describe("Set", () => { + test("keys is the same function as values", async () => { + expect(await value(`return [Set.prototype.keys === Set.prototype.values, Set.prototype.keys.name]`)).toEqual([ + true, + "values", + ]) + }) + test("forEach is live on Map and Set: deleted entries are skipped and added ones visited", async () => { expect( await value(` @@ -1554,7 +1561,18 @@ describe("built-in iterators", () => { ]) const logged = await run(`console.log([1].keys()); return null`) expect(logged.logs?.[0]).toBe("[opaque reference]") - expect(await value(`return [1].keys() + ""`)).toBe("[object Iterator]") + expect( + await value( + `return [[1].keys(), "a"[Symbol.iterator](), new Map().entries(), new Set().values(), new Headers().keys(), new URLSearchParams().keys()].map(String)`, + ), + ).toEqual([ + "[object Array Iterator]", + "[object String Iterator]", + "[object Map Iterator]", + "[object Set Iterator]", + "[object Headers Iterator]", + "[object URLSearchParams Iterator]", + ]) expect((await error(`return [1].keys().next.call({})`)).message).toContain( "Iterator.prototype.next called on incompatible receiver a data object", ) @@ -1579,7 +1597,7 @@ describe("Object.prototype.toString", () => { "[object Set]", "[object Headers]", "[object Promise]", - "[object Iterator]", + "[object Array Iterator]", "[object Object]", "[object Map]", "[object Promise]", diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index e0aa73d02482..ce9ba4100ab8 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1,4 +1,3 @@ -built-ins/AggregateError/message-undefined-no-prop.js # explicit Expected SameValue(«true», «false») to be true built-ins/Array/S15.4.5.2_A3_T3.js # RangeError: Invalid array length built-ins/Array/from/Array.from_forwards-length-for-array-likes.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/Array/from/elements-deleted-after.js # TypeError: Cannot read properties of undefined (reading '…'). @@ -872,9 +871,7 @@ built-ins/Array/prototype/values/returns-iterator-from-object.js # TypeError: A built-ins/Array/prototype/with/length-exceeding-array-length-limit.js # TypeError: Only init object properties are supported. built-ins/Array/prototype/with/length-tolength.js # TypeError: Array.prototype.with called on incompatible receiver a data object. built-ins/Array/prototype/with/this-value-boolean.js # TypeError: Array.prototype.with called on incompatible receiver a boolean. -built-ins/ArrayIteratorPrototype/Symbol.toStringTag/value-from-to-string.js # Expected SameValue(«"[object Array Iterator]"», «"[object Iterator]"») to be true built-ins/AsyncFunction/AsyncFunction-construct.js # TypeError: The Function constructor is not supported; write the function inline. -built-ins/AsyncFunction/AsyncFunctionPrototype-is-not-callable.js # Expected SameValue(«"function"», «"object"») to be true built-ins/AsyncFunction/instance-construct-throws.js # TypeError: The Function constructor is not supported; write the function inline. built-ins/AsyncGeneratorFunction/has-instance.js # TypeError: The Function constructor is not supported; write the function inline. built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js # TypeError: The Function constructor is not supported; write the function inline. @@ -931,7 +928,6 @@ built-ins/GeneratorFunction/invoked-as-constructor-no-arguments.js # TypeError: built-ins/GeneratorFunction/invoked-as-function-multiple-arguments.js # TypeError: The Function constructor is not supported; write the function inline. built-ins/GeneratorFunction/invoked-as-function-no-arguments.js # TypeError: The Function constructor is not supported; write the function inline. built-ins/GeneratorFunction/invoked-as-function-single-argument.js # TypeError: The Function constructor is not supported; write the function inline. -built-ins/GeneratorFunction/prototype/not-callable.js # Expected SameValue(«"function"», «"object"») to be true built-ins/GeneratorPrototype/throw/from-state-completed.js # Expected a E but got a TypeError built-ins/GeneratorPrototype/throw/from-state-suspended-start.js # Expected a E but got a TypeError built-ins/Iterator/from/return-method-returns-iterator-result.js # Iterator next must be a function. @@ -1273,7 +1269,6 @@ built-ins/Promise/resolve/ctx-ctor-throws.js # Expected a Test262Error to be th built-ins/Promise/resolve/resolve-from-promise-capability.js # callCount after call to resolve() Expected SameValue(«0», «1») to be true built-ins/Promise/resolve/resolve-self.js # $DONE was never called built-ins/Promise/try/ctx-ctor-throws.js # Expected a Test262Error to be thrown but no exception was thrown at all -built-ins/Promise/withResolvers/resolvers.js # Expected SameValue(«"resolve"», «""») to be true built-ins/RegExp/S15.10.3.1_A1_T1.js # The value of __instance.indicator is expected to be 1 Expected SameValue(«undefined», «1») to be tru built-ins/RegExp/S15.10.3.1_A1_T2.js # The value of __instance.indicator is expected to be 1 Expected SameValue(«undefined», «1») to be tru built-ins/RegExp/S15.10.3.1_A1_T3.js # The value of __instance.indicator is expected to be 1 Expected SameValue(«undefined», «1») to be tru @@ -1309,7 +1304,6 @@ built-ins/Set/prototype/isDisjointFrom/size-is-a-number.js # TypeError: BigInt built-ins/Set/prototype/isSubsetOf/size-is-a-number.js # TypeError: BigInt literals are not supported. built-ins/Set/prototype/isSupersetOf/set-like-iter-return.js # Expected SameValue(«4», «1») to be true built-ins/Set/prototype/isSupersetOf/size-is-a-number.js # TypeError: BigInt literals are not supported. -built-ins/Set/prototype/keys/keys.js # The value of `Set.prototype.keys` is `Set.prototype.values` Expected SameValue(«keys», «values») to built-ins/Set/prototype/symmetricDifference/size-is-a-number.js # TypeError: BigInt literals are not supported. built-ins/Set/prototype/union/size-is-a-number.js # TypeError: BigInt literals are not supported. built-ins/Set/set-iterable-calls-add.js # `Set.prototype.add` called twice. Expected SameValue(«0», «2») to be true diff --git a/packages/codemode/test/var-hoisting-test262.test.ts b/packages/codemode/test/var-hoisting-test262.test.ts index 667603f5232a..92fcd3011102 100644 --- a/packages/codemode/test/var-hoisting-test262.test.ts +++ b/packages/codemode/test/var-hoisting-test262.test.ts @@ -270,6 +270,20 @@ describe("function declarations and expressions", () => { `), ).toEqual([true, true, false, "object", "undefined"]) }) + + test("generator and async functions inherit from their own non-callable function prototypes", async () => { + expect( + await value(` + const proto = Object.getPrototypeOf + const kinds = [function* () {}, async function* () {}, async function () {}, async () => {}] + const protos = kinds.map(proto) + let failure + try { protos[0]() } catch (error) { failure = error.name } + return [protos.map((p) => typeof p), protos.map((p) => proto(p) === Function.prototype), protos[2] === protos[3], + protos[0].prototype === proto(kinds[0].prototype), Object.hasOwn(protos[2], "prototype"), failure] + `), + ).toEqual([["object", "object", "object", "object"], [true, true, true, true], true, true, false, "TypeError"]) + }) }) describe("switch case function hoisting", () => { From acd81eff92c5994600c6d601fdf989bba08cd842 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 020/100] fix(codemode): let in find an array hole's inherited index The fast path for an integer in an array answered false for a hole; it now answers only for a present element and leaves the rest to the prototype walk, so forEach, some, and reduce visit an index inherited from Array.prototype. --- .../codemode-rust/test262/reference-gaps.txt | 4 ---- packages/codemode/interpreter-support.md | 3 ++- packages/codemode/src/vm.ts | 11 +++++++++-- .../test/array-callbacks-test262.test.ts | 17 +++++++++++++++++ packages/codemode/test/test262/skipped.txt | 4 ---- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index e3c3e9be85df..feb6a0cb9980 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -6,7 +6,6 @@ built-ins/Array/length/S15.4.5.1_A1.3_T2.js # real: ToPrimitive and ToIntegerOr built-ins/Array/prototype/at/index-argument-tointeger.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/fill/return-abrupt-from-end.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/fill/return-abrupt-from-start.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/forEach/15.4.4.18-7-5.js # real: array holes read inherited Array.prototype indexes built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/includes/tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) @@ -19,10 +18,7 @@ built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js # real: ToPrimitive and built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js # accident: circular values are allowed; the reference rejects them on purpose when created built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js # real: array holes read inherited Array.prototype indexes -built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js # real: array holes read inherited Array.prototype indexes built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/some/15.4.4.17-7-6.js # real: array holes read inherited Array.prototype indexes built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/sort/bug_596_1.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 8c769c5ce042..9385d6c51e84 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -380,7 +380,8 @@ reject }` object. The resolvers are anonymous (`name` is `""`) with `length` 1, - [x] The `Array` constructor with or without `new`: `Array(a, b)` collects arguments and `Array(n)` creates a sparse array of that length; invalid lengths throw `RangeError`. Iteration, spread, join, `flatMap`, and JSON handle - holes like JavaScript, and host results normalize holes to `null`. + holes like JavaScript, and host results normalize holes to `null`. A hole reads, and `in` finds, an index + inherited from `Array.prototype`, so the callback methods visit it. - [x] Static methods: `Array.isArray`, `Array.of`, and `Array.from`, including the `Array.from` mapper form with `(value, index)` arguments and stepwise synchronous iterator consumption. - [x] Iteration/transformation: `map`, `filter`, `flatMap`, and `forEach`. diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index c6b342d75c70..fff5d0f7c933 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -836,8 +836,15 @@ export class Vm { // Op.IN const rhs = regs[--sp] as Value const lhs = regs[sp - 1] as Value - if (typeof lhs === "number" && lhs >= 0 && (lhs | 0) === lhs && rhs instanceof ArrCtor) { - regs[sp - 1] = lhs in rhs.items + // A present element; a hole or an index past the end may still be inherited. + if ( + typeof lhs === "number" && + lhs >= 0 && + (lhs | 0) === lhs && + rhs instanceof ArrCtor && + lhs in rhs.items + ) { + regs[sp - 1] = true pc++ continue } diff --git a/packages/codemode/test/array-callbacks-test262.test.ts b/packages/codemode/test/array-callbacks-test262.test.ts index 4dd980095165..1a4effed8f7e 100644 --- a/packages/codemode/test/array-callbacks-test262.test.ts +++ b/packages/codemode/test/array-callbacks-test262.test.ts @@ -380,6 +380,23 @@ describe("Array callback regressions", () => { ).toEqual(["TypeError", "TypeError"]) }) + test("a hole reads an index inherited from Array.prototype", async () => { + expect( + await value(` + Array.prototype[1] = "inherited" + try { + const holes = [0, , 2] + const seen = [] + holes.forEach((item) => seen.push(item)) + const index = 1 + return [seen, index in holes, 1 in holes, [, ,].reduce((a, b) => a + b), Object.hasOwn(holes, 1)] + } finally { + delete Array.prototype[1] + } + `), + ).toEqual([[0, "inherited", 2], true, true, "inherited", false]) + }) + test("findLast returns the value observed before predicate mutation", async () => { expect( await value(` diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index ce9ba4100ab8..205479659da3 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -241,7 +241,6 @@ built-ins/Array/prototype/forEach/15.4.4.18-3-7.js # TypeError: Array.prototype built-ins/Array/prototype/forEach/15.4.4.18-3-9.js # TypeError: Array.prototype.forEach called on incompatible receiver a data object. built-ins/Array/prototype/forEach/15.4.4.18-5-4.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/Array/prototype/forEach/15.4.4.18-5-5.js # TypeError: foo cannot be constructed: user-defined constructors and classes are not supported. Call -built-ins/Array/prototype/forEach/15.4.4.18-7-5.js # callCnt Expected SameValue(«4», «5») to be true built-ins/Array/prototype/forEach/15.4.4.18-7-8.js # TypeError: Array.prototype.forEach called on incompatible receiver a data object. built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js # TypeError: Array.prototype.forEach called on incompatible receiver a data object. built-ins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js # TypeError: Array.prototype.forEach called on incompatible receiver an Arguments. @@ -586,7 +585,6 @@ built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js # TypeError: Array.p built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js # TypeError: Con cannot be constructed: user-defined constructors and classes are not supported. Call built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js # TypeError: Con cannot be constructed: user-defined constructors and classes are not supported. Call built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js # Array.reduce of an empty array with no initial value. -built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js # Array.reduce of an empty array with no initial value. built-ins/Array/prototype/reduce/15.4.4.21-9-6.js # res Expected SameValue(«"123"», «"1235"») to be true built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js # TypeError: Array.prototype.reduce called on incompatible receiver a data object. built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js # TypeError: Array.prototype.reduce called on incompatible receiver an Arguments. @@ -680,7 +678,6 @@ built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js # TypeError: Ar built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js # TypeError: Con cannot be constructed: user-defined constructors and classes are not supported. Call built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js # TypeError: Con cannot be constructed: user-defined constructors and classes are not supported. Call built-ins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js # Array.reduceRight of an empty array with no initial value. -built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js # Array.reduceRight of an empty array with no initial value. built-ins/Array/prototype/reduceRight/15.4.4.22-9-6.js # res Expected SameValue(«"91"», «"151"») to be true built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js # TypeError: Array.prototype.reduceRight called on incompatible receiver a data object. built-ins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js # TypeError: Array.prototype.reduceRight called on incompatible receiver an Arguments. @@ -780,7 +777,6 @@ built-ins/Array/prototype/some/15.4.4.17-3-8.js # TypeError: Array.prototype.so built-ins/Array/prototype/some/15.4.4.17-3-9.js # TypeError: Array.prototype.some called on incompatible receiver a data object. built-ins/Array/prototype/some/15.4.4.17-5-4.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/Array/prototype/some/15.4.4.17-5-5.js # TypeError: foo cannot be constructed: user-defined constructors and classes are not supported. Call -built-ins/Array/prototype/some/15.4.4.17-7-6.js # res Expected SameValue(«false», «true») to be true built-ins/Array/prototype/some/15.4.4.17-7-8.js # TypeError: Array.prototype.some called on incompatible receiver a data object. built-ins/Array/prototype/some/15.4.4.17-7-c-i-1.js # TypeError: Array.prototype.some called on incompatible receiver a data object. built-ins/Array/prototype/some/15.4.4.17-7-c-i-25.js # TypeError: Array.prototype.some called on incompatible receiver an Arguments. From f6bb82cb96425998de1288933c44c2880f9a547f Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 021/100] fix(codemode): convert Array arguments, lengths and sort elements through ToPrimitive The integer arguments of the Array methods, length = object, and the elements a default sort compares call the program's own valueOf/toString, as do String.fromCharCode/fromCodePoint, JSON.parse, and the string iterator's receiver. repeat(NaN) is "", as ToIntegerOrInfinity makes NaN 0. --- .../codemode-rust/test262/reference-gaps.txt | 24 --- packages/codemode/interpreter-support.md | 12 +- packages/codemode/src/internal-prelude.ts | 5 + packages/codemode/src/prelude/bytecode.json | 2 +- packages/codemode/src/prelude/helpers.ts | 6 +- packages/codemode/src/prelude/source.ts | 4 +- packages/codemode/src/stdlib/array.ts | 149 ++++++++++++------ packages/codemode/src/stdlib/json.ts | 12 +- packages/codemode/src/stdlib/string.ts | 15 +- packages/codemode/src/vm.ts | 15 +- packages/codemode/test/parity.test.ts | 50 ++++++ packages/codemode/test/test262/skipped.txt | 24 --- 12 files changed, 203 insertions(+), 115 deletions(-) diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index feb6a0cb9980..ee6425233b4c 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -2,38 +2,14 @@ # with "real" (Rust has the behaviour and TypeScript lacks it) or "accident" (Rust passes through a looser check, # where the reference is deliberately strict). Generated by `bash test262/run.sh --write`, which keeps the categories; # CI fails when an unlisted file passes, a listed file fails here, or the reference passes a listed file. -built-ins/Array/length/S15.4.5.1_A1.3_T2.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/at/index-argument-tointeger.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/fill/return-abrupt-from-end.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/fill/return-abrupt-from-start.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/includes/tointeger-fromindex.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js # accident: circular values are allowed; the reference rejects them on purpose when created -built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js # accident: circular values are allowed; the reference rejects them on purpose when created -built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/sort/bug_596_1.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/JSON/parse/text-object.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) built-ins/JSON/stringify/value-array-circular.js # accident: circular values are allowed; the reference rejects them on purpose when created built-ins/Promise/all/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/allSettled/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/any/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/race/S25.4.4.3_A5.1_T1.js # accident: Promise.race([]) never settles; the reference rejects it on purpose with a hint -built-ins/String/fromCharCode/S9.7_A3.1_T4.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/String/fromCodePoint/to-number-conversions.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) -built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # real: ToPrimitive and ToIntegerOrInfinity of arguments, lengths and elements (TS gap, interpreter-support.md) language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/interpreter-support.md b/packages/codemode/interpreter-support.md index 9385d6c51e84..9033481589e2 100644 --- a/packages/codemode/interpreter-support.md +++ b/packages/codemode/interpreter-support.md @@ -263,7 +263,13 @@ Math.floor)` is `"3"`). A detached method loses its receiver, as in JS: `values. hint (`"abc".indexOf({ toString() { return "b" } })` is `1`, `(255).toString({ valueOf() { return 16 } })` is `"ff"`, `String.prototype.trim.call({ toString() { return " a " } })` is `"a"`). Only consumed positions convert; a RegExp pattern is used as is, and `includes`/`startsWith`/`endsWith` reject one before converting. -- [ ] ToPrimitive elsewhere: `Error.prototype.toString` on an object `message` and numeric arguments of the Array and +- [x] Array methods, lengths, and elements convert through ToPrimitive: the integer arguments of `at`, `indexOf`, + `lastIndexOf`, `includes`, `slice`, `splice`, `toSpliced`, `fill`, `copyWithin`, `with`, and `flat` (in order, + before the array is read, and not at all for an empty array's `indexOf`/`lastIndexOf`/`includes`), + `length = object` (number hint), and the elements a default `sort` compares (one ToString each). So do + `String.fromCharCode`/`fromCodePoint` arguments, `JSON.parse(text)`, and a `String.prototype[Symbol.iterator]` + receiver; `repeat(NaN)` is `""`. +- [ ] ToPrimitive elsewhere: `Error.prototype.toString` on an object `message` and numeric arguments of the Uint8Array methods (`at`, `indexOf` start, `slice`) still use the built-in form (`NaN`, `"[object Object]"`) and ignore own methods. - [x] Property keys follow ToPropertyKey: `x[null]` and `x[true]` become string keys, and a data object key @@ -413,8 +419,8 @@ reject }` object. The resolvers are anonymous (`name` is `""`) with `length` 1, `String.fromCharCode("65")`, and the Uint8Array equivalents. `join(sep)` and `JSON.parse(text)` apply ToString (`join(null)` is `"1null2"`, `JSON.parse(123)` is `123`). `Array.from({ length: "2" })` applies ToLength; a promise source still throws with an `await` hint rather than JS's silent `[]`. `join`, `Math.*`, `parseInt`, - and the String and Number methods consult a program object's own `valueOf`/`toString`; the array methods do not - yet (see ToPrimitive above). + and the String, Number, and Array methods consult a program object's own `valueOf`/`toString`; the Uint8Array + methods do not yet (see ToPrimitive above). ## Strings diff --git a/packages/codemode/src/internal-prelude.ts b/packages/codemode/src/internal-prelude.ts index 6a17d482cdc6..e63d0d9363e7 100644 --- a/packages/codemode/src/internal-prelude.ts +++ b/packages/codemode/src/internal-prelude.ts @@ -94,6 +94,11 @@ function $vmBinary(op, lhs, rhs) { return $ApplyBinary(op, l, r) } +function $vmSetLength(o, v) { + o.length = $vmToPrimitive(v, "number") + return v +} + function $vmGetElem(o, k) { return o[$vmToKey(k)] } diff --git a/packages/codemode/src/prelude/bytecode.json b/packages/codemode/src/prelude/bytecode.json index 667be7156c7a..72170c3d045a 100644 --- a/packages/codemode/src/prelude/bytecode.json +++ b/packages/codemode/src/prelude/bytecode.json @@ -1 +1 @@ -{"@prelude":{"text":"f135511dc7fc0839","codes":[{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65546,328,262411,3,327947,327690,65546,46,1835069,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,393276,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,54,2,52,3,50,4,58,5,56,6,61,7,62,8,60,9,59,10,67,11,68,12,66,13,68,14,66,15,72,16,71,17,74,18,75,19,73,20,76,21,69,22,66,23,65,24,79,25,78,26,79,27,59,28,81,29,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,262154,328,327947,3,393483,393226,262154,46,2752573,393226,10,33,2490429,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,983100,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,151,11,149,12,147,13,155,14,153,15,158,16,159,17,157,18,156,19,163,20,164,21,162,22,161,23,168,24,169,25,167,26,169,27,167,28,173,29,172,30,175,31,176,32,174,33,177,34,178,35,170,36,167,37,166,38,181,39,180,40,181,41,156,42,183,43,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":33,"name":"sortDefault","flags":72,"length":5,"params":5,"locals":6,"maxStack":9,"code":[0,20,196618,326,327947,0,65556,327690,326,720957,327740,0,131092,10,65546,131082,0,196628,327690,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1221,1,1222,2,1223,3,1221,4,1219,5,1225,6,1226,7,1227,8,1225,9,1224,11,1230,12,1231,13,1232,14,1233,15,1234,16,1235,17,1236,18,1237,19,1238,20,1235,21,1239,22,1230,23,1229],"localNames":["target","into","holes","values","undefs","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1240,2,1246,3,1247,4,1248,5,1249,6,1250,7,1246,8,1244,9,1254,10,1252,11,1258,12,1256,13,1260,15,1264,16,1266,17,1265,18,1263,19,1262,20,1271,21,1272,22,1270,23,1269,24,1275,25,1276,26,1274,27,1275,28,1281,29,1282,30,1280,31,1279,32,1286,33,1287,34,1285,35,1284,36,1289,37,1290,38,1288,39,1283,40,1293,41,1294,42,1295,43,1298,44,1297,45,1296,46,1294,47,1292,48,1293,49,1302,50,1301,51,1302,52,1262,53,1304,54,1303],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1316,1,1317,2,1315,3,1314,4,1319,5,1320,6,1318,7,1312,9,1325,10,1321,16,1322,17,1329,18,1328,19,1327,20,1331,21,1332,22,1333,23,1334,24,1335,25,1331,27,1327,28,1338,29,1339,30,1340,31,1338,32,1337,33,1336,34,1342,35,1343,36,1344,37,1347,38,1348,39,1346,40,1349,41,1345,42,1342,44,1336,45,1351,46,1352,47,1353,48,1354,49,1356,50,1357,51,1355,52,1359,53,1360,54,1358,55,1351,57,1321,72,1362,73,1361],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1369,1,1370,2,1371,3,1372,4,1373,5,1369,6,1368],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1380,1,1381,2,1382,3,1383,4,1384,5,1380,6,1379],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1394,1,1395,2,1393,3,1392,4,1397,5,1398,6,1396,7,1391,8,1400,9,1401,10,1402,11,1404,12,1405,13,1403,14,1400,16,1407,17,1408,18,1409,19,1411,20,1412,21,1410,22,1407,24,1416,25,1417,26,1418,27,1419,28,1416,29,1414,30,1423,31,1421,32,1425,35,1431,36,1427,42,1428,43,1436,44,1437,45,1438,46,1440,48,1439,50,1440,51,1436,52,1435,53,1443,54,1444,55,1442,56,1441,57,1448,58,1449,59,1450,60,1451,61,1452,62,1453,63,1450,64,1448,65,1447,66,1455,67,1456,68,1457,69,1458,70,1459,71,1460,72,1455,74,1427,89,1462,90,1461],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1472,1,1473,2,1474,3,1472,4,1470,5,1476,6,1477,7,1478,8,1479,9,1480,10,1481,11,1476,13,1483,14,1482],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1484,2,1486,4,1487,6,1489,7,1487,8,1492,9,1493,10,1494,11,1495,12,1496,13,1497,14,1498,15,1494,16,1499,17,1500,18,1501,19,1492,21,1490],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1502,2,1504,4,1505,6,1507,7,1505,8,1510,9,1511,10,1512,11,1513,12,1514,13,1515,14,1516,15,1512,16,1517,17,1518,18,1519,19,1510,21,1508],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1528,1,1529,2,1530,3,1531,4,1528,7,1536,8,1537,9,1538,10,1539,11,1536,12,1532,18,1533,19,1544,20,1543,21,1546,22,1547,23,1545,24,1549,25,1550,26,1548,27,1551,28,1541,30,1532,45,1526],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1552,2,1557,3,1558,4,1559,5,1560,6,1561,7,1562,8,1563,9,1559,10,1564,11,1565,12,1557,13,1556],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1566,2,1571,3,1572,4,1573,5,1574,6,1575,7,1576,8,1577,9,1573,10,1578,11,1579,12,1571,13,1570],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1580,2,1585,3,1586,4,1587,5,1588,6,1589,7,1590,8,1591,9,1587,10,1592,11,1593,12,1585,13,1584],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1594,2,1599,3,1600,4,1601,5,1602,6,1603,7,1604,8,1605,9,1601,10,1606,11,1607,12,1599,13,1598],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1608,2,1613,3,1614,4,1615,5,1616,6,1617,7,1618,8,1619,9,1615,10,1620,11,1621,12,1613,13,1612],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1622,2,1627,3,1628,4,1629,5,1630,6,1631,7,1632,8,1633,9,1629,10,1634,11,1635,12,1627,13,1626],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1636,2,1641,3,1642,4,1643,5,1644,6,1645,7,1646,8,1647,9,1643,10,1648,11,1649,12,1641,13,1640],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7143485,1114132,72,8388667,131082,1179652,50,7602239,131082,1245188,50,7864383,131082,1310724,50,8323133,0,851988,1376260,10,582,8388667,0,459019,131082,917508,50,9699391,131082,1048580,50,9175103,131082,1245188,50,9437247,131082,1441796,50,9699647,393226,196618,47,524555,0,590091,524298,15990845,720908,0,851988,1507332,131082,1245188,50,10682429,458762,10747963,10,582,14549066,14549051,852235,15469900,14745659,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12648509,589834,12582973,0,851988,1572868,458762,720906,838,5,14483515,131082,1245188,50,13566013,589834,13500477,0,851988,1638404,458762,720906,838,5,14483515,589834,131082,1441796,50,50,14483517,2,983307,14355790,70,1611,5,983050,67,11010108,70,75,10944571,70,15469901,11141179,917771,15207758,70,5,917514,64,5,15204411,458762,0,50,15859773,258,15925307,458762,67,65546,327690,70,655627,0,20,655370,326,54,17301565,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23134282,23134267,1048843,24055884,23330875,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19398717,0,851988,1572868,458762,786442,838,5,23068731,131082,1048580,50,20316221,589834,20250685,0,851988,1572868,458762,786442,838,5,23068731,131082,1245188,50,21102653,0,851988,1638404,458762,786442,838,5,23068731,131082,1310724,50,22151229,0,851988,589834,21758013,1638404,21823547,1572868,458762,786442,838,5,23068731,589834,131082,1441796,50,50,23068733,2,983307,22941774,70,1611,5,983050,67,17891388,70,75,17825851,70,24055885,18022459,1114379,23793742,70,5,1114122,64,5,23789627,458762,0,50,24444989,258,24510523,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[170,222,228,0,229,232,234,0,275,353,359,0,360,363,365,0],"finallies":[],"finallyOffsets":[],"sites":[0,1658,1,1659,2,1660,3,1658,4,1657,5,1656,6,1662,7,1663,8,1664,9,1667,10,1668,11,1666,12,1669,13,1665,14,1662,16,1675,17,1674,18,1673,19,1671,20,1679,21,1680,22,1678,23,1677,24,1682,25,1683,26,1684,27,1687,28,1688,29,1686,30,1689,31,1685,32,1682,34,1692,35,1693,36,1691,37,1690,38,1695,39,1696,40,1697,41,1700,42,1701,43,1699,44,1702,45,1698,46,1695,48,1707,49,1706,50,1704,51,1713,52,1712,53,1710,54,1718,55,1719,56,1720,57,1718,58,1717,59,1716,60,1722,61,1723,62,1724,63,1722,64,1721,65,1715,66,1726,67,1727,68,1728,69,1731,70,1732,71,1730,72,1733,73,1729,74,1726,76,1737,77,1738,78,1739,79,1740,80,1737,81,1735,82,1744,83,1745,84,1743,85,1742,86,1747,87,1748,88,1746,89,1741,90,1750,91,1749,92,1754,93,1755,94,1753,95,1752,96,1757,97,1758,98,1756,99,1751,100,1760,101,1759,102,1766,103,1767,104,1765,105,1764,106,1769,107,1768,108,1764,109,1774,110,1775,111,1773,112,1772,113,1777,114,1778,115,1776,116,1771,117,1780,118,1781,119,1779,120,1770,121,1782,122,1783,123,1784,124,1785,125,1782,126,1770,127,1786,128,1762,129,1792,130,1793,131,1791,132,1790,133,1798,134,1799,135,1797,136,1796,137,1801,138,1802,139,1800,140,1795,141,1804,142,1805,143,1803,144,1794,145,1807,146,1808,147,1806,148,1788,149,1810,151,1813,152,1812,154,1819,155,1820,156,1821,157,1824,158,1825,159,1823,160,1822,161,1826,162,1822,163,1827,164,1819,165,1815,171,1816,172,1837,173,1836,174,1838,175,1834,176,1833,177,1832,178,1831,179,1841,180,1842,181,1840,182,1839,183,1845,184,1844,185,1847,186,1848,187,1849,188,1850,189,1851,190,1847,192,1839,193,1854,194,1855,195,1853,196,1852,197,1858,198,1857,199,1860,200,1861,201,1862,202,1863,203,1864,204,1860,206,1852,207,1867,208,1869,209,1870,210,1868,211,1866,212,1865,213,1872,214,1871,221,1815,236,1876,237,1877,238,1875,239,1874,240,1878,241,1874,242,1879,243,1873,244,1886,245,1885,246,1883,247,1881,248,1889,249,1890,250,1891,251,1889,252,1888,253,1887,254,1893,255,1894,256,1895,257,1898,258,1899,259,1897,260,1900,261,1896,262,1893,265,1905,266,1906,267,1907,268,1908,269,1905,270,1901,276,1902,277,1913,278,1914,279,1915,280,1916,281,1917,282,1913,283,1912,284,1920,285,1921,286,1919,287,1918,288,1923,289,1924,290,1925,291,1926,292,1927,293,1923,295,1918,296,1930,297,1931,298,1929,299,1928,300,1934,301,1933,302,1936,303,1937,304,1938,305,1939,306,1940,307,1936,309,1928,310,1943,311,1944,312,1942,313,1941,314,1946,315,1947,316,1948,317,1949,318,1950,319,1946,321,1941,322,1953,323,1954,324,1952,325,1951,326,1956,327,1957,328,1959,329,1958,330,1960,331,1958,332,1961,333,1962,334,1963,335,1956,337,1951,338,1966,339,1968,340,1969,341,1967,342,1965,343,1964,344,1971,345,1970,352,1901,367,1975,368,1976,369,1974,370,1973,371,1977,372,1973,373,1978,374,1972],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1986,1,1984,3,1991,4,1987,10,1988,11,1995,12,1996,13,1997,14,1998,15,1995,16,1994,17,1993,18,2000,19,2001,20,2002,21,2003,22,2000,24,2005,25,2006,26,2007,27,2008,28,2009,29,2011,30,2012,31,2010,32,2008,33,2014,34,2015,35,2013,36,2016,37,2005,39,1987,54,2018,55,2017],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2026,1,2024,3,2031,4,2027,10,2028,11,2036,12,2035,13,2037,14,2034,15,2033,16,2039,17,2040,18,2041,19,2042,20,2039,22,2046,23,2048,24,2047,25,2045,26,2047,27,2045,28,2050,29,2045,30,2044,31,2027,46,2052,47,2053,48,2054,49,2052,50,2051],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2063,1,2061,3,2068,4,2064,10,2065,11,2072,12,2074,13,2073,14,2071,15,2073,16,2071,17,2076,18,2071,19,2070,20,2064,35,2078,36,2079,37,2080,38,2081,39,2082,40,2083,41,2078,42,2077],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2095,1,2096,2,2097,3,2095,4,2094,5,2093,6,2099,7,2100,8,2101,9,2105,10,2106,11,2104,12,2107,13,2108,14,2109,15,2107,16,2103,17,2110,18,2102,19,2099,21,2114,22,2112,24,2119,25,2115,31,2116,32,2123,33,2125,34,2124,35,2122,36,2124,37,2122,38,2127,39,2122,40,2121,41,2115,56,2131,57,2129,58,2134,59,2135,60,2133,61,2132,62,2139,63,2141,64,2140,65,2138,66,2137,67,2147,68,2148,69,2146,70,2148,71,2146,72,2152,73,2151,74,2154,75,2155,76,2153,77,2156,78,2149,79,2146,80,2145,81,2159,82,2158,83,2159,84,2137,85,2161,86,2162,87,2163,88,2164,89,2165,90,2161,91,2160],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2175,1,2176,2,2177,3,2175,4,2174,5,2173,6,2179,7,2180,8,2181,9,2182,10,2183,11,2184,12,2179,13,2178,14,2188,15,2186,16,2190,19,2196,20,2192,26,2193,27,2200,28,2201,29,2202,30,2200,31,2199,32,2198,33,2204,34,2205,35,2206,36,2208,37,2209,38,2207,39,2204,41,2213,42,2212,44,2218,45,2214,51,2215,52,2222,53,2224,54,2223,55,2221,56,2223,57,2221,58,2226,59,2227,60,2228,61,2226,62,2221,63,2220,64,2214,79,2232,80,2234,81,2233,82,2231,83,2233,84,2231,85,2236,86,2231,87,2230,88,2192,103,2238,104,2239,105,2240,106,2241,107,2242,108,2243,109,2238,110,2237],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2254,1,2252,2,2257,3,2259,4,2258,5,2256,6,2255,7,2266,8,2265,9,2269,10,2270,11,2268,12,2271,13,2267,14,2274,15,2275,16,2273,17,2276,18,2272,19,2277,20,2263,22,2280,23,2279,24,2280,25,2255,26,2250],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2287,1,2288,2,2289,3,2287,4,2286,5,2290,6,2291,7,2292,8,2294,9,2293,10,2290,11,2285,12,2297,13,2296,14,2299,15,2300,16,2301,17,2302,18,2303,19,2304,20,2305,21,2306,22,2307,23,2308,24,2304,25,2301,26,2299,27,2298],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2309,1,2317,2,2315,3,2321,13,2325,14,2324,16,2330,17,2326,23,2327,24,2333,25,2332,38,2326,53,2318,59,2337,60,2336,61,2335,62,2339,63,2340,64,2341,65,2339,67,2318,70,2313],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2342,2,2349,3,2350,4,2351,5,2352,6,2349,7,2347,8,2354,9,2355,10,2356,11,2357,12,2354,14,2359,15,2360,16,2361,17,2362,18,2363,19,2364,20,2365,21,2361,22,2359,23,2358],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2366,1,2375,2,2373,4,2379,14,2383,15,2382,16,2387,17,2385,19,2392,20,2388,26,2389,27,2395,28,2396,29,2397,30,2399,32,2398,34,2399,35,2395,36,2394,49,2388,64,2376,70,2403,71,2402,72,2401,73,2405,74,2406,75,2407,76,2405,78,2376,81,2371],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2408,2,2415,3,2416,4,2417,5,2418,6,2415,7,2413,8,2420,9,2421,10,2422,11,2423,12,2420,14,2425,15,2426,16,2427,17,2428,18,2429,19,2430,20,2431,21,2427,22,2425,23,2424],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2432,1,2441,2,2439,4,2445,14,2449,15,2448,16,2453,17,2451,19,2458,20,2454,26,2455,27,2460,28,2461,29,2462,30,2464,32,2463,34,2464,35,2460,36,2459,37,2467,38,2466,51,2454,66,2442,72,2471,73,2470,74,2469,75,2473,76,2474,77,2475,78,2473,80,2442,83,2437],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2476,2,2483,3,2484,4,2485,5,2486,6,2483,7,2481,8,2488,9,2489,10,2490,11,2491,12,2492,13,2493,14,2494,15,2495,16,2496,17,2497,18,2494,19,2490,20,2488,21,2487],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2498,1,2507,2,2505,3,2511,13,2515,14,2514,15,2518,16,2519,17,2517,18,2516,19,2521,20,2522,21,2523,22,2521,23,2520,30,2528,31,2524,37,2525,38,2532,39,2531,40,2532,41,2535,42,2534,55,2538,56,2539,57,2537,58,2536,59,2540,64,2524,79,2508,85,2544,86,2543,87,2542,88,2546,89,2547,90,2548,91,2546,93,2508,96,2503],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2549,2,2556,3,2557,4,2558,5,2559,6,2556,7,2554,8,2561,9,2562,10,2563,11,2564,12,2565,13,2566,14,2567,15,2568,16,2569,17,2570,18,2567,19,2563,20,2561,21,2560],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2571,1,2580,2,2578,3,2584,13,2588,14,2587,16,2593,17,2589,23,2590,24,2597,25,2598,26,2596,27,2595,28,2601,29,2600,30,2601,31,2595,32,2604,33,2603,46,2589,61,2581,67,2608,68,2607,69,2606,70,2610,71,2611,72,2612,73,2610,75,2581,78,2576],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2613,2,2620,3,2621,4,2622,5,2623,6,2620,7,2618,8,2625,9,2626,10,2627,11,2628,12,2625,14,2630,15,2631,16,2632,17,2633,18,2634,19,2635,20,2636,21,2632,22,2630,23,2629],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2637,1,2646,2,2644,4,2650,14,2654,15,2653,16,2658,17,2656,19,2663,20,2659,26,2660,28,2669,29,2670,30,2671,31,2672,32,2673,33,2675,35,2674,37,2675,38,2671,39,2676,40,2677,41,2669,42,2665,48,2666,49,2680,50,2679,67,2665,82,2659,97,2647,103,2684,104,2683,105,2682,106,2686,107,2687,108,2688,109,2686,111,2647,114,2642],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2696,1,2695,2,2694,4,2699,5,2698],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2709,1,2708,2,2706,3,2716,4,2717,5,2715,6,2714,7,2719,8,2721,9,2720,10,2718,11,2713,12,2722,13,2713,14,2724,15,2726,16,2727,17,2725,18,2723,19,2711,20,2731,21,2732,22,2730,23,2729,24,2734,25,2735,26,2733,27,2728,28,2737,29,2738,30,2739,31,2744,32,2745,33,2743,34,2746,35,2742,36,2747,37,2741,38,2748,39,2740,40,2737,42,2750,43,2749],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2761,1,2760,2,2762,3,2759,4,2758,5,2764,6,2763,7,2758,8,2766,9,2767,10,2768,11,2766,12,2765,13,2757,14,2770,15,2771,16,2772,17,2776,18,2777,19,2775,20,2778,21,2779,22,2780,23,2778,24,2774,25,2781,26,2773,27,2770,29,2786,30,2788,31,2787,32,2785,33,2783,34,2791,35,2792,36,2796,37,2797,38,2795,39,2794,40,2799,41,2800,42,2798,43,2793,44,2801,45,2793,46,2805,47,2804,48,2802,49,2806,50,2791,51,2790],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2815,1,2814,2,2812,3,2821,4,2822,5,2820,6,2819,7,2824,8,2825,9,2823,10,2818,11,2827,12,2828,13,2832,14,2831,15,2829,16,2827,17,2826,18,2817,19,2834,20,2835,21,2836,22,2837,23,2834,25,2810],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2838,2,2844,3,2842,5,2849,6,2850,7,2851,8,2852,9,2849,10,2845,16,2846,17,2856,18,2858,19,2857,20,2855,21,2857,22,2855,23,2860,24,2855,25,2854,26,2845,41,2862,42,2861],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2863,2,2865,4,2866,6,2872,7,2873,8,2874,9,2875,10,2872,11,2870,12,2877,13,2878,14,2879,15,2880,16,2877,18,2885,19,2886,20,2884,21,2882,22,2892,23,2891,24,2894,25,2890,26,2888,27,2898,28,2896,30,2903,31,2899,37,2900,38,2906,39,2905,40,2910,41,2911,42,2912,43,2913,44,2914,45,2910,46,2909,47,2905,48,2918,49,2917,50,2922,51,2921,52,2925,53,2924,54,2925,55,2899,70,2928,71,2927,72,2926,73,2930,74,2931,75,2932,76,2933,77,2930,79,2935,80,2934],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2936,2,2941,3,2942,4,2943,5,2944,6,2945,7,2941,9,2939],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2946,2,2951,3,2952,4,2953,5,2954,6,2955,7,2951,8,2950],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2956,2,2961,3,2962,4,2963,5,2964,6,2965,7,2961,8,2960],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2966,2,2971,3,2972,4,2973,5,2974,6,2975,7,2971,8,2970],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2985,1,2986,2,2987,3,2988,4,2985,5,2983,6,2990,7,2991,8,2992,9,2994,10,2995,11,2993,12,2990,14,2999,15,2997,16,3001,19,3007,20,3003,26,3004,27,3012,28,3013,29,3014,30,3016,32,3015,34,3016,35,3012,36,3011,37,3020,38,3021,39,3019,40,3018,41,3022,42,3017,43,3024,44,3023,51,3028,52,3029,53,3027,54,3026,55,3031,56,3030,57,3025,58,3033,59,3032,66,3037,67,3038,68,3036,69,3035,70,3039,71,3034,72,3041,73,3040,80,3003,95,3045,96,3046,97,3044,98,3043,99,3047,100,3043,101,3050,102,3051,103,3049,104,3048,105,3052,106,3048,107,3053,108,3042],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3064,1,3065,2,3063,3,3061,4,3067,5,3068,6,3069,7,3067,8,3066,12,3074,13,3075,14,3076,15,3074,16,3072,17,3080,18,3078,19,3082,21,3086,22,3088,23,3087,24,3085,25,3084,26,3094,27,3095,28,3096,29,3098,30,3099,31,3097,32,3100,33,3094,34,3093,35,3103,36,3104,37,3102,38,3101,39,3108,40,3110,41,3111,42,3109,43,3107,44,3106,45,3101,46,3115,47,3117,48,3118,49,3116,50,3114,51,3116,52,3114,53,3119,54,3114,55,3113,56,3122,57,3121,58,3122,59,3084,60,3127,61,3126,62,3128,63,3129,64,3124,65,3123],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"09669ecd0f4d23fd"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3139,1,3137,2,3143,3,3141,4,3146,5,3148,6,3147,7,3145,8,3144,9,3153,10,3157,11,3158,12,3156,13,3159,14,3155,15,3160,16,3161,17,3162,18,3163,19,3162,20,3167,21,3168,22,3166,23,3169,24,3165,25,3164,40,3162,41,3160,42,3154,43,3152,44,3153,45,3172,46,3171,47,3172,48,3144,49,3175,50,3176,51,3174,52,3173],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"dedf05ab29c415d3","codes":[{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,655423,0,65556,10,326,852029,10,67,65546,131076,50,1638463,65546,196612,50,1638719,0,262164,10,326,1835069,327684,1900603,393220,131339,131082,327684,50,2359357,393220,2424891,327684,196875,0,458772,10,131082,582,262411,262154,0,51,3997757,393228,10,262154,70,393483,0,20,393226,326,54,3997757,393226,67,0,458772,10,196618,582,327947,327690,0,51,5505085,458764,10,327690,70,459019,0,20,458762,326,54,5505085,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsObj","$IsPromise","string","default","$IsDate","toString","valueOf","$GetMethod","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,9,1,10,2,11,3,9,4,8,5,7,6,12,7,13,8,14,9,12,10,6,11,16,12,15,13,23,14,24,15,22,16,21,17,27,18,28,19,26,20,25,21,29,22,30,23,31,24,29,25,20,26,32,27,20,28,33,29,18,30,39,31,40,32,38,33,37,34,41,35,37,36,42,37,35,38,46,39,47,40,48,41,49,42,46,43,44,44,52,45,53,46,51,47,50,49,61,50,60,51,58,52,56,53,64,54,65,55,66,56,64,57,63,58,62,59,68,60,67,61,72,62,73,63,74,64,75,65,72,66,70,67,78,68,79,69,77,70,76,72,87,73,86,74,84,75,82,76,90,77,91,78,92,79,90,80,89,81,88,82,94,83,93,84,96,85,97,86,98,87,99,88,96,90,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,105,1,106,2,107,3,108,4,109,5,110,6,107,7,105,8,104],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,116,1,117,2,118,3,119,4,120,5,121,6,118,7,116,8,115],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,128,1,129,2,130,3,131,4,132,5,133,6,134,7,131,8,128,9,127],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,143,1,144,2,145,3,146,4,147,5,148,6,149,7,146,8,143,9,141,10,153,11,154,12,152,13,151,14,156,15,157,16,155,17,151,18,159,19,160,20,158,21,150],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,167,1,168,2,169,3,170,4,171,5,172,6,173,7,170,8,167,9,166],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,183,1,184,2,185,3,186,4,187,5,183,6,181,7,190,8,191,9,189,10,188,11,193,12,194,13,195,14,196,15,197,16,193,17,192,18,200,19,201,20,199,21,198,23,206,24,207,25,208,26,209,27,206,28,204,29,211,30,212,31,213,32,214,33,215,34,211,35,210,36,221,37,222,38,220,39,219,40,223,41,219,42,224,43,217,44,228,45,229,46,230,47,231,48,228,49,226,50,235,51,236,52,237,53,238,54,235,55,233,56,240,57,241,58,242,59,243,60,244,61,240,62,239],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":8,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,252,1,253,2,254,3,255,4,253,5,251,6,250],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":9,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,264,1,265,2,266,3,267,4,265,5,263,6,261],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":10,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,278,1,277,9,283,10,284,11,285,12,283,13,281,14,289,15,290,16,291,17,292,18,289,19,287,20,296,21,297,22,298,23,299,24,296,25,294,26,304,27,303,28,301,29,309,30,307,31,313,32,311,33,316,34,317,35,315,36,314,40,323,41,324,42,322,43,320,44,328,45,329,46,330,47,331,48,328,49,326,50,336,51,337,52,338,53,336,54,335,55,339,56,340,57,341,58,342,59,339,60,335,61,343,62,333,63,347,64,348,65,346,66,348,67,346,68,350,69,349,70,351,71,352,72,353,73,354,74,351,75,349,76,355,77,346,78,345,79,358,80,357,81,358,82,314,83,362,84,363,85,361,86,363,87,361,88,364,89,361,90,360,91,368,92,369,93,370,94,371,95,372,96,373,97,374,98,368,99,366,100,377,101,378,102,379,103,377,104,376,105,375,106,381,107,380,108,385,109,384,110,277,111,276],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":11,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,786454,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,386,5,396,7,395,8,393,9,643,10,642],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":12,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,396,1,404,2,405,3,403,4,402,5,407,6,408,7,409,8,410,9,407,11,415,12,416,13,414,14,412,15,418,16,419,17,420,18,418,19,417,20,424,21,423,22,422,23,427,24,428,25,429,26,430,27,427,29,435,30,434,33,433,34,437,35,438,36,439,37,437,38,436,40,445,41,444,42,442,43,448,44,449,45,450,46,448,47,447,48,457,49,456,50,458,51,454,52,453,53,461,54,462,55,460,56,459,57,469,58,468,59,470,60,471,61,466,62,465,63,475,64,476,65,477,66,478,67,479,68,475,69,473,70,482,71,483,72,481,73,480,74,485,75,484,76,488,77,489,78,487,79,486,80,491,81,490,82,494,83,495,84,493,85,492,86,497,87,496,88,500,89,501,90,499,91,498,92,503,93,504,94,505,95,506,96,503,97,502,98,512,99,513,100,511,101,510,102,514,103,515,104,516,105,514,106,510,107,517,108,508,109,521,110,523,111,522,112,520,113,522,114,520,115,525,116,520,117,519,118,527,120,530,121,531,122,532,123,530,124,529,127,537,128,536,129,542,130,541,131,539,132,547,133,545,134,550,135,551,136,549,137,548,139,557,140,558,141,559,142,560,143,561,144,562,145,560,146,564,147,565,148,563,149,557,150,556,181,554,182,569,183,570,184,568,185,570,186,568,187,573,188,574,189,572,190,571,191,575,192,571,193,576,194,568,195,567,196,579,197,578,198,579,199,548,200,529,203,584,204,585,205,584,206,583,207,589,208,590,209,591,210,592,211,593,212,589,213,587,214,597,215,595,216,600,217,602,218,601,219,599,220,598,223,609,224,610,225,608,226,606,227,615,228,616,229,617,230,618,231,620,232,621,233,619,234,615,235,614,266,612,267,624,268,625,269,623,270,622,271,627,272,628,273,629,274,630,275,631,276,632,277,627,279,635,280,634,281,635,282,598,283,637,284,638,285,639,286,637,288,641,289,640],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":13,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,657,1,658,2,659,3,660,4,661,5,662,6,658,7,663,8,666,9,664,10,667,11,668,12,657,13,656,14,655,15,654,16,652,17,672,18,673,19,674,20,675,21,676,22,677,23,672,24,671],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":14,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,685,1,686,2,687,3,688,4,689,5,685,6,684],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":15,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,698,1,699,2,700,3,701,4,698,5,696,7,706,8,702,14,703,15,709,16,710,17,711,18,712,19,709,21,702,36,714,37,715,38,716,39,714,41,694],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":16,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,723,1,724,2,728,3,727,4,725,5,723,6,722],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":17,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,739,1,740,2,741,3,739,4,737,5,747,6,748,7,746,8,745,9,749,10,750,11,751,12,749,13,745,14,752,15,753,16,754,17,755,18,756,19,752,20,743,21,760,22,761,23,759,24,758,25,763,26,764,27,762,28,757,30,768,31,769,32,767,33,766,34,772,35,773,36,774,37,772,39,775,41,779,42,780,43,781,44,782,45,783,46,779,47,777,48,787,49,788,50,786,51,785,52,790,53,791,54,789,55,784,56,794,57,795,58,796,59,800,60,799,61,797,62,801,63,794,65,803,66,804,67,805,68,803,70,806,72,811,73,810,74,815,75,814,76,816,77,812,78,810,79,820,80,819,81,817,82,808,83,822,84,823,85,824,86,825,87,826,88,822,90,833,91,832,92,831,93,830,94,828,95,839,96,838,97,836,98,842,99,843,100,844,101,845,102,846,103,848,104,849,105,847,106,842,108,735],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":18,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,858,1,857,2,855,3,863,4,864,5,862,6,861,7,866,8,867,9,865,10,860,11,872,12,871,13,869,15,853],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"e56e054a140aee6d"},"index":19,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,882,1,880,2,886,3,884,4,889,5,891,6,890,7,888,8,887,12,898,13,899,14,897,15,895,16,903,17,904,18,902,19,901,20,905,21,906,22,907,23,905,24,900,25,912,26,911,27,910,28,916,29,917,30,918,31,919,32,920,33,921,34,917,35,922,36,925,37,923,38,926,39,927,40,916,41,914,42,933,43,932,44,931,45,929,46,938,47,937,48,936,49,935,50,945,51,944,52,949,53,948,54,947,55,943,56,942,57,935,58,954,59,955,60,953,61,955,62,953,63,956,64,957,65,958,66,960,67,959,68,962,69,963,70,956,71,953,72,952,73,966,74,965,75,966,76,887,77,969,78,970,79,968,80,967,81,973,82,974,83,972,84,971,85,977,86,978,87,976,88,975,89,980,90,981,91,982,92,980,93,979,94,984,95,985,96,986,97,987,98,988,99,984,101,878],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} +{"@prelude":{"text":"6a8a4e5b2e42496b","codes":[{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":1,"name":"arrayFromIterable","flags":72,"length":3,"params":3,"locals":8,"maxStack":6,"code":[36,196875,3,262411,327692,10,2293834,2293819,393483,3212876,2490427,327692,327947,196618,262154,31,32,543,65546,0,50,1572925,327690,1900603,131082,65546,327690,262154,582,28,5,262154,56,262155,589884,70,75,524347,70,3212877,720955,459019,2950734,70,5,458762,64,5,2949179,196618,67],"consts":[],"captures":[],"handlers":[11,35,41,0,42,45,47,0],"finallies":[],"finallyOffsets":[],"sites":[0,10,1,8,2,14,3,12,5,19,6,15,12,16,13,24,14,25,15,23,16,25,17,23,18,28,19,29,20,27,21,26,22,30,23,26,24,34,25,33,26,35,27,36,28,31,29,23,30,22,31,39,32,38,33,39,34,15,49,41,50,40],"localNames":["items","mapper","thisArg","result","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":2,"name":"arrayFromLike","flags":72,"length":4,"params":4,"locals":6,"maxStack":6,"code":[20,65546,328,262411,3,327947,327690,65546,46,1835069,262154,327690,31,32,543,196618,131082,10,327690,26,327690,582,28,5,327690,56,327691,393276,262154,67],"consts":["Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,53,1,54,2,52,3,50,4,58,5,56,6,61,7,62,8,60,9,59,10,67,11,68,12,66,13,68,14,66,15,72,16,71,17,74,18,75,19,73,20,76,21,69,22,66,23,65,24,79,25,78,26,79,27,59,28,81,29,80],"localNames":["source","length","mapper","thisArg","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":3,"name":"Array$prototype$map","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["mapItems","$Receiver","Array","Array.prototype.map","Array.map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,82,2,84,4,85,6,87,7,85,8,90,9,91,10,92,11,93,12,94,13,95,14,96,15,92,16,97,17,98,18,99,19,90,20,89],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":4,"name":"Uint8Array$prototype$map","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.map","$Bytes","mapItems","Uint8Array.map","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,100,2,102,4,103,6,105,7,103,8,110,9,111,10,112,11,113,12,114,13,110,14,108,15,116,16,117,17,118,18,119,19,120,20,121,21,122,22,123,23,118,24,125,25,124,26,127,27,116,28,115],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":5,"name":"mapItems","flags":72,"length":4,"params":4,"locals":7,"maxStack":7,"code":[0,20,65546,196618,582,5,10,65561,262411,131092,262154,328,327947,3,393483,393226,262154,46,2752573,393226,10,33,2490429,327690,393226,31,32,543,131082,65546,10,393226,26,393226,10,838,28,5,393226,56,393227,983100,327690,67],"consts":["$Callback","length","Array"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,136,1,137,2,138,3,139,4,136,6,144,7,143,8,141,9,150,10,151,11,149,12,147,13,155,14,153,15,158,16,159,17,157,18,156,19,163,20,164,21,162,22,161,23,168,24,169,25,167,26,169,27,167,28,173,29,172,30,175,31,176,32,174,33,177,34,178,35,170,36,167,37,166,38,181,39,180,40,181,41,156,42,183,43,182],"localNames":["array","callback","thisArg","label","length","result","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":6,"name":"Array$prototype$filter","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,67],"consts":["filterItems","$Receiver","Array","Array.prototype.filter","Array.filter"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,184,2,186,4,187,6,189,7,187,8,192,9,193,10,194,11,195,12,196,13,197,14,198,15,194,16,199,17,200,18,201,19,192,20,191],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":7,"name":"Uint8Array$prototype$filter","flags":592,"length":1,"params":2,"locals":4,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,0,262164,196618,65546,131082,327684,1094,65556,393241,3,838,67],"consts":["$Receiver","Uint8Array","Uint8Array.prototype.filter","$Bytes","filterItems","Uint8Array.filter","prototype"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,202,2,204,4,205,6,207,7,205,8,212,9,213,10,214,11,215,12,216,13,212,14,210,15,218,16,219,17,220,18,221,19,222,20,223,21,224,22,225,23,220,24,227,25,226,26,229,27,218,28,217],"localNames":["this","callback","thisArg","bytes"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":8,"name":"filterItems","flags":72,"length":4,"params":4,"locals":9,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,36,327947,3,393483,3,459019,0,524555,458762,262154,46,3407933,458762,10,33,3145789,10,458762,26,524299,131082,65546,524298,458762,10,838,3145789,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,1114172,327690,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,238,1,239,2,240,3,241,4,238,6,246,7,245,8,243,9,251,10,249,11,255,12,253,13,259,14,257,15,261,17,265,18,266,19,264,20,263,21,270,22,271,23,269,24,268,25,277,26,278,27,276,28,275,29,283,30,282,31,284,32,285,33,286,34,280,35,279,36,290,37,292,39,291,41,292,42,289,43,291,44,289,45,293,46,289,47,288,48,296,49,295,50,296,51,263,52,298,53,297],"localNames":["array","callback","thisArg","label","length","result","count","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":9,"name":"Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Array","Array.prototype.forEach","Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,299,2,301,4,302,6,304,7,302,8,307,9,308,10,309,11,310,12,311,13,312,14,313,15,309,16,314,17,315,18,316,19,307,21,305],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":10,"name":"Uint8Array$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["forEachItem","$Receiver","Uint8Array","Uint8Array.prototype.forEach","Uint8Array.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,317,2,319,4,320,6,322,7,320,8,325,9,326,10,327,11,328,12,329,13,330,14,331,15,327,16,332,17,333,18,334,19,325,21,323],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":11,"name":"forEachItem","flags":72,"length":4,"params":4,"locals":6,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,262411,3,327947,327690,262154,46,2097213,327690,10,33,1835069,131082,65546,10,327690,26,327690,10,838,5,327690,56,327691,720956,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,343,1,344,2,345,3,346,4,343,6,351,7,350,8,348,9,356,10,354,11,359,12,360,13,358,14,357,15,364,16,365,17,363,18,362,19,370,20,369,21,372,22,373,23,371,24,374,25,375,26,367,28,378,29,377,30,378,31,357,32,341],"localNames":["array","callback","thisArg","label","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":12,"name":"Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.some","Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,379,2,381,4,382,6,384,7,382,8,387,9,388,10,389,11,390,12,391,13,392,14,393,15,389,16,394,17,395,18,396,19,397,20,387,21,386],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":13,"name":"Uint8Array$prototype$some","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.some","Uint8Array.some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,398,2,400,4,401,6,403,7,401,8,406,9,407,10,408,11,409,12,410,13,411,14,412,15,408,16,413,17,414,18,415,19,416,20,406,21,405],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":14,"name":"Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Array","Array.prototype.every","Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,417,2,419,4,420,6,422,7,420,8,425,9,426,10,427,11,428,12,429,13,430,14,431,15,427,16,432,17,433,18,434,19,435,20,425,21,424],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":15,"name":"Uint8Array$prototype$every","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["testItems","$Receiver","Uint8Array","Uint8Array.prototype.every","Uint8Array.every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,436,2,438,4,439,6,441,7,439,8,444,9,445,10,446,11,447,12,448,13,449,14,450,15,446,16,451,17,452,18,453,19,454,20,444,21,443],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":16,"name":"testItems","flags":72,"length":5,"params":5,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,327947,3,393483,393226,327690,46,2490429,393226,10,33,1966399,131082,65546,10,393226,26,393226,10,838,54,262154,50,2228285,262154,54,67,393226,56,393227,720956,262154,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,464,1,465,2,466,3,467,4,464,6,472,7,471,8,469,9,477,10,475,11,480,12,481,13,479,14,478,15,486,16,487,17,485,18,484,19,493,20,492,21,495,22,496,23,494,24,497,25,498,26,490,27,489,28,499,29,488,30,483,31,502,32,501,33,500,34,505,35,504,36,505,37,478,38,507,39,506],"localNames":["array","callback","thisArg","label","every","length","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":17,"name":"Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.find","Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,508,2,510,4,511,6,513,7,511,8,516,9,517,10,518,11,519,12,520,13,521,14,522,15,518,16,523,17,524,18,525,19,526,20,527,21,516,22,515],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":18,"name":"Uint8Array$prototype$find","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.find","Uint8Array.find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,528,2,530,4,531,6,533,7,531,8,536,9,537,10,538,11,539,12,540,13,541,14,542,15,538,16,543,17,544,18,545,19,546,20,547,21,536,22,535],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":19,"name":"Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findIndex","Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,548,2,550,4,551,6,553,7,551,8,556,9,557,10,558,11,559,12,560,13,561,14,562,15,558,16,563,17,564,18,565,19,566,20,567,21,556,22,555],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":20,"name":"Uint8Array$prototype$findIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findIndex","Uint8Array.findIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,568,2,570,4,571,6,573,7,571,8,576,9,577,10,578,11,579,12,580,13,581,14,582,15,578,16,583,17,584,18,585,19,586,20,587,21,576,22,575],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":21,"name":"Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLast","Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,588,2,590,4,591,6,593,7,591,8,596,9,597,10,598,11,599,12,600,13,601,14,602,15,598,16,603,17,604,18,605,19,606,20,607,21,596,22,595],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":22,"name":"Uint8Array$prototype$findLast","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,2,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLast","Uint8Array.findLast"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,608,2,610,4,611,6,613,7,611,8,616,9,617,10,618,11,619,12,620,13,621,14,622,15,618,16,623,17,624,18,625,19,626,20,627,21,616,22,615],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":23,"name":"Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Array","Array.prototype.findLastIndex","Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,628,2,630,4,631,6,633,7,631,8,636,9,637,10,638,11,639,12,640,13,641,14,642,15,638,16,643,17,644,18,645,19,646,20,647,21,636,22,635],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":24,"name":"Uint8Array$prototype$findLastIndex","flags":592,"length":1,"params":2,"locals":3,"maxStack":8,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,258,1606,67],"consts":["findItem","$Receiver","Uint8Array","Uint8Array.prototype.findLastIndex","Uint8Array.findLastIndex"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,648,2,650,4,651,6,653,7,651,8,656,9,657,10,658,11,659,12,660,13,661,14,662,15,658,16,663,17,664,18,665,19,666,20,667,21,656,22,655],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":25,"name":"findItem","flags":72,"length":6,"params":6,"locals":10,"maxStack":5,"code":[0,20,65546,196618,582,5,10,65561,393483,262154,917565,65539,53,983099,65539,459019,262154,1441853,393226,65539,44,1507387,3,524555,0,590091,524298,3,49,2163007,524298,393226,46,3670077,10,524298,26,589835,131082,65546,589834,524298,10,838,3342397,327690,3211325,524298,3276859,589834,67,524298,458762,43,524299,1703996,327690,3997757,65539,53,4063291,0,67],"consts":["$Callback","length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,678,1,679,2,680,3,681,4,678,6,686,7,685,8,683,9,692,10,691,11,694,12,693,13,691,14,695,15,689,16,700,17,699,18,702,19,703,20,701,21,699,22,704,23,697,24,706,26,711,27,712,28,710,29,709,30,714,31,715,32,713,33,708,34,721,35,722,36,720,37,719,38,727,39,726,40,728,41,729,42,730,43,724,44,723,45,733,46,732,47,734,48,732,49,735,50,731,51,738,52,739,53,737,54,738,55,708,56,742,57,741,58,744,59,743,60,741,61,745,62,740],"localNames":["array","callback","thisArg","label","last","wantIndex","length","step","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":26,"name":"Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduce","Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,746,2,748,4,749,6,753,7,754,8,755,9,756,10,757,11,758,12,759,13,755,14,760,15,761,16,762,17,763,18,753,19,752],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":27,"name":"Uint8Array$prototype$reduce","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,2,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduce","Uint8Array.reduce"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,764,2,766,4,767,6,771,7,772,8,773,9,774,10,775,11,776,12,777,13,773,14,778,15,779,16,780,17,781,18,771,19,770],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":28,"name":"Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Array","Array.prototype.reduceRight","Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,782,2,784,4,785,6,789,7,790,8,791,9,792,10,793,11,794,12,795,13,791,14,796,15,797,16,798,17,799,18,789,19,788],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":29,"name":"Uint8Array$prototype$reduceRight","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,65813,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,258,1350,67],"consts":["reduceItems","$Receiver","Uint8Array","Uint8Array.prototype.reduceRight","Uint8Array.reduceRight"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,800,2,802,4,803,6,807,7,808,8,809,9,810,10,811,11,812,12,813,13,809,14,814,15,815,16,816,17,817,18,807,19,806],"localNames":["this","callback","initial"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":30,"name":"reduceItems","flags":72,"length":5,"params":5,"locals":9,"maxStack":6,"code":[0,20,65546,196618,582,5,10,65561,327947,262154,917565,65539,53,983099,65539,393483,262154,1441853,327690,65539,44,1507387,3,459019,0,524555,131082,65561,3,48,2359357,131082,3,26,524299,5111867,458762,3,49,2818367,458762,327690,46,3146047,458762,10,33,54,3539005,458762,393226,43,458763,2359356,458762,3,46,3997759,458762,327690,49,4587581,0,131092,196612,196618,262148,43,582,5,10,458762,26,524299,458762,393226,43,458763,458762,3,49,5570879,458762,327690,46,6881341,458762,10,33,6553661,0,65546,524298,10,458762,26,458762,10,1094,524299,458762,393226,43,458763,5111868,524298,67],"consts":["$Callback","length","$Throw","TypeError"," of an empty array with no initial value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,827,1,828,2,829,3,830,4,827,6,835,7,834,8,832,9,841,10,840,11,843,12,842,13,840,14,844,15,838,16,849,17,848,18,851,19,852,20,850,21,848,22,853,23,846,24,855,26,860,27,859,28,862,29,858,30,857,31,867,32,868,33,866,34,865,35,857,36,874,37,875,38,873,39,872,40,877,41,878,42,876,43,871,44,881,45,882,46,880,47,879,48,870,49,885,50,886,51,884,52,885,53,870,54,890,55,891,56,889,57,888,58,893,59,894,60,892,61,887,62,896,63,897,64,898,65,900,66,901,67,899,68,896,70,906,71,907,72,905,73,904,74,910,75,911,76,909,77,910,78,915,79,916,80,914,81,913,82,918,83,919,84,917,85,912,86,923,87,924,88,922,89,921,90,931,91,930,92,932,93,934,94,935,95,933,96,936,97,937,98,928,99,927,100,940,101,941,102,939,103,940,104,912,105,943,106,942],"localNames":["array","callback","initial","label","right","length","step","index","accumulator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":31,"name":"Array$prototype$flatMap","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,10,65540,131076,838,196875,0,196628,65546,262148,582,5,196618,327705,262411,36,327947,3,393483,3,459019,0,524555,0,590091,458762,262154,46,6684733,458762,196618,33,6422589,131082,65546,196618,458762,26,458762,196618,838,524299,0,393236,524298,326,5636157,3,589835,589834,524298,327705,46,5570621,589834,524298,33,5308477,327690,393226,55,7,56,393227,31,32,543,524298,589834,26,28,5,589834,56,589835,3801148,6422587,327690,393226,55,7,56,393227,31,32,543,524298,28,5,458762,56,458763,2228284,327690,67],"consts":["$Receiver","Array","Array.prototype.flatMap","$Callback","Array.flatMap","length","$IsArray"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,944,2,946,4,947,6,949,7,947,8,954,9,955,10,956,11,957,12,958,13,954,14,952,15,960,16,961,17,962,18,963,19,960,21,968,22,967,23,965,24,973,25,971,26,977,27,975,28,981,29,979,30,983,32,986,34,990,35,991,36,989,37,988,38,995,39,996,40,994,41,993,42,1004,43,1003,44,1006,45,1007,46,1005,47,1008,48,1009,49,1001,50,1000,51,1011,52,1012,53,1013,54,1011,55,1010,56,1018,57,1017,58,1021,59,1023,60,1022,61,1020,62,1019,63,1028,64,1029,65,1027,66,1026,67,1033,68,1035,70,1034,72,1035,73,1032,74,1034,75,1032,76,1037,77,1038,78,1036,79,1032,80,1031,81,1041,82,1040,83,1041,84,1019,85,1010,86,1045,87,1047,89,1046,91,1047,92,1044,93,1046,94,1044,95,1048,96,1044,97,1043,98,1051,99,1050,100,1051,101,988,102,1053,103,1052],"localNames":["this","callback","thisArg","array","length","result","count","index","inner","at"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":32,"name":"sortWith","flags":72,"length":7,"params":7,"locals":15,"maxStack":11,"code":[36,459019,3,524555,0,590091,0,655627,0,721163,0,786699,0,852235,0,917771,524298,393226,25,46,7733309,393226,524298,26,720907,393226,524298,65539,43,26,589835,393226,524298,131075,43,26,655371,589834,786443,3,851979,720906,589834,46,3146047,786442,655370,46,6488125,0,196618,262154,720906,26,262154,786442,26,582,309,917515,917514,3,47,4390975,917514,917514,51,5374013,458762,851978,31,32,543,262154,720906,26,28,5,720906,56,720907,6225979,458762,851978,31,32,543,262154,786442,26,28,5,786442,56,786443,851978,56,851979,2687036,0,65556,262154,458762,851978,720906,589834,786442,655370,393226,524298,26,2118,5,524298,196611,43,524299,1048636,0,131092,10,65546,131082,262154,327690,1350,67],"consts":["length","$MergeRest","$Sorted"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1067,1,1065,2,1071,3,1069,4,1073,6,1076,8,1079,10,1082,12,1085,14,1088,16,1092,17,1094,18,1093,19,1091,20,1090,21,1101,22,1102,23,1100,24,1099,25,1107,26,1109,27,1110,28,1108,29,1106,30,1105,31,1115,32,1117,33,1118,34,1116,35,1114,36,1113,37,1122,38,1121,39,1126,40,1125,41,1130,42,1131,43,1129,44,1128,45,1133,46,1134,47,1132,48,1127,49,1143,50,1142,51,1145,52,1146,53,1144,54,1148,55,1149,56,1147,57,1140,58,1139,59,1138,60,1153,61,1154,62,1152,63,1151,64,1156,65,1157,66,1155,67,1150,68,1162,69,1163,70,1161,71,1163,72,1161,73,1165,74,1166,75,1164,76,1161,77,1160,78,1169,79,1168,80,1169,81,1150,82,1174,83,1175,84,1173,85,1175,86,1173,87,1177,88,1178,89,1176,90,1173,91,1172,92,1181,93,1180,94,1181,95,1184,96,1183,97,1184,98,1127,99,1186,100,1187,101,1188,102,1189,103,1190,104,1191,105,1192,106,1193,107,1194,108,1196,109,1197,110,1195,111,1186,113,1200,114,1201,115,1199,116,1200,117,1090,118,1203,119,1204,120,1205,121,1206,122,1207,123,1208,124,1209,125,1203,126,1202],"localNames":["target","into","holes","comparator","work","undefs","merges","merged","merge","middle","high","left","right","count","order"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":33,"name":"sortDefault","flags":72,"length":6,"params":6,"locals":7,"maxStack":9,"code":[0,20,327690,326,393483,0,65556,393226,326,720957,327740,0,131092,10,65546,131082,0,196628,393226,196618,582,262154,1350,67],"consts":["$SortState","$SortStep","$Sorted","$SortResult"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1222,1,1223,2,1224,3,1222,4,1220,5,1226,6,1227,7,1228,8,1226,9,1225,11,1231,12,1232,13,1233,14,1234,15,1235,16,1236,17,1237,18,1238,19,1239,20,1236,21,1240,22,1231,23,1230],"localNames":["target","into","holes","values","undefs","keys","state"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":34,"name":"Array$prototype$toLocaleString","flags":88,"length":0,"params":0,"locals":5,"maxStack":5,"code":[789,267,0,20,10,65540,131076,838,65803,196612,131339,3,196875,0,262411,196618,65546,262169,46,3473469,196618,3,48,1835069,131082,327684,43,131083,65546,196618,26,262155,262154,1,51,2556223,262154,0,51,3211325,131082,0,393236,262154,459033,70,326,43,131083,196618,56,196619,983100,131082,67],"consts":["$Receiver","Array","Array.prototype.toLocaleString","","length",",","String","toLocaleString"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1241,2,1247,3,1248,4,1249,5,1250,6,1251,7,1247,8,1245,9,1255,10,1253,11,1259,12,1257,13,1261,15,1265,16,1267,17,1266,18,1264,19,1263,20,1272,21,1273,22,1271,23,1270,24,1276,25,1277,26,1275,27,1276,28,1282,29,1283,30,1281,31,1280,32,1287,33,1288,34,1286,35,1285,36,1290,37,1291,38,1289,39,1284,40,1294,41,1295,42,1296,43,1299,44,1298,45,1297,46,1295,47,1293,48,1294,49,1303,50,1302,51,1303,52,1263,53,1305,54,1304],"localNames":["this","array","result","index","item"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":35,"name":"fillCollection","flags":72,"length":3,"params":3,"locals":7,"maxStack":7,"code":[131082,4,50,458815,131082,65540,50,196875,262156,65546,3801162,3801147,327947,4719948,3997755,262156,262411,196618,54,1835069,0,131092,196612,10,262154,838,5,3735611,0,262164,262154,326,54,2949181,0,327700,393220,458756,131082,43,524292,43,582,5,3735611,0,131092,196612,10,262154,3,26,262154,65539,26,1094,5,852028,70,75,786491,70,4719949,983099,393483,4457806,70,5,393226,64,5,4456507,10,67],"consts":["Map","WeakMap","$Table","add","$IsObject","$Throw","TypeError","new ","(...) expects [key, value] pairs as entry objects."],"captures":[],"handlers":[15,58,64,0,65,68,70,0],"finallies":[],"finallyOffsets":[],"sites":[0,1317,1,1318,2,1316,3,1315,4,1320,5,1321,6,1319,7,1313,9,1326,10,1322,16,1323,17,1330,18,1329,19,1328,20,1332,21,1333,22,1334,23,1335,24,1336,25,1332,27,1328,28,1339,29,1340,30,1341,31,1339,32,1338,33,1337,34,1343,35,1344,36,1345,37,1348,38,1349,39,1347,40,1350,41,1346,42,1343,44,1337,45,1352,46,1353,47,1354,48,1355,49,1357,50,1358,51,1356,52,1360,53,1361,54,1359,55,1352,57,1322,72,1363,73,1362],"localNames":["target","items","kind","pairs","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":36,"name":"Map$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Map"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1370,1,1371,2,1372,3,1373,4,1374,5,1370,6,1369],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":37,"name":"Object$groupBy","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[0,20,10,65546,65540,838,67],"consts":["groupBy","Object"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1381,1,1382,2,1383,3,1384,4,1385,5,1381,6,1380],"localNames":["items","callback"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":38,"name":"groupBy","flags":72,"length":3,"params":3,"locals":9,"maxStack":6,"code":[10,1,50,458815,10,0,50,1048637,0,20,65540,131082,131076,43,582,5,0,196628,65546,131082,262148,43,582,5,0,327700,393220,131082,582,196875,3,262411,0,327947,393228,10,4915274,4915259,459019,5834572,5111867,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,458756,50,4325437,0,524308,0,327700,589828,327690,582,326,327691,0,327700,655364,196618,327690,393226,1094,5,2555964,70,75,2490427,70,5834573,2687035,524555,5572430,70,5,524298,64,5,5570619,196618,67],"consts":["$Throw","TypeError",".groupBy expects an iterable collection.","$Callback",".groupBy","$Table","groups","Object","String","groupKey","group"],"captures":[],"handlers":[41,75,81,0,82,85,87,0],"finallies":[],"finallyOffsets":[],"sites":[0,1395,1,1396,2,1394,3,1393,4,1398,5,1399,6,1397,7,1392,8,1401,9,1402,10,1403,11,1405,12,1406,13,1404,14,1401,16,1408,17,1409,18,1410,19,1412,20,1413,21,1411,22,1408,24,1417,25,1418,26,1419,27,1420,28,1417,29,1415,30,1424,31,1422,32,1426,35,1432,36,1428,42,1429,43,1437,44,1438,45,1439,46,1441,48,1440,50,1441,51,1437,52,1436,53,1444,54,1445,55,1443,56,1442,57,1449,58,1450,59,1451,60,1452,61,1453,62,1454,63,1451,64,1449,65,1448,66,1456,67,1457,68,1458,69,1459,70,1460,71,1461,72,1456,74,1428,89,1463,90,1462],"localNames":["items","callback","kind","groups","index","key","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":39,"name":"insertComputed","flags":72,"length":3,"params":3,"locals":4,"maxStack":6,"code":[0,131082,65546,326,196875,0,20,65540,10,65546,196618,1094,5,196618,67],"consts":["$Table","add"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1473,1,1474,2,1475,3,1473,4,1471,5,1477,6,1478,7,1479,8,1480,9,1481,10,1482,11,1477,13,1484,14,1483],"localNames":["target","key","callback","value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":40,"name":"Map$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Map","Map.prototype.forEach","Map.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1485,2,1487,4,1488,6,1490,7,1488,8,1493,9,1494,10,1495,11,1496,12,1497,13,1498,14,1499,15,1495,16,1500,17,1501,18,1502,19,1493,21,1491],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":41,"name":"Set$prototype$forEach","flags":592,"length":1,"params":2,"locals":3,"maxStack":7,"code":[789,267,1045,65803,66581,459583,0,131339,0,20,0,65556,10,131076,196612,838,65546,131082,262148,1094,5,0,67],"consts":["collectionForEach","$Receiver","Set","Set.prototype.forEach","Set.forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1503,2,1505,4,1506,6,1508,7,1506,8,1511,9,1512,10,1513,11,1514,12,1515,13,1516,14,1517,15,1513,16,1518,17,1519,18,1520,19,1511,21,1509],"localNames":["this","callback","thisArg"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":42,"name":"collectionForEach","flags":72,"length":4,"params":4,"locals":7,"maxStack":5,"code":[0,20,65546,196618,582,5,262156,0,65556,131076,10,582,2031690,2031675,327947,2950476,2228283,262156,262411,131082,65546,262154,65539,26,262154,3,26,10,838,5,983100,70,75,917563,70,2950477,1114171,393483,2688334,70,5,393226,64,5,2687035,0,67],"consts":["$Callback","$Table","entries"],"captures":[],"handlers":[17,31,37,0,38,41,43,0],"finallies":[],"finallyOffsets":[],"sites":[0,1529,1,1530,2,1531,3,1532,4,1529,7,1537,8,1538,9,1539,10,1540,11,1537,12,1533,18,1534,19,1545,20,1544,21,1547,22,1548,23,1546,24,1550,25,1551,26,1549,27,1552,28,1542,30,1533,45,1527],"localNames":["target","callback","thisArg","label","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":43,"name":"Set$prototype$union","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.union","union"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1553,2,1558,3,1559,4,1560,5,1561,6,1562,7,1563,8,1564,9,1560,10,1565,11,1566,12,1558,13,1557],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":44,"name":"Set$prototype$intersection","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.intersection","intersection"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1567,2,1572,3,1573,4,1574,5,1575,6,1576,7,1577,8,1578,9,1574,10,1579,11,1580,12,1572,13,1571],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":45,"name":"Set$prototype$difference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.difference","difference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1581,2,1586,3,1587,4,1588,5,1589,6,1590,7,1591,8,1592,9,1588,10,1593,11,1594,12,1586,13,1585],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":46,"name":"Set$prototype$symmetricDifference","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.symmetricDifference","symmetricDifference"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1595,2,1600,3,1601,4,1602,5,1603,6,1604,7,1605,8,1606,9,1602,10,1607,11,1608,12,1600,13,1599],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":47,"name":"Set$prototype$isSubsetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSubsetOf","isSubsetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1609,2,1614,3,1615,4,1616,5,1617,6,1618,7,1619,8,1620,9,1616,10,1621,11,1622,12,1614,13,1613],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":48,"name":"Set$prototype$isSupersetOf","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isSupersetOf","isSupersetOf"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1623,2,1628,3,1629,4,1630,5,1631,6,1632,7,1633,8,1634,9,1630,10,1635,11,1636,12,1628,13,1627],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":49,"name":"Set$prototype$isDisjointFrom","flags":88,"length":1,"params":1,"locals":2,"maxStack":7,"code":[789,65803,0,20,0,65556,65546,131076,196612,838,10,262148,838,67],"consts":["setMethod","$Receiver","Set","Set.prototype.isDisjointFrom","isDisjointFrom"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,1637,2,1642,3,1643,4,1644,5,1645,6,1646,7,1647,8,1648,9,1644,10,1649,11,1650,12,1642,13,1641],"localNames":["other","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":50,"name":"setMethod","flags":72,"length":3,"params":3,"locals":18,"maxStack":5,"code":[0,20,65546,326,54,1048637,0,65556,131076,196612,131082,43,262148,43,582,5,65546,327705,309,196875,196618,196618,51,2228285,0,65556,131076,196612,131082,43,393220,43,582,5,196618,3,46,3145789,0,65556,458756,196612,131082,43,524292,43,582,5,65546,589849,262411,65546,655385,327947,0,720916,262154,326,54,4259903,0,720916,327690,326,54,4980797,0,65556,131076,196612,131082,43,786436,43,582,5,0,851988,327684,10,582,393483,131082,917508,50,5833023,393226,196618,48,6029373,2,67,131082,983044,50,6488383,393226,196618,46,6684733,2,67,131082,1048580,50,7143485,1114132,72,8388667,131082,1179652,50,7602239,131082,1245188,50,7864383,131082,1310724,50,8323133,0,851988,1376260,10,582,8388667,0,459019,131082,917508,50,9699391,131082,1048580,50,9175103,131082,1245188,50,9437247,131082,1441796,50,9699647,393226,196618,47,524555,0,590091,524298,15990845,720908,0,851988,1507332,131082,1245188,50,10682429,458762,10747963,10,582,14549066,14549051,852235,15469900,14745659,720908,721163,65546,262154,720906,326,54,54,589835,131082,1048580,50,12648509,589834,12582973,0,851988,1572868,458762,720906,838,5,14483515,131082,1245188,50,13566013,589834,13500477,0,851988,1638404,458762,720906,838,5,14483515,589834,131082,1441796,50,50,14483517,2,983307,14355790,70,1611,5,983050,67,11010108,70,75,10944571,70,15469901,11141179,917771,15207758,70,5,917514,64,5,15204411,458762,0,50,15859773,258,15925307,458762,67,65546,327690,70,655627,0,20,655370,326,54,17301565,0,65556,131076,196612,131082,43,1703940,43,582,5,786444,0,1769492,655370,258,582,23134282,23134267,1048843,24055884,23330875,786444,786699,0,851988,589828,10,786442,838,589835,131082,1179652,50,19398717,0,851988,1572868,458762,786442,838,5,23068731,131082,1048580,50,20316221,589834,20250685,0,851988,1572868,458762,786442,838,5,23068731,131082,1245188,50,21102653,0,851988,1638404,458762,786442,838,5,23068731,131082,1310724,50,22151229,0,851988,589834,21758013,1638404,21823547,1572868,458762,786442,838,5,23068731,589834,131082,1441796,50,50,23068733,2,983307,22941774,70,1611,5,983050,67,17891388,70,75,17825851,70,24055885,18022459,1114379,23793742,70,5,1114122,64,5,23789627,458762,0,50,24444989,258,24510523,458762,67],"consts":["$IsObject","$Throw","TypeError","Set."," expects a Set-like object.","size"," received a Set-like object with an invalid size.","RangeError"," received a Set-like object with a negative size.","has","keys","$IsCallable"," expects callable 'has' and 'keys' methods.","$Table","isSubsetOf","isSupersetOf","intersection","Set","union","difference","symmetricDifference","copy","isDisjointFrom","values","add","delete"," expects 'keys' to return an iterator object.","$Direct"],"captures":[],"handlers":[170,222,228,0,229,232,234,0,275,353,359,0,360,363,365,0],"finallies":[],"finallyOffsets":[],"sites":[0,1659,1,1660,2,1661,3,1659,4,1658,5,1657,6,1663,7,1664,8,1665,9,1668,10,1669,11,1667,12,1670,13,1666,14,1663,16,1676,17,1675,18,1674,19,1672,20,1680,21,1681,22,1679,23,1678,24,1683,25,1684,26,1685,27,1688,28,1689,29,1687,30,1690,31,1686,32,1683,34,1693,35,1694,36,1692,37,1691,38,1696,39,1697,40,1698,41,1701,42,1702,43,1700,44,1703,45,1699,46,1696,48,1708,49,1707,50,1705,51,1714,52,1713,53,1711,54,1719,55,1720,56,1721,57,1719,58,1718,59,1717,60,1723,61,1724,62,1725,63,1723,64,1722,65,1716,66,1727,67,1728,68,1729,69,1732,70,1733,71,1731,72,1734,73,1730,74,1727,76,1738,77,1739,78,1740,79,1741,80,1738,81,1736,82,1745,83,1746,84,1744,85,1743,86,1748,87,1749,88,1747,89,1742,90,1751,91,1750,92,1755,93,1756,94,1754,95,1753,96,1758,97,1759,98,1757,99,1752,100,1761,101,1760,102,1767,103,1768,104,1766,105,1765,106,1770,107,1769,108,1765,109,1775,110,1776,111,1774,112,1773,113,1778,114,1779,115,1777,116,1772,117,1781,118,1782,119,1780,120,1771,121,1783,122,1784,123,1785,124,1786,125,1783,126,1771,127,1787,128,1763,129,1793,130,1794,131,1792,132,1791,133,1799,134,1800,135,1798,136,1797,137,1802,138,1803,139,1801,140,1796,141,1805,142,1806,143,1804,144,1795,145,1808,146,1809,147,1807,148,1789,149,1811,151,1814,152,1813,154,1820,155,1821,156,1822,157,1825,158,1826,159,1824,160,1823,161,1827,162,1823,163,1828,164,1820,165,1816,171,1817,172,1838,173,1837,174,1839,175,1835,176,1834,177,1833,178,1832,179,1842,180,1843,181,1841,182,1840,183,1846,184,1845,185,1848,186,1849,187,1850,188,1851,189,1852,190,1848,192,1840,193,1855,194,1856,195,1854,196,1853,197,1859,198,1858,199,1861,200,1862,201,1863,202,1864,203,1865,204,1861,206,1853,207,1868,208,1870,209,1871,210,1869,211,1867,212,1866,213,1873,214,1872,221,1816,236,1877,237,1878,238,1876,239,1875,240,1879,241,1875,242,1880,243,1874,244,1887,245,1886,246,1884,247,1882,248,1890,249,1891,250,1892,251,1890,252,1889,253,1888,254,1894,255,1895,256,1896,257,1899,258,1900,259,1898,260,1901,261,1897,262,1894,265,1906,266,1907,267,1908,268,1909,269,1906,270,1902,276,1903,277,1914,278,1915,279,1916,280,1917,281,1918,282,1914,283,1913,284,1921,285,1922,286,1920,287,1919,288,1924,289,1925,290,1926,291,1927,292,1928,293,1924,295,1919,296,1931,297,1932,298,1930,299,1929,300,1935,301,1934,302,1937,303,1938,304,1939,305,1940,306,1941,307,1937,309,1929,310,1944,311,1945,312,1943,313,1942,314,1947,315,1948,316,1949,317,1950,318,1951,319,1947,321,1942,322,1954,323,1955,324,1953,325,1952,326,1957,327,1958,328,1960,329,1959,330,1961,331,1959,332,1962,333,1963,334,1964,335,1957,337,1952,338,1967,339,1969,340,1970,341,1968,342,1966,343,1965,344,1972,345,1971,352,1902,367,1976,368,1977,369,1975,370,1974,371,1978,372,1974,373,1979,374,1973],"localNames":["target","other","name","size","has","keys","own","result","asks","found","iterator","item","item","%it","%e","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":51,"name":"Object$fromEntries","flags":72,"length":1,"params":1,"locals":5,"maxStack":7,"code":[35,65803,131084,10,2621514,2621499,196875,3539788,2818107,131084,131339,0,20,131082,258,582,54,1572925,0,65556,131076,196612,582,5,0,262164,65546,0,327700,131082,3,26,326,131082,65539,26,258,1094,5,458812,70,75,393275,70,3539789,589883,262411,3277646,70,5,262154,64,5,3276859,65546,67],"consts":["$IsObject","$Throw","TypeError","Object.fromEntries expects [key, value] entry objects.","$Define","String"],"captures":[],"handlers":[9,40,46,0,47,50,52,0],"finallies":[],"finallyOffsets":[],"sites":[0,1987,1,1985,3,1992,4,1988,10,1989,11,1996,12,1997,13,1998,14,1999,15,1996,16,1995,17,1994,18,2001,19,2002,20,2003,21,2004,22,2001,24,2006,25,2007,26,2008,27,2009,28,2010,29,2012,30,2013,31,2011,32,2009,33,2015,34,2016,35,2014,36,2017,37,2006,39,1988,54,2019,55,2018],"localNames":["entries","result","entry","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":52,"name":"Math$sumPrecise","flags":72,"length":1,"params":1,"locals":5,"maxStack":4,"code":[36,65803,131084,10,2097226,2097211,196875,3015500,2293819,131084,131339,131082,821,4,51,1441853,0,65556,131076,196612,582,5,65546,65546,262169,31,32,543,131082,28,5,458812,70,75,393275,70,3015501,589883,262411,2753358,70,5,262154,64,5,2752571,0,327700,65546,326,67],"consts":["number","$Throw","TypeError","Math.sumPrecise expects an iterable of numbers.","length","$SumPrecise"],"captures":[],"handlers":[9,32,38,0,39,42,44,0],"finallies":[],"finallyOffsets":[],"sites":[0,2027,1,2025,3,2032,4,2028,10,2029,11,2037,12,2036,13,2038,14,2035,15,2034,16,2040,17,2041,18,2042,19,2043,20,2040,22,2047,23,2049,24,2048,25,2046,26,2048,27,2046,28,2051,29,2046,30,2045,31,2028,46,2053,47,2054,48,2055,49,2053,50,2052],"localNames":["items","numbers","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":53,"name":"aggregateError","flags":72,"length":2,"params":2,"locals":6,"maxStack":6,"code":[36,131339,196620,65546,1376330,1376315,262411,2294860,1572923,196620,196875,131082,131082,25,31,32,543,196618,28,5,458812,70,75,393275,70,2294861,589883,327947,2032718,70,5,327690,64,5,2031675,0,65556,10,131076,131082,2,1094,67],"consts":["length","$Define","errors"],"captures":[],"handlers":[9,21,27,0,28,31,33,0],"finallies":[],"finallyOffsets":[],"sites":[0,2064,1,2062,3,2069,4,2065,10,2066,11,2073,12,2075,13,2074,14,2072,15,2074,16,2072,17,2077,18,2072,19,2071,20,2065,35,2079,36,2080,37,2081,38,2082,39,2083,40,2084,41,2079,42,2078],"localNames":["error","errors","list","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":54,"name":"collectBytes","flags":72,"length":6,"params":6,"locals":11,"maxStack":7,"code":[0,20,10,326,54,1376317,0,65556,131076,65546,196612,43,0,262164,10,326,43,327684,43,582,5,36,393483,524300,10,2752586,2752571,590091,3672396,2949179,524300,524555,393226,393226,393241,31,32,543,524298,28,5,1835068,70,75,1769531,70,3672397,1966139,655627,3410254,70,5,655370,64,5,3407931,3,459019,131082,0,51,5570621,458762,393226,393241,46,5570621,393226,458762,31,32,543,196618,131082,393226,458762,26,458762,582,28,5,458762,56,458763,4063292,0,458772,393226,262154,327690,838,67],"consts":["$IsIterable","$Throw","TypeError"," expects a Uint8Array, an array, or an iterable of numbers, received ","$Describe",".","length","$Bytes"],"captures":[],"handlers":[30,42,48,0,49,52,54,0],"finallies":[],"finallyOffsets":[],"sites":[0,2096,1,2097,2,2098,3,2096,4,2095,5,2094,6,2100,7,2101,8,2102,9,2106,10,2107,11,2105,12,2108,13,2109,14,2110,15,2108,16,2104,17,2111,18,2103,19,2100,21,2115,22,2113,24,2120,25,2116,31,2117,32,2124,33,2126,34,2125,35,2123,36,2125,37,2123,38,2128,39,2123,40,2122,41,2116,56,2132,57,2130,58,2135,59,2136,60,2134,61,2133,62,2140,63,2142,64,2141,65,2139,66,2138,67,2148,68,2149,69,2147,70,2149,71,2147,72,2153,73,2152,74,2155,75,2156,76,2154,77,2157,78,2150,79,2147,80,2146,81,2160,82,2159,83,2160,84,2138,85,2162,86,2163,87,2164,88,2165,89,2166,90,2162,91,2161],"localNames":["source","name","mapper","thisArg","into","offset","values","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":55,"name":"readPairs","flags":72,"length":4,"params":4,"locals":12,"maxStack":6,"code":[0,20,10,326,54,917565,0,65556,131082,196618,10,65546,1094,67,36,262411,0,327947,393228,10,5832778,5832763,524555,6752332,6029371,393228,393483,0,20,393226,326,54,2687037,0,131092,196612,65546,262148,43,582,5,36,327691,458764,393226,4259914,4259899,655627,5179980,4456507,458764,459019,327690,327690,327705,31,32,543,0,393236,458762,326,28,5,3145788,70,75,3080251,70,5179981,3276859,721163,4917838,70,5,720906,64,5,4915259,262154,262154,327705,31,32,543,327690,28,5,1507388,70,75,1441851,70,6752333,1638459,590091,6490190,70,5,589834,64,5,6488123,0,65556,131082,196618,262154,65546,1094,67],"consts":["$IsIterable","$Pairs","$Throw","TypeError"," expects iterable [name, value] pairs.","length","String"],"captures":[],"handlers":[50,65,71,0,72,75,77,0,25,89,95,0,96,99,101,0],"finallies":[],"finallyOffsets":[],"sites":[0,2176,1,2177,2,2178,3,2176,4,2175,5,2174,6,2180,7,2181,8,2182,9,2183,10,2184,11,2185,12,2180,13,2179,14,2189,15,2187,16,2191,19,2197,20,2193,26,2194,27,2201,28,2202,29,2203,30,2201,31,2200,32,2199,33,2205,34,2206,35,2207,36,2209,37,2210,38,2208,39,2205,41,2214,42,2213,44,2219,45,2215,51,2216,52,2223,53,2225,54,2224,55,2222,56,2224,57,2222,58,2227,59,2228,60,2229,61,2227,62,2222,63,2221,64,2215,79,2233,80,2235,81,2234,82,2232,83,2234,84,2232,85,2237,86,2232,87,2231,88,2193,103,2239,104,2240,105,2241,106,2242,107,2243,108,2244,109,2239,110,2238],"localNames":["init","label","kind","proto","pairs","strings","pair","item","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":56,"name":"pairsForEach","flags":72,"length":4,"params":4,"locals":5,"maxStack":5,"code":[3,262411,262154,65546,25,46,1703997,196618,131082,65546,262154,26,65539,26,65546,262154,26,3,26,10,838,5,262154,56,262155,131132,0,67],"consts":["length"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2255,1,2253,2,2258,3,2260,4,2259,5,2257,6,2256,7,2267,8,2266,9,2270,10,2271,11,2269,12,2272,13,2268,14,2275,15,2276,16,2274,17,2277,18,2273,19,2278,20,2264,22,2281,23,2280,24,2281,25,2256,26,2251],"localNames":["target","pairs","callback","thisArg","index"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":57,"name":"Iterator$from","flags":72,"length":1,"params":1,"locals":1,"maxStack":10,"code":[0,20,10,326,721215,0,65556,10,131092,196633,582,917565,10,67,0,262164,0,327700,10,0,393236,10,258,458756,838,582,326,67],"consts":["$IsObject","$Inherits","Iterator","prototype","prime","wrapHelper","flattenable","Iterator.from"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2288,1,2289,2,2290,3,2288,4,2287,5,2291,6,2292,7,2293,8,2295,9,2294,10,2291,11,2286,12,2298,13,2297,14,2300,15,2301,16,2302,17,2303,18,2304,19,2305,20,2306,21,2307,22,2308,23,2309,24,2305,25,2302,26,2300,27,2299],"localNames":["value"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":58,"name":"wrapHelper","flags":76,"length":2,"params":2,"locals":9,"maxStack":3,"code":[81,2,131339,0,82,786515,393483,393226,327947,131075,262411,3866683,5,258,131083,196620,65546,2555978,2555963,459019,3475276,2752571,196620,196875,196618,82,2424915,393483,2099022,70,1611,5,393226,327947,131075,262411,3866683,5,1310780,70,75,1245243,70,3475277,1441851,524555,3213134,70,5,524298,64,5,3211323,3,262411,3866683,327947,65539,262411,131082,54,4390973,0,20,10,326,5,66,327690,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,39,45,0,46,49,51,0,3,53,56,0],"finallies":[4,5,0,3,70,-1,68],"finallyOffsets":[0],"sites":[0,2310,1,2318,2,2316,3,2322,13,2326,14,2325,16,2331,17,2327,23,2328,24,2334,25,2333,38,2327,53,2319,59,2338,60,2337,61,2336,62,2340,63,2341,64,2342,65,2340,67,2319,70,2314],"localNames":["source","iterator","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":59,"name":"Iterator$prototype$map","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.map","prime","mapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2343,2,2350,3,2351,4,2352,5,2353,6,2350,7,2348,8,2355,9,2356,10,2357,11,2358,12,2355,14,2360,15,2361,16,2362,17,2363,18,2364,19,2365,20,2366,21,2362,22,2360,23,2359],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":60,"name":"mapHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4587579,5,258,196619,3,262411,327692,65546,3276874,3276859,590091,4196684,3473467,327692,327947,0,131082,327690,262154,55,7,56,262155,582,82,3145811,524555,2820430,70,1611,5,524298,459019,131075,393483,4587579,5,1507388,70,75,1441851,70,4196685,1638459,655627,3934542,70,5,655370,64,5,3932219,3,393483,4587579,459019,65539,393483,196618,54,5111869,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,50,56,0,57,60,62,0,3,64,67,0],"finallies":[6,7,0,3,81,-1,79],"finallyOffsets":[0],"sites":[0,2367,1,2376,2,2374,4,2380,14,2384,15,2383,16,2388,17,2386,19,2393,20,2389,26,2390,27,2396,28,2397,29,2398,30,2400,32,2399,34,2400,35,2396,36,2395,49,2389,64,2377,70,2404,71,2403,72,2402,73,2406,74,2407,75,2408,76,2406,78,2377,81,2372],"localNames":["source","iterator","mapper","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":61,"name":"Iterator$prototype$filter","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.filter","prime","filterHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2409,2,2416,3,2417,4,2418,5,2419,6,2416,7,2414,8,2421,9,2422,10,2423,11,2424,12,2421,14,2426,15,2427,16,2428,17,2429,18,2430,19,2431,20,2432,21,2428,22,2426,23,2425],"localNames":["predicate","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":62,"name":"filterHelper","flags":76,"length":3,"params":3,"locals":11,"maxStack":5,"code":[81,2,196875,262156,0,82,852051,524555,524298,459019,131075,393483,4718651,5,258,196619,3,262411,327692,65546,3407946,3407931,590091,4327756,3604539,327692,327947,0,131082,327690,262154,55,7,56,262155,582,3342397,327690,82,3276883,524555,2951502,70,1611,5,524298,459019,131075,393483,4718651,5,1507388,70,75,1441851,70,4327757,1638459,655627,4065614,70,5,655370,64,5,4063291,3,393483,4718651,459019,65539,393483,196618,54,5242941,0,20,10,326,5,66,458762,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[25,52,58,0,59,62,64,0,3,66,69,0],"finallies":[6,7,0,3,83,-1,81],"finallyOffsets":[0],"sites":[0,2433,1,2442,2,2440,4,2446,14,2450,15,2449,16,2454,17,2452,19,2459,20,2455,26,2456,27,2461,28,2462,29,2463,30,2465,32,2464,34,2465,35,2461,36,2460,37,2468,38,2467,51,2455,66,2443,72,2472,73,2471,74,2470,75,2474,76,2475,77,2476,78,2474,80,2443,83,2438],"localNames":["source","iterator","predicate","started","counter","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":63,"name":"Iterator$prototype$take","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","takeHelper","count","take"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2477,2,2484,3,2485,4,2486,5,2487,6,2484,7,2482,8,2489,9,2490,10,2491,11,2492,12,2493,13,2494,14,2495,15,2496,16,2497,17,2498,18,2495,19,2491,20,2489,21,2488],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":64,"name":"takeHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,5570619,5,258,196619,131082,3,50,1900605,0,20,10,326,459019,458762,393483,131075,327947,5570619,262156,65546,4259914,4259899,524555,5179468,4456507,262156,262411,131082,312,131083,262154,82,3539027,459019,3213390,70,1611,5,458762,393483,131075,327947,5570619,5,131082,3,50,4194365,4130894,70,1611,5,5177403,2228284,70,75,2162747,70,5179469,2359355,590091,4917326,70,5,589834,64,5,4915259,3,327947,5570619,393483,65539,327947,196618,54,6094909,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[36,65,71,0,72,75,77,0,3,79,82,0],"finallies":[5,6,0,3,96,-1,94],"finallyOffsets":[0],"sites":[0,2499,1,2508,2,2506,3,2512,13,2516,14,2515,15,2519,16,2520,17,2518,18,2517,19,2522,20,2523,21,2524,22,2522,23,2521,30,2529,31,2525,37,2526,38,2533,39,2532,40,2533,41,2536,42,2535,55,2539,56,2540,57,2538,58,2537,59,2541,64,2525,79,2509,85,2545,86,2544,87,2543,88,2547,89,2548,90,2549,91,2547,93,2509,96,2504],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":65,"name":"Iterator$prototype$drop","flags":88,"length":1,"params":1,"locals":3,"maxStack":10,"code":[789,65803,0,20,65546,2,582,131339,0,65556,0,131092,65546,131082,0,196628,10,262148,582,838,326,67],"consts":["$Direct","prime","dropHelper","count","drop"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2550,2,2557,3,2558,4,2559,5,2560,6,2557,7,2555,8,2562,9,2563,10,2564,11,2565,12,2566,13,2567,14,2568,15,2569,16,2570,17,2571,18,2568,19,2564,20,2562,21,2561],"localNames":["limit","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":66,"name":"dropHelper","flags":76,"length":3,"params":3,"locals":10,"maxStack":3,"code":[81,2,196875,0,82,786515,459019,458762,393483,131075,327947,4390971,5,258,196619,262156,65546,3080266,3080251,524555,3999820,3276859,262156,262411,131082,3,48,2097213,131082,312,131083,3014715,262154,82,2949203,459019,2623566,70,1611,5,458762,393483,131075,327947,4390971,5,1310780,70,75,1245243,70,3999821,1441851,590091,3737678,70,5,589834,64,5,3735611,3,327947,4390971,393483,65539,327947,196618,54,4915261,0,20,10,326,5,66,393226,67,0,67],"consts":["closeIterator"],"captures":[],"handlers":[22,47,53,0,54,57,59,0,3,61,64,0],"finallies":[5,6,0,3,78,-1,76],"finallyOffsets":[0],"sites":[0,2572,1,2581,2,2579,3,2585,13,2589,14,2588,16,2594,17,2590,23,2591,24,2598,25,2599,26,2597,27,2596,28,2602,29,2601,30,2602,31,2596,32,2605,33,2604,46,2590,61,2582,67,2609,68,2608,69,2607,70,2611,71,2612,72,2613,73,2611,75,2582,78,2577],"localNames":["source","iterator","remaining","started","item","%ftag0","%fval0","%ret","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":67,"name":"Iterator$prototype$flatMap","flags":88,"length":1,"params":1,"locals":3,"maxStack":7,"code":[789,65803,0,20,65546,2,582,131339,0,65556,10,131076,582,5,0,196628,0,262164,65546,131082,10,838,326,67],"consts":["$Direct","$Callback","Iterator.prototype.flatMap","prime","flatMapHelper"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2614,2,2621,3,2622,4,2623,5,2624,6,2621,7,2619,8,2626,9,2627,10,2628,11,2629,12,2626,14,2631,15,2632,16,2633,17,2634,18,2635,19,2636,20,2637,21,2633,22,2631,23,2630],"localNames":["mapper","this","iterator"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":68,"name":"flatMapHelper","flags":76,"length":3,"params":3,"locals":14,"maxStack":7,"code":[81,2,196875,262156,0,82,852051,590091,589834,524555,131075,459019,6750267,5,258,196619,3,262411,327692,65546,5439562,5439547,655627,6359628,5636155,327692,327947,393228,0,20,0,131082,327690,262154,55,7,56,262155,582,2,65540,838,4456522,4456507,786699,5377100,4653115,393228,393483,393226,82,4325459,590091,3738702,70,1611,5,4000334,70,1611,5,589834,524555,131075,459019,6750267,5,2949180,70,75,2883643,70,5377101,3080251,852235,5114958,70,5,851978,64,5,5111867,1507388,70,75,1441851,70,6359629,1638459,721163,6097486,70,5,720906,64,5,6094907,3,459019,6750267,524555,65539,459019,196618,54,7274557,0,131092,10,326,5,66,524298,67,0,67],"consts":["flattenable","Iterator.prototype.flatMap","closeIterator"],"captures":[],"handlers":[47,68,74,0,75,78,80,0,25,83,89,0,90,93,95,0,3,97,100,0],"finallies":[7,8,0,3,114,-1,112],"finallyOffsets":[0],"sites":[0,2638,1,2647,2,2645,4,2651,14,2655,15,2654,16,2659,17,2657,19,2664,20,2660,26,2661,28,2670,29,2671,30,2672,31,2673,32,2674,33,2676,35,2675,37,2676,38,2672,39,2677,40,2678,41,2670,42,2666,48,2667,49,2681,50,2680,67,2666,82,2660,97,2648,103,2685,104,2684,105,2683,106,2687,107,2688,108,2689,109,2687,111,2648,114,2643],"localNames":["source","iterator","mapper","started","counter","item","inner","%ftag0","%fval0","%ret","%it","%e","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":69,"name":"prime","flags":72,"length":1,"params":1,"locals":1,"maxStack":2,"code":[10,281,70,5,10,67],"consts":["next"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2697,1,2696,2,2695,4,2700,5,2699],"localNames":["helper"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":70,"name":"count","flags":72,"length":2,"params":2,"locals":4,"maxStack":5,"code":[10,309,131339,131082,20,50,720959,131082,20,53,50,917565,131082,1245243,131082,131082,65539,308,44,196875,131082,131082,51,1769535,196618,3,46,2752573,0,65556,131076,196612,65546,43,262148,43,131082,43,327684,43,582,5,196618,67],"consts":["Infinity","$Throw","RangeError","Iterator.prototype."," expects a non-negative count, received ","."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2710,1,2709,2,2707,3,2717,4,2718,5,2716,6,2715,7,2720,8,2722,9,2721,10,2719,11,2714,12,2723,13,2714,14,2725,15,2727,16,2728,17,2726,18,2724,19,2712,20,2732,21,2733,22,2731,23,2730,24,2735,25,2736,26,2734,27,2729,28,2738,29,2739,30,2740,31,2745,32,2746,33,2744,34,2747,35,2743,36,2748,37,2742,38,2749,39,2741,40,2738,42,2751,43,2750],"localNames":["limit","name","number","integer"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":71,"name":"flattenable","flags":72,"length":3,"params":3,"locals":4,"maxStack":7,"code":[10,821,4,50,524349,65546,54,852027,0,65556,10,326,54,1900605,0,131092,196612,131082,262148,43,0,327700,10,326,43,393220,43,582,5,10,458772,524313,26,196875,0,589844,196618,0,50,2818111,196618,1,50,3014717,10,3211323,10,196618,70,2,582,67],"consts":["string","$IsObject","$Throw","TypeError"," expects an iterable or iterator, received ","$Describe",".","Symbol","iterator","$Direct"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2762,1,2761,2,2763,3,2760,4,2759,5,2765,6,2764,7,2759,8,2767,9,2768,10,2769,11,2767,12,2766,13,2758,14,2771,15,2772,16,2773,17,2777,18,2778,19,2776,20,2779,21,2780,22,2781,23,2779,24,2775,25,2782,26,2774,27,2771,29,2787,30,2789,31,2788,32,2786,33,2784,34,2792,35,2793,36,2797,37,2798,38,2796,39,2795,40,2800,41,2801,42,2799,43,2794,44,2802,45,2794,46,2806,47,2805,48,2803,49,2807,50,2792,51,2791],"localNames":["value","strings","name","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":72,"name":"closeIterator","flags":72,"length":1,"params":1,"locals":2,"maxStack":4,"code":[10,25,65803,65546,0,51,655679,65546,1,51,1179967,0,65556,10,65546,70,326,54,1638461,0,131092,196612,262148,582,5,0,67],"consts":["return","$IsObject","$Throw","TypeError","Iterator return() must return an object."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2816,1,2815,2,2813,3,2822,4,2823,5,2821,6,2820,7,2825,8,2826,9,2824,10,2819,11,2828,12,2829,13,2833,14,2832,15,2830,16,2828,17,2827,18,2818,19,2835,20,2836,21,2837,22,2838,23,2835,25,2811],"localNames":["iterator","method"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":73,"name":"Iterator$prototype$toArray","flags":88,"length":0,"params":0,"locals":5,"maxStack":4,"code":[789,267,36,65803,131084,0,20,10,2,582,1769546,1769531,196875,2687820,1966139,131084,131339,65546,65546,65561,31,32,543,131082,28,5,852028,70,75,786491,70,2687821,983099,262411,2425678,70,5,262154,64,5,2424891,65546,67],"consts":["$Direct","length"],"captures":[],"handlers":[15,27,33,0,34,37,39,0],"finallies":[],"finallyOffsets":[],"sites":[0,2839,2,2845,3,2843,5,2850,6,2851,7,2852,8,2853,9,2850,10,2846,16,2847,17,2857,18,2859,19,2858,20,2856,21,2858,22,2856,23,2861,24,2856,25,2855,26,2846,41,2863,42,2862],"localNames":["this","result","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":74,"name":"Iterator$prototype$reduce","flags":592,"length":1,"params":2,"locals":10,"maxStack":5,"code":[789,267,1045,65803,65813,131339,0,20,10,2,582,196875,0,65556,65546,131076,582,5,131082,3,26,262411,131082,196633,3,48,327947,3,393483,458764,196618,3670090,3670075,524555,4589644,3866683,458764,459019,327690,3145789,0,65546,262154,458762,393226,838,262155,3276859,458762,262155,258,327691,393226,56,393227,2228284,70,75,2162747,70,4589645,2359355,590091,4327502,70,5,589834,64,5,4325435,327690,54,5177405,0,262164,327684,393220,582,5,262154,67],"consts":["$Direct","$Callback","Iterator.prototype.reduce","length","$Throw","TypeError","Iterator.prototype.reduce of an empty iterator with no initial value."],"captures":[],"handlers":[36,56,62,0,63,66,68,0],"finallies":[],"finallyOffsets":[],"sites":[0,2864,2,2866,4,2867,6,2873,7,2874,8,2875,9,2876,10,2873,11,2871,12,2878,13,2879,14,2880,15,2881,16,2878,18,2886,19,2887,20,2885,21,2883,22,2893,23,2892,24,2895,25,2891,26,2889,27,2899,28,2897,30,2904,31,2900,37,2901,38,2907,39,2906,40,2911,41,2912,42,2913,43,2914,44,2915,45,2911,46,2910,47,2906,48,2919,49,2918,50,2923,51,2922,52,2926,53,2925,54,2926,55,2900,70,2929,71,2928,72,2927,73,2931,74,2932,75,2933,76,2934,77,2931,79,2936,80,2935],"localNames":["this","callback","initial","iterator","accumulator","started","index","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":75,"name":"Iterator$prototype$forEach","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,5,0,67],"consts":["iteratorTest","forEach"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2937,2,2942,3,2943,4,2944,5,2945,6,2946,7,2942,9,2940],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":76,"name":"Iterator$prototype$some","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","some"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2947,2,2952,3,2953,4,2954,5,2955,6,2956,7,2952,8,2951],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":77,"name":"Iterator$prototype$every","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","every"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2957,2,2962,3,2963,4,2964,5,2965,6,2966,7,2962,8,2961],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":78,"name":"Iterator$prototype$find","flags":88,"length":1,"params":1,"locals":2,"maxStack":5,"code":[789,65803,0,20,65546,10,65540,838,67],"consts":["iteratorTest","find"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,2967,2,2972,3,2973,4,2974,5,2975,6,2976,7,2972,8,2971],"localNames":["callback","this"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":79,"name":"iteratorTest","flags":72,"length":3,"params":3,"locals":10,"maxStack":5,"code":[0,20,10,2,582,196875,0,65556,65546,131076,131082,43,582,5,3,262411,0,327947,393228,196618,5308490,5308475,459019,6227788,5505083,393228,393483,0,65546,393226,262154,55,7,56,262155,582,327691,131082,196612,50,2752831,327690,3342397,258,590091,3213134,70,1611,5,589834,67,131082,262148,50,3735871,327690,54,4325437,2,590091,4196174,70,1611,5,589834,67,131082,327684,50,4653375,327690,5242941,393226,590091,5113678,70,1611,5,589834,67,1507388,70,75,1441851,70,6227789,1638459,524555,5965646,70,5,524298,64,5,5963835,131082,262148,50,6619197,258,7077947,131082,196612,50,7012413,2,7077947,0,67],"consts":["$Direct","$Callback","Iterator.prototype.","some","every","find"],"captures":[],"handlers":[25,81,87,0,88,91,93,0],"finallies":[],"finallyOffsets":[],"sites":[0,2986,1,2987,2,2988,3,2989,4,2986,5,2984,6,2991,7,2992,8,2993,9,2995,10,2996,11,2994,12,2991,14,3000,15,2998,16,3002,19,3008,20,3004,26,3005,27,3013,28,3014,29,3015,30,3017,32,3016,34,3017,35,3013,36,3012,37,3021,38,3022,39,3020,40,3019,41,3023,42,3018,43,3025,44,3024,51,3029,52,3030,53,3028,54,3027,55,3032,56,3031,57,3026,58,3034,59,3033,66,3038,67,3039,68,3037,69,3036,70,3040,71,3035,72,3042,73,3041,80,3004,95,3046,96,3047,97,3045,98,3044,99,3048,100,3044,101,3051,102,3052,103,3050,104,3049,105,3053,106,3049,107,3054,108,3043],"localNames":["self","callback","name","iterator","index","result","item","%it","%e","%ret"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":80,"name":"revive","flags":72,"length":3,"params":3,"locals":7,"maxStack":5,"code":[10,65546,26,196875,0,20,196618,326,3932221,262156,327692,393228,0,65556,196618,326,262411,3,327947,0,393483,327690,262154,131097,46,3932221,0,196628,196618,262154,327690,26,131082,838,393227,393226,0,50,3014717,196618,262154,327690,26,30,5,3670075,196618,262154,327690,26,31,32,543,393226,28,5,327690,56,327691,1376316,10,131082,65546,196618,582,67],"consts":["$IsObject","$Keys","length","revive"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3065,1,3066,2,3064,3,3062,4,3068,5,3069,6,3070,7,3068,8,3067,12,3075,13,3076,14,3077,15,3075,16,3073,17,3081,18,3079,19,3083,21,3087,22,3089,23,3088,24,3086,25,3085,26,3095,27,3096,28,3097,29,3099,30,3100,31,3098,32,3101,33,3095,34,3094,35,3104,36,3105,37,3103,38,3102,39,3109,40,3111,41,3112,42,3110,43,3108,44,3107,45,3102,46,3116,47,3118,48,3119,49,3117,50,3115,51,3117,52,3115,53,3120,54,3115,55,3114,56,3123,57,3122,58,3123,59,3085,60,3128,61,3127,62,3129,63,3130,64,3125,65,3124],"localNames":["holder","key","reviver","value","names","index","revived"],"upvalNames":[]},{"source":{"id":"@prelude","hash":"201e50b8e15a2e40"},"index":81,"name":"replaceWith","flags":72,"length":3,"params":3,"locals":6,"maxStack":9,"code":[4,196875,3,262411,262154,10,65561,46,3211325,196618,10,262154,26,3,26,0,131092,0,131082,36,10,262154,26,65539,26,2228810,2228283,327947,1967439,2621499,2622796,2424891,37,1966139,70,587,1769531,70,2622797,2097211,71,326,43,43,196619,262154,56,262155,262204,196618,65546,43,67],"consts":["","length","String"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,3140,1,3138,2,3144,3,3142,4,3147,5,3149,6,3148,7,3146,8,3145,9,3154,10,3158,11,3159,12,3157,13,3160,14,3156,15,3161,16,3162,17,3163,18,3164,19,3163,20,3168,21,3169,22,3167,23,3170,24,3166,25,3165,40,3163,41,3161,42,3155,43,3153,44,3154,45,3173,46,3172,47,3173,48,3145,49,3176,50,3177,51,3175,52,3174],"localNames":["matches","rest","callback","result","index","%it"],"upvalNames":[]}]},"@vm-internal":{"text":"41bc09556396ce5e","codes":[{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":0,"name":"","flags":202,"length":0,"params":0,"locals":0,"maxStack":1,"code":[0,87],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,0],"localNames":[],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":1,"name":"$vmToPrimitive","flags":72,"length":2,"params":2,"locals":8,"maxStack":4,"code":[0,20,10,326,54,655423,0,65556,10,326,852029,10,67,65546,131076,50,1638463,65546,196612,50,1638719,0,262164,10,326,1835069,327684,1900603,393220,131339,131082,327684,50,2359357,393220,2424891,327684,196875,0,458772,10,131082,582,262411,262154,0,51,3997757,393228,10,262154,70,393483,0,20,393226,326,54,3997757,393226,67,0,458772,10,196618,582,327947,327690,0,51,5505085,458764,10,327690,70,459019,0,20,458762,326,54,5505085,458762,67,0,524308,589828,655364,582,5,0,67],"consts":["$IsObj","$IsPromise","string","default","$IsDate","toString","valueOf","$GetMethod","$Throw","TypeError","Cannot convert object to primitive value."],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,9,1,10,2,11,3,9,4,8,5,7,6,12,7,13,8,14,9,12,10,6,11,16,12,15,13,23,14,24,15,22,16,21,17,27,18,28,19,26,20,25,21,29,22,30,23,31,24,29,25,20,26,32,27,20,28,33,29,18,30,39,31,40,32,38,33,37,34,41,35,37,36,42,37,35,38,46,39,47,40,48,41,49,42,46,43,44,44,52,45,53,46,51,47,50,49,61,50,60,51,58,52,56,53,64,54,65,55,66,56,64,57,63,58,62,59,68,60,67,61,72,62,73,63,74,64,75,65,72,66,70,67,78,68,79,69,77,70,76,72,87,73,86,74,84,75,82,76,90,77,91,78,92,79,90,80,89,81,88,82,94,83,93,84,96,85,97,86,98,87,99,88,96,90,5],"localNames":["v","hint","first","second","m1","m2","r1","r2"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":2,"name":"$vmToKey","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$PropKey","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,105,1,106,2,107,3,108,4,109,5,110,6,107,7,105,8,104],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":3,"name":"$vmToString","flags":72,"length":1,"params":1,"locals":1,"maxStack":6,"code":[0,20,0,65556,10,131076,582,326,67],"consts":["$CoerceToString","$vmToPrimitive","string"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,116,1,117,2,118,3,119,4,120,5,121,6,118,7,116,8,115],"localNames":["v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":4,"name":"$vmToNumeric","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,128,1,129,2,130,3,131,4,132,5,133,6,134,7,131,8,128,9,127],"localNames":["incFlag","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":5,"name":"$vmInc","flags":72,"length":2,"params":2,"locals":3,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,131339,10,3,50,1179709,131082,65539,43,1376315,131082,65539,44,67],"consts":["$ApplyToNumeric","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,143,1,144,2,145,3,146,4,147,5,148,6,149,7,146,8,143,9,141,10,153,11,154,12,152,13,151,14,156,15,157,16,155,17,151,18,159,19,160,20,158,21,150],"localNames":["incFlag","v","n"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":6,"name":"$vmUnary","flags":72,"length":2,"params":2,"locals":2,"maxStack":7,"code":[0,20,10,0,65556,65546,131076,582,582,67],"consts":["$ApplyUnary","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,167,1,168,2,169,3,170,4,171,5,172,6,173,7,170,8,167,9,166],"localNames":["sub","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":7,"name":"$vmBinary","flags":72,"length":3,"params":3,"locals":8,"maxStack":5,"code":[0,20,10,65546,131082,838,196875,196618,3,50,1179709,0,65556,10,65546,131082,838,67,196618,65539,50,2359357,458764,0,131092,65546,196612,582,459019,0,65556,10,458762,131082,838,67,196618,131075,50,2752573,262148,2818107,327684,262411,0,131092,65546,262154,582,327947,0,131092,131082,262154,582,393483,0,65556,10,327690,393226,838,67],"consts":["$OpConvKind","$ApplyBinary","$vmToPrimitive","string","default","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,183,1,184,2,185,3,186,4,187,5,183,6,181,7,190,8,191,9,189,10,188,11,193,12,194,13,195,14,196,15,197,16,193,17,192,18,200,19,201,20,199,21,198,23,206,24,207,25,208,26,209,27,206,28,204,29,211,30,212,31,213,32,214,33,215,34,211,35,210,36,221,37,222,38,220,39,219,40,223,41,219,42,224,43,217,44,228,45,229,46,230,47,231,48,228,49,226,50,235,51,236,52,237,53,238,54,235,55,233,56,240,57,241,58,242,59,243,60,244,61,240,62,239],"localNames":["op","lhs","rhs","kind","hint","l","r","key"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":8,"name":"$vmSetLength","flags":72,"length":2,"params":2,"locals":2,"maxStack":5,"code":[10,0,65556,65546,131076,582,1055,27,5,65546,67],"consts":["length","$vmToPrimitive","number"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,253,1,255,2,256,3,257,4,258,5,255,6,252,8,251,9,260,10,259],"localNames":["o","v"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":9,"name":"$vmGetElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,26,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,268,1,269,2,270,3,271,4,269,5,267,6,266],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":10,"name":"$vmDeleteElem","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[10,0,20,65546,326,30,67],"consts":["$vmToKey"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,280,1,281,2,282,3,283,4,281,5,279,6,277],"localNames":["o","k"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":11,"name":"$vmConvert","flags":72,"length":6,"params":6,"locals":16,"maxStack":7,"code":[258,7274557,393228,458764,524300,589836,655372,720908,786444,0,20,327690,326,393483,0,65556,327690,3,582,459019,0,65556,327690,65539,582,524555,393226,131097,590091,36,655627,3,721163,720906,589834,46,5439549,851980,917516,983052,393226,720906,26,852235,0,196628,327690,720906,582,917771,0,262164,851978,326,3997757,0,327700,851978,917514,582,4063291,851978,983307,655370,720906,31,32,543,458762,4980797,0,393236,917514,983050,582,5046331,983050,28,5,720906,56,720907,2162748,262154,524298,31,32,543,655370,28,5,0,458772,10,65546,131082,196618,262154,1350,786699,0,524308,786442,326,54,7077949,786442,67,786442,327691,60,0,67],"consts":["$ConvValues","$ConvFlag","length","$ConvHint","$IsObj","$vmToPrimitive","$ConvCoerce","$ConvReplay","$IsConvert"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,294,1,293,9,299,10,300,11,301,12,299,13,297,14,305,15,306,16,307,17,308,18,305,19,303,20,312,21,313,22,314,23,315,24,312,25,310,26,320,27,319,28,317,29,325,30,323,31,329,32,327,33,332,34,333,35,331,36,330,40,339,41,340,42,338,43,336,44,344,45,345,46,346,47,347,48,344,49,342,50,352,51,353,52,354,53,352,54,351,55,355,56,356,57,357,58,358,59,355,60,351,61,359,62,349,63,363,64,364,65,362,66,364,67,362,68,366,69,365,70,367,71,368,72,369,73,370,74,367,75,365,76,371,77,362,78,361,79,374,80,373,81,374,82,330,83,378,84,379,85,377,86,379,87,377,88,380,89,377,90,376,91,384,92,385,93,386,94,387,95,388,96,389,97,390,98,384,99,382,100,393,101,394,102,395,103,393,104,392,105,391,106,397,107,396,108,401,109,400,110,293,111,292],"localNames":["callable","target","args","constructing","replay","req","values","coerce","ordinal","len","converted","i","res","val","hint","prim"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":12,"name":"$vmJsonVisitor","flags":72,"length":3,"params":3,"locals":5,"maxStack":1,"code":[269,65805,131341,196621,262157,851990,262416,36,196880,262159,67],"consts":[],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,402,5,412,7,411,8,409,9,659,10,658],"localNames":["boundary","replacer","properties","ancestors","visit"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":13,"name":"visit","flags":76,"length":3,"params":3,"locals":19,"maxStack":6,"code":[81,131082,6553603,48,720957,0,20,65540,131076,582,5,10,65546,26,196875,0,196628,196618,326,2228285,17,54,1900605,0,20,262148,327684,582,5,196618,82,2162771,67,196619,0,393236,196618,326,3473469,458764,196618,458777,459019,0,524308,458762,326,3473469,196618,458762,65546,326,196619,65553,0,51,4128829,10,65553,65546,196618,582,196619,0,589844,196618,17,131089,838,262411,262154,3,50,4980797,0,67,262154,65539,50,5374013,196618,67,262154,131075,50,5767229,1,67,262154,196611,50,6422589,0,655380,196618,17,582,67,262154,262147,50,7012413,0,720916,196618,326,7077947,196618,327947,131089,131089,786457,31,32,543,327690,28,5,0,393483,0,851988,327690,326,13172797,524300,589836,36,393227,327690,786457,524555,3,590091,589834,524298,46,13107261,655372,0,196625,327690,0,917524,589834,326,131082,65539,43,838,11338570,11337787,983307,0,3,7,1048843,11079509,1048586,131075,50,10682429,67,5,11013966,70,1611,5,983105,326,11538518,82,10158140,70,843,9961531,1048586,131075,50,11862077,67,655627,393226,589834,31,32,543,655370,0,50,12648509,1,12714043,655370,28,5,589834,56,589835,8781884,18546747,720908,786444,0,1048596,70,393227,0,1114132,327690,17,262161,838,721163,3,786699,786442,720906,786457,46,18546749,851980,917516,720906,786442,26,852235,0,196625,327690,851978,131082,65539,43,838,16909130,16908347,1114379,0,3,7,1179915,16650581,1179658,131075,50,16252989,67,5,16585038,70,1611,5,1179713,326,17109590,82,15728700,70,843,15532091,1179658,131075,50,17432637,67,917771,917514,0,51,18284605,0,1245204,393226,851978,917514,258,1094,5,786442,56,786443,14155836,0,1310740,131089,326,5,393226,67],"consts":["$Throw","RangeError","Value exceeds the maximum depth of 100.","$IsPromise","InvalidData","JSON.stringify received an un-awaited Promise; await it first - e.g. `const result = await tools.ns.tool(...)`.","$IsObj","toJSON","$IsCallableAny","$JsonClassify","$JsonSpecial","$SetToArray","length","$IsArray","String",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$NewNullProtoObj","$JsonNames",{"type":"TypeError","message":"The delegated iterator does not provide a throw() method."},"$Define","$ArrayPop"],"captures":[0,0,0,1,0,3,0,4,0,2],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,412,1,420,2,421,3,419,4,418,5,423,6,424,7,425,8,426,9,423,11,431,12,432,13,430,14,428,15,434,16,435,17,436,18,434,19,433,20,440,21,439,22,438,23,443,24,444,25,445,26,446,27,443,29,451,30,450,33,449,34,453,35,454,36,455,37,453,38,452,40,461,41,460,42,458,43,464,44,465,45,466,46,464,47,463,48,473,49,472,50,474,51,470,52,469,53,477,54,478,55,476,56,475,57,485,58,484,59,486,60,487,61,482,62,481,63,491,64,492,65,493,66,494,67,495,68,491,69,489,70,498,71,499,72,497,73,496,74,501,75,500,76,504,77,505,78,503,79,502,80,507,81,506,82,510,83,511,84,509,85,508,86,513,87,512,88,516,89,517,90,515,91,514,92,519,93,520,94,521,95,522,96,519,97,518,98,528,99,529,100,527,101,526,102,530,103,531,104,532,105,530,106,526,107,533,108,524,109,537,110,539,111,538,112,536,113,538,114,536,115,541,116,536,117,535,118,543,120,546,121,547,122,548,123,546,124,545,127,553,128,552,129,558,130,557,131,555,132,563,133,561,134,566,135,567,136,565,137,564,139,573,140,574,141,575,142,576,143,577,144,578,145,576,146,580,147,581,148,579,149,573,150,572,181,570,182,585,183,586,184,584,185,586,186,584,187,589,188,590,189,588,190,587,191,591,192,587,193,592,194,584,195,583,196,595,197,594,198,595,199,564,200,545,203,600,204,601,205,600,206,599,207,605,208,606,209,607,210,608,211,609,212,605,213,603,214,613,215,611,216,616,217,618,218,617,219,615,220,614,223,625,224,626,225,624,226,622,227,631,228,632,229,633,230,634,231,636,232,637,233,635,234,631,235,630,266,628,267,640,268,641,269,639,270,638,271,643,272,644,273,645,274,646,275,647,276,648,277,643,279,651,280,650,281,651,282,614,283,653,284,654,285,655,286,653,288,657,289,656],"localNames":["holder","key","depth","val","kind","target","out","toJSON","len","i","elem","names","i","k","propVal","%it","%kind","%it","%kind"],"upvalNames":["boundary","replacer","ancestors","visit","properties"]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":14,"name":"$vmJsonWalk","flags":72,"length":4,"params":4,"locals":5,"maxStack":6,"code":[0,0,20,2,10,131082,838,35,65546,65574,65540,3,838,131353,70,196633,262411,0,262164,2,262154,131082,196618,1094,67],"consts":["$vmJsonVisitor","","next","value","$JsonFinish"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,673,1,674,2,675,3,676,4,677,5,678,6,674,7,679,8,682,9,680,10,683,11,684,12,673,13,672,14,671,15,670,16,668,17,688,18,689,19,690,20,691,21,692,22,693,23,688,24,687],"localNames":["replacer","value","properties","indent","json"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":15,"name":"$vmSettleCall","flags":72,"length":3,"params":3,"locals":3,"maxStack":5,"code":[0,20,10,65546,131082,838,67],"consts":["$Apply"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,701,1,702,2,703,3,704,4,705,5,701,6,700],"localNames":["callable","thisVal","args"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":16,"name":"$vmCombine","flags":72,"length":2,"params":2,"locals":6,"maxStack":4,"code":[0,20,10,65546,582,131339,196620,65546,1441866,1441851,262411,2360396,1638459,196620,196875,0,65556,131082,196618,582,5,720956,70,75,655419,70,2360397,852027,327947,2098254,70,5,327690,64,5,2097211,0,131092,131082,326,5,0,67],"consts":["$CombineStart","$CombineAdd","$CombineEnd"],"captures":[],"handlers":[13,22,28,0,29,32,34,0],"finallies":[],"finallyOffsets":[],"sites":[0,714,1,715,2,716,3,717,4,714,5,712,7,722,8,718,14,719,15,725,16,726,17,727,18,728,19,725,21,718,36,730,37,731,38,732,39,730,41,710],"localNames":["name","items","c","item","%it","%e"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":17,"name":"$vmOpenSyncForAsync","flags":72,"length":2,"params":2,"locals":2,"maxStack":4,"code":[0,20,10,65546,70,326,67],"consts":["$WrapAsyncFromSync"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,739,1,740,2,744,3,743,4,741,5,739,6,738],"localNames":["v","method"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":18,"name":"$vmAsyncFromSync","flags":72,"length":4,"params":4,"locals":10,"maxStack":7,"code":[0,20,10,326,262411,65546,65540,50,917565,0,131092,10,326,1310779,0,196628,10,262154,65546,838,327947,327690,0,50,1835071,327690,1,50,4718653,589836,65546,262148,50,2687037,0,327700,196618,326,5,0,67,0,196628,10,262154,262148,838,590091,589834,0,51,3604799,589834,1,51,4259901,0,393236,10,262154,589834,70,262148,838,5,0,458772,10,326,5,0,67,131082,5177405,262154,327690,196618,326,5374011,262154,327690,70,393483,0,393236,10,393226,65546,838,5,393226,524313,54,54,459019,393226,589849,524555,0,655380,10,524298,458762,65546,262148,51,1094,5,0,67],"consts":["$AfsGetIter","next","$AfsGetNext","$AfsGetMethod","return","$AfsResolveDone","$AfsCheckObj","$AfsRejectNoThrow","done","value","$AfsSettle"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,755,1,756,2,757,3,755,4,753,5,763,6,764,7,762,8,761,9,765,10,766,11,767,12,765,13,761,14,768,15,769,16,770,17,771,18,772,19,768,20,759,21,776,22,777,23,775,24,774,25,779,26,780,27,778,28,773,30,784,31,785,32,783,33,782,34,788,35,789,36,790,37,788,39,791,41,795,42,796,43,797,44,798,45,799,46,795,47,793,48,803,49,804,50,802,51,801,52,806,53,807,54,805,55,800,56,810,57,811,58,812,59,816,60,815,61,813,62,817,63,810,65,819,66,820,67,821,68,819,70,822,72,827,73,826,74,831,75,830,76,832,77,828,78,826,79,836,80,835,81,833,82,824,83,838,84,839,85,840,86,841,87,842,88,838,90,849,91,848,92,847,93,846,94,844,95,855,96,854,97,852,98,858,99,859,100,860,101,861,102,862,103,864,104,865,105,863,106,858,108,751],"localNames":["adapter","kind","hasArg","val","iter","method","res","done","value","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":19,"name":"$vmAsyncFromSyncClose","flags":72,"length":1,"params":1,"locals":2,"maxStack":2,"code":[10,25,65803,65546,0,51,655679,65546,1,51,983101,10,65546,70,5,0,67],"consts":["return"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,874,1,873,2,871,3,879,4,880,5,878,6,877,7,882,8,883,9,881,10,876,11,888,12,887,13,885,15,869],"localNames":["iter","ret"],"upvalNames":[]},{"source":{"id":"@vm-internal","hash":"7bf6f42afc755c3b"},"index":20,"name":"$vmCross","flags":74,"length":3,"params":3,"locals":8,"maxStack":8,"code":[36,196875,3,262411,262154,10,25,46,5046333,327692,393228,458764,10,262154,26,327947,65546,0,50,1573183,0,65556,327690,326,1835069,327690,340,327691,0,0,131092,258,0,1,838,35,327690,196646,196612,3,838,393483,393226,262425,70,459019,458762,327705,54,3801149,393226,262425,458762,393241,340,326,458763,3014716,196618,262154,31,32,543,0,458772,258,458762,393241,1,0,1094,28,5,262154,56,262155,262204,65546,0,50,5570621,196618,3,26,67,65546,524292,50,6160445,0,589844,196618,326,67,0,655380,65546,196618,131082,838,5,0,67],"consts":["length","$IsThenable","$vmJsonVisitor","","next","done","value","$JsonFinish","search","$HostSearch","$HostTool"],"captures":[],"handlers":[],"finallies":[],"finallyOffsets":[],"sites":[0,898,1,896,2,902,3,900,4,905,5,907,6,906,7,904,8,903,12,914,13,915,14,913,15,911,16,919,17,920,18,918,19,917,20,921,21,922,22,923,23,921,24,916,25,928,26,927,27,926,28,932,29,933,30,934,31,935,32,936,33,937,34,933,35,938,36,941,37,939,38,942,39,943,40,932,41,930,42,949,43,948,44,947,45,945,46,954,47,953,48,952,49,951,50,961,51,960,52,965,53,964,54,963,55,959,56,958,57,951,58,970,59,971,60,969,61,971,62,969,63,972,64,973,65,974,66,976,67,975,68,978,69,979,70,972,71,969,72,968,73,982,74,981,75,982,76,903,77,985,78,986,79,984,80,983,81,989,82,990,83,988,84,987,85,993,86,994,87,992,88,991,89,996,90,997,91,998,92,996,93,995,94,1000,95,1001,96,1002,97,1003,98,1004,99,1000,101,894],"localNames":["roots","path","resolving","crossed","r","root","walk","step"],"upvalNames":[]}]}} diff --git a/packages/codemode/src/prelude/helpers.ts b/packages/codemode/src/prelude/helpers.ts index 1d02f065d84a..919461d7bd30 100644 --- a/packages/codemode/src/prelude/helpers.ts +++ b/packages/codemode/src/prelude/helpers.ts @@ -149,7 +149,7 @@ export const helpers = (ctx: Interpreter): Array sortState(builtins, values as Arr)], + $SortState: [1, ([keys]) => sortState(builtins, keys as Arr)], $SortStep: [1, ([state]) => sortStep(state as Arr)], $SortResult: [ 2, @@ -225,8 +225,8 @@ const MERGE_STEP = 65_536 * the next run to sort, and the merge pass's run width, output position, and positions in its two runs. Runs of * SORT_RUN are sorted first, then merged in passes of doubling width from the order into the buffer, which swap. */ -const sortState = (builtins: Builtins, values: Arr): Arr => { - const keys = values.items.map(coerceToString) +const sortState = (builtins: Builtins, strings: Arr): Arr => { + const keys = strings.items as Array const order = keys.map((_, at) => at) return new Arr(builtins.Array, [ new Arr(builtins.Array, keys), diff --git a/packages/codemode/src/prelude/source.ts b/packages/codemode/src/prelude/source.ts index 7992d6bf48cb..b7d4429f2567 100644 --- a/packages/codemode/src/prelude/source.ts +++ b/packages/codemode/src/prelude/source.ts @@ -243,8 +243,8 @@ function sortWith(target, into, holes, comparator, work, undefs, merges) { // The default sort over more values than one native sort may take at once: native steps of bounded size (see // $SortStep), so the run can pause between them like any loop. -function sortDefault(target, into, holes, values, undefs) { - const state = $SortState(values) +function sortDefault(target, into, holes, values, undefs, keys) { + const state = $SortState(keys) while ($SortStep(state)) {} return $Sorted(target, into, holes, $SortResult(state, values), undefs) } diff --git a/packages/codemode/src/stdlib/array.ts b/packages/codemode/src/stdlib/array.ts index fbd300a82e48..1c50404e84e3 100644 --- a/packages/codemode/src/stdlib/array.ts +++ b/packages/codemode/src/stdlib/array.ts @@ -18,6 +18,7 @@ import { coerceToNumber, coerceToString, rejectAddition, + type NativeResult, type Value, } from "../runtime/objects.js" import { describeValue, rejectCircularInsertion } from "../runtime/references.js" @@ -82,29 +83,30 @@ export const sortArray = ( target: Arr | Bytes, comparator: Value, into: SortInto, -): Value | Invoke => { +): NativeResult => { const builtins = ctx.builtins const items = target instanceof Arr ? [...target.items] : [...target.bytes] // Counted before any comparator runs; a comparator that changes the array does not change where holes go. let holes = 0 if (target instanceof Arr) for (let index = 0; index < items.length; index++) if (!(index in target.items)) holes++ const callback = comparator === undefined ? undefined : requireCallback(comparator, into) - if (callback === undefined && items.length <= SORT_RUN) { - return sorted( - builtins, - target, - into, - holes, - items.sort((a, b) => compareText(coerceToString(a), coerceToString(b))), - ) - } const defined = new Arr( builtins.Array, items.filter((item) => item !== undefined), ) const undefs = items.length - defined.items.length if (callback === undefined) { - return new Invoke(ctx.prelude.fn("sortDefault"), undefined, [target, into, holes, defined, undefs], undefined) + // Each value's ToString, through its own toString or valueOf, once; equal keys keep their order. + return withPrimitives("string", defined.items, (primitives) => { + const keys = primitives.map(coerceToString) + if (keys.length > SORT_RUN) { + const args = [target, into, holes, defined, undefs, new Arr(builtins.Array, keys)] + return new Invoke(ctx.prelude.fn("sortDefault"), undefined, args, undefined) + } + const order = keys.map((_, at) => at).sort((left, right) => compareText(keys[left]!, keys[right]!)) + const result = [...order.map((at) => defined.items[at]), ...Array.from({ length: undefs }, () => undefined)] + return sorted(builtins, target, into, holes, result) + }) } const merges: Array = [] const plan = (low: number, high: number) => { @@ -185,6 +187,19 @@ export const arrayGlobal = (ctx: Interpreter) => { return target } const optNumber = (value: Value): number | undefined => (value === undefined ? undefined : coerceToInteger(value)) + // ToIntegerOrInfinity's ToPrimitive step for the arguments at `positions`, in order, before `body` reads them. + const integers = (args: Array, positions: ReadonlyArray, body: (args: Array) => NativeResult) => + withPrimitives( + "number", + positions.map((at) => args[at]), + (primitives) => { + const converted = [...args] + positions.forEach((at, index) => { + if (at < args.length) converted[at] = primitives[index] + }) + return body(converted) + }, + ) methods(builtins, proto, [ [ @@ -214,24 +229,48 @@ export const arrayGlobal = (ctx: Interpreter) => { "includes", 1, (thisValue, args) => { - return self(thisValue, "includes").items.includes(args[0], optNumber(args[1])) + const target = self(thisValue, "includes").items + // An empty array answers before fromIndex converts. + if (target.length === 0) return false + return integers(args, [1], (args) => target.includes(args[0], optNumber(args[1]))) + }, + ], + [ + "indexOf", + 1, + (thisValue, args) => { + const target = self(thisValue, "indexOf").items + if (target.length === 0) return -1 + return integers(args, [1], (args) => target.indexOf(args[0], optNumber(args[1]))) }, ], - ["indexOf", 1, (thisValue, args) => self(thisValue, "indexOf").items.indexOf(args[0], optNumber(args[1]))], [ "lastIndexOf", 1, (thisValue, args) => { const target = self(thisValue, "lastIndexOf").items + if (target.length === 0) return -1 // An explicit undefined is a fromIndex of 0, unlike omitting it. - return args.length < 2 ? target.lastIndexOf(args[0]) : target.lastIndexOf(args[0], optNumber(args[1])) + return integers(args, [1], (args) => + args.length < 2 ? target.lastIndexOf(args[0]) : target.lastIndexOf(args[0], optNumber(args[1])), + ) + }, + ], + [ + "at", + 1, + (thisValue, args) => { + const target = self(thisValue, "at").items + return integers(args, [0], (args) => target.at(optNumber(args[0]) ?? 0)) }, ], - ["at", 1, (thisValue, args) => self(thisValue, "at").items.at(optNumber(args[0]) ?? 0)], [ "slice", 2, - (thisValue, args) => wrap(self(thisValue, "slice").items.slice(optNumber(args[0]), optNumber(args[1]))), + (thisValue, args) => { + const target = self(thisValue, "slice").items + return integers(args, [0, 1], (args) => wrap(target.slice(optNumber(args[0]), optNumber(args[1])))) + }, ], [ "concat", @@ -250,9 +289,12 @@ export const arrayGlobal = (ctx: Interpreter) => { (thisValue, args) => { const flatten = (items: Array, depth: number): Array => items.flatMap((item) => (item instanceof Arr && depth > 0 ? flatten(item.items, depth - 1) : [item])) - const flattened = flatten(self(thisValue, "flat").items, optNumber(args[0]) ?? 1) - checkArrayLength(flattened.length) - return wrap(flattened) + const target = self(thisValue, "flat").items + return integers(args, [0], (args) => { + const flattened = flatten(target, optNumber(args[0]) ?? 1) + checkArrayLength(flattened.length) + return wrap(flattened) + }) }, ], [ @@ -274,12 +316,14 @@ export const arrayGlobal = (ctx: Interpreter) => { 2, (thisValue, args) => { const target = self(thisValue, "with").items - const index = optNumber(args[0]) ?? 0 - const resolved = index < 0 ? target.length + index : index - if (resolved < 0 || resolved >= target.length) throw rangeError("Array.with index is out of range.") - const copied = [...target] - copied[resolved] = args[1] - return wrap(copied) + return integers(args, [0], (args) => { + const index = optNumber(args[0]) ?? 0 + const resolved = index < 0 ? target.length + index : index + if (resolved < 0 || resolved >= target.length) throw rangeError("Array.with index is out of range.") + const copied = [...target] + copied[resolved] = args[1] + return wrap(copied) + }) }, ], [ @@ -308,46 +352,57 @@ export const arrayGlobal = (ctx: Interpreter) => { 2, (thisValue, args) => { const target = self(thisValue, "splice") - const length = target.items.length - const start = optNumber(args[0]) ?? 0 - const from = start < 0 ? Math.max(length + start, 0) : Math.min(start, length) - const deleteCount = - args.length === 1 ? length - from : Math.min(Math.max(optNumber(args[1]) ?? 0, 0), length - from) - const inserted = args.slice(2) - for (const item of inserted) rejectCircularInsertion(target, item, "Array.splice result") - mutable(target, inserted.length - deleteCount) - return wrap(target.items.splice(from, deleteCount, ...inserted)) + return integers(args, [0, 1], (args) => { + const length = target.items.length + const start = optNumber(args[0]) ?? 0 + const from = start < 0 ? Math.max(length + start, 0) : Math.min(start, length) + const deleteCount = + args.length === 1 ? length - from : Math.min(Math.max(optNumber(args[1]) ?? 0, 0), length - from) + const inserted = args.slice(2) + for (const item of inserted) rejectCircularInsertion(target, item, "Array.splice result") + mutable(target, inserted.length - deleteCount) + return wrap(target.items.splice(from, deleteCount, ...inserted)) + }) }, ], [ "toSpliced", 2, (thisValue, args) => { - const copied = [...self(thisValue, "toSpliced").items] - if (args.length === 0) return wrap(copied) - const start = optNumber(args[0]) ?? 0 - if (args.length === 1) copied.splice(start) - else copied.splice(start, optNumber(args[1]) ?? 0, ...args.slice(2)) - return wrap(copied) + const target = self(thisValue, "toSpliced").items + return integers(args, [0, 1], (args) => { + const copied = [...target] + if (args.length === 0) return wrap(copied) + const start = optNumber(args[0]) ?? 0 + if (args.length === 1) copied.splice(start) + else copied.splice(start, optNumber(args[1]) ?? 0, ...args.slice(2)) + return wrap(copied) + }) }, ], [ "fill", 1, (thisValue, args) => { - const target = mutable(self(thisValue, "fill")) - rejectCircularInsertion(target, args[0], "Array.fill result") - target.items.fill(args[0], optNumber(args[1]), optNumber(args[2])) - return target + const target = self(thisValue, "fill") + return integers(args, [1, 2], (args) => { + mutable(target) + rejectCircularInsertion(target, args[0], "Array.fill result") + target.items.fill(args[0], optNumber(args[1]), optNumber(args[2])) + return target + }) }, ], [ "copyWithin", 2, (thisValue, args) => { - const target = mutable(self(thisValue, "copyWithin")) - target.items.copyWithin(optNumber(args[0]) ?? 0, optNumber(args[1]) ?? 0, optNumber(args[2])) - return target + const target = self(thisValue, "copyWithin") + return integers(args, [0, 1, 2], (args) => { + mutable(target) + target.items.copyWithin(optNumber(args[0]) ?? 0, optNumber(args[1]) ?? 0, optNumber(args[2])) + return target + }) }, ], ...iteratorMethods(builtins, self), diff --git a/packages/codemode/src/stdlib/json.ts b/packages/codemode/src/stdlib/json.ts index e6c9c286eb07..091f4727fc2d 100644 --- a/packages/codemode/src/stdlib/json.ts +++ b/packages/codemode/src/stdlib/json.ts @@ -1,5 +1,5 @@ import { methods } from "../runtime/native.js" -import { requireCallback } from "../runtime/callback.js" +import { requireCallback, withPrimitives } from "../runtime/callback.js" import type { Interpreter } from "../runtime/interpreter.js" import { syntaxError } from "../runtime/model.js" import { typeofValue } from "../runtime/references.js" @@ -16,9 +16,11 @@ export const jsonGlobal = (ctx: Interpreter) => { return json } -const parse = (ctx: Interpreter, args: Array) => { - const text = coerceToString(args[0]) +// The text converts through its own toString first, as ToString does. +const parse = (ctx: Interpreter, args: Array) => + withPrimitives("string", [args[0]], ([text]) => parseText(ctx, coerceToString(text), args[1])) +const parseText = (ctx: Interpreter, text: string, reviverArg: Value) => { const parsed = (() => { try { return fromJson(ctx, JSON.parse(text)) @@ -26,8 +28,8 @@ const parse = (ctx: Interpreter, args: Array) => { throw syntaxError(`JSON.parse received invalid JSON: ${error instanceof Error ? error.message : String(error)}`) } })() - if (typeofValue(args[1]) !== "function") return parsed - const reviver = requireCallback(args[1], "JSON.parse") + if (typeofValue(reviverArg) !== "function") return parsed + const reviver = requireCallback(reviverArg, "JSON.parse") return new Invoke( ctx.prelude.fn("revive"), undefined, diff --git a/packages/codemode/src/stdlib/string.ts b/packages/codemode/src/stdlib/string.ts index e5da527e2de7..916d0e22d907 100644 --- a/packages/codemode/src/stdlib/string.ts +++ b/packages/codemode/src/stdlib/string.ts @@ -100,7 +100,8 @@ export const stringGlobal = (ctx: Interpreter) => { const codeUnits = (name: string, op: (...codes: Array) => string): Method => [ name, 1, - (_, args) => op(...args.map(coerceToNumber)), + // Each argument's ToNumber, through its own valueOf or toString, in order. + (_, args) => withPrimitives("number", args, (numbers) => op(...numbers.map(coerceToNumber)), true), ] methods(builtins, string, [ codeUnits("fromCharCode", String.fromCharCode), @@ -321,7 +322,8 @@ export const stringGlobal = (ctx: Interpreter) => { "repeat", 1, (value, args) => { - const count = num("repeat", args, 0) + // ToIntegerOrInfinity: NaN counts as 0. + const count = coerceToInteger(requireDataArgument("repeat", 0, args[0])) if (!Number.isFinite(count) || count < 0) { throw rangeError("String.repeat expects a finite non-negative count.") } @@ -377,9 +379,12 @@ export const stringGlobal = (ctx: Interpreter) => { define( builtins.String, IteratorSymbol, - fn(builtins, "[Symbol.iterator]", 0, (thisValue) => - positionIterator(builtins, self(thisValue, "[Symbol.iterator]"), "values"), - ), + fn(builtins, "[Symbol.iterator]", 0, (thisValue) => { + if (thisValue === null || thisValue === undefined) self(thisValue, "[Symbol.iterator]") + return withPrimitives("string", [thisValue], ([value]) => + positionIterator(builtins, self(value, "[Symbol.iterator]"), "values"), + ) + }), hidden, ) return string diff --git a/packages/codemode/src/vm.ts b/packages/codemode/src/vm.ts index fff5d0f7c933..8c0d26bb0b31 100644 --- a/packages/codemode/src/vm.ts +++ b/packages/codemode/src/vm.ts @@ -755,9 +755,11 @@ export class Vm { // Op.PUT_PROP const v = regs[--sp] as Value const o = regs[sp - 1] as Value + const key = consts[w >>> 16] as string frame.pc = pc frame.sp = sp - this.execPutProp(fcode, o, consts[w >>> 16] as string, v, pc) + if (key === "length" && this.execSetLength(frame, o, v, pc, sp)) continue outer + this.execPutProp(fcode, o, key, v, pc) regs[sp - 1] = v pc++ continue @@ -793,6 +795,7 @@ export class Vm { } frame.pc = pc frame.sp = sp + if (keyVal === "length" && this.execSetLength(frame, o, v, pc, sp)) continue outer this.execPutElem(fcode, o, keyVal, v, pc) regs[sp - 1] = v pc++ @@ -2102,6 +2105,14 @@ export class Vm { } } + // ArraySetLength converts an object through its own valueOf/toString: `[o, v] -> [v]` once the prelude has set it. + private execSetLength(frame: Frame, o: Value, v: Value, pc: number, sp: number): boolean { + if (!(o instanceof Arr) || !(v instanceof Obj)) return false + frame.sp = sp - 1 + this.pushInternalCall("$vmSetLength", [o, v], frame.code.siteAt(pc) ?? frame.origin) + return true + } + private execPutElem(fcode: Code, o: Value, keyVal: Value, v: Value, pc: number): void { this.execPutProp(fcode, o, propertyKey(keyVal), v, pc) } @@ -2720,6 +2731,7 @@ export class Vm { case Op.PUT_PROP: { const v = regs[--sp] as Value frame.sp = sp + if (consts[bx] === "length" && this.execSetLength(frame, regs[sp - 1] as Value, v, pc, sp)) return -1 this.execPutProp(fcode, regs[sp - 1] as Value, consts[bx] as string, v, pc) regs[sp - 1] = v return pc + 1 @@ -2728,6 +2740,7 @@ export class Vm { const v = regs[--sp] as Value const keyVal = regs[--sp] as Value frame.sp = sp + if (keyVal === "length" && this.execSetLength(frame, regs[sp - 1] as Value, v, pc, sp)) return -1 this.execPutElem(fcode, regs[sp - 1] as Value, keyVal, v, pc) regs[sp - 1] = v return pc + 1 diff --git a/packages/codemode/test/parity.test.ts b/packages/codemode/test/parity.test.ts index b15e9abeadfc..c568a7776b01 100644 --- a/packages/codemode/test/parity.test.ts +++ b/packages/codemode/test/parity.test.ts @@ -1877,6 +1877,45 @@ describe("computed property keys convert through the object's own toString", () }) }) +describe("Array method arguments, lengths, and elements convert through ToPrimitive", () => { + test("integer arguments use the object's own valueOf, in order, before the method reads the array", async () => { + expect( + await value(` + const n = (value) => ({ valueOf() { return value } }) + const log = [] + const at = (value) => ({ valueOf() { log.push(value); return value } }) + const items = [0, 1, 2, 3, 4] + const live = [1, 2, 3] + const removed = { valueOf() { live.length = 1; return 0 } } + return [items.at(n(1)), items.indexOf(3, n(2)), items.lastIndexOf(1, n(0)), items.includes(0, n(1)), + items.slice(n(1), n(3)), [0, 0, 0].fill(7, n(1), n(2)), [...items].splice(at(1), at(2)), log, + items.with(n(0), "x")[0], items.flat(n(0)).length, live.indexOf(2, removed)] + `), + ).toEqual([1, 3, -1, false, [1, 2], [0, 7, 0], [1, 2], [1, 2], "x", 5, -1]) + }) + + test("conversion failures surface, and an empty array answers before fromIndex converts", async () => { + expect((await error(`[1].at({ valueOf() { throw new RangeError("at") } })`)).message).toContain("at") + expect((await error(`[1].fill(0, { valueOf() { return {} }, toString() { return {} } })`)).message).toContain( + "Cannot convert object to primitive value", + ) + expect(await value(`return [].indexOf(1, { valueOf() { throw new Error("never") } })`)).toBe(-1) + }) + + test("length = object converts through valueOf, and a default sort converts each element through toString", async () => { + expect( + await value(` + const resized = [1, 2, 3] + resized.length = { valueOf() { return 1 } } + let calls = 0 + const named = (name) => ({ name, toString() { calls++; return name } }) + const sorted = [named("c"), named("a"), 2, undefined, named("b")].sort() + return [resized, sorted.map((item) => item?.name ?? item), calls] + `), + ).toEqual([[1], [2, "a", "b", "c", null], 3]) + }) +}) + describe("String and Number method arguments convert through ToPrimitive", () => { test("string positions use the string hint and numeric positions the number hint", async () => { expect( @@ -1956,6 +1995,17 @@ describe("String and Number method arguments convert through ToPrimitive", () => ]) }) + test("fromCharCode, fromCodePoint, JSON.parse, and the string iterator convert objects; repeat counts NaN as 0", async () => { + expect( + await value(` + const n = (value) => ({ valueOf() { return value } }) + const text = (value) => ({ toString() { return value } }) + return [String.fromCharCode(n(65), "66"), String.fromCodePoint(n(31)), JSON.parse(text("[1]")), + [...String.prototype[Symbol.iterator].call(text("xy"))], "ab".repeat(NaN), "ab".repeat(0.9)] + `), + ).toEqual(["AB", "\x1f", [1], ["x", "y"], "", ""]) + }) + test("conversion failures surface and opaque arguments still reject", async () => { expect((await error(`"abc".indexOf({ toString() { throw new RangeError("intostr") } })`)).message).toContain( "intostr", diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index 205479659da3..9f5c7f086b08 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -9,11 +9,9 @@ built-ins/Array/isArray/15.4.3.2-2-1.js # TypeError: Con cannot be constructed: built-ins/Array/isArray/15.4.3.2-2-2.js # TypeError: Con cannot be constructed: user-defined constructors and classes are not supported. Call built-ins/Array/length/15.4.5.1-3.d-3.js # RangeError: Invalid array length built-ins/Array/length/S15.4.2.2_A2.1_T1.js # RangeError: Invalid array length. -built-ins/Array/length/S15.4.5.1_A1.3_T2.js # RangeError: Invalid array length built-ins/Array/of/construct-this-with-the-number-of-arguments.js # The value of len is expected to be 0 Expected SameValue(«undefined», «0») to be true built-ins/Array/of/return-a-custom-instance.js # TypeError: The right-hand side of '…' has no '…' object. built-ins/Array/of/return-abrupt-from-contructor.js # Array.of.call(T) throws a Test262Error exception Expected a Test262Error to be thrown but no excepti -built-ins/Array/prototype/at/index-argument-tointeger.js # Array.at expects index to be a number. built-ins/Array/prototype/concat/S15.4.4.4_A2_T1.js # Array.prototype.concat called on incompatible receiver a data object. built-ins/Array/prototype/concat/S15.4.4.4_A2_T2.js # Array.prototype.concat called on incompatible receiver a data object. built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js # arr.hasOwnProperty("1") must return true Expected SameValue(«false», «true») to be true @@ -107,8 +105,6 @@ built-ins/Array/prototype/every/15.4.4.16-8-8.js # … cannot be constructed: u built-ins/Array/prototype/every/call-with-boolean.js # TypeError: Array.prototype.every called on incompatible receiver a boolean. built-ins/Array/prototype/fill/call-with-boolean.js # TypeError: Array.prototype.fill called on incompatible receiver a boolean. built-ins/Array/prototype/fill/length-near-integer-limit.js # TypeError: Array.prototype.fill called on incompatible receiver a data object. -built-ins/Array/prototype/fill/return-abrupt-from-end.js # Expected a Test262Error but got a TypeError -built-ins/Array/prototype/fill/return-abrupt-from-start.js # Expected a Test262Error but got a TypeError built-ins/Array/prototype/fill/return-this.js # TypeError: Array.prototype.fill called on incompatible receiver a data object. built-ins/Array/prototype/filter/15.4.4.20-1-10.js # TypeError: Array.prototype.filter called on incompatible receiver a data object. built-ins/Array/prototype/filter/15.4.4.20-1-11.js # TypeError: Array.prototype.filter called on incompatible receiver a Date. @@ -272,9 +268,7 @@ built-ins/Array/prototype/forEach/15.4.4.18-8-9.js # … cannot be constructed: built-ins/Array/prototype/forEach/call-with-boolean.js # TypeError: Array.prototype.forEach called on incompatible receiver a boolean. built-ins/Array/prototype/includes/call-with-boolean.js # TypeError: Array.prototype.includes called on incompatible receiver a boolean. built-ins/Array/prototype/includes/length-boundaries.js # TypeError: Array.prototype.includes called on incompatible receiver a data object. -built-ins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js # Expected a Test262Error but got a TypeError built-ins/Array/prototype/includes/return-abrupt-tonumber-length.js # valueOf Expected a Test262Error but got a TypeError -built-ins/Array/prototype/includes/tointeger-fromindex.js # Array.includes expects start index to be a number. built-ins/Array/prototype/includes/tolength-length.js # TypeError: Array.prototype.includes called on incompatible receiver a data object. built-ins/Array/prototype/indexOf/15.4.4.14-1-10.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js # TypeError: Array.prototype.indexOf called on incompatible receiver a Date. @@ -329,14 +323,10 @@ built-ins/Array/prototype/indexOf/15.4.4.14-4-6.js # TypeError: Array.prototype built-ins/Array/prototype/indexOf/15.4.4.14-4-7.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. built-ins/Array/prototype/indexOf/15.4.4.14-4-8.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. built-ins/Array/prototype/indexOf/15.4.4.14-4-9.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. -built-ins/Array/prototype/indexOf/15.4.4.14-5-23.js # Array.indexOf expects start index to be a number. -built-ins/Array/prototype/indexOf/15.4.4.14-5-24.js # toStringAccessed built-ins/Array/prototype/indexOf/15.4.4.14-5-25.js # … cannot be constructed: user-defined constructors and classes are not supported. Call it as a funct built-ins/Array/prototype/indexOf/15.4.4.14-9-7.js # Array assignment result contains a circular value. built-ins/Array/prototype/indexOf/15.4.4.14-9-a-2.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. -built-ins/Array/prototype/indexOf/15.4.4.14-9-a-3.js # Array.indexOf expects start index to be a number. built-ins/Array/prototype/indexOf/15.4.4.14-9-a-5.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. -built-ins/Array/prototype/indexOf/15.4.4.14-9-a-6.js # Array.indexOf expects start index to be a number. built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js # TypeError: Array.prototype.indexOf called on incompatible receiver a data object. built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js # TypeError: Array.prototype.indexOf called on incompatible receiver an Arguments. built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js # TypeError: Array.prototype.indexOf called on incompatible receiver an Arguments. @@ -403,13 +393,9 @@ built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js # TypeError: foo cannot built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver a data object. built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver a data object. built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js # Array.lastIndexOf expects start index to be a number. -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js # Array.lastIndexOf expects start index to be a number. -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js # Array.lastIndexOf expects start index to be a number. -built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js # toStringAccessed built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js # … cannot be constructed: user-defined constructors and classes are not supported. Call it as a funct built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js # Array assignment result contains a circular value. built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver a data object. -built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js # Array.lastIndexOf expects start index to be a number. built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver a data object. built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver a data object. built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js # TypeError: Array.prototype.lastIndexOf called on incompatible receiver an Arguments. @@ -719,7 +705,6 @@ built-ins/Array/prototype/shift/S15.4.4.9_A3_T3.js # Array.prototype.shift call built-ins/Array/prototype/shift/S15.4.4.9_A4_T1.js # #2: Array.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[0] === 1. Actual: undefined built-ins/Array/prototype/shift/S15.4.4.9_A4_T2.js # Array.prototype.shift called on incompatible receiver a data object. built-ins/Array/prototype/shift/call-with-boolean.js # TypeError: Array.prototype.shift called on incompatible receiver a boolean. -built-ins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js # Array.slice expects end to be a number. built-ins/Array/prototype/slice/S15.4.4.10_A2_T1.js # Array.prototype.slice called on incompatible receiver a data object. built-ins/Array/prototype/slice/S15.4.4.10_A2_T2.js # Array.prototype.slice called on incompatible receiver a data object. built-ins/Array/prototype/slice/S15.4.4.10_A2_T3.js # Array.prototype.slice called on incompatible receiver a data object. @@ -810,14 +795,11 @@ built-ins/Array/prototype/some/15.4.4.17-8-6.js # … cannot be constructed: us built-ins/Array/prototype/some/15.4.4.17-8-7.js # … cannot be constructed: user-defined constructors and classes are not supported. Call it as a funct built-ins/Array/prototype/some/15.4.4.17-8-8.js # … cannot be constructed: user-defined constructors and classes are not supported. Call it as a funct built-ins/Array/prototype/some/call-with-boolean.js # TypeError: Array.prototype.some called on incompatible receiver a boolean. -built-ins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js # #1: Check ToString operator built-ins/Array/prototype/sort/S15.4.4.11_A3_T1.js # Array.prototype.sort called on incompatible receiver a data object. built-ins/Array/prototype/sort/S15.4.4.11_A3_T2.js # Array.prototype.sort called on incompatible receiver a data object. built-ins/Array/prototype/sort/S15.4.4.11_A4_T3.js # Array.prototype.sort called on incompatible receiver a data object. built-ins/Array/prototype/sort/S15.4.4.11_A6_T2.js # Array.prototype.sort called on incompatible receiver a data object. -built-ins/Array/prototype/sort/bug_596_1.js # #1: [object, object].sort(); counter < 2. Actual: 0 built-ins/Array/prototype/sort/precise-prototype-element.js # Expected SameValue(«undefined», «4») to be true -built-ins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js # Array.splice expects delete count to be a number. built-ins/Array/prototype/splice/S15.4.4.12_A2_T1.js # Array.prototype.splice called on incompatible receiver a data object. built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js # Array.prototype.splice called on incompatible receiver a data object. built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js # Array.prototype.splice called on incompatible receiver a data object. @@ -938,7 +920,6 @@ built-ins/Iterator/prototype/take/limit-tonumber-throws.js # Expected a Test262 built-ins/Iterator/prototype/take/limit-tonumber.js # Iterator.prototype.take expects a non-negative count, received NaN. built-ins/Iterator/prototype/take/this-non-callable-next.js # TypeError: Iterator next must be a function. built-ins/JSON/parse/reviver-call-args-after-forward-modification.js # TypeError: Object destructuring requires a data object or array value, received undefined. -built-ins/JSON/parse/text-object.js # SyntaxError: JSON.parse received invalid JSON: JSON Parse error: Unexpected identifier "object" built-ins/JSON/rawJSON/basic.js # TypeError: JSON.rawJSON is not a function. built-ins/JSON/rawJSON/illegal-empty-and-start-end-chars.js # Expected a SyntaxError but got a TypeError built-ins/JSON/stringify/value-array-circular.js # TypeError: Array.push result contains a circular value. @@ -1307,17 +1288,12 @@ built-ins/Set/set-iterable-throws-when-add-is-not-callable.js # Expected a Type built-ins/Set/set-iterator-close-after-add-failure.js # TimeoutExceeded: Execution timed out after 5000ms. built-ins/Set/set-iterator-next-failure.js # Expected a MyError but got a TypeError built-ins/String/S15.5.1.1_A1_T9.js # #2: toString=function(){return "__THIS__";}; __str = String(this); __str === "__THIS__". Actual: __s -built-ins/String/fromCharCode/S9.7_A3.1_T4.js # #1: var object = {valueOf: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. -built-ins/String/fromCharCode/touint16-tonumber-throws-valueof.js # ToNumber throws when its argument's ToPrimitive step calls a throwing valueOf, and String.fromCharCo -built-ins/String/fromCodePoint/to-number-conversions.js # RangeError: Arguments contain a value that is out of range of code points built-ins/String/prototype/S15.5.4_A1.js # #1: delete String.prototype.toString; String.prototype.toString() === "[object "+"String"+"]". Actua built-ins/String/prototype/S15.5.4_A2.js # #1: String.prototype =="". Actual: String.prototype ==[object Object] built-ins/String/prototype/S15.5.4_A3.js # #2: delete String.prototype.toString; String.prototype.toString() == "[object "+"String"+"]". Actual -built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js # Expected a Test262Error to be thrown but no exception was thrown at all built-ins/String/prototype/charAt/S15.5.4.4_A2.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/String/prototype/constructor/S15.5.4.1_A1_T2.js # TypeError: new __constr(...) is not supported; call __constr(...) without new instead. -built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js # RangeError: String.repeat expects a finite non-negative count. built-ins/String/prototype/slice/S15.5.4.13_A3_T4.js # TypeError: Cannot read properties of undefined (reading '…'). built-ins/String/prototype/split/instance-is-math.js # The value of __split[0] is "[object Math]" Expected SameValue(«"[object Object]"», «"[object Math]"» built-ins/String/prototype/split/separator-tostring-error.js # TypeError: Cannot read properties of undefined (reading '…'). From 58c673fb81bc716141ed870ab5e5f570bfe5cff5 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:29:16 +0000 Subject: [PATCH 022/100] fix(codemode): parse Unicode 17 identifiers with acorn 8.16 --- bun.lock | 4 ++-- packages/codemode-rust/test262/reference-gaps.txt | 4 ---- packages/codemode/package.json | 2 +- packages/codemode/test/test262/skipped.txt | 4 ---- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bun.lock b/bun.lock index c34eb189eaca..c6a2d4c725b1 100644 --- a/bun.lock +++ b/bun.lock @@ -199,7 +199,7 @@ "name": "@opencode/codemode", "version": "2.3.0", "dependencies": { - "acorn": "8.15.0", + "acorn": "8.16.0", "effect": "catalog:", }, "devDependencies": { @@ -2591,7 +2591,7 @@ "accepts": ["accepts@2.0.0", "", { "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="], - "acorn": ["acorn@8.15.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="], + "acorn": ["acorn@8.16.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="], "acorn-jsx": ["acorn-jsx@5.3.2", "", { "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ=="], diff --git a/packages/codemode-rust/test262/reference-gaps.txt b/packages/codemode-rust/test262/reference-gaps.txt index ee6425233b4c..bdaa3cdb2e69 100644 --- a/packages/codemode-rust/test262/reference-gaps.txt +++ b/packages/codemode-rust/test262/reference-gaps.txt @@ -10,7 +10,3 @@ built-ins/Promise/allSettled/reject-element-function-nonconstructor.js # accide built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/any/reject-element-function-nonconstructor.js # accident: hasOwnProperty accepts an undefined receiver; the reference throws, as JS does built-ins/Promise/race/S25.4.4.3_A5.1_T1.js # accident: Promise.race([]) never settles; the reference rejects it on purpose with a hint -language/identifiers/part-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) -language/identifiers/part-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) -language/identifiers/start-unicode-17.0.0-escaped.js # real: Unicode 17 identifiers (parser Unicode tables) -language/identifiers/start-unicode-17.0.0.js # real: Unicode 17 identifiers (parser Unicode tables) diff --git a/packages/codemode/package.json b/packages/codemode/package.json index 7f256b2a3aeb..a4977f054ccc 100644 --- a/packages/codemode/package.json +++ b/packages/codemode/package.json @@ -28,7 +28,7 @@ "test:roundtrip": "CODEMODE_ROUNDTRIP=1 bun test" }, "dependencies": { - "acorn": "8.15.0", + "acorn": "8.16.0", "effect": "catalog:" }, "devDependencies": { diff --git a/packages/codemode/test/test262/skipped.txt b/packages/codemode/test/test262/skipped.txt index 9f5c7f086b08..c79cb1f2df19 100644 --- a/packages/codemode/test/test262/skipped.txt +++ b/packages/codemode/test/test262/skipped.txt @@ -1475,10 +1475,6 @@ language/global-code/decl-lex-restricted-global.js # expected SyntaxError but c language/global-code/return.js # expected SyntaxError but the program ran language/identifier-resolution/S11.1.2_A1_T1.js # TypeError: Cannot read properties of undefined (reading '…'). language/identifier-resolution/S11.1.2_A1_T2.js # #1.2: this.z; z === undefined throw ReferenceError. Actual: TypeError: Cannot read properties of und -language/identifiers/part-unicode-17.0.0-escaped.js # Invalid Unicode escape (17:5) -language/identifiers/part-unicode-17.0.0.js # Unexpected character '…' (15:5) -language/identifiers/start-unicode-17.0.0-escaped.js # Invalid Unicode escape (17:4) -language/identifiers/start-unicode-17.0.0.js # Unexpected character '…' (15:4) language/punctuators/S7.7_A1.js # TypeError: Cannot read properties of undefined (reading '…'). language/statements/async-generator/dstr/ary-init-iter-get-err-array-prototype.js # Expected a TypeError to be thrown but no exception was thrown at all language/statements/async-generator/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js # Expected SameValue(«3», «42») to be true From dc76fbcd19b20840ea557c02fc678298b10bf0c3 Mon Sep 17 00:00:00 2001 From: kommander <335157+kommander@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:51:19 +0000 Subject: [PATCH 023/100] feat(codemode): add OpenAPI tools to the Rust port openapi::from_spec ports OpenAPI.fromSpec: one tool per representable operation with dotted operationIds as namespaces, the reference's skip reasons, readOnly/writeOnly projection solved over reference cycles, OpenAPI 3.0 and 3.1 schema normalization, host-side auth resolution, and request building over an HttpClient trait the host implements. conformance/catalog.ts now also runs the documents of the reference's openapi.test.ts and its fixtures, recording signatures, schemas, skipped operations, and each call's requests, credentials and result; the Rust test replays them with a fake client. --- packages/codemode-rust/AGENTS.md | 4 +- .../codemode-rust/conformance/catalog.json | 7707 +++++++++++++++++ packages/codemode-rust/conformance/catalog.ts | 105 +- .../conformance/openapi-specs.ts | 1050 +++ .../crates/psychoscript/src/lib.rs | 1 + .../crates/psychoscript/src/openapi/invoke.rs | 597 ++ .../crates/psychoscript/src/openapi/mod.rs | 281 + .../psychoscript/src/openapi/normalize.rs | 264 + .../psychoscript/src/openapi/project.rs | 309 + .../crates/psychoscript/src/openapi/spec.rs | 827 ++ .../crates/psychoscript/tests/openapi.rs | 277 + 11 files changed, 11418 insertions(+), 4 deletions(-) create mode 100644 packages/codemode-rust/conformance/openapi-specs.ts create mode 100644 packages/codemode-rust/crates/psychoscript/src/openapi/invoke.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/openapi/mod.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/openapi/normalize.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/openapi/project.rs create mode 100644 packages/codemode-rust/crates/psychoscript/src/openapi/spec.rs create mode 100644 packages/codemode-rust/crates/psychoscript/tests/openapi.rs diff --git a/packages/codemode-rust/AGENTS.md b/packages/codemode-rust/AGENTS.md index aa7d9fdae100..a7fa08f322b0 100644 --- a/packages/codemode-rust/AGENTS.md +++ b/packages/codemode-rust/AGENTS.md @@ -16,11 +16,11 @@ In scope: - The language subset needed by the nine reference benchmark programs (`conformance/cases/bench-*`), the plugin reducer example, and the other conformance cases. - Pipeline: parse → compile to bytecode → stack VM. Values cross the host boundary as JSON copies (`serde_json::Value`), never shared. -- Host API in `crates/psychoscript/src/lib.rs`, the Rust form of the reference's README API: schema-described tools (sync or futures) at dotted paths with namespaces, the catalog and `search`, hooks, extensions with `import`/`require`, programs (`Runtime::program`), JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. +- Host API in `crates/psychoscript/src/lib.rs`, the Rust form of the reference's README API: schema-described tools (sync or futures) at dotted paths with namespaces, OpenAPI tools (`openapi::from_spec` over a host `HttpClient`), the catalog and `search`, hooks, extensions with `import`/`require`, programs (`Runtime::program`), JSON bindings, limits (`timeout_ms`, `max_tool_calls`, `max_output_bytes`), `console.log` captured into `logs`. - Parity runs both ways: add no language feature or host API the reference lacks. Rust-native forms of reference APIs (futures for Effects, a blocking `execute`) are fine. - `conformance/catalog.json` is generated by `bun conformance/catalog.ts` from the reference; never edit it by hand. -Out of scope: classes (rejected, like the reference), `export`, snapshots and suspend/resume, OpenAPI tools, Effect integration, RegExp, URL, Date, BigInt, Symbol beyond iterators. +Out of scope: classes (rejected, like the reference), `export`, snapshots and suspend/resume, Effect integration, RegExp, URL, Date, BigInt, Symbol beyond iterators. ## Rules diff --git a/packages/codemode-rust/conformance/catalog.json b/packages/codemode-rust/conformance/catalog.json index 91e73b072922..0c8fb94f8ecd 100644 --- a/packages/codemode-rust/conformance/catalog.json +++ b/packages/codemode-rust/conformance/catalog.json @@ -2093,5 +2093,7712 @@ ], "toolCalls": 0 } + ], + "openapi": [ + { + "name": "happy path", + "spec": { + "openapi": "3.1.0", + "info": { + "title": "CodeMode Happy Path", + "version": "1.0.0" + }, + "servers": [ + { + "url": "https://api.example.test/v1" + } + ], + "security": [ + { + "BearerAuth": [] + } + ], + "paths": { + "/users/{userId}": { + "parameters": [ + { + "$ref": "#/components/parameters/UserId" + } + ], + "get": { + "operationId": "users.get", + "summary": "Get a user", + "parameters": [ + { + "name": "include", + "in": "query", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "verbose", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "X-Trace-ID", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/UserResponse" + } + } + }, + "delete": { + "operationId": "users.remove", + "summary": "Remove a user", + "responses": { + "204": { + "description": "Removed" + } + } + } + }, + "/users": { + "post": { + "operationId": "users.create", + "summary": "Create a user", + "security": [ + { + "ApiKey": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "name", + "email" + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/vnd.example+json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + }, + "/search": { + "get": { + "operationId": "search.run", + "summary": "Search users", + "security": [], + "parameters": [ + { + "name": "filter", + "in": "query", + "style": "deepObject", + "explode": true, + "schema": { + "type": "object", + "properties": { + "query": { + "type": "string" + }, + "page": { + "type": "integer" + } + }, + "required": [ + "query" + ], + "additionalProperties": false + } + }, + { + "name": "tags", + "in": "query", + "style": "form", + "explode": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Summary", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "parameters": { + "UserId": { + "name": "userId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + }, + "responses": { + "UserResponse": { + "description": "A user", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + }, + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + }, + "securitySchemes": { + "BearerAuth": { + "type": "http", + "scheme": "bearer" + }, + "ApiKey": { + "type": "apiKey", + "in": "query", + "name": "api_key" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "BearerAuth": { + "type": "bearer", + "token": "bearer-secret" + }, + "ApiKey": { + "type": "apiKey", + "value": "api-secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.search.run", + "description": "Search users", + "signature": "tools.api.search.run({\n filter?: {\n query: string,\n /** @integer */\n page?: number,\n },\n tags?: Array,\n}): Promise" + }, + { + "path": "api.users.create", + "description": "Create a user", + "signature": "tools.api.users.create({\n name: string,\n /** @format email */\n email: string,\n role?: \"admin\" | \"member\",\n}): Promise<{\n id: string,\n name: string,\n /** @format email */\n email: string,\n role?: \"admin\" | \"member\",\n}>" + }, + { + "path": "api.users.get", + "description": "Get a user", + "signature": "tools.api.users.get({\n userId: string,\n include?: Array,\n verbose?: boolean,\n \"X-Trace-ID\"?: string,\n}): Promise<{\n id: string,\n name: string,\n /** @format email */\n email: string,\n role?: \"admin\" | \"member\",\n}>" + }, + { + "path": "api.users.remove", + "description": "Remove a user", + "signature": "tools.api.users.remove({\n userId: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "search.run", + "input": { + "type": "object", + "properties": { + "filter": { + "type": "object", + "properties": { + "query": { + "type": "string" + }, + "page": { + "type": "integer" + } + }, + "required": [ + "query" + ], + "additionalProperties": false + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + }, + "output": { + "type": "string", + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + } + }, + { + "path": "users.create", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "name", + "email" + ], + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + }, + "output": { + "$ref": "#/$defs/User", + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + } + }, + { + "path": "users.get", + "input": { + "type": "object", + "properties": { + "userId": { + "type": "string" + }, + "include": { + "type": "array", + "items": { + "type": "string" + } + }, + "verbose": { + "type": "boolean" + }, + "X-Trace-ID": { + "type": "string" + } + }, + "required": [ + "userId" + ], + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + }, + "output": { + "$ref": "#/$defs/User", + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + } + }, + { + "path": "users.remove", + "input": { + "type": "object", + "properties": { + "userId": { + "type": "string" + } + }, + "required": [ + "userId" + ], + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + }, + "output": { + "type": "null", + "$defs": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string", + "format": "email" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "member" + ] + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false + } + } + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "users.get", + "input": { + "userId": "user-1", + "include": [ + "profile", + "permissions" + ], + "verbose": true, + "X-Trace-ID": "trace-1" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"id\":\"user-1\",\"name\":\"Ada\",\"email\":\"ada@example.test\",\"role\":\"member\"}" + }, + "outcome": { + "ok": true, + "value": { + "id": "user-1", + "name": "Ada", + "email": "ada@example.test", + "role": "member" + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/users/user-1?include=profile%2Cpermissions&verbose=true", + "headers": { + "authorization": "Bearer bearer-secret", + "x-trace-id": "trace-1" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "BearerAuth", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "users.get", + "method": "GET", + "path": "/users/{userId}", + "summary": "Get a user" + } + } + ] + }, + { + "tool": "users.create", + "input": { + "name": "Grace", + "email": "grace@example.test", + "role": "admin" + }, + "reply": { + "status": 201, + "contentType": "application/vnd.example+json", + "body": "{\"id\":\"user-2\",\"name\":\"Grace\",\"email\":\"grace@example.test\",\"role\":\"admin\"}" + }, + "outcome": { + "ok": true, + "value": { + "id": "user-2", + "name": "Grace", + "email": "grace@example.test", + "role": "admin" + } + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/users?api_key=api-secret", + "headers": { + "content-type": "application/json" + }, + "body": "{\"name\":\"Grace\",\"email\":\"grace@example.test\",\"role\":\"admin\"}" + } + ], + "resolutions": [ + { + "name": "ApiKey", + "definition": { + "type": "apiKey", + "name": "api_key", + "in": "query" + }, + "scopes": [], + "operation": { + "operationId": "users.create", + "method": "POST", + "path": "/users", + "summary": "Create a user" + } + } + ] + }, + { + "tool": "search.run", + "input": { + "filter": { + "query": "effect", + "page": 2 + }, + "tags": [ + "typescript", + "runtime" + ] + }, + "reply": { + "contentType": "text/plain", + "body": "2 matches" + }, + "outcome": { + "ok": true, + "value": "2 matches" + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/search?filter%5Bquery%5D=effect&filter%5Bpage%5D=2&tags=typescript&tags=runtime", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "users.remove", + "input": { + "userId": "user-1" + }, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "DELETE", + "url": "http://localhost:4096/users/user-1", + "headers": { + "authorization": "Bearer bearer-secret" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "BearerAuth", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "users.remove", + "method": "DELETE", + "path": "/users/{userId}", + "summary": "Remove a user" + } + } + ] + }, + { + "tool": "users.get", + "input": { + "userId": "" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Invalid path parameter 'userId'." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "users.get", + "input": { + "userId": ".." + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Invalid path parameter 'userId'." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "users.get", + "input": { + "userId": "a/b c" + }, + "reply": { + "status": 404, + "contentType": "application/json", + "body": "{\"error\":\"missing\"}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /users/{userId} failed with HTTP 404: {\"error\":\"missing\"}" + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/users/a%2Fb%20c", + "headers": { + "authorization": "Bearer bearer-secret" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "BearerAuth", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "users.get", + "method": "GET", + "path": "/users/{userId}", + "summary": "Get a user" + } + } + ] + }, + { + "tool": "users.get", + "input": { + "userId": "x" + }, + "reply": { + "status": 500, + "body": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /users/{userId} failed with HTTP 500: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/users/x", + "headers": { + "authorization": "Bearer bearer-secret" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "BearerAuth", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "users.get", + "method": "GET", + "path": "/users/{userId}", + "summary": "Get a user" + } + } + ] + } + ] + }, + { + "name": "transports", + "spec": { + "openapi": "3.1.0", + "info": { + "title": "CodeMode Transport Coverage", + "version": "1.0.0" + }, + "paths": { + "/records/{recordID}": { + "get": { + "operationId": "records.get", + "parameters": [ + { + "name": "recordID", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Record", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Record" + } + } + } + } + } + } + }, + "/events": { + "get": { + "operationId": "events.subscribe", + "responses": { + "200": { + "description": "Events", + "content": { + "text/event-stream": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/files/{path}": { + "get": { + "operationId": "files.read", + "parameters": [ + { + "name": "path", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "File", + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + }, + "put": { + "operationId": "files.write", + "parameters": [ + { + "name": "path", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "responses": { + "204": { + "description": "Written" + } + } + } + }, + "/terminals/{terminalID}/connect": { + "get": { + "operationId": "terminals.connect", + "x-websocket": true, + "parameters": [ + { + "name": "terminalID", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "101": { + "description": "Connected" + } + } + } + } + }, + "components": { + "schemas": { + "Record": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "id", + "value" + ], + "additionalProperties": false + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.records.get", + "description": "GET /records/{recordID}", + "signature": "tools.api.records.get({\n recordID: string,\n}): Promise<{\n id: string,\n value: string,\n}>" + } + ], + "schemas": [ + { + "path": "records.get", + "input": { + "type": "object", + "properties": { + "recordID": { + "type": "string" + } + }, + "required": [ + "recordID" + ], + "$defs": { + "Record": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "id", + "value" + ], + "additionalProperties": false + } + } + }, + "output": { + "$ref": "#/$defs/Record", + "$defs": { + "Record": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "id", + "value" + ], + "additionalProperties": false + } + } + } + } + ], + "skipped": [ + { + "method": "GET", + "path": "/events", + "reason": "SSE operations are not supported" + }, + { + "method": "GET", + "path": "/files/{path}", + "reason": "binary responses are not supported" + }, + { + "method": "PUT", + "path": "/files/{path}", + "reason": "request body has no JSON content (declared: application/octet-stream)" + }, + { + "method": "GET", + "path": "/terminals/{terminalID}/connect", + "reason": "WebSocket operations are not supported" + } + ], + "calls": [ + { + "tool": "records.get", + "input": {}, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Missing required path parameter 'recordID'." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "records.get", + "input": { + "recordID": "r1" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"id\":\"r1\",\"value\":\"v\"}" + }, + "outcome": { + "ok": true, + "value": { + "id": "r1", + "value": "v" + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/records/r1", + "headers": {}, + "body": null + } + ], + "resolutions": [] + } + ] + }, + { + "name": "path sanitization and collisions", + "spec": { + "openapi": "3.1.0", + "paths": { + "/first": { + "get": { + "responses": { + "200": { + "description": "Success" + } + }, + "operationId": "group.item" + } + }, + "/second": { + "get": { + "responses": { + "200": { + "description": "Success" + } + }, + "operationId": "group.item" + } + }, + "/third": { + "get": { + "responses": { + "200": { + "description": "Success" + } + }, + "operationId": "group..other" + } + }, + "/fourth": { + "get": { + "responses": { + "200": { + "description": "Success" + } + }, + "operationId": "group.item.deeper" + } + }, + "/fifth": { + "get": { + "responses": { + "200": { + "description": "Success" + } + }, + "operationId": "9 lives!" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api._9_lives", + "description": "GET /fifth", + "signature": "tools.api._9_lives(): Promise" + }, + { + "path": "api.group.item", + "description": "GET /first", + "signature": "tools.api.group.item(): Promise" + }, + { + "path": "api.group.itemDeeper", + "description": "GET /fourth", + "signature": "tools.api.group.itemDeeper(): Promise" + }, + { + "path": "api.group.operation.other", + "description": "GET /third", + "signature": "tools.api.group.operation.other(): Promise" + }, + { + "path": "api.group_item_2", + "description": "GET /second", + "signature": "tools.api.group_item_2(): Promise" + } + ], + "schemas": [ + { + "path": "_9_lives", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "group.item", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "group.itemDeeper", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "group.operation.other", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "group_item_2", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "unsupported operations reserve no names", + "spec": { + "openapi": "3.1.0", + "paths": { + "/first": { + "get": { + "operationId": "group.item", + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/unsupported": { + "get": { + "operationId": "group.item", + "responses": { + "200": { + "description": "Success" + } + }, + "x-websocket": true + } + }, + "/last": { + "get": { + "operationId": "group.item", + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.group.item", + "description": "GET /first", + "signature": "tools.api.group.item(): Promise" + }, + { + "path": "api.group_item_2", + "description": "GET /last", + "signature": "tools.api.group_item_2(): Promise" + } + ], + "schemas": [ + { + "path": "group.item", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "group_item_2", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [ + { + "method": "GET", + "path": "/unsupported", + "reason": "WebSocket operations are not supported" + } + ], + "calls": [] + }, + { + "name": "synthesized operation ids", + "spec": { + "openapi": "3.1.0", + "paths": { + "/users": { + "get": { + "responses": { + "200": { + "description": "Success" + } + } + }, + "post": { + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/users/{id}": { + "get": { + "responses": { + "200": { + "description": "Success" + } + } + }, + "patch": { + "responses": { + "200": { + "description": "Success" + } + } + }, + "delete": { + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/organizations/{organizationId}/users/{id}": { + "get": { + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.deleteUsersById", + "description": "DELETE /users/{id}", + "signature": "tools.api.deleteUsersById(): Promise" + }, + { + "path": "api.getOrganizationsByOrganizationidUsersById", + "description": "GET /organizations/{organizationId}/users/{id}", + "signature": "tools.api.getOrganizationsByOrganizationidUsersById(): Promise" + }, + { + "path": "api.getUsers", + "description": "GET /users", + "signature": "tools.api.getUsers(): Promise" + }, + { + "path": "api.getUsersById", + "description": "GET /users/{id}", + "signature": "tools.api.getUsersById(): Promise" + }, + { + "path": "api.patchUsersById", + "description": "PATCH /users/{id}", + "signature": "tools.api.patchUsersById(): Promise" + }, + { + "path": "api.postUsers", + "description": "POST /users", + "signature": "tools.api.postUsers(): Promise" + } + ], + "schemas": [ + { + "path": "deleteUsersById", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "getOrganizationsByOrganizationidUsersById", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "getUsers", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "getUsersById", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "patchUsersById", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "postUsers", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "operation parameters override path parameters", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "parameters": [ + { + "name": "limit", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "get": { + "operationId": "test", + "parameters": [ + { + "name": "limit", + "in": "query", + "schema": { + "type": "boolean" + } + }, + { + "name": "limit", + "in": "query", + "required": true, + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test({\n limit: number,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "limit": { + "type": "number" + } + }, + "required": [ + "limit" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "OpenAPI 3.0 normalization", + "spec": { + "openapi": "3.0.3", + "paths": { + "/search": { + "get": { + "operationId": "search", + "parameters": [ + { + "in": "query", + "name": "value", + "schema": { + "type": "string", + "nullable": true, + "minLength": 2 + } + }, + { + "in": "query", + "name": "count", + "schema": { + "type": "integer", + "minimum": 1, + "exclusiveMinimum": true, + "maximum": 9 + } + }, + { + "in": "query", + "name": "either", + "schema": { + "nullable": true, + "allOf": [ + { + "$ref": "#/components/schemas/Mode" + } + ] + } + }, + { + "in": "query", + "name": "sample", + "schema": { + "type": "string", + "example": "abc" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Result" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Mode": { + "type": "string", + "enum": [ + "a", + "b" + ] + }, + "Result": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Mode" + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.search", + "description": "GET /search", + "signature": "tools.api.search({\n /** @minLength 2 */\n value?: string | null,\n /** @integer @maximum 9 @exclusiveMinimum 1 */\n count?: number,\n either?: \"a\" | \"b\" | null,\n sample?: string,\n}): Promise<{\n items?: Array<\"a\" | \"b\">,\n}>" + } + ], + "schemas": [ + { + "path": "search", + "input": { + "type": "object", + "properties": { + "value": { + "type": [ + "string", + "null" + ], + "minLength": 2 + }, + "count": { + "type": "integer", + "maximum": 9, + "exclusiveMinimum": 1 + }, + "either": { + "anyOf": [ + { + "$ref": "#/$defs/Mode" + }, + { + "type": "null" + } + ] + }, + "sample": { + "type": "string", + "examples": [ + "abc" + ] + } + }, + "$defs": { + "Mode": { + "type": "string", + "enum": [ + "a", + "b" + ] + }, + "Result": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/Mode" + } + } + } + } + } + }, + "output": { + "$ref": "#/$defs/Result", + "$defs": { + "Mode": { + "type": "string", + "enum": [ + "a", + "b" + ] + }, + "Result": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/$defs/Mode" + } + } + } + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "schema-local definitions", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/$defs/Local", + "$defs": { + "Local": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Global": { + "type": "number" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {}, + "$defs": { + "Global": { + "type": "number" + } + } + }, + "output": { + "$ref": "#/$defs/Local", + "$defs": { + "Global": { + "type": "number" + }, + "Local": { + "type": "string" + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "directional 3.0", + "spec": { + "openapi": "3.0.3", + "paths": { + "/users": { + "post": { + "operationId": "users.create", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "name", + "password", + "profile", + "generated" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "createdAt", + "secret", + "label" + ], + "properties": { + "createdAt": { + "type": "string", + "readOnly": true + }, + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + }, + "generated": { + "$ref": "#/components/schemas/ReadOnlyID" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.users.create", + "description": "POST /users", + "signature": "tools.api.users.create({\n name: string,\n password: string,\n profile: {\n secret: string,\n label: string,\n },\n}): Promise<{\n id: string,\n name: string,\n profile: {\n createdAt: string,\n label: string,\n },\n generated: string,\n}>" + } + ], + "schemas": [ + { + "path": "users.create", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "secret", + "label" + ], + "properties": { + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + } + }, + "required": [ + "name", + "password", + "profile" + ], + "$defs": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "password", + "profile" + ], + "properties": { + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "secret", + "label" + ], + "properties": { + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + } + } + } + } + }, + "output": { + "$ref": "#/$defs/User", + "$defs": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "name", + "profile", + "generated" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "createdAt", + "label" + ], + "properties": { + "createdAt": { + "type": "string", + "readOnly": true + }, + "label": { + "type": "string" + } + } + }, + "generated": { + "$ref": "#/$defs/ReadOnlyID" + } + } + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "directional 3.1", + "spec": { + "openapi": "3.1.0", + "paths": { + "/users": { + "post": { + "operationId": "users.create", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "name", + "password", + "profile", + "generated" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "createdAt", + "secret", + "label" + ], + "properties": { + "createdAt": { + "type": "string", + "readOnly": true + }, + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + }, + "generated": { + "$ref": "#/components/schemas/ReadOnlyID" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.users.create", + "description": "POST /users", + "signature": "tools.api.users.create({\n name: string,\n password: string,\n profile: {\n secret: string,\n label: string,\n },\n}): Promise<{\n id: string,\n name: string,\n profile: {\n createdAt: string,\n label: string,\n },\n generated: string,\n}>" + } + ], + "schemas": [ + { + "path": "users.create", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "secret", + "label" + ], + "properties": { + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + } + }, + "required": [ + "name", + "password", + "profile" + ], + "$defs": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "password", + "profile" + ], + "properties": { + "name": { + "type": "string" + }, + "password": { + "type": "string", + "writeOnly": true + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "secret", + "label" + ], + "properties": { + "secret": { + "type": "string", + "writeOnly": true + }, + "label": { + "type": "string" + } + } + } + } + } + } + }, + "output": { + "$ref": "#/$defs/User", + "$defs": { + "ReadOnlyID": { + "type": "string", + "readOnly": true + }, + "User": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "name", + "profile", + "generated" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "profile": { + "type": "object", + "additionalProperties": false, + "required": [ + "createdAt", + "label" + ], + "properties": { + "createdAt": { + "type": "string", + "readOnly": true + }, + "label": { + "type": "string" + } + } + }, + "generated": { + "$ref": "#/$defs/ReadOnlyID" + } + } + } + } + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "users.create", + "input": { + "id": "ignored-top-level", + "generated": "ignored-generated", + "name": "Ada", + "password": "request-secret", + "profile": { + "createdAt": "sent-nested", + "secret": "nested-secret", + "label": "primary" + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"id\":\"server-id\",\"name\":\"Ada\",\"password\":\"returned-by-server\",\"profile\":{\"createdAt\":\"today\",\"secret\":\"returned-secret\",\"label\":\"primary\"},\"generated\":\"generated-id\"}" + }, + "outcome": { + "ok": true, + "value": { + "id": "server-id", + "name": "Ada", + "password": "returned-by-server", + "profile": { + "createdAt": "today", + "secret": "returned-secret", + "label": "primary" + }, + "generated": "generated-id" + } + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/users", + "headers": { + "content-type": "application/json" + }, + "body": "{\"name\":\"Ada\",\"password\":\"request-secret\",\"profile\":{\"createdAt\":\"sent-nested\",\"secret\":\"nested-secret\",\"label\":\"primary\"}}" + } + ], + "resolutions": [] + } + ] + }, + { + "name": "local refs and allOf composition", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "local", + "composed", + "name" + ], + "properties": { + "local": { + "$ref": "#/$defs/ReadOnlyValue" + }, + "composed": { + "allOf": [ + { + "$ref": "#/$defs/ReadOnlyValue" + } + ] + }, + "name": { + "type": "string" + } + }, + "$defs": { + "ReadOnlyValue": { + "type": "string", + "readOnly": true + } + } + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n name: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "ref siblings", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "record" + ], + "properties": { + "record": { + "$ref": "#/components/schemas/Base", + "properties": { + "extra": { + "type": "string", + "readOnly": true + }, + "note": { + "type": "string" + } + }, + "required": [ + "extra", + "note", + "id" + ] + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Base": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n record: {\n name: string,\n } & {\n note: string,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "record": { + "$ref": "#/$defs/Base", + "properties": { + "note": { + "type": "string" + } + }, + "required": [ + "note" + ] + } + }, + "required": [ + "record" + ], + "$defs": { + "Base": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + } + } + } + } + }, + "output": { + "type": "null", + "$defs": { + "Base": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + } + } + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "intermediate reference hops", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "secret", + "name" + ], + "properties": { + "secret": { + "$ref": "#/components/schemas/Middle" + }, + "name": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Middle": { + "$ref": "#/components/schemas/Plain", + "readOnly": true + }, + "Plain": { + "type": "string" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n name: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "$defs": { + "Middle": { + "$ref": "#/$defs/Plain", + "readOnly": true + }, + "Plain": { + "type": "string" + } + } + }, + "output": { + "type": "null", + "$defs": { + "Middle": { + "$ref": "#/$defs/Plain", + "readOnly": true + }, + "Plain": { + "type": "string" + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "cyclic components", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Node" + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Node": { + "type": "object", + "required": [ + "id", + "name", + "child" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "child": { + "$ref": "#/components/schemas/Node" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n body: {\n name: string,\n child: unknown,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "body": { + "$ref": "#/$defs/Node" + } + }, + "required": [ + "body" + ], + "$defs": { + "Node": { + "type": "object", + "required": [ + "name", + "child" + ], + "properties": { + "name": { + "type": "string" + }, + "child": { + "$ref": "#/$defs/Node" + } + } + } + } + }, + "output": { + "type": "null", + "$defs": { + "Node": { + "type": "object", + "required": [ + "id", + "name", + "child" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + }, + "child": { + "$ref": "#/$defs/Node" + } + } + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "diamond references", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/C0" + } + } + } + } + } + } + }, + "components": { + "schemas": { + "C0": { + "allOf": [ + { + "$ref": "#/components/schemas/C1" + }, + { + "$ref": "#/components/schemas/C1" + } + ] + }, + "C1": { + "allOf": [ + { + "$ref": "#/components/schemas/C2" + }, + { + "$ref": "#/components/schemas/C2" + } + ] + }, + "C2": { + "allOf": [ + { + "$ref": "#/components/schemas/C3" + }, + { + "$ref": "#/components/schemas/C3" + } + ] + }, + "C3": { + "allOf": [ + { + "$ref": "#/components/schemas/C4" + }, + { + "$ref": "#/components/schemas/C4" + } + ] + }, + "C4": { + "allOf": [ + { + "$ref": "#/components/schemas/C5" + }, + { + "$ref": "#/components/schemas/C5" + } + ] + }, + "C5": { + "allOf": [ + { + "$ref": "#/components/schemas/C6" + }, + { + "$ref": "#/components/schemas/C6" + } + ] + }, + "C6": { + "allOf": [ + { + "$ref": "#/components/schemas/C7" + }, + { + "$ref": "#/components/schemas/C7" + } + ] + }, + "C7": { + "allOf": [ + { + "$ref": "#/components/schemas/C8" + }, + { + "$ref": "#/components/schemas/C8" + } + ] + }, + "C8": { + "allOf": [ + { + "$ref": "#/components/schemas/C9" + }, + { + "$ref": "#/components/schemas/C9" + } + ] + }, + "C9": { + "allOf": [ + { + "$ref": "#/components/schemas/C10" + }, + { + "$ref": "#/components/schemas/C10" + } + ] + }, + "C10": { + "allOf": [ + { + "$ref": "#/components/schemas/C11" + }, + { + "$ref": "#/components/schemas/C11" + } + ] + }, + "C11": { + "allOf": [ + { + "$ref": "#/components/schemas/C12" + }, + { + "$ref": "#/components/schemas/C12" + } + ] + }, + "C12": { + "allOf": [ + { + "$ref": "#/components/schemas/C13" + }, + { + "$ref": "#/components/schemas/C13" + } + ] + }, + "C13": { + "allOf": [ + { + "$ref": "#/components/schemas/C14" + }, + { + "$ref": "#/components/schemas/C14" + } + ] + }, + "C14": { + "allOf": [ + { + "$ref": "#/components/schemas/C15" + }, + { + "$ref": "#/components/schemas/C15" + } + ] + }, + "C15": { + "allOf": [ + { + "$ref": "#/components/schemas/C16" + }, + { + "$ref": "#/components/schemas/C16" + } + ] + }, + "C16": { + "allOf": [ + { + "$ref": "#/components/schemas/C17" + }, + { + "$ref": "#/components/schemas/C17" + } + ] + }, + "C17": { + "allOf": [ + { + "$ref": "#/components/schemas/C18" + }, + { + "$ref": "#/components/schemas/C18" + } + ] + }, + "C18": { + "allOf": [ + { + "$ref": "#/components/schemas/C19" + }, + { + "$ref": "#/components/schemas/C19" + } + ] + }, + "C19": { + "allOf": [ + { + "$ref": "#/components/schemas/C20" + }, + { + "$ref": "#/components/schemas/C20" + } + ] + }, + "C20": { + "allOf": [ + { + "$ref": "#/components/schemas/C21" + }, + { + "$ref": "#/components/schemas/C21" + } + ] + }, + "C21": { + "allOf": [ + { + "$ref": "#/components/schemas/C22" + }, + { + "$ref": "#/components/schemas/C22" + } + ] + }, + "C22": { + "allOf": [ + { + "$ref": "#/components/schemas/C23" + }, + { + "$ref": "#/components/schemas/C23" + } + ] + }, + "C23": { + "allOf": [ + { + "$ref": "#/components/schemas/C24" + }, + { + "$ref": "#/components/schemas/C24" + } + ] + }, + "C24": { + "allOf": [ + { + "$ref": "#/components/schemas/C25" + }, + { + "$ref": "#/components/schemas/C25" + } + ] + }, + "C25": { + "allOf": [ + { + "$ref": "#/components/schemas/C26" + }, + { + "$ref": "#/components/schemas/C26" + } + ] + }, + "C26": { + "allOf": [ + { + "$ref": "#/components/schemas/C27" + }, + { + "$ref": "#/components/schemas/C27" + } + ] + }, + "C27": { + "allOf": [ + { + "$ref": "#/components/schemas/C28" + }, + { + "$ref": "#/components/schemas/C28" + } + ] + }, + "C28": { + "allOf": [ + { + "$ref": "#/components/schemas/C29" + }, + { + "$ref": "#/components/schemas/C29" + } + ] + }, + "C29": { + "type": "object", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": null, + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "body": { + "$ref": "#/$defs/C0" + } + }, + "required": [ + "body" + ], + "$defs": { + "C0": { + "allOf": [ + { + "$ref": "#/$defs/C1" + }, + { + "$ref": "#/$defs/C1" + } + ] + }, + "C1": { + "allOf": [ + { + "$ref": "#/$defs/C2" + }, + { + "$ref": "#/$defs/C2" + } + ] + }, + "C2": { + "allOf": [ + { + "$ref": "#/$defs/C3" + }, + { + "$ref": "#/$defs/C3" + } + ] + }, + "C3": { + "allOf": [ + { + "$ref": "#/$defs/C4" + }, + { + "$ref": "#/$defs/C4" + } + ] + }, + "C4": { + "allOf": [ + { + "$ref": "#/$defs/C5" + }, + { + "$ref": "#/$defs/C5" + } + ] + }, + "C5": { + "allOf": [ + { + "$ref": "#/$defs/C6" + }, + { + "$ref": "#/$defs/C6" + } + ] + }, + "C6": { + "allOf": [ + { + "$ref": "#/$defs/C7" + }, + { + "$ref": "#/$defs/C7" + } + ] + }, + "C7": { + "allOf": [ + { + "$ref": "#/$defs/C8" + }, + { + "$ref": "#/$defs/C8" + } + ] + }, + "C8": { + "allOf": [ + { + "$ref": "#/$defs/C9" + }, + { + "$ref": "#/$defs/C9" + } + ] + }, + "C9": { + "allOf": [ + { + "$ref": "#/$defs/C10" + }, + { + "$ref": "#/$defs/C10" + } + ] + }, + "C10": { + "allOf": [ + { + "$ref": "#/$defs/C11" + }, + { + "$ref": "#/$defs/C11" + } + ] + }, + "C11": { + "allOf": [ + { + "$ref": "#/$defs/C12" + }, + { + "$ref": "#/$defs/C12" + } + ] + }, + "C12": { + "allOf": [ + { + "$ref": "#/$defs/C13" + }, + { + "$ref": "#/$defs/C13" + } + ] + }, + "C13": { + "allOf": [ + { + "$ref": "#/$defs/C14" + }, + { + "$ref": "#/$defs/C14" + } + ] + }, + "C14": { + "allOf": [ + { + "$ref": "#/$defs/C15" + }, + { + "$ref": "#/$defs/C15" + } + ] + }, + "C15": { + "allOf": [ + { + "$ref": "#/$defs/C16" + }, + { + "$ref": "#/$defs/C16" + } + ] + }, + "C16": { + "allOf": [ + { + "$ref": "#/$defs/C17" + }, + { + "$ref": "#/$defs/C17" + } + ] + }, + "C17": { + "allOf": [ + { + "$ref": "#/$defs/C18" + }, + { + "$ref": "#/$defs/C18" + } + ] + }, + "C18": { + "allOf": [ + { + "$ref": "#/$defs/C19" + }, + { + "$ref": "#/$defs/C19" + } + ] + }, + "C19": { + "allOf": [ + { + "$ref": "#/$defs/C20" + }, + { + "$ref": "#/$defs/C20" + } + ] + }, + "C20": { + "allOf": [ + { + "$ref": "#/$defs/C21" + }, + { + "$ref": "#/$defs/C21" + } + ] + }, + "C21": { + "allOf": [ + { + "$ref": "#/$defs/C22" + }, + { + "$ref": "#/$defs/C22" + } + ] + }, + "C22": { + "allOf": [ + { + "$ref": "#/$defs/C23" + }, + { + "$ref": "#/$defs/C23" + } + ] + }, + "C23": { + "allOf": [ + { + "$ref": "#/$defs/C24" + }, + { + "$ref": "#/$defs/C24" + } + ] + }, + "C24": { + "allOf": [ + { + "$ref": "#/$defs/C25" + }, + { + "$ref": "#/$defs/C25" + } + ] + }, + "C25": { + "allOf": [ + { + "$ref": "#/$defs/C26" + }, + { + "$ref": "#/$defs/C26" + } + ] + }, + "C26": { + "allOf": [ + { + "$ref": "#/$defs/C27" + }, + { + "$ref": "#/$defs/C27" + } + ] + }, + "C27": { + "allOf": [ + { + "$ref": "#/$defs/C28" + }, + { + "$ref": "#/$defs/C28" + } + ] + }, + "C28": { + "allOf": [ + { + "$ref": "#/$defs/C29" + }, + { + "$ref": "#/$defs/C29" + } + ] + }, + "C29": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + } + } + }, + "output": { + "type": "null", + "$defs": { + "C0": { + "allOf": [ + { + "$ref": "#/$defs/C1" + }, + { + "$ref": "#/$defs/C1" + } + ] + }, + "C1": { + "allOf": [ + { + "$ref": "#/$defs/C2" + }, + { + "$ref": "#/$defs/C2" + } + ] + }, + "C2": { + "allOf": [ + { + "$ref": "#/$defs/C3" + }, + { + "$ref": "#/$defs/C3" + } + ] + }, + "C3": { + "allOf": [ + { + "$ref": "#/$defs/C4" + }, + { + "$ref": "#/$defs/C4" + } + ] + }, + "C4": { + "allOf": [ + { + "$ref": "#/$defs/C5" + }, + { + "$ref": "#/$defs/C5" + } + ] + }, + "C5": { + "allOf": [ + { + "$ref": "#/$defs/C6" + }, + { + "$ref": "#/$defs/C6" + } + ] + }, + "C6": { + "allOf": [ + { + "$ref": "#/$defs/C7" + }, + { + "$ref": "#/$defs/C7" + } + ] + }, + "C7": { + "allOf": [ + { + "$ref": "#/$defs/C8" + }, + { + "$ref": "#/$defs/C8" + } + ] + }, + "C8": { + "allOf": [ + { + "$ref": "#/$defs/C9" + }, + { + "$ref": "#/$defs/C9" + } + ] + }, + "C9": { + "allOf": [ + { + "$ref": "#/$defs/C10" + }, + { + "$ref": "#/$defs/C10" + } + ] + }, + "C10": { + "allOf": [ + { + "$ref": "#/$defs/C11" + }, + { + "$ref": "#/$defs/C11" + } + ] + }, + "C11": { + "allOf": [ + { + "$ref": "#/$defs/C12" + }, + { + "$ref": "#/$defs/C12" + } + ] + }, + "C12": { + "allOf": [ + { + "$ref": "#/$defs/C13" + }, + { + "$ref": "#/$defs/C13" + } + ] + }, + "C13": { + "allOf": [ + { + "$ref": "#/$defs/C14" + }, + { + "$ref": "#/$defs/C14" + } + ] + }, + "C14": { + "allOf": [ + { + "$ref": "#/$defs/C15" + }, + { + "$ref": "#/$defs/C15" + } + ] + }, + "C15": { + "allOf": [ + { + "$ref": "#/$defs/C16" + }, + { + "$ref": "#/$defs/C16" + } + ] + }, + "C16": { + "allOf": [ + { + "$ref": "#/$defs/C17" + }, + { + "$ref": "#/$defs/C17" + } + ] + }, + "C17": { + "allOf": [ + { + "$ref": "#/$defs/C18" + }, + { + "$ref": "#/$defs/C18" + } + ] + }, + "C18": { + "allOf": [ + { + "$ref": "#/$defs/C19" + }, + { + "$ref": "#/$defs/C19" + } + ] + }, + "C19": { + "allOf": [ + { + "$ref": "#/$defs/C20" + }, + { + "$ref": "#/$defs/C20" + } + ] + }, + "C20": { + "allOf": [ + { + "$ref": "#/$defs/C21" + }, + { + "$ref": "#/$defs/C21" + } + ] + }, + "C21": { + "allOf": [ + { + "$ref": "#/$defs/C22" + }, + { + "$ref": "#/$defs/C22" + } + ] + }, + "C22": { + "allOf": [ + { + "$ref": "#/$defs/C23" + }, + { + "$ref": "#/$defs/C23" + } + ] + }, + "C23": { + "allOf": [ + { + "$ref": "#/$defs/C24" + }, + { + "$ref": "#/$defs/C24" + } + ] + }, + "C24": { + "allOf": [ + { + "$ref": "#/$defs/C25" + }, + { + "$ref": "#/$defs/C25" + } + ] + }, + "C25": { + "allOf": [ + { + "$ref": "#/$defs/C26" + }, + { + "$ref": "#/$defs/C26" + } + ] + }, + "C26": { + "allOf": [ + { + "$ref": "#/$defs/C27" + }, + { + "$ref": "#/$defs/C27" + } + ] + }, + "C27": { + "allOf": [ + { + "$ref": "#/$defs/C28" + }, + { + "$ref": "#/$defs/C28" + } + ] + }, + "C28": { + "allOf": [ + { + "$ref": "#/$defs/C29" + }, + { + "$ref": "#/$defs/C29" + } + ] + }, + "C29": { + "type": "object", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + } + } + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "hiding through cycles, one order", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "a", + "b", + "name" + ], + "properties": { + "a": { + "$ref": "#/components/schemas/Loop" + }, + "b": { + "$ref": "#/components/schemas/Wrap" + }, + "name": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Wrap": { + "allOf": [ + { + "$ref": "#/components/schemas/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/components/schemas/Wrap" + }, + { + "readOnly": true + } + ] + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n name: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "$defs": { + "Wrap": { + "allOf": [ + { + "$ref": "#/$defs/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/$defs/Wrap" + }, + { + "readOnly": true + } + ] + } + } + }, + "output": { + "type": "null", + "$defs": { + "Wrap": { + "allOf": [ + { + "$ref": "#/$defs/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/$defs/Wrap" + }, + { + "readOnly": true + } + ] + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "hiding through cycles, the other order", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "a", + "b", + "name" + ], + "properties": { + "a": { + "$ref": "#/components/schemas/Wrap" + }, + "b": { + "$ref": "#/components/schemas/Loop" + }, + "name": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Wrap": { + "allOf": [ + { + "$ref": "#/components/schemas/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/components/schemas/Wrap" + }, + { + "readOnly": true + } + ] + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n name: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "$defs": { + "Wrap": { + "allOf": [ + { + "$ref": "#/$defs/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/$defs/Wrap" + }, + { + "readOnly": true + } + ] + } + } + }, + "output": { + "type": "null", + "$defs": { + "Wrap": { + "allOf": [ + { + "$ref": "#/$defs/Loop" + } + ] + }, + "Loop": { + "allOf": [ + { + "$ref": "#/$defs/Wrap" + }, + { + "readOnly": true + } + ] + } + } + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "not, if and contains stay unprojected", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "record" + ], + "properties": { + "record": { + "type": "object", + "not": { + "required": [ + "secret" + ], + "properties": { + "secret": { + "type": "string", + "readOnly": true + } + } + }, + "if": { + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "readOnly": true + } + } + } + } + } + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n record: {},\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "record": { + "type": "object", + "not": { + "required": [ + "secret" + ], + "properties": { + "secret": { + "type": "string", + "readOnly": true + } + } + }, + "if": { + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "readOnly": true + } + } + } + } + }, + "required": [ + "record" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "directions only in alternatives", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "choice", + "pick" + ], + "properties": { + "choice": { + "anyOf": [ + { + "type": "string", + "readOnly": true + }, + { + "type": "number" + } + ] + }, + "pick": { + "oneOf": [ + { + "type": "string", + "readOnly": true + }, + { + "type": "number" + } + ] + } + } + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n choice: string | number,\n pick: string | number,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "choice": { + "anyOf": [ + { + "type": "string", + "readOnly": true + }, + { + "type": "number" + } + ] + }, + "pick": { + "oneOf": [ + { + "type": "string", + "readOnly": true + }, + { + "type": "number" + } + ] + } + }, + "required": [ + "choice", + "pick" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "shadowed local $defs", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": [ + "record" + ], + "$defs": { + "Value": { + "type": "string" + } + }, + "properties": { + "record": { + "type": "object", + "required": [ + "x" + ], + "properties": { + "x": { + "$ref": "#/$defs/Value" + } + }, + "$defs": { + "Value": { + "type": "string", + "readOnly": true + } + } + } + } + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n record: {\n x: string,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "record": { + "type": "object", + "required": [ + "x" + ], + "properties": { + "x": { + "$ref": "#/$defs/Value" + } + }, + "$defs": { + "Value": { + "type": "string", + "readOnly": true + } + } + } + }, + "required": [ + "record" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "directions inside parameters", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "parameters": [ + { + "name": "filter", + "in": "query", + "required": true, + "schema": { + "type": "object", + "required": [ + "state", + "id" + ], + "properties": { + "state": { + "type": "string" + }, + "id": { + "type": "string", + "readOnly": true + } + } + } + } + ] + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test({\n filter: {\n state: string,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "filter": { + "type": "object", + "required": [ + "state" + ], + "properties": { + "state": { + "type": "string" + } + } + } + }, + "required": [ + "filter" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "required across allOf branches", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "id", + "name" + ], + "allOf": [ + { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string" + } + } + } + ] + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n body: {} & {\n name: string,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "body": { + "type": "object", + "required": [ + "name" + ], + "allOf": [ + { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + } + } + } + ] + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [] + }, + { + "name": "simple and form parameters", + "spec": { + "openapi": "3.1.0", + "paths": { + "/items/{keys}": { + "get": { + "operationId": "items", + "parameters": [ + { + "name": "keys", + "in": "path", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "tags", + "in": "query", + "style": "form", + "explode": false, + "schema": { + "type": "array" + } + }, + { + "name": "filter", + "in": "query", + "style": "form", + "explode": true, + "schema": { + "type": "object" + } + }, + { + "name": "nullable", + "in": "query", + "required": true, + "schema": { + "type": [ + "string", + "null" + ] + } + }, + { + "name": "constructor", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "meta", + "in": "header", + "style": "simple", + "explode": true, + "schema": { + "type": "object" + } + }, + { + "name": "pair", + "in": "header", + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.items", + "description": "GET /items/{keys}", + "signature": "tools.api.items({\n keys: Array,\n tags?: Array,\n filter?: {},\n nullable: string | null,\n constructor?: string,\n meta?: {},\n pair?: {},\n}): Promise" + } + ], + "schemas": [ + { + "path": "items", + "input": { + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array" + }, + "filter": { + "type": "object" + }, + "nullable": { + "type": [ + "string", + "null" + ] + }, + "constructor": { + "type": "string" + }, + "meta": { + "type": "object" + }, + "pair": { + "type": "object" + } + }, + "required": [ + "keys", + "nullable" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "items", + "input": { + "keys": [ + "a!", + "b*" + ], + "tags": [ + "x", + "y" + ], + "filter": { + "state": "open", + "page": 2 + }, + "nullable": null, + "constructor": "safe", + "meta": { + "a": "b", + "c": "d" + }, + "pair": { + "a": 1.5, + "b": true + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/items/a%21,b%2A?tags=x%2Cy&state=open&page=2&nullable=null&constructor=safe", + "headers": { + "meta": "a=b,c=d", + "pair": "a,1.5,b,true" + }, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "items", + "input": { + "keys": [ + {} + ], + "nullable": 1 + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Parameter 'keys' contains an unsupported nested value." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "items", + "input": { + "keys": [ + "k" + ] + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Missing required query parameter 'nullable'." + }, + "requests": [], + "resolutions": [] + } + ] + }, + { + "name": "exploded and deep-object query parameters", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "parameters": [ + { + "name": "tags", + "in": "query", + "style": "form", + "explode": true, + "schema": { + "type": "array" + } + }, + { + "name": "filter", + "in": "query", + "style": "form", + "explode": true, + "schema": { + "type": "object" + } + }, + { + "name": "location", + "in": "query", + "style": "deepObject", + "explode": true, + "schema": { + "type": "object" + } + } + ] + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test({\n tags?: Array,\n filter?: {},\n location?: {},\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "tags": { + "type": "array" + }, + "filter": { + "type": "object" + }, + "location": { + "type": "object" + } + } + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": { + "tags": [ + "first value", + "second&value" + ], + "filter": { + "state": "open now", + "page": 2 + }, + "location": { + "directory": "/tmp/a b", + "workspace": "work&1" + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test?tags=first+value&tags=second%26value&state=open+now&page=2&location%5Bdirectory%5D=%2Ftmp%2Fa+b&location%5Bworkspace%5D=work%261", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": { + "tags": [ + {} + ] + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Parameter 'tags' contains an unsupported nested value." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "test", + "input": { + "filter": { + "state": {} + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Query parameter 'filter' contains an unsupported nested value." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "test", + "input": { + "location": { + "directory": [] + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Deep-object parameter 'location' contains an unsupported nested value." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "test", + "input": { + "location": "flat" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Deep-object parameter 'location' must be an object." + }, + "requests": [], + "resolutions": [] + } + ] + }, + { + "name": "unsupported encodings and malformed security", + "spec": { + "openapi": "3.1.0", + "security": [ + { + "bearer": [] + } + ], + "paths": { + "/cookie": { + "get": { + "operationId": "cookie", + "parameters": [ + { + "name": "session", + "in": "cookie", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/reserved": { + "get": { + "operationId": "reserved", + "parameters": [ + { + "name": "query", + "in": "query", + "allowReserved": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/invalid-style": { + "get": { + "operationId": "invalidStyle", + "parameters": [ + { + "name": "query", + "in": "query", + "style": 42, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/security": { + "get": { + "operationId": "security", + "security": null, + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/matrix": { + "get": { + "operationId": "matrix", + "parameters": [ + { + "name": "m", + "in": "path", + "style": "matrix", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/deep": { + "get": { + "operationId": "deep", + "parameters": [ + { + "name": "d", + "in": "query", + "style": "deepObject", + "explode": false, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/content": { + "get": { + "operationId": "content", + "parameters": [ + { + "name": "c", + "in": "query", + "content": { + "application/json": {} + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/neither": { + "get": { + "operationId": "neither", + "parameters": [ + { + "name": "n", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/unknown": { + "get": { + "operationId": "unknown", + "parameters": [ + { + "name": "u", + "in": "body", + "schema": {} + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/unnamed": { + "get": { + "operationId": "unnamed", + "parameters": [ + { + "in": "query", + "schema": {} + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/explode": { + "get": { + "operationId": "explode", + "parameters": [ + { + "name": "e", + "in": "query", + "explode": "yes", + "schema": {} + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/cookie", + "reason": "cookie parameter 'session' is not supported" + }, + { + "method": "GET", + "path": "/reserved", + "reason": "parameter 'query' uses unsupported allowReserved encoding" + }, + { + "method": "GET", + "path": "/invalid-style", + "reason": "parameter 'query' has an invalid style" + }, + { + "method": "GET", + "path": "/security", + "reason": "security declaration is not an array" + }, + { + "method": "GET", + "path": "/matrix", + "reason": "path parameter 'm' uses unsupported style 'matrix'" + }, + { + "method": "GET", + "path": "/deep", + "reason": "query parameter 'd' uses deepObject with explode=false" + }, + { + "method": "GET", + "path": "/content", + "reason": "parameter 'c' uses unsupported content encoding" + }, + { + "method": "GET", + "path": "/neither", + "reason": "parameter 'n' declares neither schema nor content" + }, + { + "method": "GET", + "path": "/unknown", + "reason": "parameter 'u' uses unsupported location 'body'" + }, + { + "method": "GET", + "path": "/unnamed", + "reason": "parameter declaration is missing name or location" + }, + { + "method": "GET", + "path": "/explode", + "reason": "parameter 'e' has an invalid explode value" + } + ], + "calls": [] + }, + { + "name": "prototype-named missing scheme", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "security": [ + { + "__proto__": [] + } + ] + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "security requirement references missing or malformed scheme: __proto__" + } + ], + "calls": [] + }, + { + "name": "bearer authentication", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ], + "components": { + "securitySchemes": { + "bearer": { + "type": "http", + "scheme": "bearer" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "bearer": { + "type": "bearer", + "token": "secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.getTest", + "description": "GET /test", + "signature": "tools.api.getTest(): Promise" + } + ], + "schemas": [ + { + "path": "getTest", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "getTest", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": { + "authorization": "Bearer secret" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "bearer", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "prototype-named query key", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "key": [] + } + ], + "components": { + "securitySchemes": { + "key": { + "type": "apiKey", + "in": "query", + "name": "__proto__" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "key": { + "type": "apiKey", + "value": "secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test?__proto__=secret", + "headers": {}, + "body": null + } + ], + "resolutions": [ + { + "name": "key", + "definition": { + "type": "apiKey", + "name": "__proto__", + "in": "query" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "duplicate credentials", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "first": [], + "second": [] + } + ], + "components": { + "securitySchemes": { + "first": { + "type": "apiKey", + "in": "header", + "name": "x-key" + }, + "second": { + "type": "apiKey", + "in": "header", + "name": "x-key" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "first": { + "type": "apiKey", + "value": "secret" + }, + "second": { + "type": "apiKey", + "value": "secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Authentication resolves multiple credentials for header 'x-key'." + }, + "requests": [], + "resolutions": [ + { + "name": "first", + "definition": { + "type": "apiKey", + "name": "x-key", + "in": "header" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + }, + { + "name": "second", + "definition": { + "type": "apiKey", + "name": "x-key", + "in": "header" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "cookie authentication", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "key": [] + } + ], + "components": { + "securitySchemes": { + "key": { + "type": "apiKey", + "in": "cookie", + "name": "session" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "cookie authentication 'key' is not supported" + } + ], + "calls": [] + }, + { + "name": "supported alternative", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "cookie": [] + }, + { + "bearer": [] + } + ], + "components": { + "securitySchemes": { + "cookie": { + "type": "apiKey", + "in": "cookie", + "name": "session" + }, + "bearer": { + "type": "http", + "scheme": "bearer" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "bearer": { + "type": "bearer", + "token": "secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": { + "authorization": "Bearer secret" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "bearer", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "carriers", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "parameters": [ + { + "name": "x-static", + "in": "header", + "schema": { + "type": "string" + } + } + ] + } + } + }, + "security": [ + { + "basic": [], + "custom": [] + }, + { + "none": [] + } + ], + "components": { + "securitySchemes": { + "basic": { + "type": "http", + "scheme": "Basic" + }, + "custom": { + "type": "oauth2" + }, + "none": { + "type": "openIdConnect" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "basic": { + "type": "basic", + "username": "user", + "password": "pässword" + }, + "custom": { + "type": "header", + "name": "X-Custom", + "value": "c" + } + }, + "headers": { + "X-Static": "static", + "Authorization": "overridden" + }, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test({\n \"x-static\"?: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "x-static": { + "type": "string" + } + } + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": { + "authorization": "Basic dXNlcjpww6Rzc3dvcmQ=", + "x-custom": "c", + "x-static": "static" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "basic", + "definition": { + "type": "http", + "scheme": "basic" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + }, + { + "name": "custom", + "definition": { + "type": "oauth2" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + }, + { + "tool": "test", + "input": { + "x-static": "declared" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": { + "authorization": "Basic dXNlcjpww6Rzc3dvcmQ=", + "x-custom": "c", + "x-static": "declared" + }, + "body": null + } + ], + "resolutions": [ + { + "name": "basic", + "definition": { + "type": "http", + "scheme": "basic" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + }, + { + "name": "custom", + "definition": { + "type": "oauth2" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "missing credentials", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "security": [ + { + "a": [] + }, + { + "b": [] + } + ], + "components": { + "securitySchemes": { + "a": { + "type": "http", + "scheme": "bearer" + }, + "b": { + "type": "oauth2" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "b": { + "type": "apiKey", + "value": "v" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Security scheme 'b' is not an apiKey scheme; resolve a bearer, basic, or header credential for it." + }, + "requests": [], + "resolutions": [ + { + "name": "a", + "definition": { + "type": "http", + "scheme": "bearer" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + }, + { + "name": "b", + "definition": { + "type": "oauth2" + }, + "scopes": [], + "operation": { + "operationId": "test", + "method": "GET", + "path": "/test" + } + } + ] + } + ] + }, + { + "name": "server precedence", + "spec": { + "openapi": "3.1.0", + "servers": [ + { + "url": "https://document.example" + } + ], + "paths": { + "/op": { + "get": { + "operationId": "op", + "servers": [ + { + "url": "https://operation.example/v1/" + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/path": { + "servers": [ + { + "url": "https://path.example" + } + ], + "get": { + "operationId": "path", + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/doc": { + "get": { + "operationId": "doc", + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/templated": { + "get": { + "operationId": "templated", + "servers": [ + { + "url": "https://{region}.example" + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/relative": { + "get": { + "operationId": "relative", + "servers": [ + { + "url": "/v1" + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/none": { + "get": { + "operationId": "none", + "servers": [], + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": null, + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.doc", + "description": "GET /doc", + "signature": "tools.api.doc(): Promise" + }, + { + "path": "api.op", + "description": "GET /op", + "signature": "tools.api.op(): Promise" + }, + { + "path": "api.path", + "description": "GET /path", + "signature": "tools.api.path(): Promise" + } + ], + "schemas": [ + { + "path": "doc", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "op", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + }, + { + "path": "path", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [ + { + "method": "GET", + "path": "/templated", + "reason": "server URL 'https://{region}.example' is not an absolute URL; pass baseUrl" + }, + { + "method": "GET", + "path": "/relative", + "reason": "server URL '/v1' is not an absolute HTTP(S) URL" + }, + { + "method": "GET", + "path": "/none", + "reason": "spec declares no servers; pass baseUrl" + } + ], + "calls": [ + { + "tool": "op", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "https://operation.example/v1/op", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "path", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "https://path.example/path", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "doc", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "GET", + "url": "https://document.example/doc", + "headers": {}, + "body": null + } + ], + "resolutions": [] + } + ] + }, + { + "name": "base URL with a query", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "https://example.com/api?tenant=one", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "server URL 'https://example.com/api?tenant=one' contains an unsupported query string or fragment" + } + ], + "calls": [] + }, + { + "name": "malformed base URL", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "https:/example.com", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "server URL 'https:/example.com' is not an absolute HTTP(S) URL" + } + ], + "calls": [] + }, + { + "name": "chained response refs", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "$ref": "#/components/responses/First" + } + } + } + } + }, + "components": { + "responses": { + "First": { + "$ref": "#/components/responses/Stream" + }, + "Stream": { + "content": { + "text/event-stream": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "SSE operations are not supported" + } + ], + "calls": [] + }, + { + "name": "binary response schema", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/File" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "File": { + "type": "string", + "format": "binary" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "binary responses are not supported" + } + ], + "calls": [] + }, + { + "name": "unresolved response", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "$ref": "#/components/responses/Missing" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [], + "schemas": [], + "skipped": [ + { + "method": "GET", + "path": "/test", + "reason": "successful response declaration is invalid or unresolved" + } + ], + "calls": [] + }, + { + "name": "composite parameters before auth", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "parameters": [ + { + "name": "filter", + "in": "query", + "style": "form", + "explode": true, + "schema": { + "type": "object" + } + } + ] + } + } + }, + "security": [ + { + "bearer": [] + } + ], + "components": { + "securitySchemes": { + "bearer": { + "type": "http", + "scheme": "bearer" + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": { + "bearer": { + "type": "bearer", + "token": "secret" + } + }, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test({\n filter?: {},\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "filter": { + "type": "object" + } + } + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": { + "filter": { + "value": [ + 1 + ] + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Query parameter 'filter' contains an unsupported nested value." + }, + "requests": [], + "resolutions": [] + } + ] + }, + { + "name": "JSON media types", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "post": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + }, + "requestBody": { + "required": true, + "content": { + "application/merge-patch+json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "POST /test", + "signature": "tools.api.test({\n body: {},\n}): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": { + "body": { + "type": "object" + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": { + "body": { + "name": "updated", + "n": 1.5, + "big": 1e+21 + } + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": true, + "value": { + "ok": true + } + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/test", + "headers": { + "content-type": "application/merge-patch+json" + }, + "body": "{\"name\":\"updated\",\"n\":1.5,\"big\":1e+21}" + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Missing required body field 'body'." + }, + "requests": [], + "resolutions": [] + } + ] + }, + { + "name": "oversized and malformed responses", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Success" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "contentLength": "52428801", + "body": null + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /test response exceeds 50 MiB." + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": {}, + "reply": { + "contentType": "application/json", + "body": "{" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /test returned malformed JSON." + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": {}, + "reply": { + "contentType": "application/json; charset=utf-8", + "body": "" + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": {}, + "reply": { + "status": 503, + "contentType": "application/json", + "body": "null" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /test failed with HTTP 503: no response body" + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "test", + "input": {}, + "reply": { + "status": 400, + "body": null + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "GET /test failed with HTTP 400: no response body" + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + } + ] + }, + { + "name": "non-JSON responses and unions", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "description": "Text", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "204": { + "description": "Empty" + }, + "2XX": { + "description": "Any", + "content": { + "application/json": { + "schema": { + "type": "number" + } + } + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "type": "number" + } + ] + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "contentType": "text/plain", + "body": "123" + }, + "outcome": { + "ok": true, + "value": "123" + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + } + ] + }, + { + "name": "untyped JSON response", + "spec": { + "openapi": "3.1.0", + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "200": { + "content": { + "application/json": {} + } + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.test", + "description": "GET /test", + "signature": "tools.api.test(): Promise" + } + ], + "schemas": [ + { + "path": "test", + "input": { + "type": "object", + "properties": {} + }, + "output": null + } + ], + "skipped": [], + "calls": [ + { + "tool": "test", + "input": {}, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"dropped\":true}" + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "GET", + "url": "http://localhost:4096/test", + "headers": {}, + "body": null + } + ], + "resolutions": [] + } + ] + }, + { + "name": "cross-location collisions", + "spec": { + "openapi": "3.1.0", + "info": { + "title": "collision", + "version": "1.0.0" + }, + "paths": { + "/echo": { + "post": { + "operationId": "echo", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "204": { + "description": "Echoed" + } + } + } + }, + "/things/{id}": { + "post": { + "operationId": "things.update", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "path_id", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "204": { + "description": "Updated" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.echo", + "description": "POST /echo", + "signature": "tools.api.echo({\n body: string,\n}): Promise" + }, + { + "path": "api.things.update", + "description": "POST /things/{id}", + "signature": "tools.api.things.update({\n path_id: string,\n query_id: string,\n path_id_2?: string,\n header_id: string,\n body_id: string,\n}): Promise" + } + ], + "schemas": [ + { + "path": "echo", + "input": { + "type": "object", + "properties": { + "body": { + "type": "string" + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + }, + { + "path": "things.update", + "input": { + "type": "object", + "properties": { + "path_id": { + "type": "string" + }, + "query_id": { + "type": "string" + }, + "path_id_2": { + "type": "string" + }, + "header_id": { + "type": "string" + }, + "body_id": { + "type": "string" + } + }, + "required": [ + "path_id", + "query_id", + "header_id", + "body_id" + ] + }, + "output": { + "type": "null" + } + } + ], + "skipped": [], + "calls": [ + { + "tool": "things.update", + "input": { + "path_id": "path", + "query_id": "query", + "path_id_2": "literal", + "header_id": "header", + "body_id": "body" + }, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/things/path?id=query&path_id=literal", + "headers": { + "content-type": "application/json", + "id": "header" + }, + "body": "{\"id\":\"body\"}" + } + ], + "resolutions": [] + }, + { + "tool": "things.update", + "input": { + "path_id": "path", + "query_id": "query", + "header_id": "header" + }, + "reply": { + "status": 200, + "contentType": "application/json", + "body": "{\"ok\":true}" + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Missing required body field 'body_id'." + }, + "requests": [], + "resolutions": [] + }, + { + "tool": "echo", + "input": { + "body": "hello" + }, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/echo", + "headers": { + "content-type": "application/json" + }, + "body": "\"hello\"" + } + ], + "resolutions": [] + } + ] + }, + { + "name": "bodies kept nested", + "spec": { + "openapi": "3.1.0", + "paths": { + "/body/optional": { + "post": { + "operationId": "body.optional", + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + }, + "/body/dictionary": { + "post": { + "operationId": "body.dictionary", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + }, + "/body/composed": { + "post": { + "operationId": "body.composed", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "allOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + }, + "/body/nullable": { + "post": { + "operationId": "body.nullable", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": [ + "object", + "null" + ], + "properties": { + "name": { + "type": "string" + } + }, + "additionalProperties": false + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + }, + "/body/text": { + "post": { + "operationId": "body.text", + "requestBody": { + "required": true, + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + }, + "/body/flat": { + "post": { + "operationId": "body.flat", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "a": { + "type": "string" + }, + "b": { + "type": "number" + } + }, + "required": [ + "a" + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "204": { + "description": "Accepted" + } + } + } + } + } + }, + "baseUrl": "http://localhost:4096", + "auth": {}, + "headers": {}, + "catalog": [ + { + "path": "api.body.composed", + "description": "POST /body/composed", + "signature": "tools.api.body.composed({\n body: {} & {\n name: string,\n },\n}): Promise" + }, + { + "path": "api.body.dictionary", + "description": "POST /body/dictionary", + "signature": "tools.api.body.dictionary({\n body: {\n [key: string]: string,\n },\n}): Promise" + }, + { + "path": "api.body.flat", + "description": "POST /body/flat", + "signature": "tools.api.body.flat({\n a: string,\n b?: number,\n}): Promise" + }, + { + "path": "api.body.nullable", + "description": "POST /body/nullable", + "signature": "tools.api.body.nullable({\n body: {\n name?: string,\n } | null,\n}): Promise" + }, + { + "path": "api.body.optional", + "description": "POST /body/optional", + "signature": "tools.api.body.optional({\n body?: {\n name: string,\n },\n}): Promise" + } + ], + "schemas": [ + { + "path": "body.composed", + "input": { + "type": "object", + "properties": { + "body": { + "type": "object", + "allOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + ], + "additionalProperties": false + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + }, + { + "path": "body.dictionary", + "input": { + "type": "object", + "properties": { + "body": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + }, + { + "path": "body.flat", + "input": { + "type": "object", + "properties": { + "a": { + "type": "string" + }, + "b": { + "type": "number" + } + }, + "required": [ + "a" + ] + }, + "output": { + "type": "null" + } + }, + { + "path": "body.nullable", + "input": { + "type": "object", + "properties": { + "body": { + "type": [ + "object", + "null" + ], + "properties": { + "name": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "required": [ + "body" + ] + }, + "output": { + "type": "null" + } + }, + { + "path": "body.optional", + "input": { + "type": "object", + "properties": { + "body": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "additionalProperties": false + } + } + }, + "output": { + "type": "null" + } + } + ], + "skipped": [ + { + "method": "POST", + "path": "/body/text", + "reason": "request body has no JSON content (declared: text/plain)" + } + ], + "calls": [ + { + "tool": "body.optional", + "input": {}, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/body/optional", + "headers": {}, + "body": null + } + ], + "resolutions": [] + }, + { + "tool": "body.flat", + "input": { + "a": "x" + }, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": true, + "value": null + }, + "requests": [ + { + "method": "POST", + "url": "http://localhost:4096/body/flat", + "headers": { + "content-type": "application/json" + }, + "body": "{\"a\":\"x\"}" + } + ], + "resolutions": [] + }, + { + "tool": "body.flat", + "input": { + "b": 1 + }, + "reply": { + "status": 204, + "body": null + }, + "outcome": { + "ok": false, + "kind": "ToolFailure", + "message": "Missing required body field 'a'." + }, + "requests": [], + "resolutions": [] + } + ] + } ] } diff --git a/packages/codemode-rust/conformance/catalog.ts b/packages/codemode-rust/conformance/catalog.ts index b4aa41786e0d..97e700b0e6ad 100644 --- a/packages/codemode-rust/conformance/catalog.ts +++ b/packages/codemode-rust/conformance/catalog.ts @@ -15,7 +15,10 @@ import { join, resolve } from "node:path" const override = process.argv[2] ?? process.env.CODEMODE_REF const pkg = override === undefined ? resolve(import.meta.dir, "../../codemode") : resolve(override) const { Effect, Schema } = await import(Bun.resolveSync("effect", join(pkg, "src"))) -const { CodeMode, Namespace, Tool, searchSignature, toolExpression } = await import(join(pkg, "src/index.ts")) +const { CodeMode, Namespace, OpenAPI, Tool, searchSignature, toolExpression } = await import(join(pkg, "src/index.ts")) +const { Layer } = await import(Bun.resolveSync("effect", join(pkg, "src"))) +const { HttpClient, HttpClientRequest, HttpClientResponse } = await import(Bun.resolveSync("effect/http", join(pkg, "src"))) +const { cases } = await import("./openapi-specs.ts") type Spec = { path: string @@ -286,6 +289,101 @@ const outcome = async (code: string) => { : { ok: false, error: result.error, toolCalls: result.toolCalls.length } } +// OpenAPI: each case's generated tools under `api`, what was skipped, and its calls through a recording client. +const sorted = (record: Record) => + Object.fromEntries(Object.entries(record).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) + +const openapi: Array = [] +for (const item of cases(pkg)) { + openapi.push(await (async () => { + let resolutions: Array = [] + const api = OpenAPI.fromSpec({ + spec: item.spec, + ...(item.baseUrl === undefined ? {} : { baseUrl: item.baseUrl }), + ...(item.headers === undefined ? {} : { headers: item.headers }), + auth: { + resolve: (context: { name: string }) => { + resolutions.push(JSON.parse(JSON.stringify(context))) + return Effect.succeed(item.auth?.[context.name]) + }, + }, + }) + const runtime = CodeMode.make({ tools: { api: api.tools } }) + const schemas: Array = [] + const walk = (node: Record, prefix: string) => { + for (const [name, value] of Object.entries(node)) { + const path = prefix === "" ? name : `${prefix}.${name}` + if (Tool.isTool(value)) schemas.push({ path, input: value.input, output: value.output ?? null }) + else walk(value as Record, path) + } + } + walk(api.tools, "") + schemas.sort((a: any, b: any) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0)) + const calls = [] + for (const call of item.calls ?? []) { + resolutions = [] + const requests: Array = [] + const reply = call.reply ?? {} + const layer = Layer.succeed(HttpClient.HttpClient)( + HttpClient.make((request: any) => + Effect.sync(() => { + const body = + request.body._tag === "Uint8Array" ? new TextDecoder().decode(request.body.body) : null + requests.push({ + method: request.method, + url: HttpClientRequest.toUrl(request).pipe((o: any) => (o._tag === "Some" ? o.value.toString() : request.url)), + // Tracing and framing headers come from Effect's client, not from the OpenAPI tools. + headers: sorted( + Object.fromEntries( + Object.entries(request.headers).filter( + ([name]) => !["b3", "traceparent", "content-length"].includes(name), + ), + ) as Record, + ), + body, + }) + const headers: Record = {} + if (reply.contentType !== undefined) headers["content-type"] = reply.contentType + if (reply.contentLength !== undefined) headers["content-length"] = reply.contentLength + return HttpClientResponse.fromWeb( + request, + new Response(reply.body ?? null, { status: reply.status ?? 200, headers }), + ) + }), + ), + ) + const code = `return await ${toolExpression(`api.${call.tool}`)}(${JSON.stringify(call.input)})` + const result = await Effect.runPromise(runtime.execute(code).pipe(Effect.provide(layer))) + calls.push({ + ...call, + outcome: result.ok + ? { ok: true, value: result.value } + : { ok: false, kind: result.error.kind, message: result.error.message }, + requests, + resolutions, + }) + } + return { + name: item.name, + spec: item.spec, + baseUrl: item.baseUrl ?? null, + auth: item.auth ?? {}, + headers: item.headers ?? {}, + catalog: + item.render === false + ? null + : runtime.catalog.map((tool: { path: string; description: string; signature: string }) => ({ + path: tool.path, + description: tool.description, + signature: tool.signature, + })), + schemas, + skipped: api.skipped, + calls, + } + })()) +} + const expected = { tools: specs, namespaces, @@ -300,6 +398,9 @@ const expected = { toolExpression(path), ]), programs: await Promise.all(programs.map(async (code) => ({ code, ...(await outcome(code)) }))), + openapi, } writeFileSync(join(import.meta.dir, "catalog.json"), JSON.stringify(expected, null, 2) + "\n") -console.log(`${expected.catalog.length} tools, ${expected.programs.length} programs`) +console.log( + `${expected.catalog.length} tools, ${expected.programs.length} programs, ${openapi.length} OpenAPI documents`, +) diff --git a/packages/codemode-rust/conformance/openapi-specs.ts b/packages/codemode-rust/conformance/openapi-specs.ts new file mode 100644 index 000000000000..0bbdfca6beab --- /dev/null +++ b/packages/codemode-rust/conformance/openapi-specs.ts @@ -0,0 +1,1050 @@ +// The OpenAPI documents of the reference's `test/openapi.test.ts` and its fixtures, with calls to make against each. +// `conformance/catalog.ts` runs them through the reference and records the catalog, skipped operations, requests and +// results in `catalog.json`. + +import { readFileSync } from "node:fs" +import { join } from "node:path" + +export type Credential = + | { type: "bearer"; token: string } + | { type: "basic"; username: string; password: string } + | { type: "apiKey"; value: string } + | { type: "header"; name: string; value: string } + +/** What the fake server answers. */ +export type Reply = { status?: number; contentType?: string; contentLength?: string; body?: string | null } + +export type Call = { tool: string; input: unknown; reply?: Reply } + +export type Case = { + name: string + spec: Record + baseUrl?: string + /** Credentials by security scheme name; a missing name resolves to nothing. */ + auth?: Record + headers?: Record + calls?: Array + /** False when rendering signatures would take exponential time in the reference, as for a deep diamond. */ + render?: boolean +} + +const baseUrl = "http://localhost:4096" +const json = (value: unknown, status = 200): Reply => ({ + status, + contentType: "application/json", + body: JSON.stringify(value), +}) +const ok = json({ ok: true }) + +const singleOperation = (operation: Record, method = "get") => ({ + openapi: "3.1.0", + paths: { + "/test": { [method]: { operationId: "test", responses: { 200: { description: "Success" } }, ...operation } }, + }, +}) + +const directionalSpec = (openapi: string) => ({ + openapi, + paths: { + "/users": { + post: { + operationId: "users.create", + requestBody: { + required: true, + content: { "application/json": { schema: { $ref: "#/components/schemas/User" } } }, + }, + responses: { + 200: { + description: "Created", + content: { "application/json": { schema: { $ref: "#/components/schemas/User" } } }, + }, + }, + }, + }, + }, + components: { + schemas: { + ReadOnlyID: { type: "string", readOnly: true }, + User: { + type: "object", + additionalProperties: false, + required: ["id", "name", "password", "profile", "generated"], + properties: { + id: { type: "string", readOnly: true }, + name: { type: "string" }, + password: { type: "string", writeOnly: true }, + profile: { + type: "object", + additionalProperties: false, + required: ["createdAt", "secret", "label"], + properties: { + createdAt: { type: "string", readOnly: true }, + secret: { type: "string", writeOnly: true }, + label: { type: "string" }, + }, + }, + generated: { $ref: "#/components/schemas/ReadOnlyID" }, + }, + }, + }, + }, +}) + +const body = (properties: Record) => ({ + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: [...Object.keys(properties), "name"], + properties: { ...properties, name: { type: "string" } }, + }, + }, + }, +}) +const loop = { + Wrap: { allOf: [{ $ref: "#/components/schemas/Loop" }] }, + Loop: { allOf: [{ $ref: "#/components/schemas/Wrap" }, { readOnly: true }] }, +} +const depth = 30 +const diamond = Object.fromEntries( + Array.from({ length: depth }, (_, index) => [ + `C${index}`, + index === depth - 1 + ? { type: "object", properties: { id: { type: "string", readOnly: true }, name: { type: "string" } } } + : { allOf: [{ $ref: `#/components/schemas/C${index + 1}` }, { $ref: `#/components/schemas/C${index + 1}` }] }, + ]), +) +const bodyOf = (schema: Record, required = true) => ({ + required, + content: { "application/json": { schema } }, +}) +const response = { responses: { 200: { description: "Success" } } } + +export const cases = (reference: string): Array => { + const fixture = (name: string) => + JSON.parse(readFileSync(join(reference, "test/fixtures", name), "utf8")) as Record + return [ + { + name: "happy path", + spec: fixture("openapi-happy-path.json"), + baseUrl, + auth: { BearerAuth: { type: "bearer", token: "bearer-secret" }, ApiKey: { type: "apiKey", value: "api-secret" } }, + calls: [ + { + tool: "users.get", + input: { userId: "user-1", include: ["profile", "permissions"], verbose: true, "X-Trace-ID": "trace-1" }, + reply: json({ id: "user-1", name: "Ada", email: "ada@example.test", role: "member" }), + }, + { + tool: "users.create", + input: { name: "Grace", email: "grace@example.test", role: "admin" }, + reply: { + status: 201, + contentType: "application/vnd.example+json", + body: JSON.stringify({ id: "user-2", name: "Grace", email: "grace@example.test", role: "admin" }), + }, + }, + { + tool: "search.run", + input: { filter: { query: "effect", page: 2 }, tags: ["typescript", "runtime"] }, + reply: { contentType: "text/plain", body: "2 matches" }, + }, + { tool: "users.remove", input: { userId: "user-1" }, reply: { status: 204, body: null } }, + { tool: "users.get", input: { userId: "" }, reply: ok }, + { tool: "users.get", input: { userId: ".." }, reply: ok }, + { tool: "users.get", input: { userId: "a/b c" }, reply: { status: 404, contentType: "application/json", body: '{"error":"missing"}' } }, + { tool: "users.get", input: { userId: "x" }, reply: { status: 500, body: "x".repeat(2000) } }, + ], + }, + { + name: "transports", + spec: fixture("openapi-transports.json"), + baseUrl, + calls: [{ tool: "records.get", input: {} }, { tool: "records.get", input: { recordID: "r1" }, reply: json({ id: "r1", value: "v" }) }], + }, + { + name: "path sanitization and collisions", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/first": { get: { ...response, operationId: "group.item" } }, + "/second": { get: { ...response, operationId: "group.item" } }, + "/third": { get: { ...response, operationId: "group..other" } }, + "/fourth": { get: { ...response, operationId: "group.item.deeper" } }, + "/fifth": { get: { ...response, operationId: "9 lives!" } }, + }, + }, + }, + { + name: "unsupported operations reserve no names", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/first": { get: { operationId: "group.item", ...response } }, + "/unsupported": { get: { operationId: "group.item", ...response, "x-websocket": true } }, + "/last": { get: { operationId: "group.item", ...response } }, + }, + }, + }, + { + name: "synthesized operation ids", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/users": { get: response, post: response }, + "/users/{id}": { get: response, patch: response, delete: response }, + "/organizations/{organizationId}/users/{id}": { get: response }, + }, + }, + }, + { + name: "operation parameters override path parameters", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/test": { + parameters: [{ name: "limit", in: "query", schema: { type: "string" } }], + get: { + operationId: "test", + parameters: [ + { name: "limit", in: "query", schema: { type: "boolean" } }, + { name: "limit", in: "query", required: true, schema: { type: "number" } }, + ], + responses: { 200: { description: "Success" } }, + }, + }, + }, + }, + }, + { + name: "OpenAPI 3.0 normalization", + baseUrl, + spec: { + openapi: "3.0.3", + paths: { + "/search": { + get: { + operationId: "search", + parameters: [ + { in: "query", name: "value", schema: { type: "string", nullable: true, minLength: 2 } }, + { in: "query", name: "count", schema: { type: "integer", minimum: 1, exclusiveMinimum: true, maximum: 9 } }, + { in: "query", name: "either", schema: { nullable: true, allOf: [{ $ref: "#/components/schemas/Mode" }] } }, + { in: "query", name: "sample", schema: { type: "string", example: "abc" } }, + ], + responses: { + 200: { + description: "Success", + content: { "application/json": { schema: { $ref: "#/components/schemas/Result" } } }, + }, + }, + }, + }, + }, + components: { + schemas: { + Mode: { type: "string", enum: ["a", "b"] }, + Result: { type: "object", properties: { items: { type: "array", items: { $ref: "#/components/schemas/Mode" } } } }, + }, + }, + }, + }, + { + name: "schema-local definitions", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/test": { + get: { + operationId: "test", + responses: { + 200: { + description: "Success", + content: { + "application/json": { schema: { $ref: "#/$defs/Local", $defs: { Local: { type: "string" } } } }, + }, + }, + }, + }, + }, + }, + components: { schemas: { Global: { type: "number" } } }, + }, + }, + { + name: "directional 3.0", + baseUrl, + spec: directionalSpec("3.0.3"), + }, + { + name: "directional 3.1", + baseUrl, + spec: directionalSpec("3.1.0"), + calls: [ + { + tool: "users.create", + input: { + id: "ignored-top-level", + generated: "ignored-generated", + name: "Ada", + password: "request-secret", + profile: { createdAt: "sent-nested", secret: "nested-secret", label: "primary" }, + }, + reply: json({ + id: "server-id", + name: "Ada", + password: "returned-by-server", + profile: { createdAt: "today", secret: "returned-secret", label: "primary" }, + generated: "generated-id", + }), + }, + ], + }, + { + name: "local refs and allOf composition", + baseUrl, + spec: singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["local", "composed", "name"], + properties: { + local: { $ref: "#/$defs/ReadOnlyValue" }, + composed: { allOf: [{ $ref: "#/$defs/ReadOnlyValue" }] }, + name: { type: "string" }, + }, + $defs: { ReadOnlyValue: { type: "string", readOnly: true } }, + }, + }, + }, + }, + }, + "post", + ), + }, + { + name: "ref siblings", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/test": { + post: { + operationId: "test", + responses: { 200: { description: "Success" } }, + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["record"], + properties: { + record: { + $ref: "#/components/schemas/Base", + properties: { extra: { type: "string", readOnly: true }, note: { type: "string" } }, + required: ["extra", "note", "id"], + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + schemas: { + Base: { + type: "object", + required: ["id", "name"], + properties: { id: { type: "string", readOnly: true }, name: { type: "string" } }, + }, + }, + }, + }, + }, + { + name: "intermediate reference hops", + baseUrl, + spec: { + ...singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["secret", "name"], + properties: { secret: { $ref: "#/components/schemas/Middle" }, name: { type: "string" } }, + }, + }, + }, + }, + }, + "post", + ), + components: { + schemas: { Middle: { $ref: "#/components/schemas/Plain", readOnly: true }, Plain: { type: "string" } }, + }, + }, + }, + { + name: "cyclic components", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/test": { + post: { + operationId: "test", + responses: { 200: { description: "Success" } }, + requestBody: { + required: true, + content: { "application/json": { schema: { $ref: "#/components/schemas/Node" } } }, + }, + }, + }, + }, + components: { + schemas: { + Node: { + type: "object", + required: ["id", "name", "child"], + properties: { + id: { type: "string", readOnly: true }, + name: { type: "string" }, + child: { $ref: "#/components/schemas/Node" }, + }, + }, + }, + }, + }, + }, + { + name: "diamond references", + render: false, + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/test": { + post: { + operationId: "test", + responses: { 200: { description: "Success" } }, + requestBody: { + required: true, + content: { "application/json": { schema: { $ref: "#/components/schemas/C0" } } }, + }, + }, + }, + }, + components: { schemas: diamond }, + }, + }, + { + name: "hiding through cycles, one order", + baseUrl, + spec: { + ...singleOperation( + { requestBody: body({ a: { $ref: "#/components/schemas/Loop" }, b: { $ref: "#/components/schemas/Wrap" } }) }, + "post", + ), + components: { schemas: loop }, + }, + }, + { + name: "hiding through cycles, the other order", + baseUrl, + spec: { + ...singleOperation( + { requestBody: body({ a: { $ref: "#/components/schemas/Wrap" }, b: { $ref: "#/components/schemas/Loop" } }) }, + "post", + ), + components: { schemas: loop }, + }, + }, + { + name: "not, if and contains stay unprojected", + baseUrl, + spec: singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["record"], + properties: { + record: { + type: "object", + not: { required: ["secret"], properties: { secret: { type: "string", readOnly: true } } }, + if: { required: ["kind"], properties: { kind: { type: "string", readOnly: true } } }, + }, + }, + }, + }, + }, + }, + }, + "post", + ), + }, + { + name: "directions only in alternatives", + baseUrl, + spec: singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["choice", "pick"], + properties: { + choice: { anyOf: [{ type: "string", readOnly: true }, { type: "number" }] }, + pick: { oneOf: [{ type: "string", readOnly: true }, { type: "number" }] }, + }, + }, + }, + }, + }, + }, + "post", + ), + }, + { + name: "shadowed local $defs", + baseUrl, + spec: singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + additionalProperties: false, + required: ["record"], + $defs: { Value: { type: "string" } }, + properties: { + record: { + type: "object", + required: ["x"], + properties: { x: { $ref: "#/$defs/Value" } }, + $defs: { Value: { type: "string", readOnly: true } }, + }, + }, + }, + }, + }, + }, + }, + "post", + ), + }, + { + name: "directions inside parameters", + baseUrl, + spec: singleOperation({ + parameters: [ + { + name: "filter", + in: "query", + required: true, + schema: { + type: "object", + required: ["state", "id"], + properties: { state: { type: "string" }, id: { type: "string", readOnly: true } }, + }, + }, + ], + }), + }, + { + name: "required across allOf branches", + baseUrl, + spec: singleOperation( + { + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + required: ["id", "name"], + allOf: [ + { + type: "object", + required: ["id", "name"], + properties: { id: { type: "string", readOnly: true }, name: { type: "string" } }, + }, + ], + }, + }, + }, + }, + }, + "post", + ), + }, + { + name: "simple and form parameters", + baseUrl, + spec: { + openapi: "3.1.0", + paths: { + "/items/{keys}": { + get: { + operationId: "items", + parameters: [ + { name: "keys", in: "path", required: true, schema: { type: "array", items: { type: "string" } } }, + { name: "tags", in: "query", style: "form", explode: false, schema: { type: "array" } }, + { name: "filter", in: "query", style: "form", explode: true, schema: { type: "object" } }, + { name: "nullable", in: "query", required: true, schema: { type: ["string", "null"] } }, + { name: "constructor", in: "query", schema: { type: "string" } }, + { name: "meta", in: "header", style: "simple", explode: true, schema: { type: "object" } }, + { name: "pair", in: "header", schema: { type: "object" } }, + ], + responses: { 200: { description: "Success" } }, + }, + }, + }, + }, + calls: [ + { + tool: "items", + input: { + keys: ["a!", "b*"], + tags: ["x", "y"], + filter: { state: "open", page: 2 }, + nullable: null, + constructor: "safe", + meta: { a: "b", c: "d" }, + pair: { a: 1.5, b: true }, + }, + reply: ok, + }, + { tool: "items", input: { keys: [{}], nullable: 1 }, reply: ok }, + { tool: "items", input: { keys: ["k"] }, reply: ok }, + ], + }, + { + name: "exploded and deep-object query parameters", + baseUrl, + spec: singleOperation({ + parameters: [ + { name: "tags", in: "query", style: "form", explode: true, schema: { type: "array" } }, + { name: "filter", in: "query", style: "form", explode: true, schema: { type: "object" } }, + { name: "location", in: "query", style: "deepObject", explode: true, schema: { type: "object" } }, + ], + }), + calls: [ + { + tool: "test", + input: { + tags: ["first value", "second&value"], + filter: { state: "open now", page: 2 }, + location: { directory: "/tmp/a b", workspace: "work&1" }, + }, + reply: ok, + }, + { tool: "test", input: { tags: [{}] }, reply: ok }, + { tool: "test", input: { filter: { state: {} } }, reply: ok }, + { tool: "test", input: { location: { directory: [] } }, reply: ok }, + { tool: "test", input: { location: "flat" }, reply: ok }, + ], + }, + { + name: "unsupported encodings and malformed security", + baseUrl, + spec: { + openapi: "3.1.0", + security: [{ bearer: [] }], + paths: { + "/cookie": { + get: { + operationId: "cookie", + parameters: [{ name: "session", in: "cookie", schema: { type: "string" } }], + ...response, + }, + }, + "/reserved": { + get: { + operationId: "reserved", + parameters: [{ name: "query", in: "query", allowReserved: true, schema: { type: "string" } }], + ...response, + }, + }, + "/invalid-style": { + get: { + operationId: "invalidStyle", + parameters: [{ name: "query", in: "query", style: 42, schema: { type: "string" } }], + ...response, + }, + }, + "/security": { get: { operationId: "security", security: null, ...response } }, + "/matrix": { + get: { + operationId: "matrix", + parameters: [{ name: "m", in: "path", style: "matrix", required: true, schema: { type: "string" } }], + ...response, + }, + }, + "/deep": { + get: { + operationId: "deep", + parameters: [{ name: "d", in: "query", style: "deepObject", explode: false, schema: { type: "object" } }], + ...response, + }, + }, + "/content": { + get: { + operationId: "content", + parameters: [{ name: "c", in: "query", content: { "application/json": {} } }], + ...response, + }, + }, + "/neither": { get: { operationId: "neither", parameters: [{ name: "n", in: "query" }], ...response } }, + "/unknown": { + get: { operationId: "unknown", parameters: [{ name: "u", in: "body", schema: {} }], ...response }, + }, + "/unnamed": { get: { operationId: "unnamed", parameters: [{ in: "query", schema: {} }], ...response } }, + "/explode": { + get: { + operationId: "explode", + parameters: [{ name: "e", in: "query", explode: "yes", schema: {} }], + ...response, + }, + }, + }, + }, + }, + { + name: "prototype-named missing scheme", + baseUrl, + spec: singleOperation({ security: [JSON.parse('{"__proto__":[]}')] }), + }, + { + name: "bearer authentication", + baseUrl, + spec: { + ...singleOperation({ operationId: undefined }), + security: [{ bearer: [] }], + components: { securitySchemes: { bearer: { type: "http", scheme: "bearer" } } }, + }, + auth: { bearer: { type: "bearer", token: "secret" } }, + calls: [{ tool: "getTest", input: {}, reply: ok }], + }, + { + name: "prototype-named query key", + baseUrl, + spec: { + ...singleOperation({}), + security: [{ key: [] }], + components: { securitySchemes: { key: { type: "apiKey", in: "query", name: "__proto__" } } }, + }, + auth: { key: { type: "apiKey", value: "secret" } }, + calls: [{ tool: "test", input: {}, reply: ok }], + }, + { + name: "duplicate credentials", + baseUrl, + spec: { + ...singleOperation({}), + security: [{ first: [], second: [] }], + components: { + securitySchemes: { + first: { type: "apiKey", in: "header", name: "x-key" }, + second: { type: "apiKey", in: "header", name: "x-key" }, + }, + }, + }, + auth: { first: { type: "apiKey", value: "secret" }, second: { type: "apiKey", value: "secret" } }, + calls: [{ tool: "test", input: {}, reply: ok }], + }, + { + name: "cookie authentication", + baseUrl, + spec: { + ...singleOperation({}), + security: [{ key: [] }], + components: { securitySchemes: { key: { type: "apiKey", in: "cookie", name: "session" } } }, + }, + }, + { + name: "supported alternative", + baseUrl, + spec: { + ...singleOperation({}), + security: [{ cookie: [] }, { bearer: [] }], + components: { + securitySchemes: { + cookie: { type: "apiKey", in: "cookie", name: "session" }, + bearer: { type: "http", scheme: "bearer" }, + }, + }, + }, + auth: { bearer: { type: "bearer", token: "secret" } }, + calls: [{ tool: "test", input: {}, reply: ok }], + }, + { + name: "carriers", + baseUrl, + headers: { "X-Static": "static", Authorization: "overridden" }, + spec: { + ...singleOperation({ parameters: [{ name: "x-static", in: "header", schema: { type: "string" } }] }), + security: [{ basic: [], custom: [] }, { none: [] }], + components: { + securitySchemes: { + basic: { type: "http", scheme: "Basic" }, + custom: { type: "oauth2" }, + none: { type: "openIdConnect" }, + }, + }, + }, + auth: { + basic: { type: "basic", username: "user", password: "pässword" }, + custom: { type: "header", name: "X-Custom", value: "c" }, + }, + calls: [ + { tool: "test", input: {}, reply: ok }, + { tool: "test", input: { "x-static": "declared" }, reply: ok }, + ], + }, + { + name: "missing credentials", + baseUrl, + spec: { + ...singleOperation({}), + security: [{ a: [] }, { b: [] }], + components: { securitySchemes: { a: { type: "http", scheme: "bearer" }, b: { type: "oauth2" } } }, + }, + auth: { b: { type: "apiKey", value: "v" } }, + calls: [{ tool: "test", input: {}, reply: ok }], + }, + { + name: "server precedence", + spec: { + openapi: "3.1.0", + servers: [{ url: "https://document.example" }], + paths: { + "/op": { + get: { operationId: "op", servers: [{ url: "https://operation.example/v1/" }], ...response }, + }, + "/path": { servers: [{ url: "https://path.example" }], get: { operationId: "path", ...response } }, + "/doc": { get: { operationId: "doc", ...response } }, + "/templated": { + get: { operationId: "templated", servers: [{ url: "https://{region}.example" }], ...response }, + }, + "/relative": { get: { operationId: "relative", servers: [{ url: "/v1" }], ...response } }, + "/none": { get: { operationId: "none", servers: [], ...response } }, + }, + }, + calls: [ + { tool: "op", input: {}, reply: ok }, + { tool: "path", input: {}, reply: ok }, + { tool: "doc", input: {}, reply: ok }, + ], + }, + { + name: "base URL with a query", + spec: singleOperation({}), + baseUrl: "https://example.com/api?tenant=one", + }, + { name: "malformed base URL", spec: singleOperation({}), baseUrl: "https:/example.com" }, + { + name: "chained response refs", + baseUrl, + spec: { + ...singleOperation({ responses: { 200: { $ref: "#/components/responses/First" } } }), + components: { + responses: { + First: { $ref: "#/components/responses/Stream" }, + Stream: { content: { "text/event-stream": { schema: { type: "string" } } } }, + }, + }, + }, + }, + { + name: "binary response schema", + baseUrl, + spec: { + ...singleOperation({ + responses: { 200: { content: { "text/plain": { schema: { $ref: "#/components/schemas/File" } } } } }, + }), + components: { schemas: { File: { type: "string", format: "binary" } } }, + }, + }, + { + name: "unresolved response", + baseUrl, + spec: singleOperation({ responses: { 200: { $ref: "#/components/responses/Missing" } } }), + }, + { + name: "composite parameters before auth", + baseUrl, + spec: { + ...singleOperation({ + parameters: [{ name: "filter", in: "query", style: "form", explode: true, schema: { type: "object" } }], + }), + security: [{ bearer: [] }], + components: { securitySchemes: { bearer: { type: "http", scheme: "bearer" } } }, + }, + auth: { bearer: { type: "bearer", token: "secret" } }, + calls: [{ tool: "test", input: { filter: { value: [1] } }, reply: ok }], + }, + { + name: "JSON media types", + baseUrl, + spec: singleOperation( + { requestBody: { required: true, content: { "application/merge-patch+json": { schema: { type: "object" } } } } }, + "post", + ), + calls: [ + { tool: "test", input: { body: { name: "updated", n: 1.5, big: 1e21 } }, reply: ok }, + { tool: "test", input: {}, reply: ok }, + ], + }, + { + name: "oversized and malformed responses", + baseUrl, + spec: singleOperation({}), + calls: [ + { tool: "test", input: {}, reply: { contentLength: String(50 * 1024 * 1024 + 1), body: null } }, + { tool: "test", input: {}, reply: { contentType: "application/json", body: "{" } }, + { tool: "test", input: {}, reply: { contentType: "application/json; charset=utf-8", body: "" } }, + { tool: "test", input: {}, reply: { status: 503, contentType: "application/json", body: "null" } }, + { tool: "test", input: {}, reply: { status: 400, body: null } }, + ], + }, + { + name: "non-JSON responses and unions", + baseUrl, + spec: singleOperation({ + responses: { + 200: { description: "Text", content: { "text/plain": { schema: { type: "string" } } } }, + 204: { description: "Empty" }, + "2XX": { description: "Any", content: { "application/json": { schema: { type: "number" } } } }, + }, + }), + calls: [{ tool: "test", input: {}, reply: { contentType: "text/plain", body: "123" } }], + }, + { + name: "untyped JSON response", + baseUrl, + spec: singleOperation({ responses: { 200: { content: { "application/json": {} } } } }), + calls: [{ tool: "test", input: {}, reply: json({ dropped: true }) }], + }, + { + name: "cross-location collisions", + baseUrl, + spec: { + openapi: "3.1.0", + info: { title: "collision", version: "1.0.0" }, + paths: { + "/echo": { + post: { + operationId: "echo", + requestBody: { required: true, content: { "application/json": { schema: { type: "string" } } } }, + responses: { "204": { description: "Echoed" } }, + }, + }, + "/things/{id}": { + post: { + operationId: "things.update", + parameters: [ + { name: "id", in: "path", required: true, schema: { type: "string" } }, + { name: "id", in: "query", required: true, schema: { type: "string" } }, + { name: "path_id", in: "query", schema: { type: "string" } }, + { name: "id", in: "header", required: true, schema: { type: "string" } }, + ], + requestBody: { + required: true, + content: { + "application/json": { + schema: { + type: "object", + properties: { id: { type: "string" } }, + required: ["id"], + additionalProperties: false, + }, + }, + }, + }, + responses: { "204": { description: "Updated" } }, + }, + }, + }, + }, + calls: [ + { + tool: "things.update", + input: { path_id: "path", query_id: "query", path_id_2: "literal", header_id: "header", body_id: "body" }, + reply: { status: 204, body: null }, + }, + { tool: "things.update", input: { path_id: "path", query_id: "query", header_id: "header" }, reply: ok }, + { tool: "echo", input: { body: "hello" }, reply: { status: 204, body: null } }, + ], + }, + { + name: "bodies kept nested", + baseUrl, + spec: { + openapi: "3.1.0", + paths: Object.fromEntries( + [ + [ + "optional", + bodyOf( + { type: "object", properties: { name: { type: "string" } }, required: ["name"], additionalProperties: false }, + false, + ), + ], + ["dictionary", bodyOf({ type: "object", additionalProperties: { type: "string" } })], + [ + "composed", + bodyOf({ + type: "object", + allOf: [{ type: "object", properties: { name: { type: "string" } }, required: ["name"] }], + additionalProperties: false, + }), + ], + [ + "nullable", + bodyOf({ type: ["object", "null"], properties: { name: { type: "string" } }, additionalProperties: false }), + ], + ["text", { required: true, content: { "text/plain": { schema: { type: "string" } } } }], + ["flat", bodyOf({ type: "object", properties: { a: { type: "string" }, b: { type: "number" } }, required: ["a"], additionalProperties: false })], + ].map(([name, requestBody]) => [ + `/body/${name}`, + { post: { operationId: `body.${name}`, requestBody, responses: { "204": { description: "Accepted" } } } }, + ]), + ), + }, + calls: [ + { tool: "body.optional", input: {}, reply: { status: 204, body: null } }, + { tool: "body.flat", input: { a: "x" }, reply: { status: 204, body: null } }, + { tool: "body.flat", input: { b: 1 }, reply: { status: 204, body: null } }, + ], + }, + ] +} diff --git a/packages/codemode-rust/crates/psychoscript/src/lib.rs b/packages/codemode-rust/crates/psychoscript/src/lib.rs index 300632b5bfd5..a5dcb92e3a62 100644 --- a/packages/codemode-rust/crates/psychoscript/src/lib.rs +++ b/packages/codemode-rust/crates/psychoscript/src/lib.rs @@ -16,6 +16,7 @@ mod extension; mod hooks; mod host; mod object; +pub mod openapi; mod ops; mod program; mod promise; diff --git a/packages/codemode-rust/crates/psychoscript/src/openapi/invoke.rs b/packages/codemode-rust/crates/psychoscript/src/openapi/invoke.rs new file mode 100644 index 000000000000..dec5fe0f09e7 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/openapi/invoke.rs @@ -0,0 +1,597 @@ +//! Calling an operation, as the reference's `openapi/runtime.ts` does: the model's input becomes the URL, query, +//! headers and JSON body, authentication is resolved and applied, and the response becomes the tool's result. + +use std::sync::Arc; + +use super::spec::{Body, BodyMode, InputField, Location, SecurityRequirement, Style}; +use super::{ApiKeyLocation, AuthContext, AuthResolver, Credential, Operation, SecurityScheme}; +use crate::Json; +use crate::schema::js_stringify; +use crate::tool::{BoxFuture, ToolError}; +use crate::value::write_num; + +const MAX_ERROR_BODY_CHARS: usize = 1024; +const MAX_RESPONSE_BODY_BYTES: usize = 50 * 1024 * 1024; + +/// A request the generated tools send. Header names are lowercase; `url` includes the query string. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct HttpRequest { + pub method: String, + pub url: String, + pub headers: Vec<(String, String)>, + pub body: Option>, +} + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct HttpResponse { + pub status: u16, + pub headers: Vec<(String, String)>, + pub body: Vec, +} + +impl HttpResponse { + fn header(&self, name: &str) -> Option<&str> { + self.headers + .iter() + .find(|(k, _)| k.eq_ignore_ascii_case(name)) + .map(|(_, v)| v.as_str()) + } +} + +/// The HTTP transport the host provides, the counterpart of the reference's `HttpClient.HttpClient`. An error is a +/// transport failure. +pub trait HttpClient: Send + Sync { + fn execute(&self, request: HttpRequest) -> BoxFuture<'static, Result>; +} + +pub struct Plan { + pub operation: Operation, + pub url: String, + pub fields: Vec, + pub body: Option, + pub security: Vec, + pub schemes: Vec<(String, SecurityScheme)>, + pub auth: Option, + pub headers: Arc>, +} + +fn error(message: impl Into) -> ToolError { + ToolError::new(message) +} + +pub async fn invoke(plan: &Plan, client: &dyn HttpClient, input: Json) -> Result { + let empty = serde_json::Map::new(); + let value = input.as_object().unwrap_or(&empty); + let mut request = build_request(plan, value)?; + let (headers, query) = resolve_auth(plan).await?; + for (name, item) in query { + request.query.retain(|(k, _)| *k != name); + request.query.push((name, item)); + } + for (name, item) in headers { + set_header(&mut request.headers, &name, item); + } + let op = &plan.operation; + let response = client + .execute(request.finish()) + .await + .map_err(|_| error(format!("{} {} failed: transport error", op.method, op.path)))?; + let declared = response.header("content-length").and_then(parse_int); + if declared.is_some_and(|n| n > MAX_RESPONSE_BODY_BYTES as f64) + || response.body.len() > MAX_RESPONSE_BODY_BYTES + { + return Err(error(format!( + "{} {} response exceeds 50 MiB.", + op.method, op.path + ))); + } + let text = String::from_utf8_lossy(&response.body); + let text = text.strip_prefix('\u{feff}').unwrap_or(&text).to_owned(); + let media = response + .header("content-type") + .map(|m| m.split(';').next().unwrap_or("").trim().to_lowercase()); + let json = media + .as_deref() + .is_some_and(|m| m == "application/json" || m.ends_with("+json")); + let decoded: Option = if text.is_empty() { + Some(Json::Null) + } else if json { + serde_json::from_str(&text).ok() + } else { + None + }; + let parsed = if json { + decoded + .clone() + .unwrap_or_else(|| Json::String(text.clone())) + } else if text.is_empty() { + Json::Null + } else { + Json::String(text.clone()) + }; + if !(200..300).contains(&response.status) { + let rendered = match &parsed { + Json::String(s) => s.clone(), + other => js_stringify(other), + }; + let summary = if rendered.is_empty() || rendered == "null" { + "no response body".to_owned() + } else if rendered.encode_utf16().count() > MAX_ERROR_BODY_CHARS { + let mut cut = String::new(); + let mut units = 0; + for c in rendered.chars() { + units += c.len_utf16(); + if units > MAX_ERROR_BODY_CHARS { + break; + } + cut.push(c); + } + format!("{cut}...") + } else { + rendered + }; + return Err(error(format!( + "{} {} failed with HTTP {}: {summary}", + op.method, op.path, response.status + ))); + } + if json && decoded.is_none() { + return Err(error(format!( + "{} {} returned malformed JSON.", + op.method, op.path + ))); + } + Ok(parsed) +} + +/// `Number.parseInt(text, 10)` when it is a non-negative safe integer. +fn parse_int(text: &str) -> Option { + let t = text.trim_start(); + let digits: String = t.chars().take_while(char::is_ascii_digit).collect(); + let n: f64 = digits.parse().ok()?; + (n <= 9_007_199_254_740_991.0).then_some(n) +} + +struct Building { + method: String, + url: String, + query: Vec<(String, String)>, + headers: Vec<(String, String)>, + body: Option>, +} + +impl Building { + fn finish(self) -> HttpRequest { + let mut url = self.url; + if !self.query.is_empty() { + url.push('?'); + let pairs: Vec = self + .query + .iter() + .map(|(k, v)| format!("{}={}", form_encode(k), form_encode(v))) + .collect(); + url.push_str(&pairs.join("&")); + } + HttpRequest { + method: self.method, + url, + headers: self.headers, + body: self.body, + } + } +} + +fn set_header(headers: &mut Vec<(String, String)>, name: &str, value: String) { + let name = name.to_ascii_lowercase(); + match headers.iter_mut().find(|(k, _)| *k == name) { + Some(entry) => entry.1 = value, + None => headers.push((name, value)), + } +} + +fn build_request( + plan: &Plan, + input: &serde_json::Map, +) -> Result { + // Model input is checked before auth resolution can refresh credentials. + let url = build_url(plan, input)?; + if let Some(missing) = plan + .fields + .iter() + .find(|f| f.required && f.location != Location::Path && !input.contains_key(&f.input_name)) + { + let label = if missing.location == Location::Body { + "body field".to_owned() + } else { + format!("{} parameter", missing.location.name()) + }; + return Err(error(format!( + "Missing required {label} '{}'.", + missing.input_name + ))); + } + let mut request = Building { + method: plan.operation.method.clone(), + url, + query: Vec::new(), + headers: Vec::new(), + body: None, + }; + for field in plan.fields.iter().filter(|f| f.location == Location::Query) { + if let Some(item) = input.get(&field.input_name) { + request.query.extend(serialize_query(field, item)?); + } + } + for (k, v) in plan.headers.iter() { + set_header(&mut request.headers, k, v.clone()); + } + for field in plan + .fields + .iter() + .filter(|f| f.location == Location::Header) + { + if let Some(item) = input.get(&field.input_name) { + let serialized = serialize_simple(field, item, &|s| s.to_owned())?; + set_header(&mut request.headers, &field.name, serialized); + } + } + let mut set_body = |value: &Json, media: &str| { + request.body = Some(js_stringify(value).into_bytes()); + set_header(&mut request.headers, "content-type", media.to_owned()); + }; + match &plan.body { + Some(Body { + mode: BodyMode::Value, + media_type, + .. + }) => { + let field = plan.fields.iter().find(|f| f.location == Location::Body); + if let Some(body) = field.and_then(|f| input.get(&f.input_name)) { + set_body(body, media_type); + } + } + Some(Body { + mode: BodyMode::Object, + media_type, + required, + }) => { + let entries: serde_json::Map = plan + .fields + .iter() + .filter(|f| f.location == Location::Body) + .filter_map(|f| { + input + .get(&f.input_name) + .map(|v| (f.name.clone(), v.clone())) + }) + .collect(); + if *required || !entries.is_empty() { + set_body(&Json::Object(entries), media_type); + } + } + None => {} + } + Ok(request) +} + +/// The headers and query parameters of the first security alternative whose credentials all resolve. +async fn resolve_auth( + plan: &Plan, +) -> Result<(Vec<(String, String)>, Vec<(String, String)>), ToolError> { + if plan.security.is_empty() { + return Ok((Vec::new(), Vec::new())); + } + let mut unavailable: Vec = Vec::new(); + 'alternatives: for requirement in &plan.security { + if requirement.is_empty() { + return Ok((Vec::new(), Vec::new())); + } + let mut credentials = Vec::new(); + for (name, scopes) in requirement { + let scheme = plan.schemes.iter().find(|(n, _)| n == name).map(|(_, s)| s); + let (Some(scheme), Some(auth)) = (scheme, &plan.auth) else { + unavailable.push(name.clone()); + continue 'alternatives; + }; + let context = AuthContext { + name: name.clone(), + definition: scheme.clone(), + scopes: scopes.clone(), + operation: plan.operation.clone(), + }; + match auth(&context).await? { + Some(credential) => credentials.push((name.clone(), scheme.clone(), credential)), + None => { + unavailable.push(name.clone()); + continue 'alternatives; + } + } + } + return apply_credentials(&credentials); + } + let mut names: Vec = Vec::new(); + for n in unavailable { + if !names.contains(&n) { + names.push(n); + } + } + Err(error(format!( + "{} {} requires authentication; no credential available for: {}.", + plan.operation.method, + plan.operation.path, + names.join(", ") + ))) +} + +type Carriers = (Vec<(String, String)>, Vec<(String, String)>); + +fn apply_credentials( + credentials: &[(String, SecurityScheme, Credential)], +) -> Result { + let mut headers: Vec<(String, String)> = Vec::new(); + let mut query: Vec<(String, String)> = Vec::new(); + fn add( + target: &mut Vec<(String, String)>, + carrier: &str, + name: String, + value: String, + ) -> Result<(), ToolError> { + if target.iter().any(|(k, _)| *k == name) { + return Err(error(format!( + "Authentication resolves multiple credentials for {carrier} '{name}'." + ))); + } + target.push((name, value)); + Ok(()) + } + for (name, definition, credential) in credentials { + match credential { + Credential::Bearer { token } => add( + &mut headers, + "header", + "authorization".into(), + format!("Bearer {token}"), + )?, + Credential::Basic { username, password } => add( + &mut headers, + "header", + "authorization".into(), + format!( + "Basic {}", + base64(format!("{username}:{password}").as_bytes()) + ), + )?, + Credential::Header { name, value } => { + add(&mut headers, "header", name.to_lowercase(), value.clone())? + } + Credential::ApiKey { value } => { + let SecurityScheme::ApiKey { + name: parameter, + location, + } = definition + else { + return Err(error(format!( + "Security scheme '{name}' is not an apiKey scheme; resolve a bearer, basic, or header credential for it." + ))); + }; + match location { + ApiKeyLocation::Cookie => { + return Err(error(format!( + "Cookie authentication '{name}' is not supported." + ))); + } + ApiKeyLocation::Header => add( + &mut headers, + "header", + parameter.to_lowercase(), + value.clone(), + )?, + ApiKeyLocation::Query => { + add(&mut query, "query", parameter.clone(), value.clone())? + } + } + } + } + } + Ok((headers, query)) +} + +fn build_url(plan: &Plan, input: &serde_json::Map) -> Result { + let mut url = plan.url.clone(); + for field in plan.fields.iter().filter(|f| f.location == Location::Path) { + let Some(item) = input.get(&field.input_name) else { + return Err(error(format!( + "Missing required path parameter '{}'.", + field.input_name + ))); + }; + let value = serialize_simple(field, item, &encode_uri_component)?; + // URL normalization collapses encoded `.` and `..`, which could retarget the request. + if value.is_empty() || value == "." || value == ".." { + return Err(error(format!( + "Invalid path parameter '{}'.", + field.input_name + ))); + } + url = url.replace(&format!("{{{}}}", field.name), &value); + } + if super::spec::has_template(&url) { + let start = url + .match_indices('{') + .map(|(i, _)| i) + .find(|&i| { + let rest = &url[i + 1..]; + matches!(rest.find(['{', '}']), Some(j) if j > 0 && rest.as_bytes()[j] == b'}') + }) + .unwrap_or(0); + let end = url[start..].find('}').map_or(url.len(), |j| start + j + 1); + return Err(error(format!( + "Unresolved path parameter {}.", + &url[start..end] + ))); + } + Ok(url) +} + +/// JavaScript's `String(value)` for a JSON scalar. +fn js_string(v: &Json) -> String { + match v { + Json::String(s) => s.clone(), + Json::Number(n) => { + let mut out = String::new(); + write_num(&mut out, n.as_f64().unwrap_or(f64::NAN)); + out + } + other => js_stringify(other), + } +} + +fn is_scalar(v: &Json) -> bool { + !matches!(v, Json::Array(_) | Json::Object(_)) +} + +fn serialize_simple( + field: &InputField, + value: &Json, + encode: &dyn Fn(&str) -> String, +) -> Result { + let scalar = |item: &Json| { + if is_scalar(item) { + Ok(encode(&js_string(item))) + } else { + Err(error(format!( + "Parameter '{}' contains an unsupported nested value.", + field.input_name + ))) + } + }; + match value { + Json::Array(items) => Ok(items + .iter() + .map(scalar) + .collect::, _>>()? + .join(",")), + Json::Object(map) => { + let mut parts = Vec::new(); + for (name, item) in map { + let rendered = scalar(item)?; + if field.explode { + parts.push(format!("{}={rendered}", encode(name))); + } else { + parts.push(encode(name)); + parts.push(rendered); + } + } + Ok(parts.join(",")) + } + other => scalar(other), + } +} + +fn serialize_query(field: &InputField, value: &Json) -> Result, ToolError> { + if field.style == Some(Style::DeepObject) { + let Json::Object(map) = value else { + return Err(error(format!( + "Deep-object parameter '{}' must be an object.", + field.input_name + ))); + }; + let mut out = Vec::new(); + for (name, item) in map { + if !is_scalar(item) { + return Err(error(format!( + "Deep-object parameter '{}' contains an unsupported nested value.", + field.input_name + ))); + } + out.push((format!("{}[{name}]", field.name), js_string(item))); + } + return Ok(out); + } + match value { + Json::Array(items) if field.explode => items + .iter() + .map(|item| { + if is_scalar(item) { + Ok((field.name.clone(), js_string(item))) + } else { + Err(error(format!( + "Parameter '{}' contains an unsupported nested value.", + field.input_name + ))) + } + }) + .collect(), + Json::Object(map) if field.explode => map + .iter() + .map(|(name, item)| { + if is_scalar(item) { + Ok((name.clone(), js_string(item))) + } else { + Err(error(format!( + "Query parameter '{}' contains an unsupported nested value.", + field.input_name + ))) + } + }) + .collect(), + other => Ok(vec![( + field.name.clone(), + serialize_simple(field, other, &|s| s.to_owned())?, + )]), + } +} + +/// `encodeURIComponent`, with `!'()*` also encoded as the reference does for path segments. +fn encode_uri_component(s: &str) -> String { + let mut out = String::new(); + for b in s.bytes() { + if b.is_ascii_alphanumeric() || b"-_.~".contains(&b) { + out.push(b as char); + } else { + out.push_str(&format!("%{b:02X}")); + } + } + out +} + +/// The `application/x-www-form-urlencoded` serializer `URLSearchParams` uses. +fn form_encode(s: &str) -> String { + let mut out = String::new(); + for b in s.bytes() { + match b { + b' ' => out.push('+'), + b if b.is_ascii_alphanumeric() || b"*-._".contains(&b) => out.push(b as char), + b => out.push_str(&format!("%{b:02X}")), + } + } + out +} + +fn base64(bytes: &[u8]) -> String { + const TABLE: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + let mut out = String::new(); + for chunk in bytes.chunks(3) { + let n = (u32::from(chunk[0]) << 16) + | (u32::from(*chunk.get(1).unwrap_or(&0)) << 8) + | u32::from(*chunk.get(2).unwrap_or(&0)); + for i in 0..4 { + if i <= chunk.len() { + out.push(TABLE[((n >> (18 - 6 * i)) & 63) as usize] as char); + } else { + out.push('='); + } + } + } + out +} + +#[cfg(test)] +mod tests { + #[test] + fn encodings_match_javascript() { + assert_eq!(super::encode_uri_component("a!b*"), "a%21b%2A"); + assert_eq!(super::form_encode("/tmp/a b&c"), "%2Ftmp%2Fa+b%26c"); + assert_eq!(super::base64(b"user:p\xc3\xa4ss"), "dXNlcjpww6Rzcw=="); + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/openapi/mod.rs b/packages/codemode-rust/crates/psychoscript/src/openapi/mod.rs new file mode 100644 index 000000000000..7c44fd33d52a --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/openapi/mod.rs @@ -0,0 +1,281 @@ +//! OpenAPI tools, the counterpart of the reference's `OpenAPI.fromSpec`: one tool per representable OpenAPI 3.x +//! operation, with dotted `operationId`s as namespaces. Authentication is resolved by the host and never shown to the +//! model, and requests go through an [`HttpClient`] the host implements. Operations that cannot be represented are +//! reported in [`Generated::skipped`] with the reference's reasons. + +mod invoke; +mod normalize; +mod project; +mod spec; + +use std::collections::HashSet; +use std::sync::Arc; + +use crate::Json; +use crate::schema::Schema; +use crate::tool::{BoxFuture, Tool, ToolError}; + +pub use invoke::{HttpClient, HttpRequest, HttpResponse}; + +/// The operation identity handed to auth resolution and errors. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Operation { + pub operation_id: Option, + pub method: String, + pub path: String, + pub summary: Option, + pub description: Option, +} + +/// A resolved security scheme from `components.securitySchemes`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum SecurityScheme { + ApiKey { + name: String, + location: ApiKeyLocation, + }, + Http { + scheme: String, + }, + OAuth2, + OpenIdConnect, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ApiKeyLocation { + Header, + Query, + Cookie, +} + +/// Credential material from the host's resolver. `ApiKey` uses its scheme's carrier; `Header` supports nonstandard +/// schemes. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Credential { + Bearer { token: String }, + Basic { username: String, password: String }, + ApiKey { value: String }, + Header { name: String, value: String }, +} + +/// What a credential is resolved for. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct AuthContext { + pub name: String, + pub definition: SecurityScheme, + pub scopes: Vec, + pub operation: Operation, +} + +/// Resolves credentials at call time. `Ok(None)` tries the next alternative requirement; an error aborts the call. +pub type AuthResolver = Arc< + dyn Fn(&AuthContext) -> BoxFuture<'static, Result, ToolError>> + Send + Sync, +>; + +/// The counterpart of the reference's `OpenAPI.Options`, with the HTTP client the generated tools call. +#[derive(Clone)] +pub struct Options { + /// A parsed OpenAPI 3.x document. + pub spec: Json, + /// Overrides every document, path and operation `servers`. Needed when no absolute server URL applies. + pub base_url: Option, + pub auth: Option, + /// Static headers on every request. Not model-visible; declared header parameters may override them, and + /// authentication always wins. + pub headers: Vec<(String, String)>, + pub client: Arc, +} + +impl Options { + pub fn new(spec: Json, client: Arc) -> Self { + Self { + spec, + base_url: None, + auth: None, + headers: Vec::new(), + client, + } + } + + pub fn base_url(mut self, url: impl Into) -> Self { + self.base_url = Some(url.into()); + self + } + + /// Credentials resolved by a function that decides at once. + pub fn auth( + self, + resolve: impl Fn(&AuthContext) -> Result, ToolError> + Send + Sync + 'static, + ) -> Self { + self.auth_async(move |ctx| std::future::ready(resolve(ctx))) + } + + pub fn auth_async( + mut self, + resolve: impl Fn(&AuthContext) -> F + Send + Sync + 'static, + ) -> Self + where + F: std::future::Future, ToolError>> + Send + 'static, + { + self.auth = Some(Arc::new(move |ctx| Box::pin(resolve(ctx)))); + self + } + + pub fn header(mut self, name: impl Into, value: impl Into) -> Self { + self.headers.push((name.into(), value.into())); + self + } +} + +/// An operation that could not be represented as a tool, and why. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Skipped { + pub method: String, + pub path: String, + pub reason: String, +} + +/// The generated tools by dotted path, for the host to register under a namespace of its choice, and what was +/// skipped. +pub struct Generated { + pub tools: Vec<(String, Tool)>, + pub skipped: Vec, +} + +const METHODS: [&str; 8] = [ + "get", "put", "post", "delete", "options", "head", "patch", "trace", +]; + +/// Builds one tool per representable operation of an OpenAPI 3.x document. +pub fn from_spec(options: Options) -> Generated { + let doc = &options.spec; + let mut projector = project::Projector::new(doc); + let schemes = spec::security_schemes(doc); + let default_security = spec::security_requirements(doc.get("security")); + let request_definitions = + spec::component_definitions(&mut projector, project::Direction::Request); + let response_definitions = if projector.directional() { + spec::component_definitions(&mut projector, project::Direction::Response) + } else { + request_definitions.clone() + }; + let mut used: HashSet = HashSet::new(); + let mut namespaces: HashSet = HashSet::new(); + let mut skipped = Vec::new(); + let mut tools: Vec<(String, Tool)> = Vec::new(); + let empty = serde_json::Map::new(); + let paths = doc.get("paths").and_then(Json::as_object).unwrap_or(&empty); + let headers: Arc> = Arc::new( + options + .headers + .iter() + .map(|(k, v)| (k.to_ascii_lowercase(), v.clone())) + .collect(), + ); + for (path, path_value) in paths { + let Some(path_item) = path_value.as_object() else { + continue; + }; + for (method, operation_value) in path_item { + if !METHODS.contains(&method.as_str()) { + continue; + } + let Some(operation_object) = operation_value.as_object() else { + continue; + }; + let operation = Operation { + operation_id: spec::non_empty(operation_object.get("operationId")) + .map(str::to_owned), + method: method.to_uppercase(), + path: path.clone(), + summary: spec::non_empty(operation_object.get("summary")).map(str::to_owned), + description: spec::non_empty(operation_object.get("description")) + .map(str::to_owned), + }; + let mut skip = |reason: String| { + skipped.push(Skipped { + method: operation.method.clone(), + path: path.clone(), + reason, + }) + }; + let output = match spec::operation_output( + &mut projector, + operation_value, + &response_definitions, + ) { + Ok(o) => o, + Err(reason) => { + skip(reason); + continue; + } + }; + let base_url = match &options.base_url { + Some(url) => spec::validate_base_url(url), + None if operation_object.contains_key("servers") => { + spec::spec_server_url(operation_value) + } + None if path_item.contains_key("servers") => spec::spec_server_url(path_value), + None => spec::spec_server_url(doc), + }; + let base_url = match base_url { + Ok(u) => u, + Err(reason) => { + skip(reason); + continue; + } + }; + let input = match spec::operation_input(&mut projector, path_value, operation_value) { + Ok(i) => i, + Err(reason) => { + skip(reason); + continue; + } + }; + let security = match spec::operation_security_requirements( + operation_object.get("security"), + &default_security, + &schemes, + ) { + Ok(s) => s, + Err(reason) => { + skip(reason); + continue; + } + }; + let input_schema = spec::input_schema(&input.fields, &request_definitions); + let plan = Arc::new(invoke::Plan { + url: format!("{}{path}", base_url.trim_end_matches('/')), + operation: operation.clone(), + fields: input.fields, + body: input.body, + security, + schemes: schemes.clone(), + auth: options.auth.clone(), + headers: headers.clone(), + }); + let segments = spec::operation_path(method, path, operation_value, &used, &namespaces); + used.insert(segments.join(".")); + for i in 0..segments.len().saturating_sub(1) { + namespaces.insert(segments[..=i].join(".")); + } + let description = operation + .description + .clone() + .or_else(|| operation.summary.clone()) + .unwrap_or_else(|| format!("{} {path}", operation.method)); + let client = options.client.clone(); + let mut tool = Tool::new_async(description, move |input, _| { + let plan = plan.clone(); + let client = client.clone(); + async move { invoke::invoke(&plan, client.as_ref(), input).await } + }) + .input(Schema::render_only(input_schema)); + if let Some(output) = output { + tool = tool.output(Schema::render_only(output)); + } + tools.push((segments.join("."), tool)); + } + } + Generated { tools, skipped } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/openapi/normalize.rs b/packages/codemode-rust/crates/psychoscript/src/openapi/normalize.rs new file mode 100644 index 000000000000..e817a8d416a4 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/openapi/normalize.rs @@ -0,0 +1,264 @@ +//! OpenAPI schemas as JSON Schema 2020-12, the way the reference normalizes them with Effect's +//! `JsonSchema.fromSchemaOpenApi3_0` and `fromSchemaOpenApi3_1`: component references become `#/$defs/...`, +//! `nullable` becomes a `null` type, boolean exclusive bounds become numeric ones, and `example` becomes `examples`. +//! The result's `$defs` move to the end of the document. + +use crate::Json; + +const META_OPEN_API_3_1: &str = "https://spec.openapis.org/oas/3.1/dialect/base"; +const META_DRAFT_2020_12: &str = "https://json-schema.org/draft/2020-12/schema"; + +/// A schema of the document as a JSON Schema 2020-12 document. +pub fn normalize(doc: &Json, value: &Json) -> Json { + if !value.is_object() { + return Json::Object(Default::default()); + } + let v30 = doc + .get("openapi") + .and_then(Json::as_str) + .is_some_and(|v| !v.is_empty() && v.starts_with("3.0")); + let converted = if v30 { + convert_30(value) + } else { + let root = creates_resource(value.get("$id")); + walk_31(value, false, true, root) + }; + let Json::Object(mut schema) = converted else { + return converted; + }; + let defs = schema.shift_remove("$defs"); + match defs { + Some(Json::Object(defs)) if !defs.is_empty() => { + schema.insert("$defs".into(), Json::Object(defs)); + } + Some(Json::Array(items)) if !items.is_empty() => { + let defs = items + .into_iter() + .enumerate() + .map(|(i, v)| (i.to_string(), v)) + .collect(); + schema.insert("$defs".into(), Json::Object(defs)); + } + _ => {} + } + Json::Object(schema) +} + +fn creates_resource(id: Option<&Json>) -> bool { + matches!(id, Some(Json::String(s)) if !s.is_empty() && !s.starts_with('#')) +} + +/// `#/components/schemas/X` → `#/$defs/X`; anything else is kept. +fn rewrite_reference(reference: &str) -> String { + let Some(path) = parse_fragment(reference) else { + return reference.to_owned(); + }; + if path.len() >= 2 && path[0] == "components" && path[1] == "schemas" { + let mut out = String::from("#/$defs"); + for token in &path[2..] { + out.push('/'); + out.push_str(&format_token(token)); + } + return out; + } + reference.to_owned() +} + +fn parse_fragment(reference: &str) -> Option> { + let encoded = reference.strip_prefix('#')?; + let pointer = percent_decode(encoded)?; + if pointer.is_empty() { + return Some(Vec::new()); + } + let rest = pointer.strip_prefix('/')?; + Some( + rest.split('/') + .map(|t| t.replace("~1", "/").replace("~0", "~")) + .collect(), + ) +} + +fn percent_decode(s: &str) -> Option { + let bytes = s.as_bytes(); + let mut out = Vec::with_capacity(bytes.len()); + let mut i = 0; + while i < bytes.len() { + if bytes[i] == b'%' { + out.push(u8::from_str_radix(s.get(i + 1..i + 3)?, 16).ok()?); + i += 3; + } else { + out.push(bytes[i]); + i += 1; + } + } + String::from_utf8(out).ok() +} + +/// A pointer token escaped and URI-encoded the way `encodeURI` leaves it, with `#` encoded. +fn format_token(token: &str) -> String { + let escaped = token.replace('~', "~0").replace('/', "~1"); + let mut out = String::new(); + for b in escaped.bytes() { + let keep = b.is_ascii_alphanumeric() || b";,/?:@&=+$-_.!~*'()".contains(&b); + if keep { + out.push(b as char); + } else { + out.push_str(&format!("%{b:02X}")); + } + } + out +} + +enum Kind { + Map, + Array, + Schema, +} + +fn subschema_kind(key: &str) -> Option { + match key { + "$defs" | "properties" | "patternProperties" | "dependentSchemas" => Some(Kind::Map), + "allOf" | "anyOf" | "oneOf" | "prefixItems" => Some(Kind::Array), + "not" + | "additionalProperties" + | "propertyNames" + | "unevaluatedProperties" + | "items" + | "contains" + | "unevaluatedItems" + | "if" + | "then" + | "else" + | "contentSchema" => Some(Kind::Schema), + _ => None, + } +} + +fn walk_31(node: &Json, inherited: bool, is_root: bool, root_resource: bool) -> Json { + let Json::Object(map) = node else { + return node.clone(); + }; + let embedded = inherited || (!is_root && creates_resource(map.get("$id"))); + let mut out = serde_json::Map::new(); + for (key, value) in map { + let transformed = match subschema_kind(key) { + Some(Kind::Map) => match value { + Json::Object(m) => Json::Object( + m.iter() + .map(|(k, v)| (k.clone(), walk_31(v, embedded, false, root_resource))) + .collect(), + ), + _ => value.clone(), + }, + Some(Kind::Array) => match value { + Json::Array(items) => Json::Array( + items + .iter() + .map(|v| walk_31(v, embedded, false, root_resource)) + .collect(), + ), + _ => value.clone(), + }, + Some(Kind::Schema) => walk_31(value, embedded, false, root_resource), + None => value.clone(), + }; + out.insert(key.clone(), transformed); + } + if !root_resource && !embedded { + for key in ["$ref", "$dynamicRef"] { + if let Some(Json::String(r)) = out.get(key) { + let rewritten = rewrite_reference(r); + out.insert(key.into(), Json::String(rewritten)); + } + } + } + if let Some(Json::String(s)) = out.get("$schema") + && (s == META_OPEN_API_3_1 || *s == format!("{META_OPEN_API_3_1}#")) + { + out.insert("$schema".into(), Json::String(META_DRAFT_2020_12.into())); + } + if let Some(example) = out.get("example").cloned() { + match out.get("examples") { + None => { + out.insert("examples".into(), Json::Array(vec![example])); + out.shift_remove("example"); + } + Some(Json::Array(examples)) => { + let mut all = vec![example]; + all.extend(examples.iter().cloned()); + out.insert("examples".into(), Json::Array(all)); + out.shift_remove("example"); + } + Some(_) => {} + } + } + Json::Object(out) +} + +fn convert_30(node: &Json) -> Json { + let Json::Object(source) = node else { + return node.clone(); + }; + let mut out = serde_json::Map::new(); + if let Some(Json::String(r)) = source.get("$ref") { + out.insert("$ref".into(), Json::String(rewrite_reference(r))); + return Json::Object(out); + } + let nullable = source.get("nullable") == Some(&Json::Bool(true)); + let nullable_all_of = nullable + && !matches!(source.get("type"), Some(Json::String(_))) + && !source.contains_key("anyOf") + && matches!(source.get("allOf"), Some(Json::Array(a)) if a.len() == 1); + for (key, value) in source { + if nullable_all_of && key == "allOf" { + let first = value + .as_array() + .and_then(|a| a.first()) + .map(convert_30) + .unwrap_or(Json::Null); + out.insert( + "anyOf".into(), + Json::Array(vec![first, serde_json::json!({ "type": "null" })]), + ); + continue; + } + let converted = match (key.as_str(), value) { + ("properties", Json::Object(m)) => { + Json::Object(m.iter().map(|(k, v)| (k.clone(), convert_30(v))).collect()) + } + ("properties", other) => other.clone(), + ("allOf" | "anyOf" | "oneOf", Json::Array(items)) => { + Json::Array(items.iter().map(convert_30).collect()) + } + ("allOf" | "anyOf" | "oneOf", other) => other.clone(), + ("not" | "items" | "additionalProperties", v) => convert_30(v), + ("example", v) => { + out.insert("examples".into(), Json::Array(vec![v.clone()])); + continue; + } + ("nullable" | "exclusiveMinimum" | "exclusiveMaximum", _) => continue, + (_, v) => v.clone(), + }; + out.insert(key.clone(), converted); + } + for (bound, exclusive_key) in [ + ("minimum", "exclusiveMinimum"), + ("maximum", "exclusiveMaximum"), + ] { + match source.get(exclusive_key) { + Some(Json::Bool(true)) if source.get(bound).is_some_and(Json::is_number) => { + let b = source[bound].clone(); + out.insert(exclusive_key.into(), b); + out.shift_remove(bound); + } + Some(Json::Bool(_)) | None => {} + Some(other) => { + out.insert(exclusive_key.into(), other.clone()); + } + } + } + if nullable && let Some(Json::String(t)) = source.get("type") { + out.insert("type".into(), serde_json::json!([t, "null"])); + } + Json::Object(out) +} diff --git a/packages/codemode-rust/crates/psychoscript/src/openapi/project.rs b/packages/codemode-rust/crates/psychoscript/src/openapi/project.rs new file mode 100644 index 000000000000..21be557ef46e --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/openapi/project.rs @@ -0,0 +1,309 @@ +//! The model-facing directional projection, as in the reference's `spec.ts`: request schemas omit `readOnly` +//! properties, response schemas omit `writeOnly` ones, and `required` stays consistent. Runtime values pass through +//! unchanged. +//! +//! Hidden-ness and hidden names are memoized per schema (by its place in the document) and direction, and +//! reference cycles are solved with Tarjan's strongly connected components, so the results do not depend on the +//! order schemas are visited in. + +use std::collections::{HashMap, HashSet}; + +use super::spec::{own, resolve_pointer}; +use crate::Json; + +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum Direction { + Request, + Response, +} + +impl Direction { + fn keyword(self) -> &'static str { + match self { + Direction::Request => "readOnly", + Direction::Response => "writeOnly", + } + } + + fn index(self) -> usize { + self as usize + } +} + +/// A schema and the root its local `$defs` pointers resolve against. +#[derive(Clone, Copy)] +pub struct Resource<'a> { + pub value: &'a Json, + pub root: &'a Json, +} + +type Key = *const Json; + +struct Solver { + values: HashMap, + pending: HashMap, + stack: Vec, +} + +impl Default for Solver { + fn default() -> Self { + Self { + values: HashMap::new(), + pending: HashMap::new(), + stack: Vec::new(), + } + } +} + +pub struct Projector<'a> { + pub doc: &'a Json, + directional: bool, + hidden: [Solver; 2], + names: [Solver>; 2], +} + +const NESTED: [&str; 6] = [ + "items", + "additionalProperties", + "unevaluatedProperties", + "propertyNames", + "then", + "else", +]; +const NESTED_LISTS: [&str; 3] = ["anyOf", "oneOf", "prefixItems"]; +const NESTED_MAPS: [&str; 4] = [ + "patternProperties", + "dependentSchemas", + "$defs", + "definitions", +]; + +fn contains_directional(v: &Json) -> bool { + match v { + Json::Array(items) => items.iter().any(contains_directional), + Json::Object(m) => { + m.get("readOnly") == Some(&Json::Bool(true)) + || m.get("writeOnly") == Some(&Json::Bool(true)) + || m.values().any(contains_directional) + } + _ => false, + } +} + +/// Solves one value through the strongly connected components of the reference graph; see the module docs. +macro_rules! solve { + ($self:ident, $field:ident, $d:expr, $key:expr, $provisional:expr, $scope:expr, |$inner:ident| $compute:expr) => {{ + let key = $key; + let d = $d.index(); + if let Some(v) = $self.$field[d].values.get(&key) { + v.clone() + } else if let Some(&pending) = $self.$field[d].pending.get(&key) { + *$scope = (*$scope).min(pending); + $provisional + } else { + let index = $self.$field[d].pending.len(); + let base = $self.$field[d].stack.len(); + $self.$field[d].pending.insert(key, index); + $self.$field[d].stack.push(key); + let mut lowlink = usize::MAX; + let $inner: &mut usize = &mut lowlink; + let value = $compute; + if lowlink < index { + *$scope = (*$scope).min(lowlink); + value + } else { + let members: Vec = $self.$field[d].stack.drain(base..).collect(); + for member in members { + $self.$field[d].pending.remove(&member); + $self.$field[d].values.insert(member, value.clone()); + } + value + } + } + }}; +} + +impl<'a> Projector<'a> { + pub fn new(doc: &'a Json) -> Self { + Self { + doc, + directional: contains_directional(doc), + hidden: Default::default(), + names: Default::default(), + } + } + + /// Whether the document has any directional keyword; most have none, and skip projection entirely. + pub fn directional(&self) -> bool { + self.directional + } + + /// Follows one `$ref` hop. Local `$defs`/`definitions` pointers resolve against the schema being projected; + /// other pointers rebase onto the target. + fn resolve_resource(&self, r: Resource<'a>) -> Resource<'a> { + let Some(reference) = r + .value + .as_object() + .and_then(|m| super::spec::non_empty(m.get("$ref"))) + else { + return r; + }; + if !reference.starts_with("#/") { + return r; + } + let local = reference.starts_with("#/$defs/") || reference.starts_with("#/definitions/"); + let Some(target) = resolve_pointer(if local { r.root } else { self.doc }, reference) else { + return r; + }; + Resource { + value: target, + root: if local { r.root } else { target }, + } + } + + fn is_hidden(&mut self, r: Resource<'a>, d: Direction, scope: &mut usize) -> bool { + let Some(map) = r.value.as_object() else { + return false; + }; + if map.get(d.keyword()) == Some(&Json::Bool(true)) { + return true; + } + let key: Key = r.value; + solve!(self, hidden, d, key, false, scope, |inner| { + let mut hidden = false; + if let Some(Json::Array(all)) = own(map, "allOf") { + for item in all { + if self.is_hidden(Resource { value: item, ..r }, d, inner) { + hidden = true; + break; + } + } + } + if !hidden { + let target = self.resolve_resource(r); + hidden = !std::ptr::eq(target.value, r.value) && self.is_hidden(target, d, inner); + } + hidden + }) + } + + fn hidden_names( + &mut self, + r: Resource<'a>, + d: Direction, + scope: &mut usize, + ) -> HashSet { + let Some(map) = r.value.as_object() else { + return HashSet::new(); + }; + let key: Key = r.value; + solve!(self, names, d, key, HashSet::new(), scope, |inner| { + let mut names = HashSet::new(); + if let Some(Json::Object(props)) = own(map, "properties") { + for (name, property) in props { + let mut fresh = usize::MAX; + if self.is_hidden( + Resource { + value: property, + ..r + }, + d, + &mut fresh, + ) { + names.insert(name.clone()); + } + } + } + if let Some(Json::Array(all)) = own(map, "allOf") { + for item in all { + names.extend(self.hidden_names(Resource { value: item, ..r }, d, inner)); + } + } + let target = self.resolve_resource(r); + if !std::ptr::eq(target.value, r.value) { + names.extend(self.hidden_names(target, d, inner)); + } + names + }) + } + + /// The schema with hidden properties removed, recursively; `excluded` are names hidden by `allOf` siblings. + pub fn directional_schema( + &mut self, + r: Resource<'a>, + d: Direction, + excluded: &HashSet, + ) -> Json { + let Some(map) = r.value.as_object() else { + return r.value.clone(); + }; + let mut hidden = excluded.clone(); + let mut fresh = usize::MAX; + hidden.extend(self.hidden_names(r, d, &mut fresh)); + let none = HashSet::new(); + let mut out = serde_json::Map::new(); + for (key, item) in map { + let projected = match (key.as_str(), item) { + ("properties", Json::Object(props)) => Json::Object( + props + .iter() + .filter(|(name, _)| !hidden.contains(*name)) + .map(|(name, p)| { + ( + name.clone(), + self.directional_schema(Resource { value: p, ..r }, d, &none), + ) + }) + .collect(), + ), + ("required", Json::Array(names)) => Json::Array( + names + .iter() + .filter(|n| n.as_str().is_none_or(|n| !hidden.contains(n))) + .cloned() + .collect(), + ), + // allOf branches share one object; hidden names apply across every branch. + ("allOf", Json::Array(all)) => Json::Array( + all.iter() + .map(|e| self.directional_schema(Resource { value: e, ..r }, d, &hidden)) + .collect(), + ), + (k, _) if NESTED.contains(&k) => { + self.directional_schema(Resource { value: item, ..r }, d, &none) + } + (k, Json::Array(list)) if NESTED_LISTS.contains(&k) => Json::Array( + list.iter() + .map(|e| self.directional_schema(Resource { value: e, ..r }, d, &none)) + .collect(), + ), + (k, Json::Object(m)) if NESTED_MAPS.contains(&k) => Json::Object( + m.iter() + .map(|(n, e)| { + ( + n.clone(), + self.directional_schema(Resource { value: e, ..r }, d, &none), + ) + }) + .collect(), + ), + _ => item.clone(), + }; + out.insert(key.clone(), projected); + } + Json::Object(out) + } + + /// A schema as a model-facing JSON Schema document: projected for its direction, then normalized. + pub fn project_schema(&mut self, value: Option<&'a Json>, d: Direction) -> Json { + let Some(value) = value else { + return Json::Object(Default::default()); + }; + if !self.directional { + return super::normalize::normalize(self.doc, value); + } + let projected = + self.directional_schema(Resource { value, root: value }, d, &HashSet::new()); + super::normalize::normalize(self.doc, &projected) + } +} diff --git a/packages/codemode-rust/crates/psychoscript/src/openapi/spec.rs b/packages/codemode-rust/crates/psychoscript/src/openapi/spec.rs new file mode 100644 index 000000000000..eb0db51c1298 --- /dev/null +++ b/packages/codemode-rust/crates/psychoscript/src/openapi/spec.rs @@ -0,0 +1,827 @@ +//! Reading an OpenAPI document into tool plans, as the reference's `spec.ts` does: parameters and bodies become +//! input fields, successful responses the output schema, and `operationId`s the tool paths. + +use std::collections::{HashMap, HashSet}; + +use super::project::{Direction, Projector}; +use super::{ApiKeyLocation, SecurityScheme}; +use crate::Json; + +pub type Parsed = Result; + +pub fn own<'a>(map: &'a serde_json::Map, key: &str) -> Option<&'a Json> { + map.get(key) +} + +pub fn non_empty(v: Option<&Json>) -> Option<&str> { + match v { + Some(Json::String(s)) if !s.is_empty() => Some(s), + _ => None, + } +} + +fn as_array(v: Option<&Json>) -> &[Json] { + match v { + Some(Json::Array(items)) => items, + _ => &[], + } +} + +pub fn resolve_pointer<'a>(root: &'a Json, reference: &str) -> Option<&'a Json> { + let mut item = root; + for segment in reference.get(2..)?.split('/') { + let segment = segment.replace("~1", "/").replace("~0", "~"); + item = item.as_object()?.get(&segment)?; + } + Some(item) +} + +/// Follows `#/` references to what they name; an unresolvable or cyclic one stays as it is. +pub fn resolve<'a>(doc: &'a Json, value: Option<&'a Json>) -> Option<&'a Json> { + let mut current = value?; + let mut seen: Vec<&str> = Vec::new(); + loop { + let Some(map) = current.as_object() else { + return Some(current); + }; + let Some(reference) = non_empty(map.get("$ref")) else { + return Some(current); + }; + if !reference.starts_with("#/") || seen.contains(&reference) { + return Some(current); + } + let Some(target) = resolve_pointer(doc, reference) else { + return Some(current); + }; + seen.push(reference); + current = target; + } +} + +pub type Definitions = serde_json::Map; + +pub fn component_definitions(p: &mut Projector<'_>, d: Direction) -> Definitions { + let doc = p.doc; + let Some(Json::Object(schemas)) = doc.get("components").and_then(|c| c.get("schemas")) else { + return Definitions::new(); + }; + schemas + .iter() + .map(|(name, value)| (name.clone(), p.project_schema(Some(value), d))) + .collect() +} + +fn with_definitions(schema: Json, definitions: &Definitions) -> Json { + if definitions.is_empty() { + return schema; + } + let Json::Object(mut map) = schema else { + return schema; + }; + let mut merged = definitions.clone(); + if let Some(Json::Object(local)) = map.get("$defs") { + for (k, v) in local { + merged.insert(k.clone(), v.clone()); + } + } + map.insert("$defs".into(), Json::Object(merged)); + Json::Object(map) +} + +fn media_type(m: &str) -> String { + m.split(';').next().unwrap_or("").trim().to_lowercase() +} + +pub fn is_json_media_type(m: &str) -> bool { + let n = media_type(m); + n == "application/json" || n.ends_with("+json") +} + +fn is_binary_media_type(doc: &Json, m: &str, value: &Json) -> bool { + let n = media_type(m); + if !is_json_media_type(&n) && !n.starts_with("text/") { + return true; + } + if !value.is_object() { + return false; + } + resolve(doc, value.get("schema")) + .and_then(Json::as_object) + .is_some_and(|s| s.get("format").and_then(Json::as_str) == Some("binary")) +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Location { + Path, + Query, + Header, + Body, +} + +impl Location { + pub fn name(self) -> &'static str { + match self { + Location::Path => "path", + Location::Query => "query", + Location::Header => "header", + Location::Body => "body", + } + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Style { + Simple, + Form, + DeepObject, +} + +#[derive(Clone, Debug)] +pub struct InputField { + pub input_name: String, + pub name: String, + pub location: Location, + pub required: bool, + pub schema: Json, + pub style: Option