@scriptc/compiler 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +35 -5
- package/dist/backend/executable-features.js +7 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.js +3 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +2 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +1 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/array-search.js +3 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +27 -1
- package/dist/backend/llvm/classes.js +115 -22
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -9
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +21 -3
- package/dist/backend/llvm/common.js +50 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +3 -1
- package/dist/backend/llvm/dense-array-access.js +61 -38
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +4 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.js +3 -3
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +9 -0
- package/dist/backend/llvm/dyn.js +62 -6
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +5 -2
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +54 -32
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +3 -2
- package/dist/backend/llvm/emit-statements.js +90 -13
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +20 -9
- package/dist/backend/llvm/emitter.js +42 -31
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +17 -4
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +6 -9
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +46 -4
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +3 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +11 -15
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/integer-clones.js +3 -3
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +18 -0
- package/dist/backend/llvm/js-ic.js +712 -0
- package/dist/backend/llvm/js-ic.js.map +1 -0
- package/dist/backend/llvm/jsval.js +139 -11
- package/dist/backend/llvm/jsval.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +4 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +22 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +40 -31
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -4
- package/dist/backend/llvm/map-number-lookup.js +43 -7
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/narrow-guards.js +64 -0
- package/dist/backend/llvm/narrow-guards.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +36 -17
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/regions.js +2 -2
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/regions.test.js +7 -1
- package/dist/backend/llvm/regions.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +8 -2
- package/dist/backend/llvm/shapes.js +9 -7
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +20 -1
- package/dist/backend/llvm/speculative-integers.js +94 -6
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.test.js +55 -1
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +4 -4
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/thread-slots.test.js +5 -4
- package/dist/backend/llvm/thread-slots.test.js.map +1 -1
- package/dist/backend/mangle.d.ts +5 -0
- package/dist/backend/mangle.js +7 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +20 -0
- package/dist/backend/native/executable.js +20 -3
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +2 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +6 -0
- package/dist/backend/native-codegen.js +19 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +27 -0
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +18 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +32 -0
- package/dist/backend/native-profile.js +39 -0
- package/dist/backend/native-profile.js.map +1 -0
- package/dist/backend/native-profile.test.d.ts +1 -0
- package/dist/backend/native-profile.test.js +58 -0
- package/dist/backend/native-profile.test.js.map +1 -0
- package/dist/backend/native-tools.d.ts +14 -0
- package/dist/backend/native-tools.js +13 -0
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +4 -0
- package/dist/backend/runtime-pack-core.js +4 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +4 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +4 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +7 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +63 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +2 -0
- package/dist/cli/output-options.js +9 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +11 -1
- package/dist/cli/usage.js +23 -0
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +9 -0
- package/dist/contracts/check.js +1 -2
- package/dist/contracts/check.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +10 -0
- package/dist/executable/executable-cache.js +6 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +5 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/arguments-usage.d.ts +8 -0
- package/dist/frontend/arguments-usage.js +98 -0
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/arguments-usage.test.d.ts +1 -0
- package/dist/frontend/arguments-usage.test.js +32 -0
- package/dist/frontend/arguments-usage.test.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.d.ts +24 -0
- package/dist/frontend/builtin-package-aliases.js +133 -0
- package/dist/frontend/builtin-package-aliases.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
- package/dist/frontend/builtin-package-aliases.test.js +48 -0
- package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +4 -0
- package/dist/frontend/dts-paths.js +9 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.d.ts +8 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js +50 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +3 -2
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -0
- package/dist/frontend/lowering/builtins/crypto.js +4 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/ecdh.d.ts +10 -0
- package/dist/frontend/lowering/builtins/ecdh.js +208 -0
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.js +52 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +9 -0
- package/dist/frontend/lowering/builtins/process.js +44 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.d.ts +3 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js +21 -3
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +26 -0
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/timers.js +5 -1
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
- package/dist/frontend/lowering/call-signatures.d.ts +4 -0
- package/dist/frontend/lowering/call-signatures.js +126 -9
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js +34 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +9 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +10 -0
- package/dist/frontend/lowering/class-protocols.js +53 -3
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +6 -1
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +2 -2
- package/dist/frontend/lowering/class-to-primitive.js +6 -3
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
- package/dist/frontend/lowering/coercions/fresh-spread.d.ts +13 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +99 -70
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +22 -19
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +7 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +5 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +9 -0
- package/dist/frontend/lowering/containers/bytes.js +493 -17
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +72 -3
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +49 -13
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +26 -10
- package/dist/frontend/lowering/cycle-initialization.js +152 -35
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +33 -13
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +79 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +13 -6
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +14 -2
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +91 -10
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +17 -2
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +48 -1
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +12 -3
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +5 -0
- package/dist/frontend/lowering/expressions/property-access.js +252 -9
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +49 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +13 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +1 -1
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +191 -1
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +4 -0
- package/dist/frontend/lowering/generic-functions.js +213 -56
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +24 -0
- package/dist/frontend/lowering/handle-properties.js +281 -0
- package/dist/frontend/lowering/handle-properties.js.map +1 -0
- package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
- package/dist/frontend/lowering/iterable-spelling.js +38 -0
- package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +33 -15
- package/dist/frontend/lowering/lower-array-sort.js +117 -21
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +1 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +166 -7
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -0
- package/dist/frontend/lowering/lower-classes.js +59 -7
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +62 -13
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +32 -1
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +4 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +10 -4
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +569 -11
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +11 -3
- package/dist/frontend/lowering/lower-modules.js +212 -67
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +20 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +26 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +28 -9
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +7 -10
- package/dist/frontend/lowering/lower-stmts.js +418 -51
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +17 -1
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +29 -5
- package/dist/frontend/lowering/lowerer.js +172 -25
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/rebindable-functions.d.ts +8 -0
- package/dist/frontend/lowering/rebindable-functions.js +54 -0
- package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +26 -0
- package/dist/frontend/lowering/static-typeof.js +133 -0
- package/dist/frontend/lowering/static-typeof.js.map +1 -0
- package/dist/frontend/lowering/string-index-bounds.js +3 -2
- package/dist/frontend/lowering/string-index-bounds.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +30 -4
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/thenables.d.ts +16 -0
- package/dist/frontend/lowering/thenables.js +124 -0
- package/dist/frontend/lowering/thenables.js.map +1 -0
- package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
- package/dist/frontend/npm-static-builtin-aliases.js +65 -0
- package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.d.ts +8 -1
- package/dist/frontend/npm-static-bundled-chunks.js +173 -2
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +112 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.js +224 -4
- package/dist/frontend/npm-static-bundled-esm.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.test.js +129 -0
- package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -1
- package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
- package/dist/frontend/npm-static-enum-iife.js +280 -0
- package/dist/frontend/npm-static-enum-iife.js.map +1 -0
- package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
- package/dist/frontend/npm-static-enum-iife.test.js +116 -0
- package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +8 -0
- package/dist/frontend/npm-static.js +46 -1
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +13 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +47 -0
- package/dist/frontend/package-shims.js +300 -0
- package/dist/frontend/package-shims.js.map +1 -0
- package/dist/frontend/pipeline.js +67 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +8 -0
- package/dist/frontend/program.js +72 -9
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.js +13 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/services.d.ts +6 -0
- package/dist/frontend/services.js +19 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +6 -5
- package/dist/frontend/ts7/program-host.js +7 -0
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +3 -0
- package/dist/frontend/ts7/semantic-model.js +26 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +19 -4
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/type-mapper.js +201 -15
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +3 -2
- package/dist/ir/array-length-stability.js +15 -2
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +22 -1
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +13 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +46 -4
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +5 -0
- package/dist/ir/integer-loop-facts.js +79 -14
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +10 -1
- package/dist/ir/integer-ranges.js +122 -25
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +191 -1
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.js +8 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +52 -0
- package/dist/ir/js-ic.js +199 -0
- package/dist/ir/js-ic.js.map +1 -0
- package/dist/ir/js-ic.test.d.ts +1 -0
- package/dist/ir/js-ic.test.js +148 -0
- package/dist/ir/js-ic.test.js.map +1 -0
- package/dist/ir/jsval.js +38 -4
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +39 -4
- package/dist/ir/runtime-features.js +229 -99
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/traverse.js +110 -68
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +21 -8
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +15 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cli.js +17 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +33 -4
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.js +3 -0
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.js +3 -0
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +21 -20
- package/shims/fs-extra/core/api.ts +1192 -0
- package/shims/fs-extra/index.ts +9 -0
- package/shims/undici/core/agent.ts +163 -0
- package/shims/undici/core/api.ts +93 -0
- package/shims/undici/core/client.ts +1304 -0
- package/shims/undici/core/connector.ts +157 -0
- package/shims/undici/core/diagnostics-types.ts +68 -0
- package/shims/undici/core/diagnostics.ts +16 -0
- package/shims/undici/core/dispatcher.ts +574 -0
- package/shims/undici/core/errors-v5.ts +22 -0
- package/shims/undici/core/errors-v7.ts +25 -0
- package/shims/undici/core/errors.ts +255 -0
- package/shims/undici/core/fetch.ts +635 -0
- package/shims/undici/core/pool.ts +280 -0
- package/shims/undici/core/readable.ts +268 -0
- package/shims/undici/core/request.ts +313 -0
- package/shims/undici/core/timers.ts +80 -0
- package/shims/undici/core/types.ts +167 -0
- package/shims/undici/core/util.ts +67 -0
- package/shims/undici/v5.ts +119 -0
- package/shims/undici/v7.ts +119 -0
- package/surface-manifest.json +2 -4
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { lowerTupleAliasDecl, stripTypeWrappers } from "./typed-arguments.js";
|
|
2
|
-
import { declaredMemberOf } from "./expressions/property-access.js";
|
|
2
|
+
import { declaredMemberOf, isPromisePrototypeRead } from "./expressions/property-access.js";
|
|
3
3
|
import { hostsAll } from "./expressions/hosted-narrowing.js";
|
|
4
4
|
import { requestGeneralStreamSurface } from "./general-streams.js";
|
|
5
5
|
import { lowerForAwaitDynStream } from "./dyn-streams.js";
|
|
6
|
+
import { lowerChildPropertyWrite } from "./handle-properties.js";
|
|
6
7
|
import { matchAllRowsReadByElements, storedMatchAllRowsReadByElements, } from "./containers/match-row-uses.js";
|
|
7
|
-
import { dynUndefinedExpr, numLit, varRef } from "../../ir/build.js";
|
|
8
|
+
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
9
|
+
import { runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
|
|
10
|
+
import { declaresHoistedBinding, staticCondition } from "./static-typeof.js";
|
|
8
11
|
import { lowerCollectionSpread } from "./containers/collection-methods.js";
|
|
9
12
|
import { lowerEventObjectPropertyWrite } from "./lower-event-target.js";
|
|
10
13
|
import { lowerDynObjectLiteral } from "./expressions/object-literals.js";
|
|
11
14
|
import { importMetaBindingSource } from "./import-meta.js";
|
|
12
15
|
import { iteratorCanStep, iteratorValue } from "./iterator-consumption.js";
|
|
16
|
+
import { notIterableSpelling } from "./iterable-spelling.js";
|
|
13
17
|
import { isPrivateSplitConsumer } from "./split-consumers.js";
|
|
14
18
|
import { InternalCompilerError } from "../../errors.js";
|
|
15
19
|
/* Statement lowering: the statement dispatch (lowerStmt), variable
|
|
@@ -65,8 +69,9 @@ import { lowerNodeModuleCall } from "./builtins/module-resolution.js";
|
|
|
65
69
|
import { registerBuiltinCallableAlias } from "./builtins/callable-aliases.js";
|
|
66
70
|
import { builtinClassAliasOwnsNoSlot, registerBuiltinClassAlias } from "./builtins/class-values.js";
|
|
67
71
|
import { lowerEnumDeclaration } from "./lower-enums.js";
|
|
68
|
-
import { abstractPropertyDeclOf, aliasTypeofNarrows, isMatchSliceType, lowerAbsenceProbe, lowerCompoundValueToTarget, lowerElementCompoundStatement, lowerIncDec, lowerIncDecTarget, lowerGroupsProjection, matchResultNamedGroupsOf, runtimeOptionalGuardIds, runtimeOptionalTrueIds, symbolFieldInfo, withRuntimeOptionalNarrowed, } from "./lower-exprs.js";
|
|
72
|
+
import { abstractPropertyDeclOf, aliasTypeofNarrows, isMatchSliceType, lowerAbsenceProbe, lowerCompoundValueToTarget, lowerElementCompoundStatement, lowerIncDec, lowerIncDecTarget, lowerOptionalNumber, lowerGroupsProjection, matchResultNamedGroupsOf, runtimeOptionalGuardIds, runtimeOptionalTrueIds, symbolFieldInfo, withRuntimeOptionalNarrowed, } from "./lower-exprs.js";
|
|
69
73
|
import { globalSymbolKey } from "./expressions/global-symbols.js";
|
|
74
|
+
import { identifiersNamed } from "./identifier-uses.js";
|
|
70
75
|
import { lowerShortCircuitAssignment } from "./expressions/nullish-assignment.js";
|
|
71
76
|
import { builtinGlobalValue, jsHoldsDynObject, lowerEnvironmentKey, lowerNativeFunctionAssignment, lowerStrictEquality, } from "./lower-exprs.js";
|
|
72
77
|
import { keptIdentityAssertion } from "./assertion-identity.js";
|
|
@@ -1007,6 +1012,10 @@ function varBindingType(lowerer, nameNode) {
|
|
|
1007
1012
|
ts.isVariableDeclaration(nameNode.parent) &&
|
|
1008
1013
|
isNativeBuiltinValueInitializer(lowerer, nameNode.parent.initializer))
|
|
1009
1014
|
return DYN;
|
|
1015
|
+
if (ts.isVariableDeclaration(nameNode.parent) &&
|
|
1016
|
+
!nameNode.parent.type &&
|
|
1017
|
+
isPromisePrototypeRead(lowerer, nameNode.parent.initializer))
|
|
1018
|
+
return DYN;
|
|
1010
1019
|
let type = lowerer.mapTypeOf(lowerer.typeOf(nameNode));
|
|
1011
1020
|
if (type?.kind === "record" && isJsSourceFile(ts.getSourceFileOfNode(nameNode))) {
|
|
1012
1021
|
const shape = lowerer.shapes.get(type.shapeId);
|
|
@@ -1311,6 +1320,20 @@ export function lowerStmt(lowerer, stmt) {
|
|
|
1311
1320
|
}
|
|
1312
1321
|
if (ts.isIfStatement(stmt)) {
|
|
1313
1322
|
const cond = lowerer.lowerCondition(stmt.expression);
|
|
1323
|
+
// A global-detection condition (static-typeof.ts) folds; its untaken
|
|
1324
|
+
// arm is code Node never runs and does not lower, unless it declares a
|
|
1325
|
+
// hoisted binding.
|
|
1326
|
+
const decided = staticCondition(lowerer, stmt.expression);
|
|
1327
|
+
if (decided !== null) {
|
|
1328
|
+
const taken = decided ? stmt.thenStatement : stmt.elseStatement;
|
|
1329
|
+
const untaken = decided ? stmt.elseStatement : stmt.thenStatement;
|
|
1330
|
+
if (untaken === undefined || !declaresHoistedBinding(untaken)) {
|
|
1331
|
+
const arm = taken === undefined ? [] : lowerer.lowerScopedBlock(taken);
|
|
1332
|
+
return decided
|
|
1333
|
+
? { kind: "if", cond, then: arm, else_: null, loc: locOf(stmt) }
|
|
1334
|
+
: { kind: "if", cond, then: [], else_: arm, loc: locOf(stmt) };
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1314
1337
|
// Aliased-typeof narrows (ms's `var type = typeof val` guard): the
|
|
1315
1338
|
// then-branch lowers under what a TRUE condition proves, the
|
|
1316
1339
|
// else-branch under a FALSE one — the var/let alias narrowing the
|
|
@@ -1953,11 +1976,19 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
1953
1976
|
// destructure property 'a' of 'f(...)' as it is null.") for the source
|
|
1954
1977
|
// spellings the assignment form reproduces; other sources are refused,
|
|
1955
1978
|
// as in the assignment form. JavaScript files keep their existing
|
|
1956
|
-
// per-read errors
|
|
1957
|
-
|
|
1979
|
+
// per-read errors, except that a runtime computed first key checks the
|
|
1980
|
+
// source first: Node throws before it evaluates any key, and V8's bare
|
|
1981
|
+
// message names the source.
|
|
1982
|
+
const jsRuntimeKeyCheck = init.type.kind === "dyn" &&
|
|
1958
1983
|
ts.isObjectBindingPattern(decl.name) &&
|
|
1959
|
-
|
|
1960
|
-
lowerer
|
|
1984
|
+
isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
1985
|
+
startsWithRuntimeKey(lowerer, decl.name) &&
|
|
1986
|
+
destrSpellingOf(decl.initializer) !== null;
|
|
1987
|
+
if (jsRuntimeKeyCheck ||
|
|
1988
|
+
(init.type.kind === "dyn" &&
|
|
1989
|
+
ts.isObjectBindingPattern(decl.name) &&
|
|
1990
|
+
!isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
1991
|
+
lowerer.anyOrigin(decl.initializer))) {
|
|
1961
1992
|
const spelling = destrSpellingOf(decl.initializer);
|
|
1962
1993
|
if (spelling === null) {
|
|
1963
1994
|
lowerer.unsupported("SC1031", decl.initializer, "destructuring declaration from an `any` source whose expression spelling is unsupported (use a variable, ordinary property chain, or ordinary call)");
|
|
@@ -2430,6 +2461,27 @@ export function lowerBindingPattern(lowerer, pattern, srcRef, srcType, isLet, ou
|
|
|
2430
2461
|
return;
|
|
2431
2462
|
}
|
|
2432
2463
|
if (srcType.kind === "dyn") {
|
|
2464
|
+
// A runtime computed first key evaluates after RequireObjectCoercible:
|
|
2465
|
+
// a nullish source throws before the key's side effects run. Later
|
|
2466
|
+
// keys follow a read that already threw.
|
|
2467
|
+
if (ts.isObjectBindingPattern(pattern) && startsWithRuntimeKey(lowerer, pattern)) {
|
|
2468
|
+
const loc = locOf(pattern);
|
|
2469
|
+
for (const unit of ["null", "undefined"]) {
|
|
2470
|
+
out.push({
|
|
2471
|
+
kind: "if",
|
|
2472
|
+
cond: { kind: "dynTest", test: unit, value: srcRef(), type: BOOL, loc },
|
|
2473
|
+
then: [
|
|
2474
|
+
{
|
|
2475
|
+
kind: "exprStmt",
|
|
2476
|
+
expr: nodeThrowExpr(1, "", `Cannot read properties of ${unit}`, VOID, loc),
|
|
2477
|
+
loc,
|
|
2478
|
+
},
|
|
2479
|
+
],
|
|
2480
|
+
else_: null,
|
|
2481
|
+
loc,
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2433
2485
|
for (const el of pattern.elements.nodes) {
|
|
2434
2486
|
if (el.name === undefined)
|
|
2435
2487
|
continue;
|
|
@@ -2471,10 +2523,14 @@ export function lowerBindingPattern(lowerer, pattern, srcRef, srcType, isLet, ou
|
|
|
2471
2523
|
ts.isNumericLiteral(prop)
|
|
2472
2524
|
? patternKeyNameOf(lowerer, prop)
|
|
2473
2525
|
: null;
|
|
2474
|
-
|
|
2526
|
+
// A runtime computed key (`{ [name]: v }`) reads the live property.
|
|
2527
|
+
const runtimeRead = propName === null && ts.isComputedPropertyName(prop)
|
|
2528
|
+
? runtimeKeyPatternRead(lowerer, prop.expression, srcRef(), out, loc)
|
|
2529
|
+
: null;
|
|
2530
|
+
if (propName === null && runtimeRead === null) {
|
|
2475
2531
|
lowerer.unsupported("SC1031", el, "destructuring with computed keys that do not fold to one property name");
|
|
2476
2532
|
}
|
|
2477
|
-
let value = {
|
|
2533
|
+
let value = runtimeRead ?? {
|
|
2478
2534
|
kind: "dynKeyGet",
|
|
2479
2535
|
key: { kind: "strLit", value: propName, type: STRING, loc },
|
|
2480
2536
|
value: srcRef(),
|
|
@@ -2685,7 +2741,18 @@ export function lowerBindingPattern(lowerer, pattern, srcRef, srcType, isLet, ou
|
|
|
2685
2741
|
? patternKeyNameOf(lowerer, prop)
|
|
2686
2742
|
: null;
|
|
2687
2743
|
if (propName === null) {
|
|
2688
|
-
|
|
2744
|
+
// A runtime computed key (`{ [name]: v }`): the keyed read of an
|
|
2745
|
+
// index-signature entry, of the declared field a literal-union key
|
|
2746
|
+
// names, or of a JavaScript record's live property.
|
|
2747
|
+
const runtimeRead = ts.isComputedPropertyName(prop)
|
|
2748
|
+
? runtimeKeyPatternRead(lowerer, prop.expression, srcRef(), out, locOf(el))
|
|
2749
|
+
: null;
|
|
2750
|
+
if (runtimeRead === null) {
|
|
2751
|
+
lowerer.unsupported("SC1031", el, "destructuring with computed keys that do not fold to one property name");
|
|
2752
|
+
}
|
|
2753
|
+
const value = el.initializer ? applyBindingDefault(lowerer, el, runtimeRead) : runtimeRead;
|
|
2754
|
+
lowerer.bindPatternTarget(el.name, value, isLet, out);
|
|
2755
|
+
continue;
|
|
2689
2756
|
}
|
|
2690
2757
|
// An ACCESSOR property (%get:/%set: closure slots): the element's
|
|
2691
2758
|
// read IS a getter call — once, at the element's pattern position
|
|
@@ -2919,6 +2986,13 @@ function lowerModuleNamespacePattern(lowerer, pattern, source, isLet, out) {
|
|
|
2919
2986
|
lowerer.bindPatternTarget(el.name, value, isLet, out);
|
|
2920
2987
|
}
|
|
2921
2988
|
}
|
|
2989
|
+
/** Whether a pattern's first element has a computed key that does not
|
|
2990
|
+
* fold to one property name, so the key evaluates at run time. */
|
|
2991
|
+
function startsWithRuntimeKey(lowerer, pattern) {
|
|
2992
|
+
const first = pattern.elements.nodes[0];
|
|
2993
|
+
const key = first?.dotDotDotToken === undefined ? first?.propertyName : undefined;
|
|
2994
|
+
return (key !== undefined && ts.isComputedPropertyName(key) && patternKeyNameOf(lowerer, key) === null);
|
|
2995
|
+
}
|
|
2922
2996
|
function patternKeyNameOf(lowerer, prop) {
|
|
2923
2997
|
if (ts.isIdentifier(prop) || ts.isPrivateIdentifier(prop))
|
|
2924
2998
|
return prop.text;
|
|
@@ -3874,6 +3948,69 @@ export function lowerVarDeclList(lowerer, list) {
|
|
|
3874
3948
|
}
|
|
3875
3949
|
return out.length === 1 ? out[0] : { kind: "block", body: out, loc: locOf(list) };
|
|
3876
3950
|
}
|
|
3951
|
+
/** The type of an unannotated TypeScript binding initialized with `[]`
|
|
3952
|
+
* whose element type evolves: the checker types the declaration as
|
|
3953
|
+
* `never[]` or `any[]` and each later read by the elements written before
|
|
3954
|
+
* it, and reads inside closures as the unsettled array. When every read
|
|
3955
|
+
* with a settled element type maps to the same array type, the binding has
|
|
3956
|
+
* that type. When reads disagree or the binding is reassigned, it is
|
|
3957
|
+
* checked-dynamic, as the same binding is at module scope. Null for other
|
|
3958
|
+
* bindings. */
|
|
3959
|
+
function evolvingArrayType(lowerer, decl) {
|
|
3960
|
+
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined)
|
|
3961
|
+
return null;
|
|
3962
|
+
let initializer = decl.initializer;
|
|
3963
|
+
while (ts.isParenthesizedExpression(initializer))
|
|
3964
|
+
initializer = initializer.expression;
|
|
3965
|
+
if (!ts.isArrayLiteralExpression(initializer) || initializer.elements.nodes.length !== 0)
|
|
3966
|
+
return null;
|
|
3967
|
+
const unsettled = (t) => {
|
|
3968
|
+
if (!lowerer.checker.isArrayType(t))
|
|
3969
|
+
return false;
|
|
3970
|
+
const elem = lowerer.checker.getTypeArguments(t)[0];
|
|
3971
|
+
return elem !== undefined && (elem.flags & (ts.TypeFlags.Never | ts.TypeFlags.Any)) !== 0;
|
|
3972
|
+
};
|
|
3973
|
+
if (!unsettled(lowerer.typeOf(decl.name)))
|
|
3974
|
+
return null;
|
|
3975
|
+
const symbol = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
3976
|
+
if (symbol === undefined)
|
|
3977
|
+
return null;
|
|
3978
|
+
const owner = (node) => {
|
|
3979
|
+
let n = node.parent;
|
|
3980
|
+
while (n !== undefined && !ts.isFunctionLike(n) && !ts.isSourceFile(n))
|
|
3981
|
+
n = n.parent;
|
|
3982
|
+
return n ?? ts.getSourceFileOfNode(node);
|
|
3983
|
+
};
|
|
3984
|
+
const scope = owner(decl);
|
|
3985
|
+
let result = null;
|
|
3986
|
+
// The file's identifiers are indexed by name once (identifiersNamed), so
|
|
3987
|
+
// each binding resolves only the uses spelled like it.
|
|
3988
|
+
for (const node of identifiersNamed(lowerer, ts.getSourceFileOfNode(decl), decl.name.text)) {
|
|
3989
|
+
if (node === decl.name ||
|
|
3990
|
+
node.pos < scope.pos ||
|
|
3991
|
+
node.end > scope.end ||
|
|
3992
|
+
lowerer.checker.getSymbolAtLocation(node) !== symbol)
|
|
3993
|
+
continue;
|
|
3994
|
+
let target = node;
|
|
3995
|
+
while (ts.isParenthesizedExpression(target.parent))
|
|
3996
|
+
target = target.parent;
|
|
3997
|
+
const parent = target.parent;
|
|
3998
|
+
const reassigned = ts.isBinaryExpression(parent) &&
|
|
3999
|
+
parent.left === target &&
|
|
4000
|
+
parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
4001
|
+
parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment;
|
|
4002
|
+
if (reassigned)
|
|
4003
|
+
return DYN;
|
|
4004
|
+
const t = lowerer.typeOf(node);
|
|
4005
|
+
if (unsettled(t))
|
|
4006
|
+
continue;
|
|
4007
|
+
const mapped = lowerer.mapTypeOf(t);
|
|
4008
|
+
if (!mapped || mapped.kind !== "array" || (result !== null && !typeEquals(result, mapped)))
|
|
4009
|
+
return DYN;
|
|
4010
|
+
result = mapped;
|
|
4011
|
+
}
|
|
4012
|
+
return result ?? DYN;
|
|
4013
|
+
}
|
|
3877
4014
|
/** A single static type for an initializer-less JavaScript `let` whose
|
|
3878
4015
|
* later plain writes all agree. An evolving JS local reads as `undefined`
|
|
3879
4016
|
* until control flow proves a write, so a scalar slot is sound only when
|
|
@@ -4379,6 +4516,9 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4379
4516
|
!hasJsTypeAnnotation(decl) &&
|
|
4380
4517
|
init.type.kind === "func")
|
|
4381
4518
|
type = init.type;
|
|
4519
|
+
// Promise.prototype is an ordinary object the checker types Promise<any>.
|
|
4520
|
+
if (!decl.type && !hasJsTypeAnnotation(decl) && isPromisePrototypeRead(lowerer, decl.initializer))
|
|
4521
|
+
type = DYN;
|
|
4382
4522
|
// A typed-arguments function expression (typed-arguments.ts): the
|
|
4383
4523
|
// checker types the binding variadic, but its value has the fixed
|
|
4384
4524
|
// signature every use asserts.
|
|
@@ -4494,6 +4634,17 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4494
4634
|
}
|
|
4495
4635
|
}
|
|
4496
4636
|
}
|
|
4637
|
+
// A TypeScript `const nodes = [];` filled by later writes: the checker
|
|
4638
|
+
// types each read by the elements written before it (evolvingArrayType).
|
|
4639
|
+
if (returnedEmptyArrayType === null &&
|
|
4640
|
+
!decl.type &&
|
|
4641
|
+
!isJsSourceFile(ts.getSourceFileOfNode(decl))) {
|
|
4642
|
+
const evolved = evolvingArrayType(lowerer, decl);
|
|
4643
|
+
if (evolved !== null) {
|
|
4644
|
+
type = evolved;
|
|
4645
|
+
init = lowerer.lowerExprExpecting(decl.initializer, evolved);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4497
4648
|
// An unannotated binding holding an OOB-SAFE indexed read (`elem |
|
|
4498
4649
|
// undefined`) where the checker spells the bare element: the binding
|
|
4499
4650
|
// adopts the runtime-honest union. This covers both inferred package JS
|
|
@@ -4561,7 +4712,28 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4561
4712
|
// `let` may be reassigned a different shape later; genuine `any`
|
|
4562
4713
|
// only — every other unmappable keeps its own diagnostic.
|
|
4563
4714
|
const checkerAny = (lowerer.typeOf(decl.name).flags & ts.TypeFlags.Any) !== 0;
|
|
4564
|
-
|
|
4715
|
+
// An annotation the checker could not resolve (a package type alias that
|
|
4716
|
+
// reads as `any`) over an empty object literal: the binding is a
|
|
4717
|
+
// dictionary the code fills by key (`files[name] = entry`), which the
|
|
4718
|
+
// empty struct the literal would adopt cannot hold. It holds the
|
|
4719
|
+
// checked-dynamic object instead.
|
|
4720
|
+
let emptyAnyDictionary = false;
|
|
4721
|
+
if (checkerAny && decl.type && !isLet && init.type.kind === "record") {
|
|
4722
|
+
let lit = decl.initializer;
|
|
4723
|
+
while (ts.isParenthesizedExpression(lit))
|
|
4724
|
+
lit = lit.expression;
|
|
4725
|
+
const shape = lowerer.shapes.get(init.type.shapeId);
|
|
4726
|
+
if (ts.isObjectLiteralExpression(lit) &&
|
|
4727
|
+
lit.properties.nodes.length === 0 &&
|
|
4728
|
+
shape &&
|
|
4729
|
+
shape.fields.length === 0 &&
|
|
4730
|
+
!shape.indexValue) {
|
|
4731
|
+
type = DYN;
|
|
4732
|
+
emptyAnyDictionary = true;
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
if (!emptyAnyDictionary &&
|
|
4736
|
+
(type === null || (type.kind === "dyn" && checkerAny)) &&
|
|
4565
4737
|
!isLet &&
|
|
4566
4738
|
(checkerAny ||
|
|
4567
4739
|
(lowerer.checkerAnyArray(decl.name) && lowerer.isArrayValueType(init.type)) ||
|
|
@@ -4976,8 +5148,34 @@ export function jsBindingHasOpenWrites(lowerer, decl) {
|
|
|
4976
5148
|
writes = indexed;
|
|
4977
5149
|
lowerer.jsBindingWritesByOwner.set(owner, writes);
|
|
4978
5150
|
}
|
|
4979
|
-
|
|
4980
|
-
|
|
5151
|
+
const candidates = (writes.get(decl.name.text) ?? []).filter((node) => lowerer.resolveValueSymbol(node.left) === symbol);
|
|
5152
|
+
if (candidates.some((node) => (lowerer.typeOf(node.right).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0))
|
|
5153
|
+
return true;
|
|
5154
|
+
// A plain JavaScript write of a value the declared type cannot hold (the
|
|
5155
|
+
// checker does not report it): buffer-crc32 replaces its number[] table
|
|
5156
|
+
// with `new Int32Array(table)`. Only a different representation counts;
|
|
5157
|
+
// writes that coerce into the declared type keep it.
|
|
5158
|
+
// A write whose checker type is the declaration's own maps to the same
|
|
5159
|
+
// representation; the declared type is mapped only for the others.
|
|
5160
|
+
const declaredType = lowerer.typeOf(decl.name);
|
|
5161
|
+
const differing = candidates.filter((node) => node.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
5162
|
+
lowerer.typeOf(node.right) !== declaredType);
|
|
5163
|
+
if (differing.length === 0)
|
|
5164
|
+
return false;
|
|
5165
|
+
const declared = lowerer.mapTypeOf(declaredType);
|
|
5166
|
+
if (declared === null || declared.kind === "dyn" || declared.kind === "union")
|
|
5167
|
+
return false;
|
|
5168
|
+
return differing.some((node) => {
|
|
5169
|
+
const written = lowerer.mapTypeOf(lowerer.typeOf(node.right));
|
|
5170
|
+
return (written !== null &&
|
|
5171
|
+
written.kind !== "dyn" &&
|
|
5172
|
+
written.kind !== "union" &&
|
|
5173
|
+
!isUnitType(written) &&
|
|
5174
|
+
lowerer.dynConvertible(written) &&
|
|
5175
|
+
lowerer.dynConvertible(declared) &&
|
|
5176
|
+
!typeEquals(written, declared) &&
|
|
5177
|
+
(written.kind !== declared.kind || written.kind === "bytes"));
|
|
5178
|
+
});
|
|
4981
5179
|
}
|
|
4982
5180
|
function immediatelyGuardedAbsenceProbe(lowerer, decl) {
|
|
4983
5181
|
const guard = immediateAbsenceGuard(lowerer, decl);
|
|
@@ -5954,16 +6152,12 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
5954
6152
|
if (!isRelativeSpecifier(spec) && canonicalBuiltinModule(spec) === null) {
|
|
5955
6153
|
const refusal = probeNodeRequireRefusal(sf.fileName, spec);
|
|
5956
6154
|
if (refusal !== null) {
|
|
6155
|
+
// The same throw as the expression form (cjs-inline-require):
|
|
6156
|
+
// an Error carrying Node's MODULE_NOT_FOUND code.
|
|
5957
6157
|
const loc = locOf(expr);
|
|
5958
6158
|
return {
|
|
5959
|
-
kind: "
|
|
5960
|
-
|
|
5961
|
-
kind: "libCall",
|
|
5962
|
-
fn: "error.new",
|
|
5963
|
-
args: [{ kind: "strLit", value: refusal.message, type: STRING, loc }],
|
|
5964
|
-
type: { kind: "object", className: "%Error" },
|
|
5965
|
-
loc,
|
|
5966
|
-
},
|
|
6159
|
+
kind: "exprStmt",
|
|
6160
|
+
expr: nodeThrowExpr(0, "MODULE_NOT_FOUND", refusal.message, VOID, loc),
|
|
5967
6161
|
loc,
|
|
5968
6162
|
};
|
|
5969
6163
|
}
|
|
@@ -6438,6 +6632,8 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
6438
6632
|
loc,
|
|
6439
6633
|
};
|
|
6440
6634
|
}
|
|
6635
|
+
if (recv?.type.kind === "child" && isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
6636
|
+
return lowerChildPropertyWrite(lowerer, recv, expr.left, expr.right, locOf(expr));
|
|
6441
6637
|
// `err.code = v` on an Error value (`err as Error & { code?:
|
|
6442
6638
|
// string }`): typed reads come from the runtime error's code
|
|
6443
6639
|
// slot, so the write lands there. A value that is not statically
|
|
@@ -7413,7 +7609,7 @@ function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
|
|
|
7413
7609
|
if (arr.type.kind === "array") {
|
|
7414
7610
|
const recv = lowerer.declareHiddenLocal("%dtRecv", arr.type);
|
|
7415
7611
|
out.push({ kind: "varDecl", localId: recv.id, init: arr, loc });
|
|
7416
|
-
const index = lowerer.lowerExpr(t.argumentExpression);
|
|
7612
|
+
const index = lowerOptionalNumber(lowerer, lowerer.lowerExpr(t.argumentExpression), locOf(t.argumentExpression), t.argumentExpression);
|
|
7417
7613
|
if (index.type.kind !== "f64") {
|
|
7418
7614
|
lowerer.unsupported("SC1090", t.argumentExpression, "indexing with non-number keys");
|
|
7419
7615
|
}
|
|
@@ -7426,6 +7622,30 @@ function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
|
|
|
7426
7622
|
return;
|
|
7427
7623
|
}
|
|
7428
7624
|
}
|
|
7625
|
+
else if (recvT?.kind === "bytes") {
|
|
7626
|
+
// A typed-array element (`[a[i], b[i]] = [h, l]`): the receiver, then
|
|
7627
|
+
// the index, then the value, as the plain element write `b[i] = v`
|
|
7628
|
+
// stores it (an f64 the runtime coerces; invalid indices are ignored).
|
|
7629
|
+
const arr = lowerer.lowerExpr(t.expression);
|
|
7630
|
+
if (arr.type.kind === "bytes") {
|
|
7631
|
+
const recv = lowerer.declareHiddenLocal("%dtRecv", arr.type);
|
|
7632
|
+
out.push({ kind: "varDecl", localId: recv.id, init: arr, loc });
|
|
7633
|
+
const index = lowerer.lowerExpr(t.argumentExpression);
|
|
7634
|
+
if (index.type.kind !== "f64") {
|
|
7635
|
+
lowerer.unsupported("SC1090", t.argumentExpression, "indexing with non-number keys");
|
|
7636
|
+
}
|
|
7637
|
+
const idx = lowerer.declareHiddenLocal("%dtIdx", F64);
|
|
7638
|
+
out.push({ kind: "varDecl", localId: idx.id, init: index, loc });
|
|
7639
|
+
out.push({
|
|
7640
|
+
kind: "bytesSet",
|
|
7641
|
+
arr: varRef(recv.id, arr.type, loc),
|
|
7642
|
+
index: varRef(idx.id, F64, loc),
|
|
7643
|
+
value: lowerer.coerceInto(blame, valueOf(F64), F64),
|
|
7644
|
+
loc,
|
|
7645
|
+
});
|
|
7646
|
+
return;
|
|
7647
|
+
}
|
|
7648
|
+
}
|
|
7429
7649
|
else if (recvT?.kind === "record") {
|
|
7430
7650
|
// Tuple positions and LITERAL declared record keys are field
|
|
7431
7651
|
// writes (the element-write lowering's own rule); runtime keys
|
|
@@ -7727,6 +7947,14 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7727
7947
|
* specific diagnostics; other iterables fail on their types. The loop
|
|
7728
7948
|
* variable is a fresh const binding per iteration (its own scope, like a
|
|
7729
7949
|
* loop body). */
|
|
7950
|
+
/** Whether a `for await` head is untyped: the checker answers any or
|
|
7951
|
+
* unknown, or a type that maps to a checked-dynamic value. */
|
|
7952
|
+
function isUntypedIterable(lowerer, node) {
|
|
7953
|
+
const type = lowerer.typeOf(node);
|
|
7954
|
+
if ((type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
7955
|
+
return true;
|
|
7956
|
+
return lowerer.mapTypeOf(type)?.kind === "dyn";
|
|
7957
|
+
}
|
|
7730
7958
|
export function lowerForOf(lowerer, stmt) {
|
|
7731
7959
|
// Labels consume HERE (nested statements must never see them). The
|
|
7732
7960
|
// plain array/string paths carry them; the container/matchAll/stdin
|
|
@@ -7777,6 +8005,25 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
7777
8005
|
const builtin = lowerForAwaitBuiltin(lowerer, stmt);
|
|
7778
8006
|
if (builtin)
|
|
7779
8007
|
return builtin;
|
|
8008
|
+
// An untyped value (a JavaScript async generator whose recursive
|
|
8009
|
+
// return the checker types `any`): a compiled async generator steps
|
|
8010
|
+
// natively; any other value takes the checked-dynamic async protocol.
|
|
8011
|
+
// A synchronous generator, and in JavaScript any other head that
|
|
8012
|
+
// reaches here, takes the same protocol: values of a synchronous
|
|
8013
|
+
// iterator are awaited as the async-from-sync iterator awaits them, and
|
|
8014
|
+
// a value that is not iterable throws Node's TypeError.
|
|
8015
|
+
const headT = lowerer.mapTypeOf(lowerer.typeOf(stmt.expression));
|
|
8016
|
+
const syncGenerator = (headT?.kind === "generator" && headT.async !== true) || isJsSourceFile(stmt.getSourceFile());
|
|
8017
|
+
if (lowerer.ctx.isAsync && (syncGenerator || isUntypedIterable(lowerer, stmt.expression))) {
|
|
8018
|
+
const iterable = lowerer.lowerExpr(stmt.expression);
|
|
8019
|
+
if (iterable.type.kind === "generator" && iterable.type.async)
|
|
8020
|
+
return lowerForAwaitGenerator(lowerer, stmt, iterable, labels);
|
|
8021
|
+
if (iterable.type.kind === "dyn")
|
|
8022
|
+
return lowerForOfDyn(lowerer, stmt, iterable, labels, true);
|
|
8023
|
+
if ((iterable.type.kind === "generator" || isJsSourceFile(stmt.getSourceFile())) &&
|
|
8024
|
+
lowerer.dynConvertible(iterable.type))
|
|
8025
|
+
return lowerForOfDyn(lowerer, stmt, lowerer.coerceToExpected(iterable, DYN), labels, true);
|
|
8026
|
+
}
|
|
7780
8027
|
// A NodeJS.ReadableStream iterates as the general Readable.
|
|
7781
8028
|
requestGeneralStreamSurface(lowerer, stmt.expression);
|
|
7782
8029
|
lowerer.unsupported("SC1070", stmt, "'for await' over this value (supported: typed async generators, represented class async iterators, process.stdin, and Node/Web readable streams)");
|
|
@@ -8035,9 +8282,11 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
8035
8282
|
}
|
|
8036
8283
|
// A CHECKED-DYNAMIC iterable (`unknown[]`, the collapsed
|
|
8037
8284
|
// `(string | object)[]`, JSON-parsed values): a checked IteratorRecord
|
|
8038
|
-
// binds each yielded dyn value.
|
|
8285
|
+
// binds each yielded dyn value. Under `for await` (a JavaScript array
|
|
8286
|
+
// literal mixing promises and plain values) the async-from-sync rules
|
|
8287
|
+
// await each value.
|
|
8039
8288
|
if (iterable.type.kind === "dyn") {
|
|
8040
|
-
return lowerForOfDyn(lowerer, stmt, iterable, labels);
|
|
8289
|
+
return lowerForOfDyn(lowerer, stmt, iterable, labels, stmt.awaitModifier !== undefined);
|
|
8041
8290
|
}
|
|
8042
8291
|
if (tupleSource === null) {
|
|
8043
8292
|
lowerer.badType(stmt.expression, lowerer.typeOf(stmt.expression));
|
|
@@ -8941,24 +9190,9 @@ function lowerForOfClassIterator(lowerer, stmt, iterable, cit, labels) {
|
|
|
8941
9190
|
/** A checked IteratorRecord stays live throughout the loop. Cache next once,
|
|
8942
9191
|
* read done before value, and close only after a yielded value has arrived.
|
|
8943
9192
|
* Abrupt body throws retain precedence over errors raised by return(). */
|
|
8944
|
-
function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
9193
|
+
function lowerForOfDyn(lowerer, stmt, iterable, labels, asyncLoop = false) {
|
|
8945
9194
|
const loc = locOf(stmt);
|
|
8946
|
-
const
|
|
8947
|
-
if (ts.isIdentifier(e))
|
|
8948
|
-
return e.text;
|
|
8949
|
-
if (ts.isPropertyAccessExpression(e) && !e.questionDotToken && ts.isIdentifier(e.name)) {
|
|
8950
|
-
const base = headText(e.expression);
|
|
8951
|
-
return base === null ? null : `${base}.${e.name.text}`;
|
|
8952
|
-
}
|
|
8953
|
-
return null;
|
|
8954
|
-
};
|
|
8955
|
-
const name = headText(stmt.expression);
|
|
8956
|
-
const callee = ts.isCallExpression(stmt.expression) ? headText(stmt.expression.expression) : null;
|
|
8957
|
-
const spell = name !== null
|
|
8958
|
-
? `${name} is not iterable`
|
|
8959
|
-
: callee !== null
|
|
8960
|
-
? `${callee} is not a function or its return value is not iterable`
|
|
8961
|
-
: "";
|
|
9195
|
+
const spell = notIterableSpelling(stmt.expression, asyncLoop ? "async iterable" : "iterable");
|
|
8962
9196
|
const iterator = lowerer.declareHiddenLocal("%dofIterator", DYN);
|
|
8963
9197
|
const next = lowerer.declareHiddenLocal("%dofNext", DYN);
|
|
8964
9198
|
const fast = lowerer.declareHiddenLocal("%dofNative", BOOL);
|
|
@@ -8969,6 +9203,14 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
8969
9203
|
const needsClose = lowerer.declareHiddenLocal("%dofNeedsClose", BOOL);
|
|
8970
9204
|
needsClose.mutable = true;
|
|
8971
9205
|
const error = lowerer.declareHiddenLocal("%dofError", CAUGHT);
|
|
9206
|
+
const syncIterator = asyncLoop ? lowerer.declareHiddenLocal("%dofSync", BOOL) : null;
|
|
9207
|
+
const awaitDyn = (value) => ({
|
|
9208
|
+
kind: "libCall",
|
|
9209
|
+
fn: "async.awaitDyn",
|
|
9210
|
+
args: [value],
|
|
9211
|
+
type: DYN,
|
|
9212
|
+
loc,
|
|
9213
|
+
});
|
|
8972
9214
|
const get = (source, key) => ({
|
|
8973
9215
|
kind: "dynKeyGet",
|
|
8974
9216
|
value: source,
|
|
@@ -9020,7 +9262,24 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
9020
9262
|
type: BOOL,
|
|
9021
9263
|
loc,
|
|
9022
9264
|
},
|
|
9023
|
-
then: [
|
|
9265
|
+
then: [
|
|
9266
|
+
{
|
|
9267
|
+
kind: "exprStmt",
|
|
9268
|
+
// return()'s (awaited) result must be an object, as for next().
|
|
9269
|
+
expr: asyncLoop
|
|
9270
|
+
? check(awaitDyn({
|
|
9271
|
+
kind: "dynCall",
|
|
9272
|
+
callee: varRef(returned.id, DYN, loc),
|
|
9273
|
+
receiver: varRef(iterator.id, DYN, loc),
|
|
9274
|
+
calleeName: "iterator method",
|
|
9275
|
+
args: [],
|
|
9276
|
+
type: DYN,
|
|
9277
|
+
loc,
|
|
9278
|
+
}))
|
|
9279
|
+
: call(varRef(returned.id, DYN, loc)),
|
|
9280
|
+
loc,
|
|
9281
|
+
},
|
|
9282
|
+
],
|
|
9024
9283
|
else_: null,
|
|
9025
9284
|
loc,
|
|
9026
9285
|
},
|
|
@@ -9101,7 +9360,9 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
9101
9360
|
{
|
|
9102
9361
|
kind: "varDecl",
|
|
9103
9362
|
localId: value.id,
|
|
9104
|
-
init:
|
|
9363
|
+
init: syncIterator
|
|
9364
|
+
? asyncIteratorValue(lowerer, varRef(iterator.id, DYN, loc), varRef(next.id, DYN, loc), varRef(syncIterator.id, BOOL, loc), done, loc)
|
|
9365
|
+
: iteratorValue(lowerer, varRef(iterator.id, DYN, loc), varRef(next.id, DYN, loc), varRef(fast.id, BOOL, loc), done, loc, "iterator method"),
|
|
9105
9366
|
loc,
|
|
9106
9367
|
},
|
|
9107
9368
|
{
|
|
@@ -9126,13 +9387,29 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
9126
9387
|
localId: iterator.id,
|
|
9127
9388
|
init: check({
|
|
9128
9389
|
kind: "libCall",
|
|
9129
|
-
fn: "dyn.iterator",
|
|
9390
|
+
fn: asyncLoop ? "dyn.asyncIteratorOpen" : "dyn.iterator",
|
|
9130
9391
|
args: [iterable, { kind: "strLit", value: spell, type: STRING, loc }],
|
|
9131
9392
|
type: DYN,
|
|
9132
9393
|
loc,
|
|
9133
9394
|
}),
|
|
9134
9395
|
loc,
|
|
9135
9396
|
},
|
|
9397
|
+
...(syncIterator
|
|
9398
|
+
? [
|
|
9399
|
+
{
|
|
9400
|
+
kind: "varDecl",
|
|
9401
|
+
localId: syncIterator.id,
|
|
9402
|
+
init: {
|
|
9403
|
+
kind: "libCall",
|
|
9404
|
+
fn: "dyn.asyncIteratorWasSync",
|
|
9405
|
+
args: [],
|
|
9406
|
+
type: BOOL,
|
|
9407
|
+
loc,
|
|
9408
|
+
},
|
|
9409
|
+
loc,
|
|
9410
|
+
},
|
|
9411
|
+
]
|
|
9412
|
+
: []),
|
|
9136
9413
|
{
|
|
9137
9414
|
kind: "varDecl",
|
|
9138
9415
|
localId: next.id,
|
|
@@ -9142,7 +9419,9 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
9142
9419
|
{
|
|
9143
9420
|
kind: "varDecl",
|
|
9144
9421
|
localId: fast.id,
|
|
9145
|
-
init:
|
|
9422
|
+
init: asyncLoop
|
|
9423
|
+
? { kind: "boolLit", value: false, type: BOOL, loc }
|
|
9424
|
+
: iteratorCanStep(varRef(iterator.id, DYN, loc), varRef(next.id, DYN, loc), loc),
|
|
9146
9425
|
loc,
|
|
9147
9426
|
},
|
|
9148
9427
|
{
|
|
@@ -9194,6 +9473,91 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
9194
9473
|
lowerer.scopes.pop();
|
|
9195
9474
|
}
|
|
9196
9475
|
}
|
|
9476
|
+
/** One step of `for await` over a checked-dynamic iterator: await next()'s
|
|
9477
|
+
* result, read done before value, and await each value of a synchronous
|
|
9478
|
+
* iterator, including its final one, as the async-from-sync iterator does. */
|
|
9479
|
+
function asyncIteratorValue(lowerer, iterator, next, sync, done, loc) {
|
|
9480
|
+
const result = lowerer.declareHiddenLocal("%asyncIteratorResult", DYN);
|
|
9481
|
+
const get = (key) => ({
|
|
9482
|
+
kind: "dynKeyGet",
|
|
9483
|
+
value: varRef(result.id, DYN, loc),
|
|
9484
|
+
key: { kind: "strLit", value: key, type: STRING, loc },
|
|
9485
|
+
type: DYN,
|
|
9486
|
+
loc,
|
|
9487
|
+
});
|
|
9488
|
+
const awaitDyn = (value) => ({
|
|
9489
|
+
kind: "libCall",
|
|
9490
|
+
fn: "async.awaitDyn",
|
|
9491
|
+
args: [value],
|
|
9492
|
+
type: DYN,
|
|
9493
|
+
loc,
|
|
9494
|
+
});
|
|
9495
|
+
return {
|
|
9496
|
+
kind: "seqExpr",
|
|
9497
|
+
type: DYN,
|
|
9498
|
+
loc,
|
|
9499
|
+
stmts: [
|
|
9500
|
+
{
|
|
9501
|
+
kind: "varDecl",
|
|
9502
|
+
localId: result.id,
|
|
9503
|
+
init: {
|
|
9504
|
+
kind: "libCall",
|
|
9505
|
+
fn: "dyn.iteratorResult",
|
|
9506
|
+
args: [
|
|
9507
|
+
awaitDyn({
|
|
9508
|
+
kind: "dynCall",
|
|
9509
|
+
callee: next,
|
|
9510
|
+
receiver: iterator,
|
|
9511
|
+
calleeName: "iterator method",
|
|
9512
|
+
args: [],
|
|
9513
|
+
type: DYN,
|
|
9514
|
+
loc,
|
|
9515
|
+
}),
|
|
9516
|
+
],
|
|
9517
|
+
type: DYN,
|
|
9518
|
+
loc,
|
|
9519
|
+
},
|
|
9520
|
+
loc,
|
|
9521
|
+
},
|
|
9522
|
+
{
|
|
9523
|
+
kind: "assign",
|
|
9524
|
+
localId: done.id,
|
|
9525
|
+
value: { kind: "dynTest", test: "truthy", value: get("done"), type: BOOL, loc },
|
|
9526
|
+
loc,
|
|
9527
|
+
},
|
|
9528
|
+
],
|
|
9529
|
+
// A synchronous iterator's final value is still read and awaited, so a
|
|
9530
|
+
// throwing getter or a rejected promise there rejects the loop.
|
|
9531
|
+
result: {
|
|
9532
|
+
kind: "ternary",
|
|
9533
|
+
cond: sync,
|
|
9534
|
+
then: {
|
|
9535
|
+
kind: "ternary",
|
|
9536
|
+
cond: varRef(done.id, BOOL, loc),
|
|
9537
|
+
then: {
|
|
9538
|
+
kind: "seqExpr",
|
|
9539
|
+
stmts: [{ kind: "exprStmt", expr: awaitDyn(get("value")), loc }],
|
|
9540
|
+
result: dynUndefinedExpr(loc),
|
|
9541
|
+
type: DYN,
|
|
9542
|
+
loc,
|
|
9543
|
+
},
|
|
9544
|
+
else_: awaitDyn(get("value")),
|
|
9545
|
+
type: DYN,
|
|
9546
|
+
loc,
|
|
9547
|
+
},
|
|
9548
|
+
else_: {
|
|
9549
|
+
kind: "ternary",
|
|
9550
|
+
cond: varRef(done.id, BOOL, loc),
|
|
9551
|
+
then: dynUndefinedExpr(loc),
|
|
9552
|
+
else_: get("value"),
|
|
9553
|
+
type: DYN,
|
|
9554
|
+
loc,
|
|
9555
|
+
},
|
|
9556
|
+
type: DYN,
|
|
9557
|
+
loc,
|
|
9558
|
+
},
|
|
9559
|
+
};
|
|
9560
|
+
}
|
|
9197
9561
|
function lowerForOfString(lowerer, stmt, iterable, labels) {
|
|
9198
9562
|
let exprTarget = null;
|
|
9199
9563
|
let exprTargetNode = null;
|
|
@@ -9821,17 +10185,20 @@ export function lowerForStatement(lowerer, stmt) {
|
|
|
9821
10185
|
lowerer.scopes.pop();
|
|
9822
10186
|
}
|
|
9823
10187
|
}
|
|
9824
|
-
/** safe-buffer's `var Buffer = buffer.Buffer`
|
|
9825
|
-
*
|
|
9826
|
-
*
|
|
9827
|
-
*
|
|
9828
|
-
*
|
|
10188
|
+
/** safe-buffer's `var Buffer = buffer.Buffer` (or `var pna = process`, the
|
|
10189
|
+
* process-nextick-args binding once it compiles as process) at file scope:
|
|
10190
|
+
* a `var` alias of a surfaced global other than the global object itself
|
|
10191
|
+
* is the same alias plumbing as the const spelling when nothing reassigns
|
|
10192
|
+
* it and no code that runs before the declaration can read it (the
|
|
10193
|
+
* require-binding early-reference analysis), so the hoisted undefined is
|
|
10194
|
+
* unobservable. */
|
|
9829
10195
|
export function stdlibBufferVarAlias(lowerer, decl) {
|
|
9830
10196
|
if (!ts.isIdentifier(decl.name) ||
|
|
9831
10197
|
!ts.isVariableDeclarationList(decl.parent) ||
|
|
9832
10198
|
(decl.parent.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const)) !== 0 ||
|
|
9833
10199
|
decl.initializer === undefined ||
|
|
9834
|
-
!bufferNamespaceMember(lowerer, decl.initializer)
|
|
10200
|
+
!(bufferNamespaceMember(lowerer, decl.initializer) ||
|
|
10201
|
+
(stdlibGlobalAliasNameOf(lowerer, decl.initializer) ?? "globalThis") !== "globalThis"))
|
|
9835
10202
|
return false;
|
|
9836
10203
|
const symbol = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
9837
10204
|
return (symbol !== undefined &&
|