@scriptc/compiler 0.4.6 → 0.4.8
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/node-fallback/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +29 -6
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +57 -12
- package/ambient/node-fallback/http.d.ts +26 -18
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +25 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +95 -20
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +22 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +12 -1
- package/dist/backend/immutability.js +50 -4
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/immutability.test.js +95 -1
- package/dist/backend/immutability.test.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +18 -5
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +20 -2
- package/dist/backend/linker.js +221 -35
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +15 -6
- package/dist/backend/lld.js +24 -16
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +13 -5
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +50 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +34 -9
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +64 -3
- package/dist/backend/llvm/dyn.js +251 -15
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +68 -5
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +226 -77
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +138 -34
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +142 -10
- package/dist/backend/llvm/emitter.js +523 -73
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +38 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +237 -23
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +123 -12
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +59 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +2 -0
- package/dist/backend/llvm/integer-values.js +6 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +57 -1
- package/dist/backend/llvm/js-ic.js +389 -22
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +152 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +116 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +180 -27
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +139 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +67 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
- package/dist/backend/llvm/loop-entry-versions.js +43 -21
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +7 -1
- package/dist/backend/llvm/loop-state.js +26 -3
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
- package/dist/backend/llvm/map-number-lookup.js +7 -3
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +58 -17
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
- package/dist/backend/llvm/receiver-brackets.test.js +68 -0
- package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +147 -12
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/record-views.test.js +76 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +4 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +36 -3
- package/dist/backend/llvm/shapes.js +201 -16
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +4 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +10 -1
- package/dist/backend/llvm/speculative-integers.js +59 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +3 -3
- package/dist/backend/llvm/unwind-abi.js +8 -3
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +47 -3
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +94 -0
- package/dist/backend/native/executable.js +134 -10
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +10 -2
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +8 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +30 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +72 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +1 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-profile.d.ts +4 -1
- package/dist/backend/native-profile.js +12 -1
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +10 -0
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/publication.d.ts +4 -1
- package/dist/backend/publication.js +4 -2
- package/dist/backend/publication.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 +46 -7
- package/dist/backend/runtime-pack-core.js +37 -2
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +18 -1
- package/dist/backend/runtime-pack-native.js +138 -29
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.js +166 -4
- package/dist/backend/runtime-pack-native.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -0
- package/dist/backend/runtime-pack.js +25 -3
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +213 -12
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +8 -1
- package/dist/backend/vendor-archives.js +313 -8
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +60 -3
- package/dist/backend/vendor-inputs.js +109 -3
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +62 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +2 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +7 -1
- package/dist/compat/fetch-profile.js +25 -12
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/contracts/check.d.ts +3 -0
- package/dist/contracts/check.js +18 -5
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +14 -0
- package/dist/diagnostics/codes.js +14 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +68 -0
- package/dist/diagnostics/diagnostic.js +186 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.js +3 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +48 -0
- package/dist/executable/executable-cache.js +38 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +127 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +438 -234
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +24 -0
- package/dist/frontend/early-errors.js +836 -0
- package/dist/frontend/early-errors.js.map +1 -0
- package/dist/frontend/early-errors.test.d.ts +1 -0
- package/dist/frontend/early-errors.test.js +207 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +47 -0
- package/dist/frontend/input-tracker.js +173 -36
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +86 -2
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/js-inference.d.ts +2 -0
- package/dist/frontend/js-inference.js +18 -0
- package/dist/frontend/js-inference.js.map +1 -0
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +86 -4
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +13 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +41 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +565 -28
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
- package/dist/frontend/lowering/builtins/dates.js +23 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
- package/dist/frontend/lowering/builtins/environment.js +213 -2
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
- package/dist/frontend/lowering/builtins/filesystem.js +185 -16
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +42 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
- package/dist/frontend/lowering/builtins/operating-system.js +101 -20
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +18 -2
- package/dist/frontend/lowering/builtins/process.js +386 -25
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
- package/dist/frontend/lowering/builtins/querystring.js +202 -18
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +200 -38
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +60 -1
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +55 -13
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
- package/dist/frontend/lowering/builtins/v8.js +7 -5
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +180 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.js +5 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +59 -10
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +35 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/class-views.d.ts +13 -0
- package/dist/frontend/lowering/class-views.js +51 -0
- package/dist/frontend/lowering/class-views.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +15 -0
- package/dist/frontend/lowering/coercions/state.js +24 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +39 -2
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +37 -8
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +30 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +450 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
- package/dist/frontend/lowering/expressions/array-literals.js +88 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +216 -14
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +272 -11
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +173 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +195 -18
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
- package/dist/frontend/lowering/expressions/object-literals.js +951 -240
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
- package/dist/frontend/lowering/expressions/property-access.js +1141 -87
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +262 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +25 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +156 -22
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +6 -0
- package/dist/frontend/lowering/frozen-records.js +10 -4
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
- package/dist/frontend/lowering/frozen-records.test.js +44 -0
- package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
- package/dist/frontend/lowering/function-names.d.ts +9 -0
- package/dist/frontend/lowering/function-names.js +95 -0
- package/dist/frontend/lowering/function-names.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +42 -13
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +75 -0
- package/dist/frontend/lowering/generic-functions.js +790 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +15 -4
- package/dist/frontend/lowering/global-values.js +67 -9
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.js +34 -1
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +571 -9
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +25 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +140 -16
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +342 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -1
- package/dist/frontend/lowering/lower-calls.js +1354 -273
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-calls.test.js +121 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +36 -5
- package/dist/frontend/lowering/lower-classes.js +630 -89
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
- package/dist/frontend/lowering/lower-event-emitter.js +610 -98
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
- package/dist/frontend/lowering/lower-exprs.js +96 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +27 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +713 -92
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +135 -27
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +472 -67
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +463 -96
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.js +13 -1
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
- package/dist/frontend/lowering/lower-stdlib.js +77 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
- package/dist/frontend/lowering/lower-stmts.js +831 -136
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +126 -8
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +243 -48
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +363 -21
- package/dist/frontend/lowering/lowerer.js +1224 -129
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +19 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/module-namespace-elements.js +15 -0
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +2 -2
- package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
- package/dist/frontend/lowering/partial-assertions.js +189 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +221 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
- package/dist/frontend/lowering/private-statics.d.ts +46 -0
- package/dist/frontend/lowering/private-statics.js +322 -0
- package/dist/frontend/lowering/private-statics.js.map +1 -0
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +12 -1
- package/dist/frontend/lowering/record-sources.js +60 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.d.ts +4 -0
- package/dist/frontend/lowering/strict-equality.js +14 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +42 -1
- package/dist/frontend/lowering/surfaces.js +212 -71
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +136 -17
- package/dist/frontend/lowering/unit-journal.js +324 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +126 -3
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
- package/dist/frontend/lowering/unit-reuse.js +1008 -0
- package/dist/frontend/lowering/unit-reuse.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +12 -0
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-file-import.test.d.ts +1 -0
- package/dist/frontend/npm-file-import.test.js +76 -0
- package/dist/frontend/npm-file-import.test.js.map +1 -0
- package/dist/frontend/npm-static.js +95 -11
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/npm.d.ts +9 -0
- package/dist/frontend/npm.js +82 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/pipeline-native.js +2 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +9 -4
- package/dist/frontend/pipeline.js +162 -38
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-node.d.ts +3 -0
- package/dist/frontend/program-node.js +13 -6
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +71 -2
- package/dist/frontend/program.js +836 -411
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +4 -0
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.d.ts +14 -0
- package/dist/frontend/services.js +52 -2
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +61 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +5 -0
- package/dist/frontend/shape-inference/analyze.js +104 -4
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/domain.js +0 -1
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/index.js +5 -1
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/memo.d.ts +2 -1
- package/dist/frontend/shape-inference/memo.js +6 -2
- package/dist/frontend/shape-inference/memo.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.d.ts +1 -1
- package/dist/frontend/shape-inference/overlay.js +184 -4
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.js +11 -6
- package/dist/frontend/shape-inference/static-objects.js.map +1 -1
- package/dist/frontend/source-phase-imports.test.d.ts +1 -0
- package/dist/frontend/source-phase-imports.test.js +37 -0
- package/dist/frontend/source-phase-imports.test.js.map +1 -0
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +12 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.js +3 -5
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +13 -0
- package/dist/frontend/ts7/checker-backend.js +84 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +126 -2
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +22 -1
- package/dist/frontend/ts7/program-host.js +49 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +83 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.d.ts +16 -1
- package/dist/frontend/ts7/rpc-process.js +170 -92
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js +49 -21
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +956 -101
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +98 -11
- package/dist/frontend/type-mapper.js +770 -182
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/build.d.ts +3 -2
- package/dist/ir/build.js +4 -2
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +96 -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 +453 -26
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5350 -0
- package/dist/ir/codec.generated.js.map +1 -0
- package/dist/ir/codec.js +325 -0
- package/dist/ir/codec.js.map +1 -0
- package/dist/ir/codec.test.d.ts +1 -0
- package/dist/ir/codec.test.js +225 -0
- package/dist/ir/codec.test.js.map +1 -0
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +29 -10
- package/dist/ir/fields.generated.js +1039 -11
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/fields.test.js +46 -2
- package/dist/ir/fields.test.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +6 -4
- package/dist/ir/function-references.js +11 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +14 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-sources.js +4 -1
- package/dist/ir/inline-array-sources.js.map +1 -1
- package/dist/ir/inline-array-views.d.ts +13 -0
- package/dist/ir/inline-array-views.js +945 -0
- package/dist/ir/inline-array-views.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +7 -0
- package/dist/ir/inline-arrays.js +190 -55
- package/dist/ir/inline-arrays.js.map +1 -1
- package/dist/ir/inline-arrays.test.js +140 -2
- package/dist/ir/inline-arrays.test.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +130 -44
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +58 -25
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +37 -3
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/jsval.js +374 -63
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +96 -2
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.js +112 -9
- package/dist/ir/loop-entry-ranges.js.map +1 -1
- package/dist/ir/loop-entry-ranges.test.js +40 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -3
- package/dist/ir/parameter-versions.js +63 -40
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +139 -5
- package/dist/ir/runtime-features.js +397 -19
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +135 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +11 -2
- package/dist/ir/saturating-loop-jams.js +56 -16
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/saturating-loop-jams.test.js +39 -1
- package/dist/ir/saturating-loop-jams.test.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +40 -28
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/self-captures.test.js +15 -0
- package/dist/ir/self-captures.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +8 -2
- package/dist/ir/serialize.js +92 -24
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +170 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +46 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +4 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +49 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +26 -5
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +74 -28
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +63 -4
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +93 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.js +9 -2
- package/dist/native/toolchain.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +37 -1
- package/dist/node-islands/boundary.js +65 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +27 -1
- package/dist/node-islands/detect.js +475 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +175 -4
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/effect-gate.js +30 -20
- package/dist/node-islands/effect-gate.js.map +1 -1
- package/dist/node-islands/effect-gate.test.js +4 -1
- package/dist/node-islands/effect-gate.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/libnode.d.ts +1 -1
- package/dist/node-islands/libnode.js +1 -1
- package/dist/node-islands/libnode.js.map +1 -1
- package/dist/node-islands/modules.d.ts +28 -0
- package/dist/node-islands/modules.js +156 -0
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +105 -1
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/policy.js +2 -3
- package/dist/node-islands/policy.js.map +1 -1
- package/dist/node-islands/probe-recorder.d.ts +1 -0
- package/dist/node-islands/probe-recorder.js +596 -0
- package/dist/node-islands/probe-recorder.js.map +1 -0
- package/dist/node-islands/probe-recorder.test.d.ts +1 -0
- package/dist/node-islands/probe-recorder.test.js +80 -0
- package/dist/node-islands/probe-recorder.test.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +4 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +9 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +16 -1
- package/dist/node-islands/scan.js +110 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/node-islands/snapshot.d.ts +38 -1
- package/dist/node-islands/snapshot.js +165 -161
- package/dist/node-islands/snapshot.js.map +1 -1
- package/dist/node-islands/snapshot.test.js +63 -2
- package/dist/node-islands/snapshot.test.js.map +1 -1
- package/dist/node-islands/summary.js +8 -0
- package/dist/node-islands/summary.js.map +1 -1
- package/dist/node-islands/type-strip.d.ts +11 -0
- package/dist/node-islands/type-strip.js +157 -0
- package/dist/node-islands/type-strip.js.map +1 -0
- package/dist/node-islands/type-strip.test.d.ts +1 -0
- package/dist/node-islands/type-strip.test.js +31 -0
- package/dist/node-islands/type-strip.test.js.map +1 -0
- package/dist/project-config.d.ts +4 -0
- package/dist/project-config.js +19 -0
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +10 -0
- package/dist/project-config.test.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +221 -122
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lowerStaticPrivateAssignment } from "./private-statics.js";
|
|
2
|
+
import { keepsCheckedDynamicValue, keepsInitializerLayout, notePreservedLayout, } from "./structural-instances.js";
|
|
3
|
+
import { partialFieldRead } from "./partial-assertions.js";
|
|
2
4
|
import { jsGlobalValueByName } from "./global-values.js";
|
|
3
5
|
import { lowerTupleAliasDecl, stripTypeWrappers } from "./typed-arguments.js";
|
|
4
|
-
import { islandHandleBinding, lowerIslandExpr, lowerIslandSubclass } from "./lower-node-island.js";
|
|
6
|
+
import { islandHandleBinding, lowerIslandExpr, isIslandRequireSpec, lowerIslandRequireAtStatement, lowerIslandSubclass, } from "./lower-node-island.js";
|
|
5
7
|
import { isIslandSubclassDecl } from "../../node-islands/boundary.js";
|
|
6
8
|
import { allBytesArms, indexedUnionArms, lowerIndexedUnionMember, lowerIndexedUnionNumberRead, lowerIndexedUnionRead, } from "./indexed-unions.js";
|
|
7
|
-
import { declaredMemberOf, isPromisePrototypeRead, lowerUnionKeyedRead, } from "./expressions/property-access.js";
|
|
8
|
-
import { hostedStorageView, hostsAll } from "./expressions/hosted-narrowing.js";
|
|
9
|
+
import { declaredMemberOf, fenceDatePrototypeWrite, isPromisePrototypeRead, lowerUnionKeyedRead, } from "./expressions/property-access.js";
|
|
10
|
+
import { hostedStorageView, hostsAll, recordViewHosted } from "./expressions/hosted-narrowing.js";
|
|
11
|
+
import { assertionViewCopy, bindingIdentityUse, bindingWrite } from "./divergences.js";
|
|
9
12
|
import { requestGeneralStreamSurface } from "./general-streams.js";
|
|
10
13
|
import { lowerForAwaitDynStream, nodeStreamInterfaceSide } from "./dyn-streams.js";
|
|
11
14
|
import { lowerForAwaitValueStream } from "./builtins/hash-stream.js";
|
|
12
15
|
import { lowerChildPropertyWrite } from "./handle-properties.js";
|
|
13
16
|
import { matchAllRowsReadByElements, storedMatchAllRowsReadByElements, } from "./containers/match-row-uses.js";
|
|
14
|
-
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
15
|
-
import { runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
|
|
17
|
+
import { dynUndefinedExpr, nodeThrowExpr, numLit, strLit, varRef } from "../../ir/build.js";
|
|
18
|
+
import { literalFieldKeys, runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
|
|
16
19
|
import { declaresHoistedBinding, staticCondition } from "./static-typeof.js";
|
|
17
20
|
import { lowerCollectionSpread } from "./containers/collection-methods.js";
|
|
18
21
|
import { lowerEventObjectPropertyWrite } from "./lower-event-target.js";
|
|
19
22
|
import { lowerDynObjectLiteral } from "./expressions/object-literals.js";
|
|
20
23
|
import { importMetaBindingSource } from "./import-meta.js";
|
|
24
|
+
import { nullishEmptyPatternSource } from "./nullish-empty-pattern.js";
|
|
21
25
|
import { anyResidueReplacedBy } from "./any-collection-residue.js";
|
|
22
26
|
import { iteratorCanStep, iteratorValue } from "./iterator-consumption.js";
|
|
23
27
|
import { notIterableSpelling } from "./iterable-spelling.js";
|
|
@@ -31,21 +35,23 @@ import { isWebStreamValueInJavaScript, typeInvolvesWebStream } from "./builtins/
|
|
|
31
35
|
import * as ts from "../ts7/adapter.js";
|
|
32
36
|
import { lowerOptionalIndex } from "./undefined-index.js";
|
|
33
37
|
import { processDataMemberValue, programReadsExitCode } from "./builtins/process.js";
|
|
38
|
+
import { heldEnvValueType, refuseHeldEnvCopyHold } from "./builtins/environment.js";
|
|
34
39
|
import { requireInitFlagStmt } from "./require-initialization.js";
|
|
35
40
|
import { isJsonRequireDecl } from "./json-require.js";
|
|
36
41
|
import { isTimeValueDateDeclaration } from "./date-values.js";
|
|
37
42
|
import { bindingSource } from "../binding-source.js";
|
|
38
|
-
import { lowerConstructorReturn } from "./constructor-returns.js";
|
|
43
|
+
import { clearPendingPrimitiveReturn, lowerConstructorReturn } from "./constructor-returns.js";
|
|
39
44
|
import { statementGroupKey } from "./type-failure.js";
|
|
40
45
|
import { cjsExportValueByName, cjsNamespaceDestructureOf, cjsTableMethodEntry, inlineProgramRequireOf, requireNestedPatternsOf, splitRequireAssignmentOf, splitRequireBindingOf, splitRequireBindingOfIdent, splitRequireEarlyReadOf, wholeExportSymbolOfModule, } from "./cjs-inline-require.js";
|
|
41
46
|
import { cjsExportMemberWriteGlobalOf, isCjsExportsIdentifier, isCjsModuleExports, isFreshExportsReset, } from "./cjs-exports-object.js";
|
|
42
47
|
import { isDeadTscHelperDecl, tscInteropBindingOfDecl } from "./cjs-tsc-interop.js";
|
|
43
48
|
import { arrayValueRead, arrayValueStore, arrayValueType, unionArrayValueRead, lowerSafeIndexRead, } from "./array-values.js";
|
|
44
49
|
import { lowerForAwaitGenerator, lowerForOfGenerator, lowerYieldStarStatement, } from "./lower-generators.js";
|
|
45
|
-
import { classAsyncGeneratorIterator, lowerForAwaitBuiltin } from "./lower-async-iteration.js";
|
|
46
|
-
import { BOOL, BYTES_U8, CAUGHT, DATE_T, DYN, F64, SEARCH_PARAMS_T, STRING, UNDEFINED_T, VOID, arrayOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
|
|
50
|
+
import { classAsyncGeneratorIterator, isNodeReadableIteratorSource, isWebReadableIteratorSource, lowerForAwaitBuiltin, } from "./lower-async-iteration.js";
|
|
51
|
+
import { BOOL, BYTES_U8, CAUGHT, DATE_T, DYN_HANDLE_KINDS, DYN, F64, SEARCH_PARAMS_T, STRING, UNDEFINED_T, VOID, arrayOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
|
|
47
52
|
import { PoisonError, boundIdentifiersOf, dynFallbackType, neverTaintedJsType, staticImportNamespaceType, } from "./lowerer.js";
|
|
48
53
|
import { enforceLibBoundary, lowerSurplusCalls } from "./lib-boundary.js";
|
|
54
|
+
import { isBuiltinIdentityToken, isPrimitiveValueType, lowerPrimitiveBaseDelete, } from "./primitive-throws.js";
|
|
49
55
|
import { cjsExportAssignmentOf, cjsExportChainOf, cjsVoidInitPreambleReals, cjsExportDiscardReason, cjsExportTargetLiteral, isCjsJsFile, isEsModuleStamp, isJsSourceFile, locOf, requireEarlyReference, requireSpecOf, } from "../program.js";
|
|
50
56
|
import { isStrictCode } from "./strict-mode.js";
|
|
51
57
|
import { markSloppyRecordWrites } from "./frozen-records.js";
|
|
@@ -58,7 +64,7 @@ import { lowerForOfArrayIter, lowerForOfMap, lowerForOfSearchParams, lowerForOfS
|
|
|
58
64
|
import { lowerForOfHelperChain } from "./containers/iterator-helpers.js";
|
|
59
65
|
import { objectIterOverIndexShape } from "./containers/indexed-objects.js";
|
|
60
66
|
import { strCharsCall } from "./containers/array-construction.js";
|
|
61
|
-
import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, genericBindingPresenceStore, genericBindingStoredValue, implicitLocalFnInfoOf, implicitLocalFnNodeOf, implicitMethodCallInfersReturn, genericLocalClassBinding, } from "./generic-functions.js";
|
|
67
|
+
import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, genericAliasPresenceStore, genericBindingPresenceStore, genericBindingStoredValue, implicitLocalFnInfoOf, implicitLocalFnNodeOf, implicitMethodCallInfersReturn, genericLocalClassBinding, } from "./generic-functions.js";
|
|
62
68
|
import { bindingNeverReassigned, deadUnmappableBinding, fileWritesBinding, nullishExprUnitOf, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
|
|
63
69
|
import { hasExplicitJsDocReturn } from "./function-returns.js";
|
|
64
70
|
import { recordKeysArrayCall } from "./lower-calls.js";
|
|
@@ -734,8 +740,11 @@ function lowerOneStatement(lowerer, stmt, out, usingMarkers, diagsBefore, deferF
|
|
|
734
740
|
if (deferFences && lowerer.diagSink === null && lowerer.diags.length > diagsBefore) {
|
|
735
741
|
const flushed = lowerer.diags.splice(diagsBefore);
|
|
736
742
|
const ice = flushed.filter((d) => d.code === "SC9001");
|
|
737
|
-
|
|
738
|
-
|
|
743
|
+
for (const d of ice)
|
|
744
|
+
lowerer.diags.push(d);
|
|
745
|
+
for (const d of flushed)
|
|
746
|
+
if (d.code !== "SC9001")
|
|
747
|
+
lowerer.runtimeFences.push(d);
|
|
739
748
|
}
|
|
740
749
|
}
|
|
741
750
|
/** Whether a statement list belongs to a function body (at any block
|
|
@@ -883,6 +892,11 @@ export function predeclareForwardCapture(lowerer, symbol) {
|
|
|
883
892
|
lowerer.isStdlibGlobal(decl.initializer.expression.expression, "Object"))) &&
|
|
884
893
|
lowerer.dynConvertible(type))
|
|
885
894
|
type = DYN;
|
|
895
|
+
// An island handle binding holds a checked-dynamic value whatever its
|
|
896
|
+
// declared type says: its own declaration lowers as one, and so must
|
|
897
|
+
// the slot a closure captured first.
|
|
898
|
+
if (islandHandleBinding(lowerer, decl.name))
|
|
899
|
+
type = DYN;
|
|
886
900
|
if (!TDZ_KINDS.has(type.kind) || isUnitType(type))
|
|
887
901
|
return false;
|
|
888
902
|
const name = decl.name.text;
|
|
@@ -995,8 +1009,11 @@ export function predeclareForwardFnDecl(lowerer, symbol) {
|
|
|
995
1009
|
}
|
|
996
1010
|
catch (e) {
|
|
997
1011
|
entry.ctx.hoistedFnDecls.delete(decl);
|
|
998
|
-
if (previousSink !== null)
|
|
999
|
-
|
|
1012
|
+
if (previousSink !== null) {
|
|
1013
|
+
const flushed = lowerer.diags.splice(diagsBefore);
|
|
1014
|
+
for (const d of flushed)
|
|
1015
|
+
previousSink.push(d);
|
|
1016
|
+
}
|
|
1000
1017
|
throw e;
|
|
1001
1018
|
}
|
|
1002
1019
|
finally {
|
|
@@ -1023,7 +1040,9 @@ function hostVariableDeclarationOf(name) {
|
|
|
1023
1040
|
while (ts.isBindingElement(n) || ts.isArrayBindingPattern(n) || ts.isObjectBindingPattern(n)) {
|
|
1024
1041
|
n = n.parent;
|
|
1025
1042
|
}
|
|
1026
|
-
|
|
1043
|
+
// A catch parameter is a VariableDeclaration of the CatchClause: its
|
|
1044
|
+
// bindings are scoped to the clause, and each execution makes new ones.
|
|
1045
|
+
return ts.isVariableDeclaration(n) && !ts.isCatchClause(n.parent) ? n : null;
|
|
1027
1046
|
}
|
|
1028
1047
|
/** `for (var x of ...)` loop variables: the ONE function-scoped binding
|
|
1029
1048
|
* every for-of desugar must ASSIGN per iteration instead of declaring a
|
|
@@ -1483,10 +1502,12 @@ const THROWN_AS_DYN = new Set([
|
|
|
1483
1502
|
]);
|
|
1484
1503
|
/** A `return` at the top level of a CommonJS module (preflight admits it
|
|
1485
1504
|
* there only): it ends the module's evaluation, and its value is
|
|
1486
|
-
* evaluated and discarded, as Node's module wrapper does.
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1505
|
+
* evaluated and discarded, as Node's module wrapper does. Bindings
|
|
1506
|
+
* declared after it stay uninitialized when it is taken, which only code
|
|
1507
|
+
* that exists by then can observe: a function created before the return,
|
|
1508
|
+
* or a hoisted function declaration. A module whose such functions read a
|
|
1509
|
+
* later binding, or that assigns exports after the return, keeps a
|
|
1510
|
+
* refusal. Null for a return inside a function. */
|
|
1490
1511
|
function lowerModuleLevelReturn(lowerer, stmt) {
|
|
1491
1512
|
let top = stmt;
|
|
1492
1513
|
while (top.parent !== undefined && !ts.isSourceFile(top.parent)) {
|
|
@@ -1498,9 +1519,25 @@ function lowerModuleLevelReturn(lowerer, stmt) {
|
|
|
1498
1519
|
if (sf === undefined || !ts.isSourceFile(sf))
|
|
1499
1520
|
return null;
|
|
1500
1521
|
const stmts = sf.statements.nodes;
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1522
|
+
const index = stmts.indexOf(top);
|
|
1523
|
+
const later = stmts.slice(index + 1);
|
|
1524
|
+
if (later.some((s) => cjsExportAssignmentOf(s) !== null)) {
|
|
1525
|
+
lowerer.unsupported("SC1090", stmt, "a top-level return in a CommonJS module that assigns exports after it");
|
|
1526
|
+
}
|
|
1527
|
+
const laterBindings = laterModuleBindings(lowerer, later);
|
|
1528
|
+
if (laterBindings.size > 0) {
|
|
1529
|
+
// Functions that exist when the return is taken: every function in the
|
|
1530
|
+
// statements up to the return, and the hoisted declarations after it.
|
|
1531
|
+
const reachable = [
|
|
1532
|
+
...stmts.slice(0, index + 1),
|
|
1533
|
+
...later.filter((s) => ts.isFunctionDeclaration(s)),
|
|
1534
|
+
];
|
|
1535
|
+
const read = reachable
|
|
1536
|
+
.map((s) => functionReadOf(lowerer, s, laterBindings, ts.isFunctionDeclaration(s)))
|
|
1537
|
+
.find((r) => r !== null);
|
|
1538
|
+
if (read) {
|
|
1539
|
+
lowerer.unsupported("SC1090", read, `reading '${read.text}', declared after a top-level CommonJS return, from a function that can run once the return is taken`);
|
|
1540
|
+
}
|
|
1504
1541
|
}
|
|
1505
1542
|
const loc = locOf(stmt);
|
|
1506
1543
|
const ret = { kind: "return", value: null, loc };
|
|
@@ -1512,6 +1549,50 @@ function lowerModuleLevelReturn(lowerer, stmt) {
|
|
|
1512
1549
|
loc,
|
|
1513
1550
|
};
|
|
1514
1551
|
}
|
|
1552
|
+
/** The module-scope bindings `stmts` declare: variables and classes, with
|
|
1553
|
+
* `var` declarations in nested blocks. Bindings inside functions are not
|
|
1554
|
+
* module-scope and are skipped. */
|
|
1555
|
+
function laterModuleBindings(lowerer, stmts) {
|
|
1556
|
+
const bindings = new Set();
|
|
1557
|
+
const addName = (name) => {
|
|
1558
|
+
if (ts.isIdentifier(name)) {
|
|
1559
|
+
const symbol = lowerer.checker.getSymbolAtLocation(name);
|
|
1560
|
+
if (symbol)
|
|
1561
|
+
bindings.add(symbol);
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
for (const element of name.elements.nodes) {
|
|
1565
|
+
if (ts.isBindingElement(element) && element.name)
|
|
1566
|
+
addName(element.name);
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
const visit = (node) => {
|
|
1570
|
+
if (ts.isFunctionLike(node) || ts.isClassStaticBlockDeclaration(node))
|
|
1571
|
+
return;
|
|
1572
|
+
if (ts.isVariableDeclaration(node))
|
|
1573
|
+
addName(node.name);
|
|
1574
|
+
if (ts.isClassDeclaration(node) && node.name)
|
|
1575
|
+
addName(node.name);
|
|
1576
|
+
ts.forEachChild(node, visit);
|
|
1577
|
+
};
|
|
1578
|
+
for (const stmt of stmts)
|
|
1579
|
+
visit(stmt);
|
|
1580
|
+
return bindings;
|
|
1581
|
+
}
|
|
1582
|
+
/** The first identifier inside a function or class in `node` (anywhere in
|
|
1583
|
+
* `node` when `inFunction`) that reads one of `bindings`, or null. */
|
|
1584
|
+
function functionReadOf(lowerer, node, bindings, inFunction) {
|
|
1585
|
+
if (inFunction && ts.isIdentifier(node)) {
|
|
1586
|
+
const symbol = lowerer.resolveValueSymbol(node);
|
|
1587
|
+
return symbol && bindings.has(symbol) ? node : null;
|
|
1588
|
+
}
|
|
1589
|
+
// Class bodies count as functions: field initializers run per instance.
|
|
1590
|
+
const nested = inFunction ||
|
|
1591
|
+
ts.isFunctionLike(node) ||
|
|
1592
|
+
ts.isClassDeclaration(node) ||
|
|
1593
|
+
ts.isClassExpression(node);
|
|
1594
|
+
return (ts.forEachChild(node, (child) => functionReadOf(lowerer, child, bindings, nested) ?? undefined) ?? null);
|
|
1595
|
+
}
|
|
1515
1596
|
export function lowerStmt(lowerer, stmt) {
|
|
1516
1597
|
if (ownPrototypeResetStatement(lowerer, stmt))
|
|
1517
1598
|
return { kind: "block", body: [], loc: locOf(stmt) };
|
|
@@ -1647,6 +1728,39 @@ export function lowerStmt(lowerer, stmt) {
|
|
|
1647
1728
|
// observed empty returns even when JSDoc omits undefined. Any remaining
|
|
1648
1729
|
// incompatible boundary keeps the ordinary per-statement refusal.
|
|
1649
1730
|
let value = null;
|
|
1731
|
+
// A derived constructor that can record a pending TypeError on a
|
|
1732
|
+
// primitive return drops it when a return of its own completes: a
|
|
1733
|
+
// `finally` block's `return;`, `return undefined` or `return this`
|
|
1734
|
+
// replaces the earlier completion instead of leaving it pending. The
|
|
1735
|
+
// drop follows the operand, which may throw — an operand that throws
|
|
1736
|
+
// never completes the return, so a `finally` that catches it and then
|
|
1737
|
+
// finishes resumes the earlier primitive return (and its TypeError).
|
|
1738
|
+
const withClearedPending = (ret) => {
|
|
1739
|
+
const clear = clearPendingPrimitiveReturn(lowerer, stmt);
|
|
1740
|
+
if (clear.length === 0)
|
|
1741
|
+
return ret;
|
|
1742
|
+
const loc = locOf(stmt);
|
|
1743
|
+
const body = ret.kind === "block" ? ret.body : [ret];
|
|
1744
|
+
const last = body.at(-1);
|
|
1745
|
+
if (last?.kind !== "return")
|
|
1746
|
+
return { kind: "block", body: [...clear, ret], loc };
|
|
1747
|
+
const before = body.slice(0, -1);
|
|
1748
|
+
if (last.value === null)
|
|
1749
|
+
return { kind: "block", body: [...before, ...clear, last], loc };
|
|
1750
|
+
// A constructor returns void, so a valued operand only evaluates for
|
|
1751
|
+
// effect — ahead of the drop, since a `return this.fail()` inside a
|
|
1752
|
+
// `finally` that catches the throw never completes.
|
|
1753
|
+
return {
|
|
1754
|
+
kind: "block",
|
|
1755
|
+
body: [
|
|
1756
|
+
...before,
|
|
1757
|
+
{ kind: "exprStmt", expr: last.value, loc },
|
|
1758
|
+
...clear,
|
|
1759
|
+
{ kind: "return", value: null, loc },
|
|
1760
|
+
],
|
|
1761
|
+
loc,
|
|
1762
|
+
};
|
|
1763
|
+
};
|
|
1650
1764
|
if (stmt.expression) {
|
|
1651
1765
|
// A constructor's returned object replaces the constructed `this`.
|
|
1652
1766
|
if (lowerer.currentClass?.ctor) {
|
|
@@ -1654,7 +1768,7 @@ export function lowerStmt(lowerer, stmt) {
|
|
|
1654
1768
|
if (constructorReturn !== null)
|
|
1655
1769
|
return constructorReturn;
|
|
1656
1770
|
}
|
|
1657
|
-
return lowerer.lowerReturnStmt(stmt.expression, locOf(stmt));
|
|
1771
|
+
return withClearedPending(lowerer.lowerReturnStmt(stmt.expression, locOf(stmt)));
|
|
1658
1772
|
}
|
|
1659
1773
|
else if (lowerer.ctx.returnType.kind === "union") {
|
|
1660
1774
|
value = lowerer.wrappedUndefined(lowerer.ctx.returnType, locOf(stmt));
|
|
@@ -1670,8 +1784,8 @@ export function lowerStmt(lowerer, stmt) {
|
|
|
1670
1784
|
}
|
|
1671
1785
|
// An async generator's bare return has no operand to await.
|
|
1672
1786
|
if (lowerer.ctx.isAsync === true && lowerer.ctx.generator)
|
|
1673
|
-
return { kind: "return", value, awaited: true, loc: locOf(stmt) };
|
|
1674
|
-
return { kind: "return", value, loc: locOf(stmt) };
|
|
1787
|
+
return withClearedPending({ kind: "return", value, awaited: true, loc: locOf(stmt) });
|
|
1788
|
+
return withClearedPending({ kind: "return", value, loc: locOf(stmt) });
|
|
1675
1789
|
}
|
|
1676
1790
|
if (ts.isBreakStatement(stmt) || ts.isContinueStatement(stmt)) {
|
|
1677
1791
|
const kw = ts.isBreakStatement(stmt) ? "break" : "continue";
|
|
@@ -1865,6 +1979,11 @@ function lowerVarDeclarator(lowerer, stmt, decl, isConst, isLet) {
|
|
|
1865
1979
|
if (lowerer.externalTypes.has(spec))
|
|
1866
1980
|
lowerer.externalHostFence(spec, decl, false);
|
|
1867
1981
|
if (ts.isSourceFile(stmt.parent)) {
|
|
1982
|
+
// `const x = require("<island>")` and `const { name } = …`: the
|
|
1983
|
+
// island module loads here, at the statement (lower-node-island.ts).
|
|
1984
|
+
const island = lowerIslandRequireAtStatement(lowerer, decl);
|
|
1985
|
+
if (island !== null)
|
|
1986
|
+
return [island];
|
|
1868
1987
|
const init = lowerer.requireInitStmt(spec, decl);
|
|
1869
1988
|
const out = init ? [init] : [];
|
|
1870
1989
|
// Nested patterns destructure the named export's value right after
|
|
@@ -1883,6 +2002,12 @@ function lowerVarDeclarator(lowerer, stmt, decl, isConst, isLet) {
|
|
|
1883
2002
|
// same routing top-level requires use, and no statement remains.
|
|
1884
2003
|
// Relative requires keep the fence: their module-init-at-position
|
|
1885
2004
|
// semantics needs storage this model doesn't represent.
|
|
2005
|
+
// A nested require of an island package is an ordinary binding of the
|
|
2006
|
+
// island module, loaded at the statement (lower-node-island.ts).
|
|
2007
|
+
if (isIslandRequireSpec(lowerer, ts.getSourceFileOfNode(decl).fileName, spec)) {
|
|
2008
|
+
const lowered = lowerer.lowerVarDecl(decl, isLet);
|
|
2009
|
+
return lowered ? [lowered] : [];
|
|
2010
|
+
}
|
|
1886
2011
|
if (canonicalBuiltinModule(spec) !== null) {
|
|
1887
2012
|
return canonicalBuiltinModule(spec) === "punycode"
|
|
1888
2013
|
? [lowerer.punycodeRequireWarning(decl)]
|
|
@@ -2142,6 +2267,7 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
2142
2267
|
return tokenBound;
|
|
2143
2268
|
}
|
|
2144
2269
|
let init = importMetaBindingSource(lowerer, decl.name, decl.initializer) ??
|
|
2270
|
+
nullishEmptyPatternSource(lowerer, decl.name, decl.initializer) ??
|
|
2145
2271
|
lowerer.lowerExpr(decl.initializer);
|
|
2146
2272
|
const parseArgsDynObject = init.type.kind === "dyn" &&
|
|
2147
2273
|
isParseArgsDynCheckerType(lowerer, lowerer.typeOf(decl.initializer));
|
|
@@ -2187,13 +2313,26 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
2187
2313
|
}
|
|
2188
2314
|
}
|
|
2189
2315
|
const out = [];
|
|
2316
|
+
// V8's destructuring TypeError spells STATIC sources: an identifier
|
|
2317
|
+
// source reads "<name> is not iterable", an identifier-callee call
|
|
2318
|
+
// "<name> is not a function or its return value is not iterable";
|
|
2319
|
+
// everything else (property reads, method calls, parameters) gets the
|
|
2320
|
+
// runtime kind wording — exactly V8's CallPrinter behavior. The DYN
|
|
2321
|
+
// pattern arm and the unit arms of a narrowed union consume this.
|
|
2322
|
+
const src = decl.initializer;
|
|
2323
|
+
const dynSpell = ts.isIdentifier(src)
|
|
2324
|
+
? `${src.text} is not iterable`
|
|
2325
|
+
: ts.isCallExpression(src) && ts.isIdentifier(src.expression)
|
|
2326
|
+
? `${src.expression.text} is not a function or its return value is not iterable`
|
|
2327
|
+
: undefined;
|
|
2190
2328
|
// JS: a union source with exactly ONE destructurable arm beside unit
|
|
2191
2329
|
// arms (`nameAndArgs.match(re)` — `RegExpMatchArray | null`, the
|
|
2192
2330
|
// always-matches idiom) destructures through a VALIDATED narrow: the
|
|
2193
|
-
// unit arms throw
|
|
2194
|
-
// (
|
|
2195
|
-
//
|
|
2196
|
-
// the
|
|
2331
|
+
// unit arms throw Node's TypeError, through the checks a dyn source
|
|
2332
|
+
// takes (RequireObjectCoercible for an object pattern, GetIterator for
|
|
2333
|
+
// an array pattern). An object pattern whose source has no V8
|
|
2334
|
+
// spelling keeps the fence. TypeScript keeps the fence: narrowing
|
|
2335
|
+
// first is the annotated fix.
|
|
2197
2336
|
if (isJsSourceFile(ts.getSourceFileOfNode(decl)) && init.type.kind === "union") {
|
|
2198
2337
|
const def = lowerer.unions.get(init.type.unionId);
|
|
2199
2338
|
const dataArms = (def?.arms ?? []).filter((a) => !isUnitType(a));
|
|
@@ -2204,9 +2343,56 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
2204
2343
|
def.arms.every((a) => a === arm || isUnitType(a)) &&
|
|
2205
2344
|
(arm.kind === "array" || arm.kind === "record")) {
|
|
2206
2345
|
const tag = def.arms.indexOf(arm);
|
|
2346
|
+
const unionId = init.type.unionId;
|
|
2207
2347
|
const utmp = lowerer.declareHiddenLocal("%destrU", init.type);
|
|
2208
2348
|
out.push({ kind: "varDecl", localId: utmp.id, init, loc });
|
|
2209
2349
|
const uref = { kind: "varRef", localId: utmp.id, type: init.type, loc };
|
|
2350
|
+
// The failure branch holds one of the unit arms: the check reads it
|
|
2351
|
+
// as the dyn null or undefined it is, so the data arm needs no dyn
|
|
2352
|
+
// form (a record holding a generator has none).
|
|
2353
|
+
const unitValue = () => {
|
|
2354
|
+
const unitOf = (t) => lowerer.coerceToExpected({ kind: "unitLit", unit: t.kind === "nullT" ? "null" : "undefined", type: t, loc }, DYN);
|
|
2355
|
+
const units = def.arms.filter(isUnitType);
|
|
2356
|
+
const last = units[units.length - 1];
|
|
2357
|
+
return units.slice(0, -1).reduceRight((rest, t) => ({
|
|
2358
|
+
kind: "ternary",
|
|
2359
|
+
cond: {
|
|
2360
|
+
kind: "unionIsTag",
|
|
2361
|
+
unionId,
|
|
2362
|
+
tag: def.arms.indexOf(t),
|
|
2363
|
+
negated: false,
|
|
2364
|
+
value: uref,
|
|
2365
|
+
type: BOOL,
|
|
2366
|
+
loc,
|
|
2367
|
+
},
|
|
2368
|
+
then: unitOf(t),
|
|
2369
|
+
else_: rest,
|
|
2370
|
+
type: DYN,
|
|
2371
|
+
loc,
|
|
2372
|
+
}), unitOf(last));
|
|
2373
|
+
};
|
|
2374
|
+
const spelling = destrSpellingOf(src);
|
|
2375
|
+
const check = ts.isArrayBindingPattern(decl.name)
|
|
2376
|
+
? {
|
|
2377
|
+
kind: "dynIterN",
|
|
2378
|
+
value: unitValue(),
|
|
2379
|
+
count: decl.name.elements.nodes.length,
|
|
2380
|
+
...(dynSpell ? { notIterableMessage: dynSpell } : {}),
|
|
2381
|
+
type: DYN,
|
|
2382
|
+
loc,
|
|
2383
|
+
}
|
|
2384
|
+
: firstReadsWithDefault(decl.name)
|
|
2385
|
+
? firstKeyRead(lowerer, decl.name, unitValue, loc)
|
|
2386
|
+
: spelling !== null
|
|
2387
|
+
? {
|
|
2388
|
+
kind: "dynDestrCheck",
|
|
2389
|
+
value: unitValue(),
|
|
2390
|
+
spelling,
|
|
2391
|
+
...firstPatternProp(lowerer, decl.name),
|
|
2392
|
+
type: DYN,
|
|
2393
|
+
loc,
|
|
2394
|
+
}
|
|
2395
|
+
: null;
|
|
2210
2396
|
out.push({
|
|
2211
2397
|
kind: "if",
|
|
2212
2398
|
cond: {
|
|
@@ -2219,6 +2405,7 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
2219
2405
|
loc,
|
|
2220
2406
|
},
|
|
2221
2407
|
then: [
|
|
2408
|
+
...(check !== null ? [{ kind: "exprStmt", expr: check, loc }] : []),
|
|
2222
2409
|
{
|
|
2223
2410
|
kind: "runtimeFence",
|
|
2224
2411
|
code: "SC1031",
|
|
@@ -2241,58 +2428,40 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
2241
2428
|
// value: RequireObjectCoercible with V8's own TypeError ("Cannot
|
|
2242
2429
|
// destructure property 'a' of 'f(...)' as it is null.") for the source
|
|
2243
2430
|
// spellings the assignment form reproduces; other sources are refused,
|
|
2244
|
-
// as in the assignment form. JavaScript
|
|
2245
|
-
//
|
|
2246
|
-
// source
|
|
2247
|
-
//
|
|
2248
|
-
|
|
2431
|
+
// as in the assignment form. A JavaScript object pattern over a dyn
|
|
2432
|
+
// source checks the source first in the same way when V8 can spell it,
|
|
2433
|
+
// so a null or undefined source throws Node's message before any key
|
|
2434
|
+
// is read or evaluated; other sources keep their per-read errors. V8
|
|
2435
|
+
// skips the check when the first element has a default and a static
|
|
2436
|
+
// key: the read of that key throws ("Cannot read properties of null
|
|
2437
|
+
// (reading 'a')"), and so does the lowering's.
|
|
2438
|
+
const jsSourceCheck = init.type.kind === "dyn" &&
|
|
2249
2439
|
ts.isObjectBindingPattern(decl.name) &&
|
|
2250
2440
|
isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
2251
|
-
(decl.name.elements.nodes.length === 0 || startsWithRuntimeKey(lowerer, decl.name)) &&
|
|
2252
2441
|
destrSpellingOf(decl.initializer) !== null;
|
|
2253
|
-
if (
|
|
2442
|
+
if ((jsSourceCheck ||
|
|
2254
2443
|
(init.type.kind === "dyn" &&
|
|
2255
2444
|
ts.isObjectBindingPattern(decl.name) &&
|
|
2256
2445
|
!isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
2257
|
-
lowerer.anyOrigin(decl.initializer)))
|
|
2446
|
+
lowerer.anyOrigin(decl.initializer))) &&
|
|
2447
|
+
!firstReadsWithDefault(decl.name)) {
|
|
2258
2448
|
const spelling = destrSpellingOf(decl.initializer);
|
|
2259
2449
|
if (spelling === null) {
|
|
2260
2450
|
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)");
|
|
2261
2451
|
}
|
|
2262
|
-
const first = decl.name.elements.nodes[0];
|
|
2263
|
-
const firstKey = first === undefined || first.dotDotDotToken !== undefined
|
|
2264
|
-
? undefined
|
|
2265
|
-
: (first.propertyName ?? first.name);
|
|
2266
|
-
// V8 names the first property when its key is an identifier, a string
|
|
2267
|
-
// or a number; a computed first key takes the bare (source-only) form.
|
|
2268
|
-
const firstProp = firstKey === undefined || ts.isComputedPropertyName(firstKey)
|
|
2269
|
-
? undefined
|
|
2270
|
-
: (patternKeyNameOf(lowerer, firstKey) ?? undefined);
|
|
2271
2452
|
out.push({
|
|
2272
2453
|
kind: "exprStmt",
|
|
2273
2454
|
expr: {
|
|
2274
2455
|
kind: "dynDestrCheck",
|
|
2275
2456
|
value: { kind: "varRef", localId: tmp.id, type: init.type, loc },
|
|
2276
2457
|
spelling,
|
|
2277
|
-
...(
|
|
2458
|
+
...firstPatternProp(lowerer, decl.name),
|
|
2278
2459
|
type: init.type,
|
|
2279
2460
|
loc,
|
|
2280
2461
|
},
|
|
2281
2462
|
loc,
|
|
2282
2463
|
});
|
|
2283
2464
|
}
|
|
2284
|
-
// V8's destructuring TypeError spells STATIC sources: an identifier
|
|
2285
|
-
// source reads "<name> is not iterable", an identifier-callee call
|
|
2286
|
-
// "<name> is not a function or its return value is not iterable";
|
|
2287
|
-
// everything else (property reads, method calls, parameters) gets the
|
|
2288
|
-
// runtime kind wording — exactly V8's CallPrinter behavior. Only the
|
|
2289
|
-
// DYN pattern arm consumes this.
|
|
2290
|
-
const src = decl.initializer;
|
|
2291
|
-
const dynSpell = ts.isIdentifier(src)
|
|
2292
|
-
? `${src.text} is not iterable`
|
|
2293
|
-
: ts.isCallExpression(src) && ts.isIdentifier(src.expression)
|
|
2294
|
-
? `${src.expression.text} is not a function or its return value is not iterable`
|
|
2295
|
-
: undefined;
|
|
2296
2465
|
lowerer.lowerBindingPattern(decl.name, () => ({ kind: "varRef", localId: tmp.id, type: init.type, loc }), init.type, isLet, out, dynSpell, parseArgsDynObject);
|
|
2297
2466
|
return out;
|
|
2298
2467
|
}
|
|
@@ -3198,6 +3367,10 @@ export function lowerBindingPattern(lowerer, pattern, srcRef, srcType, isLet, ou
|
|
|
3198
3367
|
type: fieldType,
|
|
3199
3368
|
loc,
|
|
3200
3369
|
};
|
|
3370
|
+
// A field some partial record assertion leaves unwritten (a partial
|
|
3371
|
+
// record view, partial-assertions.ts): the element read throws the
|
|
3372
|
+
// catchable TypeError instead of reading a slot the view lacks.
|
|
3373
|
+
value = partialFieldRead(lowerer, srcRef(), srcType.shapeId, propName, fieldType, loc) ?? value;
|
|
3201
3374
|
// `{ tld = "localhost" }`: the element default applies exactly when
|
|
3202
3375
|
// the field holds the undefined arm — the same undefined test and
|
|
3203
3376
|
// narrow/retag as a defaulted parameter's prologue (declareParams).
|
|
@@ -4643,9 +4816,13 @@ export function lowerVarDeclList(lowerer, list) {
|
|
|
4643
4816
|
const out = [];
|
|
4644
4817
|
for (const decl of list.declarations.nodes) {
|
|
4645
4818
|
if (ts.isArrayBindingPattern(decl.name) || ts.isObjectBindingPattern(decl.name)) {
|
|
4646
|
-
//
|
|
4647
|
-
//
|
|
4648
|
-
|
|
4819
|
+
// The pattern desugars to a flat statement list whose bindings are
|
|
4820
|
+
// ordinary head declarations (`for (let [a, b] = xs; ...)`: `%destr`
|
|
4821
|
+
// plus `a`, `b`), so the loop emitter finds them as head lets and
|
|
4822
|
+
// freshens the captured ones per iteration like any other
|
|
4823
|
+
// declarator (emit-statements: capturedLets).
|
|
4824
|
+
out.push(...lowerer.lowerDestructuringDecl(decl, isLet));
|
|
4825
|
+
continue;
|
|
4649
4826
|
}
|
|
4650
4827
|
const lowered = lowerer.lowerVarDecl(decl, isLet);
|
|
4651
4828
|
if (!lowered)
|
|
@@ -4861,20 +5038,30 @@ function evolvingArrayHolderType(lowerer, decl) {
|
|
|
4861
5038
|
return null;
|
|
4862
5039
|
return evolvingArrayHold(lowerer, decl.initializer) === null ? null : DYN;
|
|
4863
5040
|
}
|
|
4864
|
-
/** A single static type for an initializer-less
|
|
4865
|
-
* later plain writes all agree. An evolving
|
|
4866
|
-
* until control flow proves a write, so a scalar slot is sound
|
|
4867
|
-
* every ordinary use already has that concrete flow type
|
|
4868
|
-
*
|
|
4869
|
-
*
|
|
4870
|
-
*
|
|
4871
|
-
|
|
5041
|
+
/** A single static type for an initializer-less `let` without an
|
|
5042
|
+
* annotation whose later plain writes all agree. An evolving local reads as
|
|
5043
|
+
* `undefined` until control flow proves a write, so a scalar slot is sound
|
|
5044
|
+
* only when every ordinary use already has that concrete flow type (or an
|
|
5045
|
+
* arm of it). A write of `null` or `undefined` joins the written type as an
|
|
5046
|
+
* optional arm (`let stat; try { stat = lstatSync(".") } catch { stat = null }`
|
|
5047
|
+
* holds `Stats | null`). A write's call counts when its signature is
|
|
5048
|
+
* declared in the standard library, whose return types are declared rather
|
|
5049
|
+
* than inferred from JavaScript. A closure capture can observe the local
|
|
5050
|
+
* before an outer assignment, and the checker leaves captured evolving lets
|
|
5051
|
+
* broad: a captured runtime handle (`let child; if (...) child = spawn(...)`)
|
|
5052
|
+
* takes the handle or `undefined`, which nested functions read as a
|
|
5053
|
+
* checked-dynamic value (closureDynLets), and other captured bindings stay
|
|
5054
|
+
* checked-dynamic. */
|
|
5055
|
+
export function inferredEvolvingLetType(lowerer, decl) {
|
|
4872
5056
|
if (!ts.isIdentifier(decl.name))
|
|
4873
5057
|
return null;
|
|
4874
5058
|
const symbol = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
4875
5059
|
const scope = decl.parent?.parent?.parent;
|
|
4876
5060
|
if (symbol === undefined || (!ts.isBlock(scope) && !ts.isSourceFile(scope)))
|
|
4877
5061
|
return null;
|
|
5062
|
+
// Another module reads an exported binding, which this scan does not see.
|
|
5063
|
+
if (ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export)
|
|
5064
|
+
return null;
|
|
4878
5065
|
// A shorthand property's name (`{ width }`) resolves to the property
|
|
4879
5066
|
// symbol, but it reads the binding: the checker's shorthand-value symbol.
|
|
4880
5067
|
const refersToBinding = (node) => (ts.isShorthandPropertyAssignment(node.parent) && node.parent.name === node
|
|
@@ -4904,13 +5091,25 @@ function inferredEvolvingLetType(lowerer, decl) {
|
|
|
4904
5091
|
const writes = [];
|
|
4905
5092
|
const reads = [];
|
|
4906
5093
|
let invalid = false;
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
5094
|
+
let captured = false;
|
|
5095
|
+
// The capturing closure being scanned: reads inside one carry the
|
|
5096
|
+
// checker's broad type, so only its writes are collected.
|
|
5097
|
+
let closure = null;
|
|
5098
|
+
const visit = (node) => {
|
|
5099
|
+
if (node !== scope && node !== closure && ts.isFunctionLike(node)) {
|
|
5100
|
+
if (captures(node)) {
|
|
5101
|
+
captured = true;
|
|
5102
|
+
const outer = closure;
|
|
5103
|
+
closure = node;
|
|
5104
|
+
ts.walkPreorder(node, visit);
|
|
5105
|
+
closure = outer;
|
|
5106
|
+
}
|
|
4911
5107
|
return "skip";
|
|
4912
5108
|
}
|
|
4913
|
-
|
|
5109
|
+
// A compound assignment (`x += 1`) reads and rewrites the binding
|
|
5110
|
+
// through an operator this scan does not model; a comparison
|
|
5111
|
+
// (`x === null`) only reads it, and the read check below covers that.
|
|
5112
|
+
if (ts.isBinaryExpression(node) && ts.isAssignmentOperator(node.operatorToken.kind)) {
|
|
4914
5113
|
let left = node.left;
|
|
4915
5114
|
while (ts.isParenthesizedExpression(left))
|
|
4916
5115
|
left = left.expression;
|
|
@@ -4919,9 +5118,7 @@ function inferredEvolvingLetType(lowerer, decl) {
|
|
|
4919
5118
|
invalid = true;
|
|
4920
5119
|
return "stop";
|
|
4921
5120
|
}
|
|
4922
|
-
if (ts.isCallExpression(node.right) &&
|
|
4923
|
-
(implicitMethodCallInfersReturn(lowerer, node.right) ||
|
|
4924
|
-
isJsSourceFile(ts.getSourceFileOfNode(node.right)))) {
|
|
5121
|
+
if (ts.isCallExpression(node.right) && !stdlibDeclaredCall(lowerer, node.right)) {
|
|
4925
5122
|
invalid = true;
|
|
4926
5123
|
return "stop";
|
|
4927
5124
|
}
|
|
@@ -4935,7 +5132,7 @@ function inferredEvolvingLetType(lowerer, decl) {
|
|
|
4935
5132
|
return "stop";
|
|
4936
5133
|
}
|
|
4937
5134
|
const mapped = lowerer.mapTypeOf(lowerer.typeOf(node.right));
|
|
4938
|
-
if (!mapped || mapped.kind === "dyn" || mapped.kind === "void"
|
|
5135
|
+
if (!mapped || mapped.kind === "dyn" || mapped.kind === "void") {
|
|
4939
5136
|
invalid = true;
|
|
4940
5137
|
return "stop";
|
|
4941
5138
|
}
|
|
@@ -4948,23 +5145,69 @@ function inferredEvolvingLetType(lowerer, decl) {
|
|
|
4948
5145
|
invalid = true;
|
|
4949
5146
|
return "stop";
|
|
4950
5147
|
}
|
|
4951
|
-
if (
|
|
5148
|
+
if (closure === null &&
|
|
5149
|
+
ts.isIdentifier(node) &&
|
|
4952
5150
|
node !== decl.name &&
|
|
4953
5151
|
refersToBinding(node) &&
|
|
4954
5152
|
!isPlainAssignmentTarget(node)) {
|
|
4955
5153
|
reads.push(node);
|
|
4956
5154
|
}
|
|
4957
5155
|
return undefined;
|
|
4958
|
-
}
|
|
4959
|
-
|
|
4960
|
-
|
|
5156
|
+
};
|
|
5157
|
+
ts.walkPreorder(scope, visit);
|
|
5158
|
+
// A write of an already-unioned value contributes its arms, so a call
|
|
5159
|
+
// declared `Stats | null` reads the same as separate value and unit
|
|
5160
|
+
// writes.
|
|
5161
|
+
const armsOf = (t) => t.kind === "union" ? (lowerer.unions.get(t.unionId)?.arms ?? [t]) : [t];
|
|
5162
|
+
const valueArms = [];
|
|
5163
|
+
const unitArms = [];
|
|
5164
|
+
for (const write of writes) {
|
|
5165
|
+
for (const arm of armsOf(write)) {
|
|
5166
|
+
const seen = isUnitType(arm) ? unitArms : valueArms;
|
|
5167
|
+
if (!seen.some((other) => typeEquals(other, arm)))
|
|
5168
|
+
seen.push(arm);
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5171
|
+
const value = valueArms[0];
|
|
5172
|
+
if (invalid || value === undefined || valueArms.length > 1)
|
|
4961
5173
|
return null;
|
|
4962
|
-
|
|
5174
|
+
const arms = [value];
|
|
5175
|
+
if (unitArms.length > 0) {
|
|
5176
|
+
// An evolving local reads as `undefined` before control flow proves a
|
|
5177
|
+
// write, so the optional storage carries that arm as well.
|
|
5178
|
+
arms.push(UNDEFINED_T);
|
|
5179
|
+
for (const unit of unitArms) {
|
|
5180
|
+
if (unit.kind !== "undefinedT")
|
|
5181
|
+
arms.push(unit);
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
const storage = arms.length === 1 ? value : { kind: "union", unionId: lowerer.unions.intern(arms) };
|
|
5185
|
+
// A narrowed read sees an arm, or a sub-union of arms, of the storage.
|
|
5186
|
+
if (!reads.every((read) => {
|
|
4963
5187
|
const mapped = lowerer.mapTypeOf(lowerer.typeOf(read));
|
|
4964
|
-
return mapped !== null && typeEquals(
|
|
4965
|
-
})
|
|
4966
|
-
|
|
4967
|
-
|
|
5188
|
+
return (mapped !== null && armsOf(mapped).every((arm) => arms.some((own) => typeEquals(own, arm))));
|
|
5189
|
+
}))
|
|
5190
|
+
return null;
|
|
5191
|
+
if (!captured)
|
|
5192
|
+
return storage;
|
|
5193
|
+
if (!DYN_HANDLE_KINDS.has(value.kind))
|
|
5194
|
+
return null;
|
|
5195
|
+
lowerer.closureDynLets.add(symbol);
|
|
5196
|
+
// A nested function can read the binding before the outer assignment:
|
|
5197
|
+
// the optional arm is what the checked-dynamic read of the closure sees.
|
|
5198
|
+
return storage.kind === "union"
|
|
5199
|
+
? storage
|
|
5200
|
+
: { kind: "union", unionId: lowerer.unions.intern([value, UNDEFINED_T]) };
|
|
5201
|
+
}
|
|
5202
|
+
/** Whether a call's resolved signature is declared in the standard library
|
|
5203
|
+
* (`spawn(...)`), so its declared return type is the value's type. Calls of
|
|
5204
|
+
* JavaScript functions, and implicit generic methods, infer theirs, and a
|
|
5205
|
+
* `require(...)` result is a module rather than a value of its type. */
|
|
5206
|
+
function stdlibDeclaredCall(lowerer, call) {
|
|
5207
|
+
if (implicitMethodCallInfersReturn(lowerer, call) || requireSpecOf(call) !== null)
|
|
5208
|
+
return false;
|
|
5209
|
+
const declaration = lowerer.checker.getResolvedSignature(call)?.declaration;
|
|
5210
|
+
return declaration !== undefined && lowerer.isStdlibFile(ts.getSourceFileOfNode(declaration));
|
|
4968
5211
|
}
|
|
4969
5212
|
export function lowerVarDecl(lowerer, decl, isLet) {
|
|
4970
5213
|
// --provenance-sources: an elided pure-annotated dead const emits
|
|
@@ -5001,6 +5244,10 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5001
5244
|
}
|
|
5002
5245
|
if (!ts.isIdentifier(decl.name))
|
|
5003
5246
|
lowerer.unsupported("SC1031", decl.name);
|
|
5247
|
+
// A binding that holds `process.env` under any type but the env record
|
|
5248
|
+
// is a snapshot copy whose reads would drift from Node's live table
|
|
5249
|
+
// (refuseHeldEnvCopyHold); refuse it here, at the hold itself.
|
|
5250
|
+
refuseHeldEnvCopyHold(lowerer, decl.name, decl);
|
|
5004
5251
|
{
|
|
5005
5252
|
const alias = lowerTupleAliasDecl(lowerer, decl);
|
|
5006
5253
|
if (alias)
|
|
@@ -5136,11 +5383,11 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5136
5383
|
}
|
|
5137
5384
|
// `const h = id` — an ALIAS of a generic function: the alias's symbol
|
|
5138
5385
|
// registers the target's info (calls and pinned values resolve like
|
|
5139
|
-
// the target's own name)
|
|
5140
|
-
// statement emits nothing
|
|
5141
|
-
//
|
|
5386
|
+
// the target's own name) and the binding has no runtime value, so the
|
|
5387
|
+
// statement emits nothing but the flag of a module-scope alias whose
|
|
5388
|
+
// reads can run before it (genericAliasPresenceStore).
|
|
5142
5389
|
if (bindingGenericFnAliasInfoOf(lowerer, decl))
|
|
5143
|
-
return
|
|
5390
|
+
return genericAliasPresenceStore(lowerer, decl);
|
|
5144
5391
|
// `const stored = overloadedDeclaration`: no runtime slot is needed;
|
|
5145
5392
|
// calls project onto the declaration's implementation ABI and value
|
|
5146
5393
|
// reads reuse its interned closure identity.
|
|
@@ -5262,6 +5509,12 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5262
5509
|
raw.type.kind === "dyn" &&
|
|
5263
5510
|
(g.type.kind === "record" ||
|
|
5264
5511
|
g.type.kind === "object" ||
|
|
5512
|
+
// `const p = Promise.all.call(C, xs)` in JavaScript: the call runs
|
|
5513
|
+
// the specification's algorithm with `C`'s capability and returns
|
|
5514
|
+
// whatever `C` constructed, a foreign instance the checker still
|
|
5515
|
+
// calls `Promise<T>`. The binding holds that value as dyn; a
|
|
5516
|
+
// native-promise check would reject it (t262-db B3).
|
|
5517
|
+
(g.type.kind === "promise" && isJsPromiseStaticCall(raw)) ||
|
|
5265
5518
|
(ts.isIdentifier(decl.name) &&
|
|
5266
5519
|
jsBindingKeepsCheckedObject(lowerer, decl.name, g.type) &&
|
|
5267
5520
|
(existingValueForm(decl.initializer) || jsHoldsDynObject(lowerer, decl.initializer)))))
|
|
@@ -5275,6 +5528,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5275
5528
|
g.type = raw.type;
|
|
5276
5529
|
notePreservedLayout(lowerer, decl);
|
|
5277
5530
|
}
|
|
5531
|
+
// The same for a module const initialized by an assertion: the value's
|
|
5532
|
+
// storage already answers the asserted view (narrowing.ts), so the
|
|
5533
|
+
// module holds that layout and writes through it reach the object.
|
|
5534
|
+
if (!isVarDeclared(decl) &&
|
|
5535
|
+
(ts.getCombinedNodeFlags(decl) & ts.NodeFlags.Const) !== 0 &&
|
|
5536
|
+
assertionKeepsStorageLayout(lowerer, decl, raw.type, g.type)) {
|
|
5537
|
+
g.type = raw.type;
|
|
5538
|
+
notePreservedLayout(lowerer, decl);
|
|
5539
|
+
}
|
|
5540
|
+
if (!isVarDeclared(decl) &&
|
|
5541
|
+
keepsCheckedDynamicValue(lowerer, decl.initializer, raw.type, g.type))
|
|
5542
|
+
g.type = raw.type;
|
|
5278
5543
|
const arithmetic = raw.type.kind === "union" ? lowerer.unions.get(raw.type.unionId)?.arms : undefined;
|
|
5279
5544
|
if (arithmetic?.length === 2 &&
|
|
5280
5545
|
arithmetic.every((a) => a.kind === "f64" || a.kind === "string" || a.kind === "bool") &&
|
|
@@ -5287,6 +5552,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5287
5552
|
lowerer.runtimeOptionalArithmeticGlobals.add(g);
|
|
5288
5553
|
}
|
|
5289
5554
|
const init = lowerer.coerceInto(decl.initializer, raw, g.type);
|
|
5555
|
+
refuseAssertionViewWrite(lowerer, decl);
|
|
5290
5556
|
return {
|
|
5291
5557
|
kind: "assign",
|
|
5292
5558
|
localId: g.id,
|
|
@@ -5328,12 +5594,13 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5328
5594
|
// `let x: number;` — declared, uninitialized. tsc guarantees no read
|
|
5329
5595
|
// before assignment (TS2454) and rejects uninitialized const (TS1155).
|
|
5330
5596
|
// Unannotated `let x;` is an evolving `any` — the checked-dynamic
|
|
5331
|
-
// binding fallback (irTypeOf → dynFallbackType)
|
|
5597
|
+
// binding fallback (irTypeOf → dynFallbackType) unless its writes agree
|
|
5598
|
+
// on a type.
|
|
5332
5599
|
// Undefined-armed unions (`let x: string | undefined;`) are readable
|
|
5333
5600
|
// immediately (the type covers the unassigned state), so they
|
|
5334
5601
|
// initialize to the interned undefined arm like an omitted optional.
|
|
5335
5602
|
let type = lowerer.irTypeOf(decl.name);
|
|
5336
|
-
if (type.kind === "dyn" && isLet &&
|
|
5603
|
+
if (type.kind === "dyn" && isLet && decl.type === undefined) {
|
|
5337
5604
|
type = inferredEvolvingLetType(lowerer, decl) ?? type;
|
|
5338
5605
|
}
|
|
5339
5606
|
// `var v: void;` / `let x: undefined;` — a unit-only binding rides
|
|
@@ -5444,6 +5711,19 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5444
5711
|
type = init.type;
|
|
5445
5712
|
notePreservedLayout(lowerer, decl);
|
|
5446
5713
|
}
|
|
5714
|
+
// An index-signature binding whose assertion of an existing value lowered
|
|
5715
|
+
// to that value (narrowing.ts keeps it instead of answering a copy whose
|
|
5716
|
+
// keys live in a map of its own) keeps the value too: converting it here
|
|
5717
|
+
// would take every write through the binding with it.
|
|
5718
|
+
if (keepsCheckedDynamicValue(lowerer, decl.initializer, init.type, type))
|
|
5719
|
+
type = init.type;
|
|
5720
|
+
// A JavaScript binding assigned values outside its declared type
|
|
5721
|
+
// (analyzeJsWidenedBindings in lowerer.ts) holds them as checked-dynamic.
|
|
5722
|
+
{
|
|
5723
|
+
const symbol = lowerer.resolveValueSymbol(decl.name);
|
|
5724
|
+
if (symbol && lowerer.jsWidenedBindings.has(symbol))
|
|
5725
|
+
type = DYN;
|
|
5726
|
+
}
|
|
5447
5727
|
// A typed-arguments function expression (typed-arguments.ts): the
|
|
5448
5728
|
// checker types the binding variadic, but its value has the fixed
|
|
5449
5729
|
// signature every use asserts.
|
|
@@ -5494,9 +5774,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5494
5774
|
const keepsAssertedObject = init.type.kind === "dyn" &&
|
|
5495
5775
|
!decl.type &&
|
|
5496
5776
|
keptIdentityAssertion(lowerer, decl.initializer) !== undefined;
|
|
5777
|
+
// `const p = Promise.all.call(C, xs)` in JavaScript: the checked-dynamic
|
|
5778
|
+
// promise-static call returns whatever `C` constructed — a foreign
|
|
5779
|
+
// instance, not the `Promise<T>` the checker infers from the signature —
|
|
5780
|
+
// so the binding holds it as dyn (t262-db B3).
|
|
5781
|
+
const keepsPromiseStaticValue = isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
5782
|
+
!decl.type &&
|
|
5783
|
+
!hasJsTypeAnnotation(decl) &&
|
|
5784
|
+
isJsPromiseStaticCall(init);
|
|
5497
5785
|
if (expandsObject ||
|
|
5498
5786
|
preservesObjectIdentity ||
|
|
5499
5787
|
keepsAssertedObject ||
|
|
5788
|
+
keepsPromiseStaticValue ||
|
|
5500
5789
|
(isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
5501
5790
|
!decl.type &&
|
|
5502
5791
|
isNativeBuiltinValueInitializer(lowerer, decl.initializer))) {
|
|
@@ -5793,13 +6082,9 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5793
6082
|
// the stored type hosts (`const view: Route & { order: number } = ...`)
|
|
5794
6083
|
// keeps it too: coercing into the annotated layout would copy the
|
|
5795
6084
|
// value and read members the writes have not created yet.
|
|
5796
|
-
if (!isLet &&
|
|
5797
|
-
decl.initializer &&
|
|
5798
|
-
isAssertionInitializer(decl.initializer) &&
|
|
5799
|
-
(settledType.kind === "union" || settledType.kind === "record") &&
|
|
5800
|
-
(init.type.kind === "union" || init.type.kind === "record") &&
|
|
5801
|
-
hostsAll(lowerer, init.type, settledType)) {
|
|
6085
|
+
if (!isLet && assertionKeepsStorageLayout(lowerer, decl, init.type, settledType)) {
|
|
5802
6086
|
settledType = init.type;
|
|
6087
|
+
notePreservedLayout(lowerer, decl);
|
|
5803
6088
|
}
|
|
5804
6089
|
// An exact class behind a generic interface keeps its native
|
|
5805
6090
|
// representation so generic calls can specialize against its body.
|
|
@@ -5828,6 +6113,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
5828
6113
|
// Slot coercion: `const r: A | B = bValue;` wraps implicitly; width
|
|
5829
6114
|
// subtyping (`const p: {a: number} = wider;`) is rejected, not coerced.
|
|
5830
6115
|
init = lowerer.coerceInto(decl.initializer, init, settledType);
|
|
6116
|
+
refuseAssertionViewWrite(lowerer, decl);
|
|
5831
6117
|
const local = lowerer.declareLocal(decl.name, decl.name.text, settledType, isLet);
|
|
5832
6118
|
if (runtimeStringArithmetic && init.type.kind === "union") {
|
|
5833
6119
|
lowerer.runtimeOptionalArithmeticLocals.add(lowerer.runtimeOptionalRootOf(local));
|
|
@@ -5877,6 +6163,17 @@ function inferredOptionalRecordType(lowerer, decl, declared, actual) {
|
|
|
5877
6163
|
return declared;
|
|
5878
6164
|
return actual;
|
|
5879
6165
|
}
|
|
6166
|
+
/** Whether a lowered initializer is the checked-dynamic `Promise.<static>.call(C, …)`
|
|
6167
|
+
* call (lower-calls.ts, JavaScript sources only). Its result is whatever `C`
|
|
6168
|
+
* constructed, so a binding the checker typed `Promise<T>` holds it as dyn. */
|
|
6169
|
+
function isJsPromiseStaticCall(value) {
|
|
6170
|
+
// Surplus arguments evaluate as statements before the call, so the
|
|
6171
|
+
// initializer is a sequence expression whose result is the call.
|
|
6172
|
+
let result = value;
|
|
6173
|
+
while (result.kind === "seqExpr")
|
|
6174
|
+
result = result.result;
|
|
6175
|
+
return result.kind === "libCall" && result.fn === "promise.genericStatic";
|
|
6176
|
+
}
|
|
5880
6177
|
function lowerVariableInitializer(lowerer, node, expected) {
|
|
5881
6178
|
let value = node;
|
|
5882
6179
|
while (ts.isParenthesizedExpression(value) ||
|
|
@@ -6129,10 +6426,14 @@ export function jsBindingHasOpenWrites(lowerer, decl) {
|
|
|
6129
6426
|
return false;
|
|
6130
6427
|
if (candidates.some((node) => (lowerer.typeOf(node.right).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0))
|
|
6131
6428
|
return true;
|
|
6132
|
-
// A `+=` of a string
|
|
6133
|
-
// (`n += "px"`); the checker keeps the
|
|
6429
|
+
// A `+=` of a string, or of a value that may be one, turns a number or
|
|
6430
|
+
// boolean binding into a string (`n += "px"`); the checker keeps the
|
|
6431
|
+
// declared type.
|
|
6432
|
+
const mayBeString = (type) => type.flags & ts.TypeFlags.Union
|
|
6433
|
+
? constituentTypes(type).some(mayBeString)
|
|
6434
|
+
: (type.flags & ts.TypeFlags.StringLike) !== 0;
|
|
6134
6435
|
if (candidates.some((node) => node.operatorToken.kind === ts.SyntaxKind.PlusEqualsToken &&
|
|
6135
|
-
(lowerer.typeOf(node.right)
|
|
6436
|
+
mayBeString(lowerer.typeOf(node.right)))) {
|
|
6136
6437
|
const declared = lowerer.mapTypeOf(lowerer.typeOf(decl.name));
|
|
6137
6438
|
if (declared?.kind === "f64" || declared?.kind === "bool")
|
|
6138
6439
|
return true;
|
|
@@ -6163,6 +6464,11 @@ export function jsBindingHasOpenWrites(lowerer, decl) {
|
|
|
6163
6464
|
return false;
|
|
6164
6465
|
return differing.some((node) => {
|
|
6165
6466
|
const written = lowerer.mapTypeOf(lowerer.typeOf(node.right));
|
|
6467
|
+
// A union a primitive binding cannot hold (`x = c ? 1 : "a"` into
|
|
6468
|
+
// `var x = 0`).
|
|
6469
|
+
if (written?.kind === "union" &&
|
|
6470
|
+
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string"))
|
|
6471
|
+
return true;
|
|
6166
6472
|
return (written !== null &&
|
|
6167
6473
|
written.kind !== "dyn" &&
|
|
6168
6474
|
written.kind !== "union" &&
|
|
@@ -6480,10 +6786,15 @@ function lowerBranchSwitch(lowerer, stmt, disc, labels, compare) {
|
|
|
6480
6786
|
* === "string"/"number"/"boolean"`), reads under a proven narrow
|
|
6481
6787
|
* (caughtRead bridges them with caughtNarrow, verified at run time like
|
|
6482
6788
|
* unionNarrow), and rethrow (`throw e`). Unsupported raw uses and
|
|
6483
|
-
* assignments are fenced (SC1063 and friends)
|
|
6484
|
-
*
|
|
6485
|
-
*
|
|
6486
|
-
*
|
|
6789
|
+
* assignments are fenced (SC1063 and friends). The `: any` /
|
|
6790
|
+
* `: unknown` annotations tsc admits both lower the same way (tsc
|
|
6791
|
+
* narrows either through the tests). Captures retain the snapshot
|
|
6792
|
+
* beyond the catch scope.
|
|
6793
|
+
* - `catch ([a])` / `catch ({ p })` binds the thrown value through a
|
|
6794
|
+
* destructuring pattern: the exception cell keeps its hidden CAUGHT
|
|
6795
|
+
* local, and the pattern reads its checked-dynamic view
|
|
6796
|
+
* (caughtToDyn), so a JS catch parameter that destructures lowers the
|
|
6797
|
+
* way the same pattern does over an `any` source.
|
|
6487
6798
|
* - `finally` runs on normal completion, exception paths, and every
|
|
6488
6799
|
* abrupt completion that crosses it. Return values are snapshotted
|
|
6489
6800
|
* before cleanup; an abrupt completion inside the finally replaces the
|
|
@@ -6496,9 +6807,6 @@ export function lowerTry(lowerer, stmt) {
|
|
|
6496
6807
|
let catchLocalId = null;
|
|
6497
6808
|
if (stmt.catchClause) {
|
|
6498
6809
|
const vd = stmt.catchClause.variableDeclaration;
|
|
6499
|
-
if (vd && !ts.isIdentifier(vd.name)) {
|
|
6500
|
-
lowerer.unsupported("SC1062", vd);
|
|
6501
|
-
}
|
|
6502
6810
|
if (vd && ts.isIdentifier(vd.name)) {
|
|
6503
6811
|
lowerer.scopes.push(new Map());
|
|
6504
6812
|
try {
|
|
@@ -6511,7 +6819,59 @@ export function lowerTry(lowerer, stmt) {
|
|
|
6511
6819
|
}
|
|
6512
6820
|
}
|
|
6513
6821
|
else {
|
|
6514
|
-
|
|
6822
|
+
lowerer.scopes.push(new Map());
|
|
6823
|
+
try {
|
|
6824
|
+
if (vd) {
|
|
6825
|
+
// `catch ([a])` / `catch ({ a })`: the thrown value crosses into
|
|
6826
|
+
// the checked-dynamic tree and the pattern binds through the same
|
|
6827
|
+
// per-read fences a dyn source takes — GetIterator for an array
|
|
6828
|
+
// pattern (positions past the end bind undefined, an iterator
|
|
6829
|
+
// with values left closes) and RequireObjectCoercible plus keyed
|
|
6830
|
+
// reads for an object pattern. The hidden CAUGHT local is the
|
|
6831
|
+
// exception cell every other catch path binds; the dyn conversion
|
|
6832
|
+
// is its identity-preserving view (caughtToDyn).
|
|
6833
|
+
const loc = locOf(vd);
|
|
6834
|
+
const local = lowerer.declareHiddenLocal("%caught", CAUGHT);
|
|
6835
|
+
catchLocalId = local.id;
|
|
6836
|
+
const tmp = lowerer.declareHiddenLocal("%destr", DYN);
|
|
6837
|
+
const out = [
|
|
6838
|
+
{
|
|
6839
|
+
kind: "varDecl",
|
|
6840
|
+
localId: tmp.id,
|
|
6841
|
+
init: { kind: "caughtToDyn", value: varRef(local.id, CAUGHT, loc), type: DYN, loc },
|
|
6842
|
+
loc,
|
|
6843
|
+
},
|
|
6844
|
+
];
|
|
6845
|
+
// V8 spells the catch parameter's source '.catch' in the
|
|
6846
|
+
// RequireObjectCoercible TypeError ("Cannot destructure property
|
|
6847
|
+
// 'a' of '.catch' as it is null."), except when the first element
|
|
6848
|
+
// has a default: V8 reads that key first, so a nullish source
|
|
6849
|
+
// throws the read's TypeError, which the pattern's own first read
|
|
6850
|
+
// throws.
|
|
6851
|
+
if (ts.isObjectBindingPattern(vd.name) && !firstReadsWithDefault(vd.name))
|
|
6852
|
+
out.push({
|
|
6853
|
+
kind: "exprStmt",
|
|
6854
|
+
expr: {
|
|
6855
|
+
kind: "dynDestrCheck",
|
|
6856
|
+
value: varRef(tmp.id, DYN, loc),
|
|
6857
|
+
spelling: ".catch",
|
|
6858
|
+
...firstPatternProp(lowerer, vd.name),
|
|
6859
|
+
type: DYN,
|
|
6860
|
+
loc,
|
|
6861
|
+
},
|
|
6862
|
+
loc,
|
|
6863
|
+
});
|
|
6864
|
+
lowerer.lowerBindingPattern(vd.name, () => varRef(tmp.id, DYN, loc), DYN, true, // catch bindings are mutable
|
|
6865
|
+
out);
|
|
6866
|
+
catchBody = [...out, ...lowerer.lowerScopedBlock(stmt.catchClause.block)];
|
|
6867
|
+
}
|
|
6868
|
+
else {
|
|
6869
|
+
catchBody = lowerer.lowerScopedBlock(stmt.catchClause.block);
|
|
6870
|
+
}
|
|
6871
|
+
}
|
|
6872
|
+
finally {
|
|
6873
|
+
lowerer.scopes.pop();
|
|
6874
|
+
}
|
|
6515
6875
|
}
|
|
6516
6876
|
}
|
|
6517
6877
|
const finallyBody = stmt.finallyBlock ? lowerer.lowerScopedBlock(stmt.finallyBlock) : null;
|
|
@@ -6524,13 +6884,67 @@ export function lowerTry(lowerer, stmt) {
|
|
|
6524
6884
|
loc: locOf(stmt),
|
|
6525
6885
|
};
|
|
6526
6886
|
}
|
|
6887
|
+
/** The refusal for `delete` of an optional `unknown`/`any` field, whose
|
|
6888
|
+
* slot is the checked-dynamic one and so has no ABSENT state to write. */
|
|
6889
|
+
const OPTIONAL_CHECKED_DYN_DELETE = "'delete' of optional 'unknown'/'any' fields (the checked-dynamic slot has no absent state yet — an omitted such field already reads as present)";
|
|
6890
|
+
/** TypeScript's declaration marks property `name` of `receiver` optional
|
|
6891
|
+
* (`?:`), in every union constituent. A mapped IR type cannot tell an
|
|
6892
|
+
* optional `unknown`/`any` field from a required one — both ride the
|
|
6893
|
+
* checked-dynamic slot — so a refused `delete`'s real reason comes from
|
|
6894
|
+
* the declaration. */
|
|
6895
|
+
function declaredOptionalProperty(lowerer, receiver, name) {
|
|
6896
|
+
const receiverType = lowerer.typeOf(receiver);
|
|
6897
|
+
const parts = receiverType.flags & ts.TypeFlags.Union ? constituentTypes(receiverType) : [receiverType];
|
|
6898
|
+
return parts.every((part) => {
|
|
6899
|
+
const property = lowerer.checker.getPropertyOfType(part, name);
|
|
6900
|
+
return property !== undefined && (property.flags & ts.SymbolFlags.Optional) !== 0;
|
|
6901
|
+
});
|
|
6902
|
+
}
|
|
6903
|
+
/** `type` — a record or a union whose every arm is a non-tuple record —
|
|
6904
|
+
* declares `name` in the checked-dynamic slot, which has no ABSENT state:
|
|
6905
|
+
* an optional such field cannot be removed by a `delete`. */
|
|
6906
|
+
function declaresCheckedDynField(lowerer, type, name) {
|
|
6907
|
+
if (type.kind === "record") {
|
|
6908
|
+
const shape = lowerer.shapes.get(type.shapeId);
|
|
6909
|
+
if (!shape || shape.tuple)
|
|
6910
|
+
return false;
|
|
6911
|
+
return shape.fields.find((f) => f.name === name)?.type.kind === "dyn";
|
|
6912
|
+
}
|
|
6913
|
+
if (type.kind !== "union")
|
|
6914
|
+
return false;
|
|
6915
|
+
const arms = lowerer.unions.get(type.unionId)?.arms ?? [];
|
|
6916
|
+
return arms.length > 0 && arms.every((arm) => declaresCheckedDynField(lowerer, arm, name));
|
|
6917
|
+
}
|
|
6918
|
+
/** The constant property key of a `delete` target: the name of a dot
|
|
6919
|
+
* access, or the one key of a bracket access spelled as a literal or
|
|
6920
|
+
* proved by a literal-typed binding (`const key = "a"`). A key of several
|
|
6921
|
+
* literals folds to nothing — deleting it would need per-key dispatch, so
|
|
6922
|
+
* the record branch refuses and names the keys. Consistent with keyed
|
|
6923
|
+
* record reads/writes (literalFieldKeys), the key expression is not
|
|
6924
|
+
* evaluated: only a literal or an identifier folds, and an identifier
|
|
6925
|
+
* read is pure. */
|
|
6926
|
+
function constantDeleteKey(lowerer, target) {
|
|
6927
|
+
if (ts.isPropertyAccessExpression(target))
|
|
6928
|
+
return target.name.text;
|
|
6929
|
+
if (!ts.isElementAccessExpression(target))
|
|
6930
|
+
return null;
|
|
6931
|
+
const keyNode = target.argumentExpression;
|
|
6932
|
+
if (ts.isStringLiteralLike(keyNode))
|
|
6933
|
+
return keyNode.text;
|
|
6934
|
+
if (!ts.isIdentifier(keyNode))
|
|
6935
|
+
return null;
|
|
6936
|
+
const keys = literalFieldKeys(lowerer, keyNode);
|
|
6937
|
+
return keys?.length === 1 ? keys[0] : null;
|
|
6938
|
+
}
|
|
6527
6939
|
/** Statement-position `delete`: process.env keys → process.envUnset
|
|
6528
6940
|
* (unsetenv), pure `Record<string, T>` keys → recordKeyDelete (the
|
|
6529
6941
|
* overflow Map delete), declared OPTIONAL fields → the field's ABSENT
|
|
6530
6942
|
* state (the slot reads undefined and no longer counts as an own
|
|
6531
6943
|
* property). Everything else
|
|
6532
|
-
* fences with the honest reason — a required field is a struct slot
|
|
6533
|
-
*
|
|
6944
|
+
* fences with the honest reason — a required record field is a struct slot
|
|
6945
|
+
* with no ABSENT state, a class field is part of the instance's fixed
|
|
6946
|
+
* layout, and an optional `unknown`/`any` field maps to the
|
|
6947
|
+
* checked-dynamic slot, which has no ABSENT state yet. */
|
|
6534
6948
|
function lowerDeleteStatement(lowerer, expr) {
|
|
6535
6949
|
const loc = locOf(expr);
|
|
6536
6950
|
let target = expr.expression;
|
|
@@ -6539,6 +6953,9 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6539
6953
|
if (!ts.isElementAccessExpression(target) && !ts.isPropertyAccessExpression(target)) {
|
|
6540
6954
|
lowerer.unsupported("SC1090", expr, "'delete' of non-property expressions");
|
|
6541
6955
|
}
|
|
6956
|
+
// Deleting a member of `Date.prototype` is a write through the read-only
|
|
6957
|
+
// prototype value (property-access.ts's fence).
|
|
6958
|
+
fenceDatePrototypeWrite(lowerer, target);
|
|
6542
6959
|
fenceNodeModuleMutation(lowerer, target, "delete");
|
|
6543
6960
|
if (ts.isPropertyAccessExpression(target) && target.name.text === "cause") {
|
|
6544
6961
|
const field = lowerer.fieldTarget(target);
|
|
@@ -6564,7 +6981,8 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6564
6981
|
return { kind: "strLit", value: target.name.text, type: STRING, loc: locOf(target.name) };
|
|
6565
6982
|
}
|
|
6566
6983
|
const keyNode = target.argumentExpression;
|
|
6567
|
-
let key = lowerer.isProcessEnv(target.expression)
|
|
6984
|
+
let key = lowerer.isProcessEnv(target.expression) ||
|
|
6985
|
+
heldEnvValueType(lowerer, target.expression) !== null
|
|
6568
6986
|
? lowerEnvironmentKey(lowerer, keyNode)
|
|
6569
6987
|
: lowerer.lowerExpr(keyNode);
|
|
6570
6988
|
if (key.type.kind === "dyn") {
|
|
@@ -6578,7 +6996,8 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6578
6996
|
}
|
|
6579
6997
|
return key;
|
|
6580
6998
|
};
|
|
6581
|
-
if (lowerer.isProcessEnv(target.expression)
|
|
6999
|
+
if (lowerer.isProcessEnv(target.expression) ||
|
|
7000
|
+
heldEnvValueType(lowerer, target.expression) !== null) {
|
|
6582
7001
|
return {
|
|
6583
7002
|
kind: "exprStmt",
|
|
6584
7003
|
expr: { kind: "libCall", fn: "process.envUnset", args: [lowerKey()], type: VOID, loc },
|
|
@@ -6595,6 +7014,18 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6595
7014
|
return unionDelete;
|
|
6596
7015
|
}
|
|
6597
7016
|
let obj = lowerer.lowerExpr(target.expression);
|
|
7017
|
+
// A PRIMITIVE receiver: `delete` runs ToObject on the base AFTER the key,
|
|
7018
|
+
// and the base's type decides the answer — null and undefined throw
|
|
7019
|
+
// Node's TypeError, `?.` on a nullish base short-circuits to `true`
|
|
7020
|
+
// without evaluating the key, and every other primitive deletes from its
|
|
7021
|
+
// ToObject wrapper (a String's indexes and `length` refuse the delete).
|
|
7022
|
+
if (isPrimitiveValueType(obj.type) && !isBuiltinIdentityToken(lowerer, target.expression, obj)) {
|
|
7023
|
+
return {
|
|
7024
|
+
kind: "exprStmt",
|
|
7025
|
+
expr: lowerPrimitiveBaseDelete(lowerer, expr, target, obj, VOID),
|
|
7026
|
+
loc,
|
|
7027
|
+
};
|
|
7028
|
+
}
|
|
6598
7029
|
// `delete this.stack` in an Error subclass that declares a `stack`
|
|
6599
7030
|
// accessor (quickjs-wasi's JSException): V8 gives each error an own
|
|
6600
7031
|
// `stack` that shadows the accessor, and the delete removes it so reads
|
|
@@ -6670,6 +7101,19 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6670
7101
|
loc,
|
|
6671
7102
|
};
|
|
6672
7103
|
}
|
|
7104
|
+
// The constant property key of the target: dot access, a literal
|
|
7105
|
+
// bracket, or an element access whose key is a literal-typed binding
|
|
7106
|
+
// (`const key = "a"; delete r[key]`) — the same stance a keyed record
|
|
7107
|
+
// read/write takes (literalFieldKeys): identifier evaluation is pure, so
|
|
7108
|
+
// skipping it matches JavaScript.
|
|
7109
|
+
const constantKey = constantDeleteKey(lowerer, target);
|
|
7110
|
+
// An OPTIONAL `unknown`/`any` field rides the checked-dynamic slot,
|
|
7111
|
+
// which has no ABSENT state yet (an omitted such field already reads as
|
|
7112
|
+
// present), so it cannot delete. Name that reason instead of calling
|
|
7113
|
+
// the field required or blaming the receiver.
|
|
7114
|
+
const optionalCheckedDynDelete = constantKey !== null &&
|
|
7115
|
+
declaresCheckedDynField(lowerer, obj.type, constantKey) &&
|
|
7116
|
+
declaredOptionalProperty(lowerer, target.expression, constantKey);
|
|
6673
7117
|
if (obj.type.kind === "record") {
|
|
6674
7118
|
const shape = lowerer.shapes.get(obj.type.shapeId);
|
|
6675
7119
|
if (shape?.indexValue && shape.fields.length === 0 && !shape.tuple) {
|
|
@@ -6682,13 +7126,8 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6682
7126
|
// while a later write makes it present again. Constant keys only
|
|
6683
7127
|
// (dot access or a literal bracket); required fields keep the honest
|
|
6684
7128
|
// fence below.
|
|
6685
|
-
const
|
|
6686
|
-
?
|
|
6687
|
-
: ts.isStringLiteral(target.argumentExpression)
|
|
6688
|
-
? target.argumentExpression.text
|
|
6689
|
-
: null;
|
|
6690
|
-
const field = fieldName !== null && !shape?.tuple
|
|
6691
|
-
? shape?.fields.find((f) => f.name === fieldName)
|
|
7129
|
+
const field = constantKey !== null && !shape?.tuple
|
|
7130
|
+
? shape?.fields.find((f) => f.name === constantKey)
|
|
6692
7131
|
: undefined;
|
|
6693
7132
|
if (field) {
|
|
6694
7133
|
const absent = lowerer.absentFieldValue(field.type, loc);
|
|
@@ -6706,9 +7145,32 @@ function lowerDeleteStatement(lowerer, expr) {
|
|
|
6706
7145
|
if (shape?.indexValue) {
|
|
6707
7146
|
lowerer.unsupported("SC1090", expr, "'delete' of hybrid index-signature keys (declared struct slots and overflow entries answer differently — model deletable dynamic keys with a pure Record<string, T>)");
|
|
6708
7147
|
}
|
|
6709
|
-
|
|
7148
|
+
if (optionalCheckedDynDelete) {
|
|
7149
|
+
lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
|
|
7150
|
+
}
|
|
7151
|
+
// A key of SEVERAL literals names no single slot: say that instead of
|
|
7152
|
+
// blaming a field the caller never named.
|
|
7153
|
+
const keyNames = constantKey === null && ts.isElementAccessExpression(target)
|
|
7154
|
+
? literalFieldKeys(lowerer, target.argumentExpression)
|
|
7155
|
+
: null;
|
|
7156
|
+
if (keyNames !== null && keyNames.length > 1) {
|
|
7157
|
+
lowerer.unsupported("SC1090", expr, `'delete' through keys of ${keyNames.length} literals (${keyNames.map((k) => `'${k}'`).join(", ")}; delete one constant key at a time, or switch over the key)`);
|
|
7158
|
+
}
|
|
7159
|
+
lowerer.unsupported("SC1090", expr, "'delete' of required record fields (the shape's slot cannot be removed — only an optional field (`f?: T`) has an absent state, which Object.keys, 'in', and JSON.stringify follow; make the field optional if the program must remove it)");
|
|
7160
|
+
}
|
|
7161
|
+
if (optionalCheckedDynDelete) {
|
|
7162
|
+
lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
|
|
7163
|
+
}
|
|
7164
|
+
// A class field lives in the instance's fixed layout: there is no
|
|
7165
|
+
// per-field presence state for a delete to write, so Object.keys,
|
|
7166
|
+
// `in`, and JSON.stringify would keep reporting the field where Node
|
|
7167
|
+
// drops it. Name that reason instead of the generic receiver fence.
|
|
7168
|
+
if (obj.type.kind === "object" &&
|
|
7169
|
+
constantKey !== null &&
|
|
7170
|
+
lowerer.classes.get(obj.type.className)?.fields.has(constantKey)) {
|
|
7171
|
+
lowerer.unsupported("SC1090", expr, "'delete' of class fields (an instance's fields are its fixed layout — there is no per-field presence state, so Object.keys, 'in', and JSON.stringify would still report a deleted field; only optional record fields (`f?: T`) and Record<string, T> keys delete)");
|
|
6710
7172
|
}
|
|
6711
|
-
lowerer.unsupported("SC1090", expr, `'delete' on '${lowerer.fmt(obj.type)}' receivers (process.env keys
|
|
7173
|
+
lowerer.unsupported("SC1090", expr, `'delete' on '${lowerer.fmt(obj.type)}' receivers (process.env keys, pure Record<string, T> keys, and optional record fields delete)`);
|
|
6712
7174
|
}
|
|
6713
7175
|
/** True when the `var`/`let` binding `nameNode` names cannot change after
|
|
6714
7176
|
* the top-level CommonJS export statement `exportNode` that exports it by
|
|
@@ -7384,6 +7846,13 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
7384
7846
|
return { kind: "exprStmt", expr: urlWrite, loc: locOf(expr) };
|
|
7385
7847
|
}
|
|
7386
7848
|
if (opKind === ts.SyntaxKind.EqualsToken) {
|
|
7849
|
+
// A write through `Date.prototype` or one of its members keeps its
|
|
7850
|
+
// fence: the prototype value is a read surface (property-access.ts).
|
|
7851
|
+
if (ts.isPropertyAccessExpression(expr.left) || ts.isElementAccessExpression(expr.left))
|
|
7852
|
+
fenceDatePrototypeWrite(lowerer, expr.left);
|
|
7853
|
+
const staticPrivateWrite = lowerStaticPrivateAssignment(lowerer, expr);
|
|
7854
|
+
if (staticPrivateWrite)
|
|
7855
|
+
return { kind: "exprStmt", expr: staticPrivateWrite, loc: locOf(expr) };
|
|
7387
7856
|
const callableWrite = lowerNativeFunctionAssignment(lowerer, expr);
|
|
7388
7857
|
if (callableWrite)
|
|
7389
7858
|
return { kind: "exprStmt", expr: callableWrite, loc: locOf(expr) };
|
|
@@ -7431,7 +7900,12 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
7431
7900
|
// (Node stringifies everything; a non-string RHS fences instead
|
|
7432
7901
|
// of diverging from Node). The computed-key form lands in
|
|
7433
7902
|
// lowerElementWrite.
|
|
7434
|
-
|
|
7903
|
+
// The same setenv for a value HELD from process.env (`const env =
|
|
7904
|
+
// process.env; env.X = v`): the hold aliases the live table, as
|
|
7905
|
+
// Node's does.
|
|
7906
|
+
if (!expr.left.questionDotToken &&
|
|
7907
|
+
(lowerer.isProcessEnv(expr.left.expression) ||
|
|
7908
|
+
heldEnvValueType(lowerer, expr.left.expression) !== null)) {
|
|
7435
7909
|
const loc = locOf(expr);
|
|
7436
7910
|
const key = {
|
|
7437
7911
|
kind: "strLit",
|
|
@@ -7901,6 +8375,39 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
7901
8375
|
};
|
|
7902
8376
|
}
|
|
7903
8377
|
}
|
|
8378
|
+
// process.stdout.write = fn (and stderr): replace the stream object's
|
|
8379
|
+
// write slot. Every later write to the stream — console output, typed
|
|
8380
|
+
// write calls (programPatchesStdio), runtime writers — goes through it.
|
|
8381
|
+
if (ts.isPropertyAccessExpression(expr.left) && expr.left.name.text === "write") {
|
|
8382
|
+
const recv = expr.left.expression;
|
|
8383
|
+
const stream = ts.isPropertyAccessExpression(recv)
|
|
8384
|
+
? lowerer.stdlibGlobalMember(recv, "process")
|
|
8385
|
+
: null;
|
|
8386
|
+
if (stream === "stdout" || stream === "stderr") {
|
|
8387
|
+
const loc = locOf(expr);
|
|
8388
|
+
return {
|
|
8389
|
+
kind: "exprStmt",
|
|
8390
|
+
expr: {
|
|
8391
|
+
kind: "libCall",
|
|
8392
|
+
fn: "dyn.keySet",
|
|
8393
|
+
args: [
|
|
8394
|
+
{
|
|
8395
|
+
kind: "libCall",
|
|
8396
|
+
fn: "process.stdioSlot",
|
|
8397
|
+
args: [numLit(stream === "stdout" ? 1 : 2, loc)],
|
|
8398
|
+
type: DYN,
|
|
8399
|
+
loc,
|
|
8400
|
+
},
|
|
8401
|
+
strLit("write", locOf(expr.left.name)),
|
|
8402
|
+
lowerer.lowerExprExpecting(expr.right, DYN),
|
|
8403
|
+
],
|
|
8404
|
+
type: VOID,
|
|
8405
|
+
loc,
|
|
8406
|
+
},
|
|
8407
|
+
loc,
|
|
8408
|
+
};
|
|
8409
|
+
}
|
|
8410
|
+
}
|
|
7904
8411
|
if (!ts.isIdentifier(expr.left)) {
|
|
7905
8412
|
lowerer.unsupported("SC1090", expr.left, "assignment to non-variables");
|
|
7906
8413
|
}
|
|
@@ -7933,6 +8440,8 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
7933
8440
|
const compound = COMPOUND_ASSIGN_OPS[opKind];
|
|
7934
8441
|
if (compound !== undefined) {
|
|
7935
8442
|
// Desugar `x op= e` to `x = x op e` — reads x before e, like JS.
|
|
8443
|
+
if (ts.isPropertyAccessExpression(expr.left) || ts.isElementAccessExpression(expr.left))
|
|
8444
|
+
fenceDatePrototypeWrite(lowerer, expr.left);
|
|
7936
8445
|
if (ts.isElementAccessExpression(expr.left)) {
|
|
7937
8446
|
// `this[kLimit] += v` — a declared symbol-keyed class field is
|
|
7938
8447
|
// the dotted compound in element spelling. Array and byte-view
|
|
@@ -7974,6 +8483,7 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
7974
8483
|
(expr.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
7975
8484
|
expr.operator === ts.SyntaxKind.MinusMinusToken)) {
|
|
7976
8485
|
if (ts.isPropertyAccessExpression(expr.operand) || ts.isElementAccessExpression(expr.operand)) {
|
|
8486
|
+
fenceDatePrototypeWrite(lowerer, expr.operand);
|
|
7977
8487
|
// Statement and value positions share ToNumeric and reference order.
|
|
7978
8488
|
// Namespace/expando globals retain their direct binding path below.
|
|
7979
8489
|
const binding = ts.isPropertyAccessExpression(expr.operand)
|
|
@@ -8193,6 +8703,45 @@ export function lowerDestructuringAssign(lowerer, target, init, blame, loc) {
|
|
|
8193
8703
|
const parts = destructuringAssignInto(lowerer, target, init, null, blame, loc);
|
|
8194
8704
|
return { kind: "block", body: parts.stmts, loc };
|
|
8195
8705
|
}
|
|
8706
|
+
/** An object pattern whose first element has a default and a static key
|
|
8707
|
+
* (`{ a = 1 }`, `{ a: b = 1 }`): V8 reads that key without checking the
|
|
8708
|
+
* source first, so a null or undefined source throws the read's TypeError. */
|
|
8709
|
+
function firstReadsWithDefault(pattern) {
|
|
8710
|
+
const first = pattern.elements.nodes[0];
|
|
8711
|
+
return (first !== undefined &&
|
|
8712
|
+
first.dotDotDotToken === undefined &&
|
|
8713
|
+
first.initializer !== undefined &&
|
|
8714
|
+
!(first.propertyName !== undefined && ts.isComputedPropertyName(first.propertyName)));
|
|
8715
|
+
}
|
|
8716
|
+
/** The read of the first key of a pattern that `firstReadsWithDefault`
|
|
8717
|
+
* accepts, over a dyn source: on null or undefined it throws the read's
|
|
8718
|
+
* TypeError, as V8 does. Null when the key has no static name. */
|
|
8719
|
+
function firstKeyRead(lowerer, pattern, source, loc) {
|
|
8720
|
+
const { firstProp } = firstPatternProp(lowerer, pattern);
|
|
8721
|
+
if (firstProp === undefined)
|
|
8722
|
+
return null;
|
|
8723
|
+
return {
|
|
8724
|
+
kind: "dynKeyGet",
|
|
8725
|
+
key: { kind: "strLit", value: firstProp, type: STRING, loc },
|
|
8726
|
+
value: source(),
|
|
8727
|
+
type: DYN,
|
|
8728
|
+
loc,
|
|
8729
|
+
};
|
|
8730
|
+
}
|
|
8731
|
+
/** The first property V8 names in an object pattern's destructuring
|
|
8732
|
+
* TypeError ("Cannot destructure property 'a' of ..."): an identifier,
|
|
8733
|
+
* string or numeric first key. A computed first key, a rest element or
|
|
8734
|
+
* an empty pattern takes the bare (source-only) form. */
|
|
8735
|
+
function firstPatternProp(lowerer, pattern) {
|
|
8736
|
+
const first = pattern.elements.nodes[0];
|
|
8737
|
+
const firstKey = first === undefined || first.dotDotDotToken !== undefined
|
|
8738
|
+
? undefined
|
|
8739
|
+
: (first.propertyName ?? first.name);
|
|
8740
|
+
const firstProp = firstKey === undefined || ts.isComputedPropertyName(firstKey)
|
|
8741
|
+
? undefined
|
|
8742
|
+
: (patternKeyNameOf(lowerer, firstKey) ?? undefined);
|
|
8743
|
+
return firstProp !== undefined ? { firstProp } : {};
|
|
8744
|
+
}
|
|
8196
8745
|
/** V8's spelling of a destructuring RHS in its TypeError message
|
|
8197
8746
|
* ("Cannot destructure 'a' as it is undefined.") — plain identifiers
|
|
8198
8747
|
* spell their name (parens unwrap), `this`, property chains and
|
|
@@ -8341,8 +8890,8 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
|
|
|
8341
8890
|
ts.isBinaryExpression(rhsInner) &&
|
|
8342
8891
|
rhsInner.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
8343
8892
|
(ts.isObjectLiteralExpression(rhsInner.left) || ts.isArrayLiteralExpression(rhsInner.left));
|
|
8344
|
-
if (!checkedByInner) {
|
|
8345
|
-
const spelling =
|
|
8893
|
+
if (!checkedByInner && rhs !== null) {
|
|
8894
|
+
const spelling = destrSpellingOf(rhs);
|
|
8346
8895
|
if (spelling === null) {
|
|
8347
8896
|
lowerer.unsupported("SC1031", blame, "destructuring assignment from a checked-dynamic source whose expression spelling is unsupported (use a variable, ordinary property chain, or ordinary call)");
|
|
8348
8897
|
}
|
|
@@ -8373,20 +8922,57 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
|
|
|
8373
8922
|
}
|
|
8374
8923
|
for (const prop of target.properties.nodes) {
|
|
8375
8924
|
const piece = destructAssignPiece(lowerer, prop);
|
|
8376
|
-
const
|
|
8925
|
+
const propLoc = locOf(prop);
|
|
8926
|
+
let read = {
|
|
8377
8927
|
kind: "dynKeyGet",
|
|
8378
|
-
key: { kind: "strLit", value: piece.field, type: STRING, loc:
|
|
8928
|
+
key: { kind: "strLit", value: piece.field, type: STRING, loc: propLoc },
|
|
8379
8929
|
value: tmpRef(),
|
|
8380
8930
|
type: DYN,
|
|
8381
|
-
loc:
|
|
8931
|
+
loc: propLoc,
|
|
8382
8932
|
};
|
|
8933
|
+
if (piece.dflt !== undefined) {
|
|
8934
|
+
// `{ x = 1 }` / `{ x: y = 1 }`: the default fires on the undefined
|
|
8935
|
+
// read and is evaluated lazily, exactly the declaration path's
|
|
8936
|
+
// checked-dynamic default.
|
|
8937
|
+
const readTmp = lowerer.declareHiddenLocal("%destr", DYN);
|
|
8938
|
+
out.push({ kind: "varDecl", localId: readTmp.id, init: read, loc: propLoc });
|
|
8939
|
+
const readRef = { kind: "varRef", localId: readTmp.id, type: DYN, loc: propLoc };
|
|
8940
|
+
read = {
|
|
8941
|
+
kind: "ternary",
|
|
8942
|
+
cond: { kind: "dynTest", test: "undefined", value: readRef, type: BOOL, loc: propLoc },
|
|
8943
|
+
then: lowerer.coerceInto(piece.dflt, lowerer.lowerExpr(piece.dflt), DYN),
|
|
8944
|
+
else_: readRef,
|
|
8945
|
+
type: DYN,
|
|
8946
|
+
loc: propLoc,
|
|
8947
|
+
};
|
|
8948
|
+
}
|
|
8383
8949
|
out.push({
|
|
8384
8950
|
kind: "assign",
|
|
8385
8951
|
localId: piece.target.id,
|
|
8386
8952
|
value: lowerer.coerceInto(prop, read, piece.target.type),
|
|
8387
|
-
loc:
|
|
8953
|
+
loc: propLoc,
|
|
8388
8954
|
});
|
|
8389
8955
|
}
|
|
8956
|
+
if (rhs === null && target.properties.nodes.length === 0) {
|
|
8957
|
+
// A pattern with no reads still owes the source's own coercion, and a
|
|
8958
|
+
// PRE-LOWERED source (`for ({} of …)`) has no source text: V8 reads
|
|
8959
|
+
// the value instead of spelling it ("Cannot read properties of null").
|
|
8960
|
+
for (const unit of ["null", "undefined"]) {
|
|
8961
|
+
out.push({
|
|
8962
|
+
kind: "if",
|
|
8963
|
+
cond: { kind: "dynTest", test: unit, value: tmpRef(), type: BOOL, loc },
|
|
8964
|
+
then: [
|
|
8965
|
+
{
|
|
8966
|
+
kind: "exprStmt",
|
|
8967
|
+
expr: nodeThrowExpr(1, "", `Cannot read properties of ${unit}`, VOID, loc),
|
|
8968
|
+
loc,
|
|
8969
|
+
},
|
|
8970
|
+
],
|
|
8971
|
+
else_: null,
|
|
8972
|
+
loc,
|
|
8973
|
+
});
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8390
8976
|
return { stmts: out, value };
|
|
8391
8977
|
}
|
|
8392
8978
|
if (target.properties.nodes.length === 0) {
|
|
@@ -8860,10 +9446,11 @@ function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
|
|
|
8860
9446
|
function destructAssignPiece(lowerer, prop) {
|
|
8861
9447
|
let fieldName;
|
|
8862
9448
|
let bindTo;
|
|
9449
|
+
let dflt;
|
|
8863
9450
|
if (ts.isShorthandPropertyAssignment(prop)) {
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
9451
|
+
// `{ x = 1 }`: the shorthand's default (the checker's name resolution
|
|
9452
|
+
// still answers the outer binding through the shorthand).
|
|
9453
|
+
dflt = prop.objectAssignmentInitializer;
|
|
8867
9454
|
fieldName = prop.name.text;
|
|
8868
9455
|
bindTo = prop.name;
|
|
8869
9456
|
}
|
|
@@ -8874,7 +9461,12 @@ function destructAssignPiece(lowerer, prop) {
|
|
|
8874
9461
|
lowerer.unsupported("SC1031", prop, "destructuring assignment with computed keys that do not fold to one property name");
|
|
8875
9462
|
}
|
|
8876
9463
|
fieldName = folded ?? "";
|
|
9464
|
+
// `{ x: y = 1 }`: a defaulted target, the AssignmentPattern spelling.
|
|
8877
9465
|
bindTo = prop.initializer;
|
|
9466
|
+
if (ts.isBinaryExpression(bindTo) && bindTo.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
9467
|
+
dflt = bindTo.right;
|
|
9468
|
+
bindTo = bindTo.left;
|
|
9469
|
+
}
|
|
8878
9470
|
}
|
|
8879
9471
|
else {
|
|
8880
9472
|
lowerer.unsupported("SC1031", prop, "destructuring assignment with rest or spread properties");
|
|
@@ -8895,7 +9487,7 @@ function destructAssignPiece(lowerer, prop) {
|
|
|
8895
9487
|
if (!target) {
|
|
8896
9488
|
lowerer.rejectUnresolved(bindTo, `assignment to '${bindTo.text}' (not a writable local or module global)`);
|
|
8897
9489
|
}
|
|
8898
|
-
return { field: fieldName, target };
|
|
9490
|
+
return { field: fieldName, target, ...(dflt !== undefined ? { dflt } : {}) };
|
|
8899
9491
|
}
|
|
8900
9492
|
/** The ARRAY half of destructuring assignment: element assigns from a
|
|
8901
9493
|
* tuple/array/checked-dynamic source pushed into `out` (see
|
|
@@ -9238,7 +9830,12 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
9238
9830
|
}
|
|
9239
9831
|
const awaitArray = !!stmt.awaitModifier && lowerer.mapTypeOf(lowerer.typeOf(stmt.expression))?.kind === "array";
|
|
9240
9832
|
if (stmt.awaitModifier && !awaitArray) {
|
|
9241
|
-
|
|
9833
|
+
// A web ReadableStream's and a Node readable's iterator views both type
|
|
9834
|
+
// as AsyncIterableIterator, which lowers like the async protocols — but
|
|
9835
|
+
// the loop consumes each view through its own lowering
|
|
9836
|
+
// (lowerForAwaitBuiltin below).
|
|
9837
|
+
if (!isWebReadableIteratorSource(lowerer, stmt.expression) &&
|
|
9838
|
+
!isNodeReadableIteratorSource(lowerer, stmt.expression)) {
|
|
9242
9839
|
const genT = lowerer.stageSourceType(stmt.expression) ??
|
|
9243
9840
|
lowerer.mapTypeOf(lowerer.typeOf(stmt.expression));
|
|
9244
9841
|
if (genT?.kind === "generator" && genT.async) {
|
|
@@ -11174,7 +11771,55 @@ function lowerForIn(lowerer, stmt) {
|
|
|
11174
11771
|
receiver = lowerer.coerceToExpected(receiver, DYN);
|
|
11175
11772
|
}
|
|
11176
11773
|
}
|
|
11774
|
+
return lowerForInReceiver(lowerer, stmt, labels, receiver);
|
|
11775
|
+
}
|
|
11776
|
+
/** for-in over the lowered `receiver` of `stmt`. */
|
|
11777
|
+
function lowerForInReceiver(lowerer, stmt, labels, receiver) {
|
|
11778
|
+
const loc = locOf(stmt);
|
|
11177
11779
|
const recvT = receiver.type;
|
|
11780
|
+
// A receiver that may be null or undefined: for-in visits nothing for
|
|
11781
|
+
// either, and walks a present value as its own type. The receiver is
|
|
11782
|
+
// evaluated once.
|
|
11783
|
+
if (recvT.kind === "union") {
|
|
11784
|
+
const arms = lowerer.unions.get(recvT.unionId)?.arms ?? [];
|
|
11785
|
+
const present = arms.filter((arm) => arm.kind !== "undefinedT" && arm.kind !== "nullT");
|
|
11786
|
+
if (present.length === 1 && present.length < arms.length) {
|
|
11787
|
+
const arm = present[0];
|
|
11788
|
+
const tag = lowerer.armTag(recvT.unionId, arm);
|
|
11789
|
+
const recv = lowerer.declareHiddenLocal("%innullable", recvT);
|
|
11790
|
+
const ref = varRef(recv.id, recvT, loc);
|
|
11791
|
+
const narrowed = {
|
|
11792
|
+
kind: "unionNarrow",
|
|
11793
|
+
unionId: recvT.unionId,
|
|
11794
|
+
tag,
|
|
11795
|
+
value: ref,
|
|
11796
|
+
type: arm,
|
|
11797
|
+
loc,
|
|
11798
|
+
};
|
|
11799
|
+
return {
|
|
11800
|
+
kind: "block",
|
|
11801
|
+
body: [
|
|
11802
|
+
{ kind: "varDecl", localId: recv.id, init: receiver, loc },
|
|
11803
|
+
{
|
|
11804
|
+
kind: "if",
|
|
11805
|
+
cond: {
|
|
11806
|
+
kind: "unionIsTag",
|
|
11807
|
+
unionId: recvT.unionId,
|
|
11808
|
+
tag,
|
|
11809
|
+
negated: false,
|
|
11810
|
+
value: ref,
|
|
11811
|
+
type: BOOL,
|
|
11812
|
+
loc,
|
|
11813
|
+
},
|
|
11814
|
+
then: [lowerForInReceiver(lowerer, stmt, labels, narrowed)],
|
|
11815
|
+
else_: null,
|
|
11816
|
+
loc,
|
|
11817
|
+
},
|
|
11818
|
+
],
|
|
11819
|
+
loc,
|
|
11820
|
+
};
|
|
11821
|
+
}
|
|
11822
|
+
}
|
|
11178
11823
|
if (recvT.kind === "dyn") {
|
|
11179
11824
|
const recv = lowerer.declareHiddenLocal("%indyn", DYN);
|
|
11180
11825
|
const ref = { kind: "varRef", localId: recv.id, type: DYN, loc };
|
|
@@ -11845,4 +12490,54 @@ function isAssertionInitializer(node) {
|
|
|
11845
12490
|
e = e.expression;
|
|
11846
12491
|
return ts.isAsExpression(e) || ts.isTypeAssertion(e);
|
|
11847
12492
|
}
|
|
12493
|
+
/** `const view = route as Route & { order: number }`: the asserted type
|
|
12494
|
+
* refines the record arms the value is stored in (hosted-narrowing.ts), and
|
|
12495
|
+
* a projection (`{ text: string }` over `TextBlock`) only names members the
|
|
12496
|
+
* stored record already holds. Either way Node erases the assertion and
|
|
12497
|
+
* keeps the object, so the binding keeps the value's layout and its writes
|
|
12498
|
+
* reach that object instead of a copy. */
|
|
12499
|
+
function assertionKeepsStorageLayout(lowerer, decl, init, settled) {
|
|
12500
|
+
if (decl.initializer === undefined || !isAssertionInitializer(decl.initializer))
|
|
12501
|
+
return false;
|
|
12502
|
+
if (settled.kind !== "union" && settled.kind !== "record")
|
|
12503
|
+
return false;
|
|
12504
|
+
if (init.kind !== "union" && init.kind !== "record")
|
|
12505
|
+
return false;
|
|
12506
|
+
if (hostsAll(lowerer, init, settled))
|
|
12507
|
+
return true;
|
|
12508
|
+
// A projection (`{ text: string }` over `TextBlock`) keeps the stored
|
|
12509
|
+
// record only when the binding's identity is observable through it
|
|
12510
|
+
// (a write, an identity comparison). A read-only view is equal either
|
|
12511
|
+
// way, keeps the copy narrowing.ts made, and stays reported.
|
|
12512
|
+
if (!bindingIdentityUse(decl, lowerer.checker))
|
|
12513
|
+
return false;
|
|
12514
|
+
return (init.kind === "record" &&
|
|
12515
|
+
settled.kind === "record" &&
|
|
12516
|
+
recordViewHosted(lowerer, init.shapeId, settled.shapeId));
|
|
12517
|
+
}
|
|
12518
|
+
/** `const v = x as { a: number; extra?: string }; v.extra = "x"`: the
|
|
12519
|
+
* assertion's view names a member the value's own layout does not, so the
|
|
12520
|
+
* binding receives a COPY of `x` and the write lands on that copy — Node
|
|
12521
|
+
* erases the assertion and adds the property to `x` itself, so the write
|
|
12522
|
+
* must reach a caller-visible object. Reads of a copy are equal either
|
|
12523
|
+
* way, and so is a nested write through a member the copy shares (the same
|
|
12524
|
+
* child object in both), so only a write to the copy's own field is
|
|
12525
|
+
* refused, by name. Where the layouts agree the binding keeps the value's
|
|
12526
|
+
* storage instead (assertionKeepsStorageLayout), narrowing.ts and
|
|
12527
|
+
* lowerVarDecl record that in layoutKeptNodes, and nothing here fires.
|
|
12528
|
+
* Runs for file-scope and local bindings alike, after the declaration has
|
|
12529
|
+
* been lowered (so the keep is known). */
|
|
12530
|
+
function refuseAssertionViewWrite(lowerer, decl) {
|
|
12531
|
+
if (decl.initializer === undefined || !isAssertionInitializer(decl.initializer))
|
|
12532
|
+
return;
|
|
12533
|
+
if (lowerer.layoutKeptNodes.has(decl.initializer))
|
|
12534
|
+
return;
|
|
12535
|
+
const copy = assertionViewCopy(lowerer, decl.initializer);
|
|
12536
|
+
if (copy === null)
|
|
12537
|
+
return;
|
|
12538
|
+
const write = bindingWrite(lowerer, decl);
|
|
12539
|
+
if (write === null)
|
|
12540
|
+
return;
|
|
12541
|
+
lowerer.unsupported("SC1090", decl, `writing '${write.text}' through '${decl.name.getText()}', a copy of the '${copy.source}' value the assertion views as '${copy.target}' (the write would land on the copy; write through the original binding, or declare the member on the value's type)`);
|
|
12542
|
+
}
|
|
11848
12543
|
//# sourceMappingURL=lower-stmts.js.map
|