@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
|
@@ -10,15 +10,18 @@ import { NARROW_FIRST } from "../surfaces.js";
|
|
|
10
10
|
import { recordShapeMismatchDiag, unionLiteralMismatchDiag, } from "../../../diagnostics/diagnostic.js";
|
|
11
11
|
import { PoisonError, jsFuncNameOf, neverTaintedJsType } from "../lowerer.js";
|
|
12
12
|
import { lowerIndexMergeHelper } from "../containers/indexed-objects.js";
|
|
13
|
+
import { recordMayKeepSource } from "../record-sources.js";
|
|
13
14
|
import { PERF_ENTRY_MARKER, X509_PUBLIC_KEY_FIELD, isGenericCallableMemberType, jsOpenObjectType, } from "../../type-mapper.js";
|
|
14
15
|
import { isSafeToRepeat } from "./evaluation-safety.js";
|
|
15
16
|
import { tryLowerExpression } from "./try-lower-expression.js";
|
|
16
17
|
import { classSymbolKeyOf, fenceSymbolFieldCopy, symbolFieldDisplayName, } from "../symbol-fields.js";
|
|
17
18
|
import { planUnionRetag } from "../union-retag.js";
|
|
19
|
+
import { literalValues } from "../../literal-values.js";
|
|
18
20
|
import { jsHoldsDynObject, runtimeOptionalStorageOperand } from "../lower-exprs.js";
|
|
19
21
|
import { builtinGlobalValue } from "./property-access.js";
|
|
20
22
|
import { holdsEvolvingArray } from "../lower-stmts.js";
|
|
21
23
|
import { builtinNamespaceValue } from "../builtin-namespaces.js";
|
|
24
|
+
import { tsUntypedGlobalValue } from "../global-values.js";
|
|
22
25
|
/** `{ a: 1, b: "x" }` → recordLit. The record type comes from the
|
|
23
26
|
* contextual type when tsc has one (annotated declarations, arguments,
|
|
24
27
|
* nested literals) and from the literal's own type otherwise — both intern
|
|
@@ -154,6 +157,34 @@ function pureKeyExpr(lowerer, expr) {
|
|
|
154
157
|
return expr.templateSpans.nodes.every((s) => pureKeyExpr(lowerer, s.expression));
|
|
155
158
|
return false;
|
|
156
159
|
}
|
|
160
|
+
/** Whether expr reads no state that evaluating other code could change:
|
|
161
|
+
* literals, `const` bindings, and unary operators over those. */
|
|
162
|
+
function constantInitializer(lowerer, expr) {
|
|
163
|
+
if (ts.isParenthesizedExpression(expr) || ts.isNonNullExpression(expr))
|
|
164
|
+
return constantInitializer(lowerer, expr.expression);
|
|
165
|
+
if (ts.isAsExpression(expr) || ts.isTypeAssertion(expr))
|
|
166
|
+
return constantInitializer(lowerer, expr.expression);
|
|
167
|
+
if (ts.isStringLiteralLike(expr) || ts.isNumericLiteral(expr))
|
|
168
|
+
return true;
|
|
169
|
+
if (expr.kind === ts.SyntaxKind.TrueKeyword ||
|
|
170
|
+
expr.kind === ts.SyntaxKind.FalseKeyword ||
|
|
171
|
+
expr.kind === ts.SyntaxKind.NullKeyword)
|
|
172
|
+
return true;
|
|
173
|
+
if (ts.isPrefixUnaryExpression(expr) &&
|
|
174
|
+
(expr.operator === ts.SyntaxKind.MinusToken ||
|
|
175
|
+
expr.operator === ts.SyntaxKind.PlusToken ||
|
|
176
|
+
expr.operator === ts.SyntaxKind.ExclamationToken ||
|
|
177
|
+
expr.operator === ts.SyntaxKind.TildeToken))
|
|
178
|
+
return constantInitializer(lowerer, expr.operand);
|
|
179
|
+
if (ts.isIdentifier(expr)) {
|
|
180
|
+
const decls = lowerer.checker.getSymbolAtLocation(expr)?.declarations ?? [];
|
|
181
|
+
return (decls.length > 0 &&
|
|
182
|
+
decls.every((d) => ts.isVariableDeclaration(d) &&
|
|
183
|
+
ts.isVariableDeclarationList(d.parent) &&
|
|
184
|
+
(ts.getCombinedNodeFlags(d) & ts.NodeFlags.Const) !== 0));
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
157
188
|
/** A property's field name: identifier/string-literal keys directly,
|
|
158
189
|
* foldable computed keys through literalComputedKey (the syntax pass
|
|
159
190
|
* fenced everything else). */
|
|
@@ -196,6 +227,63 @@ function propertyFunctionName(lowerer, name) {
|
|
|
196
227
|
return name.text;
|
|
197
228
|
return null;
|
|
198
229
|
}
|
|
230
|
+
/** `{ __proto__: value }` (B.3.1): sets the literal's prototype when the
|
|
231
|
+
* value is an object, a function or null, and does nothing for any other
|
|
232
|
+
* primitive — unlike Object.setPrototypeOf, which throws. Interned once. */
|
|
233
|
+
function protoLiteralHelper(lowerer, loc) {
|
|
234
|
+
const key = "%dyn.protoLiteral";
|
|
235
|
+
const existing = lowerer.builtinCallableValueFns.get(key);
|
|
236
|
+
if (existing !== undefined)
|
|
237
|
+
return existing;
|
|
238
|
+
const name = keyedHelperName(lowerer, key, "proto");
|
|
239
|
+
lowerer.builtinCallableValueFns.set(key, name);
|
|
240
|
+
const value = () => varRef("value.0", DYN, loc);
|
|
241
|
+
const test = (kind) => ({
|
|
242
|
+
kind: "dynTest",
|
|
243
|
+
test: kind,
|
|
244
|
+
value: value(),
|
|
245
|
+
type: BOOL,
|
|
246
|
+
loc,
|
|
247
|
+
});
|
|
248
|
+
let primitive = test("string");
|
|
249
|
+
for (const kind of ["number", "boolean", "undefined", "symbol", "bigint"])
|
|
250
|
+
primitive = { kind: "logical", op: "||", left: primitive, right: test(kind), type: BOOL, loc };
|
|
251
|
+
lowerer.liftedFns.push({
|
|
252
|
+
name,
|
|
253
|
+
params: [
|
|
254
|
+
{ localId: "object.0", name: "object", type: DYN },
|
|
255
|
+
{ localId: "value.0", name: "value", type: DYN },
|
|
256
|
+
],
|
|
257
|
+
returnType: VOID,
|
|
258
|
+
locals: [
|
|
259
|
+
{ id: "object.0", name: "object", type: DYN, mutable: false },
|
|
260
|
+
{ id: "value.0", name: "value", type: DYN, mutable: false },
|
|
261
|
+
],
|
|
262
|
+
body: [
|
|
263
|
+
{
|
|
264
|
+
kind: "if",
|
|
265
|
+
cond: { kind: "unary", op: "!", operand: primitive, type: BOOL, loc },
|
|
266
|
+
then: [
|
|
267
|
+
{
|
|
268
|
+
kind: "exprStmt",
|
|
269
|
+
expr: {
|
|
270
|
+
kind: "libCall",
|
|
271
|
+
fn: "dyn.setPrototype",
|
|
272
|
+
args: [varRef("object.0", DYN, loc), value()],
|
|
273
|
+
type: DYN,
|
|
274
|
+
loc,
|
|
275
|
+
},
|
|
276
|
+
loc,
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
else_: null,
|
|
280
|
+
loc,
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
loc,
|
|
284
|
+
});
|
|
285
|
+
return name;
|
|
286
|
+
}
|
|
199
287
|
/** The runtime-keyed JS object literal (a computed key that doesn't fold):
|
|
200
288
|
* builds a dyn object member-by-member. Keys evaluate before their values,
|
|
201
289
|
* properties in source order — JS's object-literal evaluation exactly.
|
|
@@ -256,16 +344,43 @@ export function lowerDynObjectLiteral(lowerer, expr, boxValue, conditionalArms =
|
|
|
256
344
|
if (ts.isPropertyAssignment(prop) &&
|
|
257
345
|
!ts.isComputedPropertyName(prop.name) &&
|
|
258
346
|
prop.name.text === "__proto__") {
|
|
259
|
-
if (prop.initializer.kind !== ts.SyntaxKind.NullKeyword)
|
|
260
|
-
lowerer.unsupported("SC1090", prop, "object-literal prototypes other than null (use Object.setPrototypeOf)");
|
|
261
347
|
flushFields();
|
|
262
348
|
acc ??= { kind: "dynObjLit", fields: [], type: DYN, loc };
|
|
349
|
+
const value = lowerer.lowerExprExpecting(prop.initializer, DYN);
|
|
350
|
+
// B.3.1: a null value sets the prototype; an object or function does
|
|
351
|
+
// too, through the guarded helper (scr_dyn_set_prototype throws for
|
|
352
|
+
// primitives, where B.3.1 silently ignores the value).
|
|
353
|
+
if (prop.initializer.kind === ts.SyntaxKind.NullKeyword) {
|
|
354
|
+
acc = {
|
|
355
|
+
kind: "libCall",
|
|
356
|
+
fn: "dyn.setPrototype",
|
|
357
|
+
args: [acc, value],
|
|
358
|
+
type: DYN,
|
|
359
|
+
loc: locOf(prop),
|
|
360
|
+
};
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const local = lowerer.declareHiddenLocal("%protoLiteral", DYN);
|
|
364
|
+
const object = { kind: "varRef", localId: local.id, type: DYN, loc };
|
|
263
365
|
acc = {
|
|
264
|
-
kind: "
|
|
265
|
-
|
|
266
|
-
|
|
366
|
+
kind: "seqExpr",
|
|
367
|
+
stmts: [
|
|
368
|
+
{ kind: "varDecl", localId: local.id, init: acc, loc },
|
|
369
|
+
{
|
|
370
|
+
kind: "exprStmt",
|
|
371
|
+
expr: {
|
|
372
|
+
kind: "call",
|
|
373
|
+
callee: protoLiteralHelper(lowerer, loc),
|
|
374
|
+
args: [object, value],
|
|
375
|
+
type: VOID,
|
|
376
|
+
loc,
|
|
377
|
+
},
|
|
378
|
+
loc,
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
result: object,
|
|
267
382
|
type: DYN,
|
|
268
|
-
loc
|
|
383
|
+
loc,
|
|
269
384
|
};
|
|
270
385
|
continue;
|
|
271
386
|
}
|
|
@@ -401,8 +516,11 @@ export function lowerDynObjectLiteral(lowerer, expr, boxValue, conditionalArms =
|
|
|
401
516
|
// A PURE member read a JS file cannot lower (a namespace object
|
|
402
517
|
// in an export aggregate): the slot takes a boxed fence closure —
|
|
403
518
|
// the diagnostics defer to the runtime-fence ledger, the object
|
|
404
|
-
// builds, and only USING the member stops the run.
|
|
405
|
-
|
|
519
|
+
// builds, and only USING the member stops the run. A TypeScript
|
|
520
|
+
// source keeps the compile-time refusal: the closure would answer
|
|
521
|
+
// typeof "function" and undefined members where Node reads the
|
|
522
|
+
// value.
|
|
523
|
+
const pureMember = ts.isIdentifier(valueExpr) && isJsSourceFile(ts.getSourceFileOfNode(prop));
|
|
406
524
|
if (!(err instanceof PoisonError) || !pureMember)
|
|
407
525
|
throw err;
|
|
408
526
|
const fence = lowerer.deferToRuntimeFence(propDiagsBefore, prop, {
|
|
@@ -493,9 +611,7 @@ function fenceAccessorSpreadSource(lowerer, prop, srcShape) {
|
|
|
493
611
|
/** Only definitely present later records replace earlier defaults. A
|
|
494
612
|
* callback binding may store undefined despite its checker annotation. */
|
|
495
613
|
function laterSpreadType(lowerer, expr) {
|
|
496
|
-
|
|
497
|
-
while (ts.isParenthesizedExpression(source))
|
|
498
|
-
source = source.expression;
|
|
614
|
+
const source = spreadSourceNode(lowerer, expr);
|
|
499
615
|
if (ts.isIdentifier(source))
|
|
500
616
|
return lowerer.lowerExpr(source).type;
|
|
501
617
|
return lowerer.mapTypeOf(lowerer.typeOf(source));
|
|
@@ -772,7 +888,24 @@ function lowerOptionalIndexSpreadSource(lowerer, source, loc) {
|
|
|
772
888
|
? selected
|
|
773
889
|
: { kind: "seqExpr", stmts: prefix, result: selected, type: recordType, loc };
|
|
774
890
|
}
|
|
775
|
-
export function lowerObjectLiteral(lowerer, expr, expected
|
|
891
|
+
export function lowerObjectLiteral(lowerer, expr, expected,
|
|
892
|
+
/** Build exactly at `expected` (one arm of a distributed union spread,
|
|
893
|
+
* lowerDistributedUnionSpread): the checker types the literal as the
|
|
894
|
+
* whole union, so its contextual type cannot choose the layout. */
|
|
895
|
+
exact = false) {
|
|
896
|
+
// `__proto__: v` sets the literal's [[Prototype]] as the literal is built.
|
|
897
|
+
// A record is a native struct with no dynamic prototype slot, so a
|
|
898
|
+
// JavaScript literal that carries one builds as a checked-dynamic object,
|
|
899
|
+
// which models the prototype chain like every other JS object. A bare
|
|
900
|
+
// `__proto__: null` keeps its existing route (both representations model
|
|
901
|
+
// a null prototype, and the checked-dynamic one is the only one anyway).
|
|
902
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr)) &&
|
|
903
|
+
expr.properties.nodes.some((prop) => ts.isPropertyAssignment(prop) &&
|
|
904
|
+
!ts.isComputedPropertyName(prop.name) &&
|
|
905
|
+
prop.name.text === "__proto__" &&
|
|
906
|
+
prop.initializer.kind !== ts.SyntaxKind.NullKeyword)) {
|
|
907
|
+
return lowerDynObjectLiteral(lowerer, expr);
|
|
908
|
+
}
|
|
776
909
|
// A spread of an untyped (`any`) source into a typed slot: TypeScript
|
|
777
910
|
// types such a literal `any`, and the copy holds whatever own properties
|
|
778
911
|
// the source has at runtime. Build it as a checked-dynamic object, then
|
|
@@ -861,7 +994,7 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
861
994
|
tryLowerExpression(lowerer, property.expression)?.type.kind === "dyn"))) {
|
|
862
995
|
return lowerDynObjectLiteral(lowerer, expr);
|
|
863
996
|
}
|
|
864
|
-
const unionClone = lowerUnionRecordClone(lowerer, expr);
|
|
997
|
+
const unionClone = exact ? null : lowerUnionRecordClone(lowerer, expr);
|
|
865
998
|
if (unionClone !== null)
|
|
866
999
|
return unionClone;
|
|
867
1000
|
// The RUNTIME-KEYED literal (JS): a computed key that doesn't fold to a
|
|
@@ -993,7 +1126,7 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
993
1126
|
ts.constituentTypes(tsType).some((t) => ts.symbolNameOf(t.getSymbol()) === "PromiseLike")) {
|
|
994
1127
|
tsType = lowerer.checker.getAwaitedType(tsType) ?? tsType;
|
|
995
1128
|
}
|
|
996
|
-
let mapped = lowerer.mapTypeOf(tsType);
|
|
1129
|
+
let mapped = exact && expected ? expected : lowerer.mapTypeOf(tsType);
|
|
997
1130
|
// A checked-dynamic source has runtime keys even when later explicit
|
|
998
1131
|
// fields make the literal's inferred type look like a fixed record.
|
|
999
1132
|
// Keep a checked-dynamic destination in that representation so copying
|
|
@@ -1193,14 +1326,27 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1193
1326
|
lowerer.unsupported("SC1090", deferredConditionalSpread, CONDITIONAL_SPREAD_FENCE);
|
|
1194
1327
|
}
|
|
1195
1328
|
if (!mapped || mapped.kind !== "record") {
|
|
1329
|
+
// Distribute against the contextual union when there is one (its arms
|
|
1330
|
+
// carry the discriminants), else against the literal's own union.
|
|
1331
|
+
const ctx = lowerer.mapTypeOf(tsType);
|
|
1332
|
+
const unionCtx = ctx?.kind === "union" ? ctx : mapped;
|
|
1333
|
+
const distributed = exact ? null : lowerDistributedUnionSpread(lowerer, expr, unionCtx);
|
|
1334
|
+
if (distributed)
|
|
1335
|
+
return distributed;
|
|
1196
1336
|
// A spread merge over UNION-typed sources (`{ ...base, ...override }`
|
|
1197
1337
|
// with `base`, `override` of arm-union types) has one field set per
|
|
1198
1338
|
// combination of source arms, so its own type is a union of records.
|
|
1199
1339
|
// No single arm of the contextual union can hold that value without
|
|
1200
1340
|
// dropping the fields the other arms contributed (Node keeps them
|
|
1201
1341
|
// all), and a runtime tag would be a guess about which arm the value
|
|
1202
|
-
// "is".
|
|
1342
|
+
// "is". Build the object Node builds instead — the checked-dynamic
|
|
1343
|
+
// copy — and let the union's checked conversion validate it.
|
|
1203
1344
|
if (mapped?.kind === "union") {
|
|
1345
|
+
if (!exact && unionCtx?.kind === "union") {
|
|
1346
|
+
const merged = lowerUnionSpreadMergeDyn(lowerer, expr, unionCtx);
|
|
1347
|
+
if (merged)
|
|
1348
|
+
return merged;
|
|
1349
|
+
}
|
|
1204
1350
|
const members = tsType.isUnionType() ? ts.constituentTypes(tsType) : [tsType];
|
|
1205
1351
|
const arms = [...new Set(members.map((m) => lowerer.checker.typeToString(m)))];
|
|
1206
1352
|
lowerer.pushDiag(unionLiteralMismatchDiag(lowerer.checker.typeToString(tsType), arms, locOf(expr)));
|
|
@@ -1208,7 +1354,20 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1208
1354
|
}
|
|
1209
1355
|
lowerer.badType(expr, tsType);
|
|
1210
1356
|
}
|
|
1211
|
-
|
|
1357
|
+
// An enclosing literal that built at its OWN type (its context had no
|
|
1358
|
+
// layout) asks for the matching own layout of this nested literal. When
|
|
1359
|
+
// this literal's contextual layout cannot reach that slot, build at it:
|
|
1360
|
+
// the enclosing literal's coercion then decides, and the width lifts
|
|
1361
|
+
// (the index-signature overflow capture included) carry the whole tree
|
|
1362
|
+
// into the real destination. Otherwise the two layers disagree and the
|
|
1363
|
+
// SC2002 names the source literal's own type as the expected one.
|
|
1364
|
+
const layout = expected &&
|
|
1365
|
+
!typeEquals(mapped, expected) &&
|
|
1366
|
+
lowerer.widthLiftPlan(mapped, expected) === null &&
|
|
1367
|
+
typeEquals(lowerer.mapTypeOf(lowerer.typeOf(expr)) ?? mapped, expected)
|
|
1368
|
+
? expected
|
|
1369
|
+
: mapped;
|
|
1370
|
+
let type = layout;
|
|
1212
1371
|
// A fresh, plain literal can construct its fields directly for a known
|
|
1213
1372
|
// destination with the same field set. This matters for inferred
|
|
1214
1373
|
// conditional records: an empty array in one arm has no element layout
|
|
@@ -1219,15 +1378,31 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1219
1378
|
expr.properties.nodes.every((p) => ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p))) {
|
|
1220
1379
|
const own = lowerer.shapes.get(type.shapeId);
|
|
1221
1380
|
const target = lowerer.shapes.get(expected.shapeId);
|
|
1222
|
-
|
|
1381
|
+
// The field set to compare is the LITERAL's: its checker type. The
|
|
1382
|
+
// contextual type a few lines up can be wider than what the literal
|
|
1383
|
+
// writes (an unannotated method checked against a generic slot's
|
|
1384
|
+
// signature: `{ content, details }` under a contextual
|
|
1385
|
+
// `AgentToolResult<unknown>` whose optional members the literal never
|
|
1386
|
+
// mentions), and the destination still names the same fields as the
|
|
1387
|
+
// literal, so the build can construct them directly. Only when the
|
|
1388
|
+
// contextual build has no conversion into the destination at all: a
|
|
1389
|
+
// value that converts today keeps its exact construction.
|
|
1390
|
+
const ownType = lowerer.mapTypeOf(lowerer.typeOf(expr));
|
|
1391
|
+
const ownChecked = ownType?.kind === "record" &&
|
|
1392
|
+
ownType.shapeId !== type.shapeId &&
|
|
1393
|
+
lowerer.widthLiftPlan(type, expected) === null
|
|
1394
|
+
? lowerer.shapes.get(ownType.shapeId)
|
|
1395
|
+
: undefined;
|
|
1396
|
+
const fits = (from) => !from.tuple &&
|
|
1223
1397
|
!target.tuple &&
|
|
1224
|
-
!
|
|
1398
|
+
!from.indexValue &&
|
|
1225
1399
|
!target.indexValue &&
|
|
1226
|
-
!shapeHasAccessorSlots(
|
|
1400
|
+
!shapeHasAccessorSlots(from) &&
|
|
1227
1401
|
!shapeHasAccessorSlots(target) &&
|
|
1228
|
-
target.fields.every((field) =>
|
|
1402
|
+
target.fields.every((field) => from.fields.some((candidate) => candidate.name === field.name) ||
|
|
1229
1403
|
(field.type.kind === "union" && lowerer.armTag(field.type.unionId, UNDEFINED_T) >= 0)) &&
|
|
1230
|
-
|
|
1404
|
+
from.fields.every((field) => target.fields.some((candidate) => candidate.name === field.name));
|
|
1405
|
+
if (fits(own) || (ownChecked !== undefined && fits(ownChecked))) {
|
|
1231
1406
|
type = { kind: "record", shapeId: expected.shapeId };
|
|
1232
1407
|
}
|
|
1233
1408
|
}
|
|
@@ -1357,7 +1532,13 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1357
1532
|
lowerer.badType(valueNode, lowerer.typeOf(valueNode));
|
|
1358
1533
|
overrides.push({ name, value });
|
|
1359
1534
|
}
|
|
1360
|
-
return {
|
|
1535
|
+
return lowerer.keyOrder.clone({
|
|
1536
|
+
kind: "recordClone",
|
|
1537
|
+
source,
|
|
1538
|
+
overrides,
|
|
1539
|
+
type,
|
|
1540
|
+
loc,
|
|
1541
|
+
});
|
|
1361
1542
|
}
|
|
1362
1543
|
leadingSpreadLowered = source;
|
|
1363
1544
|
}
|
|
@@ -1383,6 +1564,26 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1383
1564
|
!shape.tuple &&
|
|
1384
1565
|
(expr.properties.nodes.some((p) => ts.isSpreadAssignment(p)) ||
|
|
1385
1566
|
expr.properties.nodes.some(isRuntimeComputedKey))) {
|
|
1567
|
+
// A conditional spread needs the value slot's undefined arm to hold its
|
|
1568
|
+
// empty branch. A slot WITHOUT one (a `null | string` header map) takes
|
|
1569
|
+
// the checked-dynamic literal instead, which writes the key only when
|
|
1570
|
+
// the condition holds and validates the result against the target type;
|
|
1571
|
+
// decide BEFORE any contributor lowers (the fallback re-lowers the
|
|
1572
|
+
// whole literal). Reading the slot's own arm (never coercing a unit
|
|
1573
|
+
// into it) keeps a literal that merges statically byte-identical: the
|
|
1574
|
+
// probe would otherwise register a stranding trap the literal never
|
|
1575
|
+
// needs.
|
|
1576
|
+
const slotHoldsUndefined = shape.indexValue.kind === "dyn" ||
|
|
1577
|
+
(shape.indexValue.kind === "union" &&
|
|
1578
|
+
lowerer.armTag(shape.indexValue.unionId, UNDEFINED_T) >= 0);
|
|
1579
|
+
if (!slotHoldsUndefined &&
|
|
1580
|
+
expr.properties.nodes.some((p) => ts.isSpreadAssignment(p) &&
|
|
1581
|
+
(conditionalSpreadOf(p.expression) !== null ||
|
|
1582
|
+
andSpreadOf(lowerer, p.expression) !== null))) {
|
|
1583
|
+
const conditionalDyn = conditionalFallback();
|
|
1584
|
+
if (conditionalDyn)
|
|
1585
|
+
return conditionalDyn;
|
|
1586
|
+
}
|
|
1386
1587
|
const contributors = [];
|
|
1387
1588
|
let mergeable = true;
|
|
1388
1589
|
for (const prop of expr.properties.nodes) {
|
|
@@ -1477,12 +1678,10 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1477
1678
|
};
|
|
1478
1679
|
}
|
|
1479
1680
|
}
|
|
1480
|
-
// Unfoldable computed keys outside the index-signature merge path
|
|
1481
|
-
// no record shape can hold a runtime-decided name.
|
|
1681
|
+
// Unfoldable computed keys outside the index-signature merge path.
|
|
1482
1682
|
for (const prop of expr.properties.nodes) {
|
|
1483
|
-
if (isRuntimeComputedKey(prop))
|
|
1484
|
-
lowerer
|
|
1485
|
-
}
|
|
1683
|
+
if (isRuntimeComputedKey(prop))
|
|
1684
|
+
return runtimeKeyedDynLiteral(lowerer, expr, prop, type, expected);
|
|
1486
1685
|
}
|
|
1487
1686
|
// A declared destination combining fixed records and runtime-keyed
|
|
1488
1687
|
// sources needs both layouts. Apply each source before evaluating the
|
|
@@ -1591,6 +1790,16 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1591
1790
|
const droppedNames = new Set();
|
|
1592
1791
|
// The order this literal creates its keys in (key-order-witness.ts).
|
|
1593
1792
|
const orderSegments = [];
|
|
1793
|
+
// The literal's contributors when a spread drops source keys the target
|
|
1794
|
+
// has no slot for (key-order-witness.ts keepWidthSpreads). Conditional
|
|
1795
|
+
// spreads leave the literal to the static copy.
|
|
1796
|
+
const widthSegments = [];
|
|
1797
|
+
let widthDrops = false;
|
|
1798
|
+
let widthBlocked = false;
|
|
1799
|
+
// A checked-dynamic spread source's own keys are a run-time fact: even
|
|
1800
|
+
// when the checker's shape fits the target, the copied object can hold
|
|
1801
|
+
// more (slice 3).
|
|
1802
|
+
let widthDynSource = false;
|
|
1594
1803
|
for (const prop of expr.properties.nodes) {
|
|
1595
1804
|
// A later contributor can mutate an earlier source or overwrite a
|
|
1596
1805
|
// value with effects. Snapshot pending fields at their source position,
|
|
@@ -1604,6 +1813,7 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1604
1813
|
if (ts.isSpreadAssignment(prop)) {
|
|
1605
1814
|
const cs = conditionalSpreadOf(prop.expression) ?? andSpreadOf(lowerer, prop.expression);
|
|
1606
1815
|
if (cs && cs !== "unsupported") {
|
|
1816
|
+
widthBlocked = true;
|
|
1607
1817
|
// `...(c ? { k: v } : {})` — one conditional field per carried
|
|
1608
1818
|
// property at the spread's own position: cond evaluates exactly
|
|
1609
1819
|
// once (into a hidden local when several fields test it), each
|
|
@@ -1676,15 +1886,25 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1676
1886
|
// earlier ones (JS last-write-wins). Evaluate the source exactly
|
|
1677
1887
|
// once, including empty sources and those whose fields are all
|
|
1678
1888
|
// overridden. Field snapshots above preserve the copy order.
|
|
1679
|
-
|
|
1680
|
-
while (ts.isParenthesizedExpression(srcNode))
|
|
1681
|
-
srcNode = srcNode.expression;
|
|
1889
|
+
const srcNode = spreadSourceNode(lowerer, prop.expression);
|
|
1682
1890
|
const condRecord = conditionalRecordSpreadOf(lowerer, prop.expression);
|
|
1683
|
-
|
|
1891
|
+
let srcLowered = capture(condRecord !== null
|
|
1684
1892
|
? lowerConditionalRecordSpread(lowerer, condRecord, locOf(prop))
|
|
1685
1893
|
: prop === expr.properties.nodes[0] && leadingSpreadLowered !== null
|
|
1686
1894
|
? leadingSpreadLowered
|
|
1687
|
-
: lowerer.lowerExpr(srcNode));
|
|
1895
|
+
: (lowerer.spreadArmOverrides.get(srcNode) ?? lowerer.lowerExpr(srcNode)));
|
|
1896
|
+
{
|
|
1897
|
+
const narrowed = checkedSpreadSource(lowerer, srcNode, srcLowered);
|
|
1898
|
+
if (narrowed !== null)
|
|
1899
|
+
srcLowered = capture(narrowed);
|
|
1900
|
+
}
|
|
1901
|
+
if (condRecord !== null || srcLowered.kind !== "varRef")
|
|
1902
|
+
widthBlocked = true;
|
|
1903
|
+
else {
|
|
1904
|
+
widthSegments.push({ kind: "spread", value: srcLowered });
|
|
1905
|
+
if (srcLowered.type.kind === "dyn")
|
|
1906
|
+
widthDynSource = true;
|
|
1907
|
+
}
|
|
1688
1908
|
// Array callbacks can receive a record-or-undefined ABI even when
|
|
1689
1909
|
// TypeScript describes a required record. Select the copy strategy
|
|
1690
1910
|
// from that stored representation so absent sources copy nothing.
|
|
@@ -1704,12 +1924,10 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1704
1924
|
const def = lowerer.unions.get(srcType.unionId);
|
|
1705
1925
|
const recArms = def?.arms.filter((a) => a.kind === "record") ?? [];
|
|
1706
1926
|
if (!def ||
|
|
1707
|
-
recArms.length
|
|
1927
|
+
recArms.length === 0 ||
|
|
1708
1928
|
!def.arms.every((a) => a.kind === "record" || isUnitType(a))) {
|
|
1709
1929
|
lowerer.unsupported("SC1090", prop, `object spread of '${lowerer.fmt(srcType)}' sources (only known record shapes spread — ${NARROW_FIRST})`);
|
|
1710
1930
|
}
|
|
1711
|
-
const recArm = recArms[0];
|
|
1712
|
-
const recTag = def.arms.indexOf(recArm);
|
|
1713
1931
|
// A checked-dynamic VALUE under the union-mapped checker type
|
|
1714
1932
|
// (a JS dyn-holding binding): the present/absent desugar tests
|
|
1715
1933
|
// union tags a dyn box does not carry — fence honestly instead
|
|
@@ -1718,230 +1936,240 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
1718
1936
|
if (probedSrc?.type.kind === "dyn") {
|
|
1719
1937
|
lowerer.unsupported("SC1090", prop, `object spread of a checked-dynamic '${lowerer.fmt(srcType)}' source (${NARROW_FIRST})`);
|
|
1720
1938
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1939
|
+
// Several record arms: each arm contributes its own fields behind its
|
|
1940
|
+
// tag test, wrapping the earlier contributor, so a key that arm lacks
|
|
1941
|
+
// keeps the earlier value (JS copies only the arm's own keys).
|
|
1942
|
+
for (const recArmCandidate of recArms) {
|
|
1943
|
+
const recArm = recArmCandidate;
|
|
1944
|
+
const recTag = def.arms.indexOf(recArm);
|
|
1945
|
+
const srcShape = lowerer.shapes.get(recArm.shapeId);
|
|
1946
|
+
if (!srcShape)
|
|
1947
|
+
throw new InternalCompilerError(`lowerer bug: spread of unknown shape ${recArm.shapeId}`);
|
|
1948
|
+
fenceAccessorSpreadSource(lowerer, prop, srcShape);
|
|
1949
|
+
if (srcShape.indexValue || shape.indexValue) {
|
|
1950
|
+
const fallback = dynSpreadLiteral(lowerer, expr, type);
|
|
1951
|
+
if (fallback)
|
|
1952
|
+
return fallback;
|
|
1953
|
+
lowerer.unsupported("SC1090", prop, "object spread involving index-signature shapes (overflow keys are runtime state — copy the fields you need explicitly)");
|
|
1954
|
+
}
|
|
1955
|
+
const laterNames = new Set();
|
|
1956
|
+
for (const later of expr.properties.nodes.slice(expr.properties.nodes.indexOf(prop) + 1)) {
|
|
1957
|
+
if (ts.isSpreadAssignment(later)) {
|
|
1958
|
+
if (conditionalSpreadOf(later.expression) || andSpreadOf(lowerer, later.expression))
|
|
1959
|
+
continue;
|
|
1960
|
+
const lt = laterSpreadType(lowerer, later.expression);
|
|
1961
|
+
if (lt?.kind === "record") {
|
|
1962
|
+
// A field the later source may lack defines nothing.
|
|
1963
|
+
for (const lf of lowerer.shapes.get(lt.shapeId)?.fields ?? [])
|
|
1964
|
+
if (!canLackField(lf.type))
|
|
1965
|
+
laterNames.add(lf.name);
|
|
1966
|
+
}
|
|
1735
1967
|
continue;
|
|
1736
|
-
const lt = laterSpreadType(lowerer, later.expression);
|
|
1737
|
-
if (lt?.kind === "record") {
|
|
1738
|
-
// A field the later source may lack defines nothing.
|
|
1739
|
-
for (const lf of lowerer.shapes.get(lt.shapeId)?.fields ?? [])
|
|
1740
|
-
if (!canLackField(lf.type))
|
|
1741
|
-
laterNames.add(lf.name);
|
|
1742
1968
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
laterNames.add(propNameText(lowerer, later.name));
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
const srcRef = () => srcLowered ?? lowerer.lowerExpr(srcNode);
|
|
1755
|
-
const srcNarrowed = () => ({
|
|
1756
|
-
kind: "unionNarrow",
|
|
1757
|
-
unionId: srcType.unionId,
|
|
1758
|
-
tag: recTag,
|
|
1759
|
-
value: srcRef(),
|
|
1760
|
-
type: recArm,
|
|
1761
|
-
loc: locOf(prop),
|
|
1762
|
-
});
|
|
1763
|
-
// The source PROVEN present: the checked extraction `x!` lowers to
|
|
1764
|
-
// (narrowedArmHelper + checkedNarrowCall). A required target field
|
|
1765
|
-
// with no earlier contributor has no absent representation, so
|
|
1766
|
-
// `{ ...maybeRecord }` into it must find the record: the unit arm
|
|
1767
|
-
// throws the catchable TypeError instead of leaving the slot unset
|
|
1768
|
-
// (divergence 38's lying-assertion stance — the checker typed the
|
|
1769
|
-
// spread's fields optional, so only a cast or an unchecked indexed
|
|
1770
|
-
// read reaches this shape).
|
|
1771
|
-
const srcPresent = () => {
|
|
1772
|
-
const helper = lowerer.narrowedArmHelper(srcType.unionId, recArm, locOf(prop));
|
|
1773
|
-
return helper
|
|
1774
|
-
? lowerer.checkedNarrowCall(helper, srcRef(), recArm, locOf(prop))
|
|
1775
|
-
: srcNarrowed();
|
|
1776
|
-
};
|
|
1777
|
-
orderSegments.push({ kind: "spread", shapeId: recArm.shapeId, maybeAbsent: true });
|
|
1778
|
-
for (const f of srcShape.fields) {
|
|
1779
|
-
if (laterNames.has(f.name))
|
|
1780
|
-
continue;
|
|
1781
|
-
const targetType = fieldTypes.get(f.name);
|
|
1782
|
-
// No slot on the target shape: the copy DROPS the field
|
|
1783
|
-
// (divergence 36's stance, same as the plain-record spread).
|
|
1784
|
-
if (!targetType)
|
|
1785
|
-
continue;
|
|
1786
|
-
if (conditionalNames.has(f.name)) {
|
|
1787
|
-
const conditionalDyn = conditionalFallback();
|
|
1788
|
-
if (conditionalDyn)
|
|
1789
|
-
return conditionalDyn;
|
|
1790
|
-
lowerer.unsupported("SC1090", prop, `spread of '${f.name}' over an earlier conditional spread (the desugar keeps one entry per name — restructure so each name has one contributor)`);
|
|
1969
|
+
if (later.name &&
|
|
1970
|
+
(ts.isIdentifier(later.name) ||
|
|
1971
|
+
ts.isStringLiteral(later.name) ||
|
|
1972
|
+
ts.isNumericLiteral(later.name) ||
|
|
1973
|
+
(ts.isComputedPropertyName(later.name) &&
|
|
1974
|
+
literalComputedKey(lowerer, later.name) !== null))) {
|
|
1975
|
+
laterNames.add(propNameText(lowerer, later.name));
|
|
1976
|
+
}
|
|
1791
1977
|
}
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
shapeId: recArm.shapeId,
|
|
1796
|
-
field: f.name,
|
|
1797
|
-
type: f.type,
|
|
1798
|
-
loc: locOf(prop),
|
|
1799
|
-
});
|
|
1800
|
-
let cond = {
|
|
1801
|
-
kind: "unionIsTag",
|
|
1978
|
+
const srcRef = () => srcLowered ?? lowerer.lowerExpr(srcNode);
|
|
1979
|
+
const srcNarrowed = () => ({
|
|
1980
|
+
kind: "unionNarrow",
|
|
1802
1981
|
unionId: srcType.unionId,
|
|
1803
1982
|
tag: recTag,
|
|
1804
|
-
negated: false,
|
|
1805
1983
|
value: srcRef(),
|
|
1806
|
-
type:
|
|
1984
|
+
type: recArm,
|
|
1807
1985
|
loc: locOf(prop),
|
|
1986
|
+
});
|
|
1987
|
+
// The source PROVEN present: the checked extraction `x!` lowers to
|
|
1988
|
+
// (narrowedArmHelper + checkedNarrowCall). A required target field
|
|
1989
|
+
// with no earlier contributor has no absent representation, so
|
|
1990
|
+
// `{ ...maybeRecord }` into it must find the record: the unit arm
|
|
1991
|
+
// throws the catchable TypeError instead of leaving the slot unset
|
|
1992
|
+
// (divergence 38's lying-assertion stance — the checker typed the
|
|
1993
|
+
// spread's fields optional, so only a cast or an unchecked indexed
|
|
1994
|
+
// read reaches this shape).
|
|
1995
|
+
const srcPresent = () => {
|
|
1996
|
+
const helper = lowerer.narrowedArmHelper(srcType.unionId, recArm, locOf(prop));
|
|
1997
|
+
return helper
|
|
1998
|
+
? lowerer.checkedNarrowCall(helper, srcRef(), recArm, locOf(prop))
|
|
1999
|
+
: srcNarrowed();
|
|
1808
2000
|
};
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
2001
|
+
orderSegments.push({ kind: "spread", shapeId: recArm.shapeId, maybeAbsent: true });
|
|
2002
|
+
for (const f of srcShape.fields) {
|
|
2003
|
+
if (laterNames.has(f.name))
|
|
2004
|
+
continue;
|
|
2005
|
+
const targetType = fieldTypes.get(f.name);
|
|
2006
|
+
// No slot on the target shape: the static copy skips the field,
|
|
2007
|
+
// and the literal keeps it through a kept source view when the
|
|
2008
|
+
// program can observe it (keepWidthSpreads).
|
|
2009
|
+
if (!targetType) {
|
|
2010
|
+
widthDrops = true;
|
|
2011
|
+
continue;
|
|
2012
|
+
}
|
|
2013
|
+
if (conditionalNames.has(f.name)) {
|
|
2014
|
+
const conditionalDyn = conditionalFallback();
|
|
2015
|
+
if (conditionalDyn)
|
|
2016
|
+
return conditionalDyn;
|
|
2017
|
+
lowerer.unsupported("SC1090", prop, `spread of '${f.name}' over an earlier conditional spread (the desugar keeps one entry per name — restructure so each name has one contributor)`);
|
|
2018
|
+
}
|
|
2019
|
+
const fRead = (present = false) => ({
|
|
2020
|
+
kind: "recordGet",
|
|
2021
|
+
obj: present ? srcPresent() : srcNarrowed(),
|
|
1825
2022
|
shapeId: recArm.shapeId,
|
|
1826
2023
|
field: f.name,
|
|
2024
|
+
type: f.type,
|
|
2025
|
+
loc: locOf(prop),
|
|
2026
|
+
});
|
|
2027
|
+
let cond = {
|
|
2028
|
+
kind: "unionIsTag",
|
|
2029
|
+
unionId: srcType.unionId,
|
|
2030
|
+
tag: recTag,
|
|
2031
|
+
negated: false,
|
|
2032
|
+
value: srcRef(),
|
|
1827
2033
|
type: BOOL,
|
|
1828
2034
|
loc: locOf(prop),
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
const canBeAbsent = f.type.kind === "union" && lowerer.armTag(f.type.unionId, UNDEFINED_T) >= 0;
|
|
1834
|
-
if (typeEquals(f.type, targetType)) {
|
|
1835
|
-
thenVal = fRead();
|
|
1836
|
-
if (canBeAbsent)
|
|
1837
|
-
cond = fieldPresent();
|
|
1838
|
-
}
|
|
1839
|
-
else if (f.type.kind === "union" &&
|
|
1840
|
-
lowerer.armTag(f.type.unionId, UNDEFINED_T) >= 0 &&
|
|
1841
|
-
typeEquals(lowerer.stripUndefinedArm(f.type), targetType)) {
|
|
1842
|
-
// Optional source field into a required target slot: present
|
|
1843
|
-
// means the source holds the record AND the field its value
|
|
1844
|
-
// arm — the spread-override completion, union-source form.
|
|
1845
|
-
const ftUndef = lowerer.armTag(f.type.unionId, UNDEFINED_T);
|
|
1846
|
-
cond = {
|
|
2035
|
+
};
|
|
2036
|
+
let thenVal;
|
|
2037
|
+
// A source field that can be absent copies only when present.
|
|
2038
|
+
const fieldPresent = () => ({
|
|
1847
2039
|
kind: "logical",
|
|
1848
2040
|
op: "&&",
|
|
1849
2041
|
left: cond,
|
|
1850
2042
|
right: {
|
|
1851
|
-
kind: "
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
2043
|
+
kind: "recordHas",
|
|
2044
|
+
obj: {
|
|
2045
|
+
kind: "unionNarrow",
|
|
2046
|
+
unionId: srcType.unionId,
|
|
2047
|
+
tag: recTag,
|
|
2048
|
+
value: srcRef(),
|
|
2049
|
+
type: recArm,
|
|
2050
|
+
loc: locOf(prop),
|
|
2051
|
+
},
|
|
2052
|
+
shapeId: recArm.shapeId,
|
|
2053
|
+
field: f.name,
|
|
1856
2054
|
type: BOOL,
|
|
1857
2055
|
loc: locOf(prop),
|
|
1858
2056
|
},
|
|
1859
2057
|
type: BOOL,
|
|
1860
2058
|
loc: locOf(prop),
|
|
1861
|
-
};
|
|
1862
|
-
const
|
|
1863
|
-
if (
|
|
1864
|
-
|
|
1865
|
-
if (
|
|
1866
|
-
|
|
1867
|
-
throw new PoisonError();
|
|
1868
|
-
}
|
|
1869
|
-
thenVal = {
|
|
1870
|
-
kind: "call",
|
|
1871
|
-
callee: retag,
|
|
1872
|
-
args: [fRead()],
|
|
1873
|
-
type: targetType,
|
|
1874
|
-
loc: locOf(prop),
|
|
1875
|
-
};
|
|
2059
|
+
});
|
|
2060
|
+
const canBeAbsent = f.type.kind === "union" && lowerer.armTag(f.type.unionId, UNDEFINED_T) >= 0;
|
|
2061
|
+
if (typeEquals(f.type, targetType)) {
|
|
2062
|
+
thenVal = fRead();
|
|
2063
|
+
if (canBeAbsent)
|
|
2064
|
+
cond = fieldPresent();
|
|
1876
2065
|
}
|
|
1877
|
-
else if (
|
|
1878
|
-
|
|
1879
|
-
lowerer.
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
2066
|
+
else if (f.type.kind === "union" &&
|
|
2067
|
+
lowerer.armTag(f.type.unionId, UNDEFINED_T) >= 0 &&
|
|
2068
|
+
typeEquals(lowerer.stripUndefinedArm(f.type), targetType)) {
|
|
2069
|
+
// Optional source field into a required target slot: present
|
|
2070
|
+
// means the source holds the record AND the field its value
|
|
2071
|
+
// arm — the spread-override completion, union-source form.
|
|
2072
|
+
const ftUndef = lowerer.armTag(f.type.unionId, UNDEFINED_T);
|
|
2073
|
+
cond = {
|
|
2074
|
+
kind: "logical",
|
|
2075
|
+
op: "&&",
|
|
2076
|
+
left: cond,
|
|
2077
|
+
right: {
|
|
2078
|
+
kind: "unionIsTag",
|
|
2079
|
+
unionId: f.type.unionId,
|
|
2080
|
+
tag: ftUndef,
|
|
2081
|
+
negated: true,
|
|
2082
|
+
value: fRead(),
|
|
2083
|
+
type: BOOL,
|
|
2084
|
+
loc: locOf(prop),
|
|
2085
|
+
},
|
|
2086
|
+
type: BOOL,
|
|
1886
2087
|
loc: locOf(prop),
|
|
1887
2088
|
};
|
|
2089
|
+
const ftDef = lowerer.unions.get(f.type.unionId);
|
|
2090
|
+
if (targetType.kind === "union") {
|
|
2091
|
+
const retag = lowerer.unionRetagHelper(f.type.unionId, targetType.unionId, locOf(prop));
|
|
2092
|
+
if (!retag) {
|
|
2093
|
+
lowerer.pushDiag(recordShapeMismatchDiag(lowerer.fmt(type), lowerer.fmt(recArm), locOf(prop), `spread field '${f.name}': '${lowerer.fmt(f.type)}' cannot re-tag into '${lowerer.fmt(targetType)}' behind the present-test`));
|
|
2094
|
+
throw new PoisonError();
|
|
2095
|
+
}
|
|
2096
|
+
thenVal = {
|
|
2097
|
+
kind: "call",
|
|
2098
|
+
callee: retag,
|
|
2099
|
+
args: [fRead()],
|
|
2100
|
+
type: targetType,
|
|
2101
|
+
loc: locOf(prop),
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
else if (ftDef &&
|
|
2105
|
+
ftDef.arms.length === 2 &&
|
|
2106
|
+
lowerer.armTag(f.type.unionId, targetType) >= 0) {
|
|
2107
|
+
thenVal = {
|
|
2108
|
+
kind: "unionNarrow",
|
|
2109
|
+
unionId: f.type.unionId,
|
|
2110
|
+
tag: lowerer.armTag(f.type.unionId, targetType),
|
|
2111
|
+
value: fRead(),
|
|
2112
|
+
type: targetType,
|
|
2113
|
+
loc: locOf(prop),
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
else {
|
|
2117
|
+
lowerer.pushDiag(recordShapeMismatchDiag(lowerer.fmt(type), lowerer.fmt(recArm), locOf(prop), `spread field '${f.name}': '${lowerer.fmt(f.type)}' cannot narrow into '${lowerer.fmt(targetType)}' behind the present-test`));
|
|
2118
|
+
throw new PoisonError();
|
|
2119
|
+
}
|
|
1888
2120
|
}
|
|
1889
2121
|
else {
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
// The width-lift fallback (arm wrap, re-tag, nested
|
|
1896
|
-
// reshape) — the same per-field rule the slot coercion
|
|
1897
|
-
// applies. Runs AFTER the optional-completion branch: a
|
|
1898
|
-
// present-test has its own semantics a re-tag's stranded
|
|
1899
|
-
// undefined trap must not shadow.
|
|
1900
|
-
const lift = lowerer.widthLiftPlan(f.type, targetType);
|
|
1901
|
-
if (!lift) {
|
|
1902
|
-
lowerer.pushDiag(recordShapeMismatchDiag(lowerer.fmt(type), lowerer.fmt(recArm), locOf(prop), `spread field '${f.name}': '${lowerer.fmt(f.type)}' does not lift into '${lowerer.fmt(targetType)}'`));
|
|
1903
|
-
throw new PoisonError();
|
|
1904
|
-
}
|
|
1905
|
-
thenVal = lowerer.applyWidthLift(lift, fRead(), targetType, locOf(prop));
|
|
1906
|
-
if (canBeAbsent)
|
|
1907
|
-
cond = fieldPresent();
|
|
1908
|
-
}
|
|
1909
|
-
const at = fields.findIndex((x) => x.name === f.name);
|
|
1910
|
-
const elseVal = at >= 0 ? fields[at].value : lowerer.absentFieldValue(targetType, locOf(prop));
|
|
1911
|
-
if (!elseVal) {
|
|
1912
|
-
if (canBeAbsent) {
|
|
1913
|
-
// The FIELD itself can be missing from a present source:
|
|
1914
|
-
// no extraction makes it exist.
|
|
1915
|
-
lowerer.unsupported("SC1090", prop, `object spread of '${lowerer.fmt(srcType)}' sources where '${f.name}' has no earlier contributor (the absent arm leaves the required field unset — spread defaults first: { ...defaults, ...overrides })`);
|
|
1916
|
-
}
|
|
1917
|
-
// No earlier contributor and the target slot cannot be absent:
|
|
1918
|
-
// the source must be here. Copy through the checked extraction
|
|
1919
|
-
// (the absent unit arm throws) — the same read the width lift
|
|
1920
|
-
// below wraps, so a lift still applies.
|
|
1921
|
-
let strict = fRead(true);
|
|
1922
|
-
if (!typeEquals(f.type, targetType)) {
|
|
2122
|
+
// The width-lift fallback (arm wrap, re-tag, nested
|
|
2123
|
+
// reshape) — the same per-field rule the slot coercion
|
|
2124
|
+
// applies. Runs AFTER the optional-completion branch: a
|
|
2125
|
+
// present-test has its own semantics a re-tag's stranded
|
|
2126
|
+
// undefined trap must not shadow.
|
|
1923
2127
|
const lift = lowerer.widthLiftPlan(f.type, targetType);
|
|
1924
2128
|
if (!lift) {
|
|
1925
2129
|
lowerer.pushDiag(recordShapeMismatchDiag(lowerer.fmt(type), lowerer.fmt(recArm), locOf(prop), `spread field '${f.name}': '${lowerer.fmt(f.type)}' does not lift into '${lowerer.fmt(targetType)}'`));
|
|
1926
2130
|
throw new PoisonError();
|
|
1927
2131
|
}
|
|
1928
|
-
|
|
2132
|
+
thenVal = lowerer.applyWidthLift(lift, fRead(), targetType, locOf(prop));
|
|
2133
|
+
if (canBeAbsent)
|
|
2134
|
+
cond = fieldPresent();
|
|
1929
2135
|
}
|
|
1930
|
-
fields.
|
|
1931
|
-
|
|
2136
|
+
const at = fields.findIndex((x) => x.name === f.name);
|
|
2137
|
+
const elseVal = at >= 0 ? fields[at].value : lowerer.absentFieldValue(targetType, locOf(prop));
|
|
2138
|
+
if (!elseVal) {
|
|
2139
|
+
if (canBeAbsent) {
|
|
2140
|
+
// The FIELD itself can be missing from a present source:
|
|
2141
|
+
// no extraction makes it exist.
|
|
2142
|
+
lowerer.unsupported("SC1090", prop, `object spread of '${lowerer.fmt(srcType)}' sources where '${f.name}' has no earlier contributor (the absent arm leaves the required field unset — spread defaults first: { ...defaults, ...overrides })`);
|
|
2143
|
+
}
|
|
2144
|
+
// No earlier contributor and the target slot cannot be absent:
|
|
2145
|
+
// the source must be here. Copy through the checked extraction
|
|
2146
|
+
// (the absent unit arm throws) — the same read the width lift
|
|
2147
|
+
// below wraps, so a lift still applies.
|
|
2148
|
+
let strict = fRead(true);
|
|
2149
|
+
if (!typeEquals(f.type, targetType)) {
|
|
2150
|
+
const lift = lowerer.widthLiftPlan(f.type, targetType);
|
|
2151
|
+
if (!lift) {
|
|
2152
|
+
lowerer.pushDiag(recordShapeMismatchDiag(lowerer.fmt(type), lowerer.fmt(recArm), locOf(prop), `spread field '${f.name}': '${lowerer.fmt(f.type)}' does not lift into '${lowerer.fmt(targetType)}'`));
|
|
2153
|
+
throw new PoisonError();
|
|
2154
|
+
}
|
|
2155
|
+
strict = lowerer.applyWidthLift(lift, strict, targetType, locOf(prop));
|
|
2156
|
+
}
|
|
2157
|
+
fields.push({ name: f.name, value: strict });
|
|
2158
|
+
continue;
|
|
2159
|
+
}
|
|
2160
|
+
const merged = {
|
|
2161
|
+
kind: "ternary",
|
|
2162
|
+
cond,
|
|
2163
|
+
then: thenVal,
|
|
2164
|
+
else_: elseVal,
|
|
2165
|
+
type: targetType,
|
|
2166
|
+
loc: locOf(prop),
|
|
2167
|
+
};
|
|
2168
|
+
if (at >= 0)
|
|
2169
|
+
fields[at] = { name: f.name, value: merged };
|
|
2170
|
+
else
|
|
2171
|
+
fields.push({ name: f.name, value: merged });
|
|
1932
2172
|
}
|
|
1933
|
-
const merged = {
|
|
1934
|
-
kind: "ternary",
|
|
1935
|
-
cond,
|
|
1936
|
-
then: thenVal,
|
|
1937
|
-
else_: elseVal,
|
|
1938
|
-
type: targetType,
|
|
1939
|
-
loc: locOf(prop),
|
|
1940
|
-
};
|
|
1941
|
-
if (at >= 0)
|
|
1942
|
-
fields[at] = { name: f.name, value: merged };
|
|
1943
|
-
else
|
|
1944
|
-
fields.push({ name: f.name, value: merged });
|
|
1945
2173
|
}
|
|
1946
2174
|
continue;
|
|
1947
2175
|
}
|
|
@@ -2006,13 +2234,15 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
2006
2234
|
if (laterNames.has(f.name))
|
|
2007
2235
|
continue;
|
|
2008
2236
|
let targetType = fieldTypes.get(f.name);
|
|
2009
|
-
// A source field with NO slot on the target shape: the
|
|
2010
|
-
//
|
|
2011
|
-
//
|
|
2012
|
-
//
|
|
2013
|
-
|
|
2014
|
-
|
|
2237
|
+
// A source field with NO slot on the target shape: the static
|
|
2238
|
+
// copy skips it (the read is pure, so skipping evaluates nothing),
|
|
2239
|
+
// and the literal keeps it through a kept source view when the
|
|
2240
|
+
// program can observe the target (keepWidthSpreads).
|
|
2241
|
+
if (!targetType) {
|
|
2242
|
+
if (srcLowered.type.kind !== "dyn")
|
|
2243
|
+
widthDrops = true;
|
|
2015
2244
|
continue;
|
|
2245
|
+
}
|
|
2016
2246
|
// A runtime-optional source field (an unchecked indexed read the
|
|
2017
2247
|
// checker calls present) keeps its undefined arm in the copy, as a
|
|
2018
2248
|
// property initialized from that read would.
|
|
@@ -2251,7 +2481,8 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
2251
2481
|
lowerer.diags.slice(propDiagsBefore).some((d) => d.code === "SC9001")) {
|
|
2252
2482
|
throw err;
|
|
2253
2483
|
}
|
|
2254
|
-
|
|
2484
|
+
for (const d of lowerer.diags.splice(propDiagsBefore))
|
|
2485
|
+
lowerer.runtimeFences.push(d);
|
|
2255
2486
|
droppedNames.add(name);
|
|
2256
2487
|
continue;
|
|
2257
2488
|
}
|
|
@@ -2297,6 +2528,7 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
2297
2528
|
fields.splice(at, 1);
|
|
2298
2529
|
fields.push({ name, value });
|
|
2299
2530
|
orderSegments.push({ kind: "key", name, definite: true });
|
|
2531
|
+
widthSegments.push({ kind: "key", name });
|
|
2300
2532
|
}
|
|
2301
2533
|
// Optional fields may be omitted: the field holds its absent state.
|
|
2302
2534
|
// tsc rejects omission of required fields before lowering.
|
|
@@ -2323,10 +2555,46 @@ export function lowerObjectLiteral(lowerer, expr, expected) {
|
|
|
2323
2555
|
}
|
|
2324
2556
|
}
|
|
2325
2557
|
const result = lowerer.keyOrder.literal({ kind: "recordLit", fields, type, loc }, orderSegments);
|
|
2558
|
+
if (!widthBlocked &&
|
|
2559
|
+
spreadStmts.length > 0 &&
|
|
2560
|
+
type.kind === "record" &&
|
|
2561
|
+
recordMayKeepSource(lowerer, type))
|
|
2562
|
+
lowerer.keyOrder.width(result, widthSegments, widthDrops || widthDynSource);
|
|
2326
2563
|
return spreadStmts.length === 0
|
|
2327
2564
|
? result
|
|
2328
2565
|
: { kind: "seqExpr", stmts: spreadStmts, result, type, loc };
|
|
2329
2566
|
}
|
|
2567
|
+
/** A spread source whose stored union holds several record arms while the
|
|
2568
|
+
* checker narrowed this site to fewer (`if (b?.type === "tool") ({ ...b })`
|
|
2569
|
+
* on an element read, or a type predicate's arm): extract the narrowed
|
|
2570
|
+
* value through the CHECKED narrowing, so every arm the checker excludes,
|
|
2571
|
+
* including a hidden absence arm, throws the catchable TypeError instead of
|
|
2572
|
+
* being copied. Null when the stored union has at most one record arm (the
|
|
2573
|
+
* present-test desugar owns that case), when the site type is not a
|
|
2574
|
+
* narrowing of the stored union, or in JavaScript files. */
|
|
2575
|
+
function checkedSpreadSource(lowerer, node, stored) {
|
|
2576
|
+
if (stored.type.kind !== "union")
|
|
2577
|
+
return null;
|
|
2578
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(node)))
|
|
2579
|
+
return null;
|
|
2580
|
+
const def = lowerer.unions.get(stored.type.unionId);
|
|
2581
|
+
if (!def || def.arms.filter((arm) => arm.kind === "record").length < 2)
|
|
2582
|
+
return null;
|
|
2583
|
+
const site = lowerer.mapTypeOf(lowerer.typeOf(node));
|
|
2584
|
+
if (!site || typeEquals(site, stored.type))
|
|
2585
|
+
return null;
|
|
2586
|
+
const loc = stored.loc;
|
|
2587
|
+
if (site.kind === "record") {
|
|
2588
|
+
if (lowerer.armTag(stored.type.unionId, site) < 0)
|
|
2589
|
+
return null;
|
|
2590
|
+
const helper = lowerer.narrowedArmHelper(stored.type.unionId, site, loc);
|
|
2591
|
+
return helper ? lowerer.checkedNarrowCall(helper, stored, site, loc) : null;
|
|
2592
|
+
}
|
|
2593
|
+
if (site.kind !== "union")
|
|
2594
|
+
return null;
|
|
2595
|
+
const helper = lowerer.narrowedRetagHelper(node, stored.type.unionId, site.unionId, loc);
|
|
2596
|
+
return helper ? { kind: "call", callee: helper, args: [stored], type: site, loc } : null;
|
|
2597
|
+
}
|
|
2330
2598
|
/** The field type is an array, or a union with exactly one array arm. */
|
|
2331
2599
|
function singleArrayArm(lowerer, type) {
|
|
2332
2600
|
if (type.kind === "array")
|
|
@@ -2342,6 +2610,269 @@ function isEmptyArrayLiteral(node) {
|
|
|
2342
2610
|
inner = inner.expression;
|
|
2343
2611
|
return ts.isArrayLiteralExpression(inner) && inner.elements.nodes.length === 0;
|
|
2344
2612
|
}
|
|
2613
|
+
/** `{ ...u, k: v }` where the spread source `u` is a union of records (and
|
|
2614
|
+
* unit arms): TypeScript types the literal as the union of one spread per
|
|
2615
|
+
* source arm, so it is built that way. The source evaluates once into a
|
|
2616
|
+
* hidden local; a tag dispatch builds the running arm's literal with that
|
|
2617
|
+
* arm as the source, at the destination arm chosen for it:
|
|
2618
|
+
* 1. the arms the discriminant's last writer selects (an explicit
|
|
2619
|
+
* property, or the source arm when it carries the field);
|
|
2620
|
+
* 2. among those, the source arm itself (`{ ...command, id }`);
|
|
2621
|
+
* 3. else the one arm whose keys are exactly the keys the literal writes.
|
|
2622
|
+
* Every key a contributor may write must be a field of the destination:
|
|
2623
|
+
* the record path's width copy would drop the others, and Node keeps them.
|
|
2624
|
+
* So a genuine merge (`{ ...http, ...patch }` where `patch` may carry a
|
|
2625
|
+
* stdio-only key) stays refused. A stored source the checker narrowed
|
|
2626
|
+
* converts through the checked re-tag first, so an excluded arm (a hidden
|
|
2627
|
+
* absence arm included) throws the catchable TypeError. Null when the
|
|
2628
|
+
* literal is not this shape, before anything is lowered except the
|
|
2629
|
+
* source; the caller keeps its refusal. */
|
|
2630
|
+
function lowerDistributedUnionSpread(lowerer, expr, mapped) {
|
|
2631
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
2632
|
+
return null;
|
|
2633
|
+
if (mapped?.kind !== "union")
|
|
2634
|
+
return null;
|
|
2635
|
+
const target = lowerer.unions.get(mapped.unionId);
|
|
2636
|
+
if (!target)
|
|
2637
|
+
return null;
|
|
2638
|
+
const props = expr.properties.nodes;
|
|
2639
|
+
// Exactly one distributed source: a plain spread whose checker type maps
|
|
2640
|
+
// to a union of records and unit arms. Several would be a product.
|
|
2641
|
+
let spreadIndex = -1;
|
|
2642
|
+
let srcNode = null;
|
|
2643
|
+
for (let i = 0; i < props.length; i++) {
|
|
2644
|
+
const prop = props[i];
|
|
2645
|
+
if (!ts.isSpreadAssignment(prop))
|
|
2646
|
+
continue;
|
|
2647
|
+
if (conditionalSpreadOf(prop.expression) !== null ||
|
|
2648
|
+
andSpreadOf(lowerer, prop.expression) !== null ||
|
|
2649
|
+
conditionalRecordSpreadOf(lowerer, prop.expression) !== null)
|
|
2650
|
+
continue;
|
|
2651
|
+
let node = prop.expression;
|
|
2652
|
+
while (ts.isParenthesizedExpression(node))
|
|
2653
|
+
node = node.expression;
|
|
2654
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(node))?.kind !== "union")
|
|
2655
|
+
continue;
|
|
2656
|
+
if (srcNode !== null)
|
|
2657
|
+
return null;
|
|
2658
|
+
spreadIndex = i;
|
|
2659
|
+
srcNode = node;
|
|
2660
|
+
}
|
|
2661
|
+
if (srcNode === null)
|
|
2662
|
+
return null;
|
|
2663
|
+
const site = srcNode;
|
|
2664
|
+
// The source evaluates before the dispatch, so everything written before
|
|
2665
|
+
// it must be free of effects. When the source itself may have effects, an
|
|
2666
|
+
// earlier property may also not read a value they could change: those
|
|
2667
|
+
// properties must be constants.
|
|
2668
|
+
const sourcePure = pureKeyExpr(lowerer, site);
|
|
2669
|
+
for (const prop of props.slice(0, spreadIndex)) {
|
|
2670
|
+
if (sourcePure && ts.isShorthandPropertyAssignment(prop))
|
|
2671
|
+
continue;
|
|
2672
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
2673
|
+
(sourcePure
|
|
2674
|
+
? pureKeyExpr(lowerer, prop.initializer)
|
|
2675
|
+
: constantInitializer(lowerer, prop.initializer)))
|
|
2676
|
+
continue;
|
|
2677
|
+
return null;
|
|
2678
|
+
}
|
|
2679
|
+
const siteType = lowerer.mapTypeOf(lowerer.typeOf(site));
|
|
2680
|
+
if (siteType?.kind !== "union")
|
|
2681
|
+
return null;
|
|
2682
|
+
const siteDef = lowerer.unions.get(siteType.unionId);
|
|
2683
|
+
if (!siteDef || !siteDef.arms.every((arm) => arm.kind === "record" || isUnitType(arm)))
|
|
2684
|
+
return null;
|
|
2685
|
+
const discField = target.discriminant?.field;
|
|
2686
|
+
// The discriminant values the literal's LAST writer of that field gives
|
|
2687
|
+
// this source arm; null when unknown.
|
|
2688
|
+
const discriminantOf = (tag, arm) => {
|
|
2689
|
+
if (discField === undefined)
|
|
2690
|
+
return null;
|
|
2691
|
+
for (let i = props.length - 1; i >= 0; i--) {
|
|
2692
|
+
const prop = props[i];
|
|
2693
|
+
if (i === spreadIndex) {
|
|
2694
|
+
if (arm.kind !== "record")
|
|
2695
|
+
continue;
|
|
2696
|
+
if (!lowerer.shapes.get(arm.shapeId)?.fields.some((f) => f.name === discField))
|
|
2697
|
+
continue;
|
|
2698
|
+
const own = siteDef.discriminant;
|
|
2699
|
+
return own?.field === discField
|
|
2700
|
+
? (own.cases.find((c) => c.tag === tag)?.values ?? null)
|
|
2701
|
+
: null;
|
|
2702
|
+
}
|
|
2703
|
+
if (ts.isSpreadAssignment(prop))
|
|
2704
|
+
return null;
|
|
2705
|
+
if ((ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&
|
|
2706
|
+
propNameText(lowerer, prop.name) === discField)
|
|
2707
|
+
return ts.isPropertyAssignment(prop)
|
|
2708
|
+
? literalValues(lowerer.typeOf(prop.initializer))
|
|
2709
|
+
: literalValues(lowerer.typeOf(prop.name));
|
|
2710
|
+
}
|
|
2711
|
+
return null;
|
|
2712
|
+
};
|
|
2713
|
+
// Every key some contributor may write for this source arm; null when a
|
|
2714
|
+
// contributor has no fixed key set (an index signature, a non-record).
|
|
2715
|
+
const writtenKeys = (arm) => {
|
|
2716
|
+
const names = new Set();
|
|
2717
|
+
for (let i = 0; i < props.length; i++) {
|
|
2718
|
+
const prop = props[i];
|
|
2719
|
+
if (ts.isSpreadAssignment(prop)) {
|
|
2720
|
+
let node = prop.expression;
|
|
2721
|
+
while (ts.isParenthesizedExpression(node))
|
|
2722
|
+
node = node.expression;
|
|
2723
|
+
const t = i === spreadIndex ? arm : lowerer.mapTypeOf(lowerer.typeOf(node));
|
|
2724
|
+
if (t !== null && isUnitType(t))
|
|
2725
|
+
continue;
|
|
2726
|
+
if (t?.kind !== "record")
|
|
2727
|
+
return null;
|
|
2728
|
+
const shape = lowerer.shapes.get(t.shapeId);
|
|
2729
|
+
if (!shape || shape.indexValue || shape.tuple)
|
|
2730
|
+
return null;
|
|
2731
|
+
for (const f of shape.fields)
|
|
2732
|
+
names.add(f.name);
|
|
2733
|
+
}
|
|
2734
|
+
else if (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) {
|
|
2735
|
+
names.add(propNameText(lowerer, prop.name));
|
|
2736
|
+
}
|
|
2737
|
+
else {
|
|
2738
|
+
return null;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
return names;
|
|
2742
|
+
};
|
|
2743
|
+
const destinationOf = (tag, arm) => {
|
|
2744
|
+
const keys = writtenKeys(arm);
|
|
2745
|
+
if (keys === null)
|
|
2746
|
+
return null;
|
|
2747
|
+
let candidates = target.arms
|
|
2748
|
+
.map((a, t) => ({ a, t }))
|
|
2749
|
+
.filter((c) => c.a.kind === "record")
|
|
2750
|
+
.filter((c) => {
|
|
2751
|
+
const fields = lowerer.shapes.get(c.a.shapeId).fields;
|
|
2752
|
+
return [...keys].every((k) => fields.some((f) => f.name === k));
|
|
2753
|
+
});
|
|
2754
|
+
const values = discriminantOf(tag, arm);
|
|
2755
|
+
if (values && values.length > 0 && target.discriminant) {
|
|
2756
|
+
const cases = target.discriminant.cases;
|
|
2757
|
+
candidates = candidates.filter((c) => (cases.find((k) => k.tag === c.t)?.values ?? []).some((v) => values.includes(v)));
|
|
2758
|
+
}
|
|
2759
|
+
if (candidates.length === 1)
|
|
2760
|
+
return candidates[0].a;
|
|
2761
|
+
if (arm.kind === "record") {
|
|
2762
|
+
const same = candidates.find((c) => c.a.shapeId === arm.shapeId);
|
|
2763
|
+
if (same)
|
|
2764
|
+
return same.a;
|
|
2765
|
+
}
|
|
2766
|
+
const exactKeys = candidates.filter((c) => lowerer.shapes.get(c.a.shapeId).fields.length === keys.size);
|
|
2767
|
+
return exactKeys.length === 1 ? exactKeys[0].a : null;
|
|
2768
|
+
};
|
|
2769
|
+
// Plan every arm before lowering anything.
|
|
2770
|
+
const plan = [];
|
|
2771
|
+
for (let tag = 0; tag < siteDef.arms.length; tag++) {
|
|
2772
|
+
const arm = siteDef.arms[tag];
|
|
2773
|
+
const destination = destinationOf(tag, arm);
|
|
2774
|
+
if (destination === null)
|
|
2775
|
+
return null;
|
|
2776
|
+
plan.push({ tag, arm, destination });
|
|
2777
|
+
}
|
|
2778
|
+
const loc = locOf(expr);
|
|
2779
|
+
let source = lowerer.lowerExpr(site);
|
|
2780
|
+
if (source.type.kind === "union" && !typeEquals(source.type, siteType)) {
|
|
2781
|
+
const helper = lowerer.narrowedRetagHelper(site, source.type.unionId, siteType.unionId, source.loc);
|
|
2782
|
+
if (helper)
|
|
2783
|
+
source = { kind: "call", callee: helper, args: [source], type: siteType, loc: source.loc };
|
|
2784
|
+
}
|
|
2785
|
+
if (!typeEquals(source.type, siteType))
|
|
2786
|
+
return null;
|
|
2787
|
+
const saved = lowerer.declareHiddenLocal("%spreadArms", siteType);
|
|
2788
|
+
const ref = varRef(saved.id, siteType, loc);
|
|
2789
|
+
let result = null;
|
|
2790
|
+
for (let i = plan.length - 1; i >= 0; i--) {
|
|
2791
|
+
const { tag, arm, destination } = plan[i];
|
|
2792
|
+
const armValue = arm.kind === "record"
|
|
2793
|
+
? { kind: "unionNarrow", value: ref, unionId: siteType.unionId, tag, type: arm, loc }
|
|
2794
|
+
: {
|
|
2795
|
+
kind: "recordLit",
|
|
2796
|
+
fields: [],
|
|
2797
|
+
type: { kind: "record", shapeId: lowerer.shapes.intern([]) },
|
|
2798
|
+
loc,
|
|
2799
|
+
};
|
|
2800
|
+
lowerer.spreadArmOverrides.set(site, armValue);
|
|
2801
|
+
let built;
|
|
2802
|
+
try {
|
|
2803
|
+
built = lowerObjectLiteral(lowerer, expr, destination, true);
|
|
2804
|
+
}
|
|
2805
|
+
finally {
|
|
2806
|
+
lowerer.spreadArmOverrides.delete(site);
|
|
2807
|
+
}
|
|
2808
|
+
const wrapped = lowerer.coerceToExpected(built, mapped);
|
|
2809
|
+
if (!typeEquals(wrapped.type, mapped))
|
|
2810
|
+
return null;
|
|
2811
|
+
result =
|
|
2812
|
+
result === null
|
|
2813
|
+
? wrapped
|
|
2814
|
+
: {
|
|
2815
|
+
kind: "ternary",
|
|
2816
|
+
cond: {
|
|
2817
|
+
kind: "unionIsTag",
|
|
2818
|
+
value: ref,
|
|
2819
|
+
unionId: siteType.unionId,
|
|
2820
|
+
tag,
|
|
2821
|
+
negated: false,
|
|
2822
|
+
type: BOOL,
|
|
2823
|
+
loc,
|
|
2824
|
+
},
|
|
2825
|
+
then: wrapped,
|
|
2826
|
+
else_: result,
|
|
2827
|
+
type: mapped,
|
|
2828
|
+
loc,
|
|
2829
|
+
};
|
|
2830
|
+
}
|
|
2831
|
+
if (result === null)
|
|
2832
|
+
return null;
|
|
2833
|
+
return {
|
|
2834
|
+
kind: "seqExpr",
|
|
2835
|
+
stmts: [{ kind: "varDecl", localId: saved.id, init: source, loc }],
|
|
2836
|
+
result,
|
|
2837
|
+
type: mapped,
|
|
2838
|
+
loc,
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
/** `{ ...a, ...b }` over union-typed sources that lowerDistributedUnionSpread
|
|
2842
|
+
* declined: no single destination arm holds every key the contributors may
|
|
2843
|
+
* write (`provider-composer`'s two all-optional compat unions, an aggregate
|
|
2844
|
+
* config merged from a http|stdio union plus a patch naming both). Node
|
|
2845
|
+
* builds ONE plain object: each source's own enumerable keys copy in source
|
|
2846
|
+
* order (later writers win), then the explicit fields write in their own
|
|
2847
|
+
* positions. Build exactly that object — the checked-dynamic literal — and
|
|
2848
|
+
* validate it into the declared union at the slot. The value keeps its
|
|
2849
|
+
* runtime keys (reflection, JSON, and inspection see what Node sees); a
|
|
2850
|
+
* value the union cannot hold throws the catchable TypeError at the
|
|
2851
|
+
* conversion instead of being reinterpreted as one arm.
|
|
2852
|
+
*
|
|
2853
|
+
* Null when the shape is not the SC2003 one (no union-typed spread source),
|
|
2854
|
+
* when the build must not demote (inside a capture buffer, or under
|
|
2855
|
+
* `--tier=static-only`, which keeps today's refusal), or when the union has
|
|
2856
|
+
* no checked extraction. The caller then keeps its refusal. */
|
|
2857
|
+
function lowerUnionSpreadMergeDyn(lowerer, expr, target) {
|
|
2858
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
2859
|
+
return null;
|
|
2860
|
+
const spreadsUnion = expr.properties.nodes.some((prop) => {
|
|
2861
|
+
if (!ts.isSpreadAssignment(prop))
|
|
2862
|
+
return false;
|
|
2863
|
+
let node = prop.expression;
|
|
2864
|
+
while (ts.isParenthesizedExpression(node))
|
|
2865
|
+
node = node.expression;
|
|
2866
|
+
return lowerer.mapTypeOf(lowerer.typeOf(node))?.kind === "union";
|
|
2867
|
+
});
|
|
2868
|
+
if (!spreadsUnion)
|
|
2869
|
+
return null;
|
|
2870
|
+
if (lowerer.tierMode !== "auto" || lowerer.diagSink !== null)
|
|
2871
|
+
return null;
|
|
2872
|
+
if (!canDynCheckTo(target, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
2873
|
+
return null;
|
|
2874
|
+
return lowerer.coerceToExpected(lowerDynObjectLiteral(lowerer, expr), target);
|
|
2875
|
+
}
|
|
2345
2876
|
/** A union of plain records can preserve its existing variant while
|
|
2346
2877
|
* replacing shared fields. Dispatch before constructing the copy: only
|
|
2347
2878
|
* the selected arm evaluates overrides, and recordClone snapshots fields
|
|
@@ -2446,6 +2977,15 @@ function lowerUnionRecordClone(lowerer, expr) {
|
|
|
2446
2977
|
};
|
|
2447
2978
|
}
|
|
2448
2979
|
}
|
|
2980
|
+
// Any other source (a capture, a runtime-optional binding, a member
|
|
2981
|
+
// read) converts through the same checked re-tag: the arms the site's
|
|
2982
|
+
// checker type excludes, a hidden absence arm included, throw the
|
|
2983
|
+
// catchable TypeError instead of being cloned.
|
|
2984
|
+
if (!typeEquals(source.type, sourceType) && source.type.kind === "union") {
|
|
2985
|
+
const helper = lowerer.narrowedRetagHelper(spread.expression, source.type.unionId, sourceType.unionId, source.loc);
|
|
2986
|
+
if (helper)
|
|
2987
|
+
source = { kind: "call", callee: helper, args: [source], type: sourceType, loc: source.loc };
|
|
2988
|
+
}
|
|
2449
2989
|
if (!typeEquals(source.type, sourceType)) {
|
|
2450
2990
|
lowerer.unsupported("SC1090", spread, "a union record clone whose stored source still includes absence");
|
|
2451
2991
|
}
|
|
@@ -2632,15 +3172,50 @@ function lowerConditionalRecordSpread(lowerer, spread, loc) {
|
|
|
2632
3172
|
loc,
|
|
2633
3173
|
};
|
|
2634
3174
|
}
|
|
3175
|
+
/** A spread's source expression with parentheses stripped, seeing through
|
|
3176
|
+
* an empty-object default: `...(x ?? {})` and `...(x || {})` spread exactly
|
|
3177
|
+
* what `...x` spreads (a nullish or other falsy value is a primitive with
|
|
3178
|
+
* no own keys, and x evaluates once either way). Only where `x` is a plain
|
|
3179
|
+
* record or a record-or-unit union, which the field copy and the
|
|
3180
|
+
* optional-spread desugar handle; index-signature and other sources keep
|
|
3181
|
+
* their paths. */
|
|
3182
|
+
function spreadSourceNode(lowerer, expr) {
|
|
3183
|
+
let e = expr;
|
|
3184
|
+
while (ts.isParenthesizedExpression(e))
|
|
3185
|
+
e = e.expression;
|
|
3186
|
+
if (!ts.isBinaryExpression(e) ||
|
|
3187
|
+
(e.operatorToken.kind !== ts.SyntaxKind.QuestionQuestionToken &&
|
|
3188
|
+
e.operatorToken.kind !== ts.SyntaxKind.BarBarToken))
|
|
3189
|
+
return e;
|
|
3190
|
+
let right = e.right;
|
|
3191
|
+
while (ts.isParenthesizedExpression(right))
|
|
3192
|
+
right = right.expression;
|
|
3193
|
+
if (!ts.isObjectLiteralExpression(right) || right.properties.nodes.length !== 0)
|
|
3194
|
+
return e;
|
|
3195
|
+
let left = e.left;
|
|
3196
|
+
while (ts.isParenthesizedExpression(left))
|
|
3197
|
+
left = left.expression;
|
|
3198
|
+
const plainRecord = (t) => t?.kind === "record" && lowerer.shapes.get(t.shapeId)?.indexValue === undefined;
|
|
3199
|
+
const source = lowerer.mapTypeOf(lowerer.typeOf(left));
|
|
3200
|
+
if (plainRecord(source ?? undefined))
|
|
3201
|
+
return left;
|
|
3202
|
+
if (source?.kind === "union") {
|
|
3203
|
+
const arms = lowerer.unions.get(source.unionId)?.arms ?? [];
|
|
3204
|
+
const records = arms.filter((arm) => arm.kind === "record");
|
|
3205
|
+
if (records.length === 1 &&
|
|
3206
|
+
plainRecord(records[0]) &&
|
|
3207
|
+
arms.every((arm) => arm.kind === "record" || isUnitType(arm)))
|
|
3208
|
+
return left;
|
|
3209
|
+
}
|
|
3210
|
+
return e;
|
|
3211
|
+
}
|
|
2635
3212
|
/** A spread source the record desugar cannot enumerate: an untyped
|
|
2636
3213
|
* (`unknown`) value, or one whose shape carries an index signature
|
|
2637
3214
|
* (`Record<string, unknown>`, `{ [key: string]: T }`) so its keys are
|
|
2638
3215
|
* runtime state. Node copies own enumerable keys in insertion order, which
|
|
2639
3216
|
* the checked-dynamic object reproduces. */
|
|
2640
3217
|
function dynSpreadSource(lowerer, node) {
|
|
2641
|
-
|
|
2642
|
-
while (ts.isParenthesizedExpression(e))
|
|
2643
|
-
e = e.expression;
|
|
3218
|
+
const e = spreadSourceNode(lowerer, node);
|
|
2644
3219
|
if ((lowerer.typeOf(e).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
|
|
2645
3220
|
return true;
|
|
2646
3221
|
const indexed = (t) => {
|
|
@@ -2681,6 +3256,53 @@ function dynSpreadLiteral(lowerer, expr, type, conditional = false) {
|
|
|
2681
3256
|
// complete.
|
|
2682
3257
|
return lowerer.coerceToExpected(lowerDynObjectLiteral(lowerer, expr, undefined, true), type);
|
|
2683
3258
|
}
|
|
3259
|
+
/** The PURE index-signature record `candidate` names — every key an overflow
|
|
3260
|
+
* entry, no declared field, no tuple — when a checked-dynamic value converts
|
|
3261
|
+
* into it. Null for any other type. */
|
|
3262
|
+
function indexSignatureDestination(lowerer, candidate) {
|
|
3263
|
+
if (candidate?.kind !== "record")
|
|
3264
|
+
return null;
|
|
3265
|
+
const shape = lowerer.shapes.get(candidate.shapeId);
|
|
3266
|
+
if (!shape || shape.tuple || shape.fields.length > 0 || !shape.indexValue)
|
|
3267
|
+
return null;
|
|
3268
|
+
return canDynCheckTo(candidate, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))
|
|
3269
|
+
? candidate
|
|
3270
|
+
: null;
|
|
3271
|
+
}
|
|
3272
|
+
/** `expr` — a literal whose property name is decided at runtime — as the
|
|
3273
|
+
* checked-dynamic object the literal's own keys describe. No record shape can
|
|
3274
|
+
* hold a runtime-decided name: a record stores declared fields sorted and
|
|
3275
|
+
* overflow entries apart, while Node writes the key where it stands
|
|
3276
|
+
* (`{ [k]: 2, n: 1 }` enumerates `k` first), and TypeScript itself drops a
|
|
3277
|
+
* union-keyed computed property from the literal's inferred type once a
|
|
3278
|
+
* spread joins the literal while the evaluated object keeps the key. The
|
|
3279
|
+
* destination's conversion checks the values afterwards (the same
|
|
3280
|
+
* copy-then-check `dynSpreadLiteral` applies to a runtime-keyed source).
|
|
3281
|
+
* A pure index-signature destination is the value's real home, so coerce
|
|
3282
|
+
* into it directly; a destination with declared fields is left to the
|
|
3283
|
+
* caller's own conversion. */
|
|
3284
|
+
function runtimeKeyedDynLiteral(lowerer, expr, prop, type, expected) {
|
|
3285
|
+
const destination = indexSignatureDestination(lowerer, expected) ?? indexSignatureDestination(lowerer, type);
|
|
3286
|
+
if (destination === null) {
|
|
3287
|
+
// A layout that keeps DECLARED fields beside an index signature
|
|
3288
|
+
// (`{ fixed: 1, [key]: 2 }`, inferred as `{ fixed: number; [x: string]:
|
|
3289
|
+
// number }`) stores the declared fields ahead of the overflow a runtime
|
|
3290
|
+
// key lands in, so the value would print them first instead of where
|
|
3291
|
+
// Node writes them. Nothing in that layout can carry the order, so the
|
|
3292
|
+
// form keeps its refusal.
|
|
3293
|
+
const mixedLayout = [expected, type].some((candidate) => {
|
|
3294
|
+
if (candidate?.kind !== "record")
|
|
3295
|
+
return false;
|
|
3296
|
+
const shape = lowerer.shapes.get(candidate.shapeId);
|
|
3297
|
+
return shape !== undefined && !shape.tuple && shape.fields.length > 0 && !!shape.indexValue;
|
|
3298
|
+
});
|
|
3299
|
+
if (mixedLayout) {
|
|
3300
|
+
lowerer.unsupported("SC1090", prop.name ?? prop, "computed property keys (compile-time-known keys fold — a pure expression whose checker type is one string or number literal: consts, enum members, quoted keys, templates of those — `{ [MARKER]: v }`; runtime string keys write through an index-signature target; symbol keys stay out)");
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
const dyn = lowerDynObjectLiteral(lowerer, expr, undefined, true);
|
|
3304
|
+
return destination === null ? dyn : lowerer.coerceToExpected(dyn, destination);
|
|
3305
|
+
}
|
|
2684
3306
|
/** A conditional spread source in a checked-dynamic literal, as the dyn
|
|
2685
3307
|
* value whose own keys the copy reads. The whole ternary lowers arm by arm
|
|
2686
3308
|
* (`c && {...}` is `c ? {...} : undefined` — a primitive contributes no
|
|
@@ -2770,6 +3392,28 @@ export function conditionalSpreadOf(expr) {
|
|
|
2770
3392
|
}
|
|
2771
3393
|
return { cond: e.condition, props, whenTrue: trueCarries };
|
|
2772
3394
|
}
|
|
3395
|
+
/** The record arms of a union spread source of the declared-shape merge,
|
|
3396
|
+
* or null unless every arm is a non-tuple record or the null/undefined
|
|
3397
|
+
* unit and at least one arm is a record. Unit arms contribute nothing:
|
|
3398
|
+
* CopyDataProperties skips nullish sources. */
|
|
3399
|
+
function declaredMergeUnionArms(lowerer, unionId) {
|
|
3400
|
+
const def = lowerer.unions.get(unionId);
|
|
3401
|
+
if (!def)
|
|
3402
|
+
return null;
|
|
3403
|
+
const arms = [];
|
|
3404
|
+
for (let tag = 0; tag < def.arms.length; tag++) {
|
|
3405
|
+
const arm = def.arms[tag];
|
|
3406
|
+
if (arm.kind === "undefinedT" || arm.kind === "nullT")
|
|
3407
|
+
continue;
|
|
3408
|
+
if (arm.kind !== "record")
|
|
3409
|
+
return null;
|
|
3410
|
+
const armShape = lowerer.shapes.get(arm.shapeId);
|
|
3411
|
+
if (!armShape || armShape.tuple)
|
|
3412
|
+
return null;
|
|
3413
|
+
arms.push({ tag, shapeId: arm.shapeId, shape: armShape });
|
|
3414
|
+
}
|
|
3415
|
+
return arms.length > 0 ? arms : null;
|
|
3416
|
+
}
|
|
2773
3417
|
/** `{ ...idx, ...idx2 }` typed a DECLARED shape (no index signature) — the
|
|
2774
3418
|
* defaults-merge idiom over runtime-keyed sources (`{ ...fromEntries(a),
|
|
2775
3419
|
* ...fromEntries(b) }` typed AppConfig). Lowers to ONE interned helper
|
|
@@ -2785,7 +3429,12 @@ export function conditionalSpreadOf(expr) {
|
|
|
2785
3429
|
* untyped copy would store the lie) — and a key naming NO declared field
|
|
2786
3430
|
* is DROPPED (the shape cannot represent it; Node keeps it invisibly —
|
|
2787
3431
|
* divergence 68). Later contributors overwrite earlier ones
|
|
2788
|
-
* (last-write-wins). Fixed, hybrid, and pure index records may contribute
|
|
3432
|
+
* (last-write-wins). Fixed, hybrid, and pure index records may contribute,
|
|
3433
|
+
* and so may a union of those records with the null/undefined unit: each
|
|
3434
|
+
* record arm copies through its own shape's helper behind its tag test,
|
|
3435
|
+
* a unit arm copies nothing (CopyDataProperties skips nullish sources),
|
|
3436
|
+
* and the union is held in a hidden local, so it still evaluates once, in
|
|
3437
|
+
* order. */
|
|
2789
3438
|
function lowerDeclaredSpreadMerge(lowerer, expr, type, shape, loc) {
|
|
2790
3439
|
const srcs = [];
|
|
2791
3440
|
for (const prop of expr.properties.nodes) {
|
|
@@ -2795,6 +3444,15 @@ function lowerDeclaredSpreadMerge(lowerer, expr, type, shape, loc) {
|
|
|
2795
3444
|
srcs.push({ value, shapeId: "dyn" });
|
|
2796
3445
|
continue;
|
|
2797
3446
|
}
|
|
3447
|
+
if (value.type.kind === "union") {
|
|
3448
|
+
const arms = declaredMergeUnionArms(lowerer, value.type.unionId);
|
|
3449
|
+
if (arms) {
|
|
3450
|
+
for (const arm of arms)
|
|
3451
|
+
fenceAccessorSpreadSource(lowerer, prop, arm.shape);
|
|
3452
|
+
srcs.push({ value, shapeId: "union", arms });
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
2798
3456
|
const srcShape = value.type.kind === "record" ? lowerer.shapes.get(value.type.shapeId) : undefined;
|
|
2799
3457
|
if (value.type.kind !== "record" || !srcShape || srcShape.tuple) {
|
|
2800
3458
|
lowerer.unsupported("SC1090", prop, `object spread of '${lowerer.fmt(value.type)}' into '${lowerer.fmt(type)}' (only records spread into a declared shape)`);
|
|
@@ -2932,12 +3590,11 @@ function lowerDeclaredSpreadMerge(lowerer, expr, type, shape, loc) {
|
|
|
2932
3590
|
loc,
|
|
2933
3591
|
},
|
|
2934
3592
|
];
|
|
2935
|
-
|
|
3593
|
+
const mergeHelper = (source, sourceType) => {
|
|
2936
3594
|
const key = `declmerge-source:${type.shapeId}:${source.shapeId}`;
|
|
2937
3595
|
let helper = lowerer.valueHelpers.get(key);
|
|
2938
3596
|
if (!helper) {
|
|
2939
3597
|
helper = keyedHelperName(lowerer, "%rec.declmerge", key);
|
|
2940
|
-
const sourceType = source.value.type;
|
|
2941
3598
|
const destination = varRef("out.0", type, loc);
|
|
2942
3599
|
const receiver = varRef("source.0", sourceType, loc);
|
|
2943
3600
|
const locals = [
|
|
@@ -3112,6 +3769,59 @@ function lowerDeclaredSpreadMerge(lowerer, expr, type, shape, loc) {
|
|
|
3112
3769
|
// leave an entry that a later literal could reuse without a body.
|
|
3113
3770
|
lowerer.valueHelpers.set(key, helper);
|
|
3114
3771
|
}
|
|
3772
|
+
return helper;
|
|
3773
|
+
};
|
|
3774
|
+
for (const source of srcs) {
|
|
3775
|
+
if (source.arms && source.value.type.kind === "union") {
|
|
3776
|
+
// Evaluate the union once, then copy the running arm's own keys.
|
|
3777
|
+
const unionType = source.value.type;
|
|
3778
|
+
const held = lowerer.declareHiddenLocal("%declMergeSource", unionType);
|
|
3779
|
+
const heldRef = varRef(held.id, unionType, loc);
|
|
3780
|
+
stmts.push({ kind: "varDecl", localId: held.id, init: source.value, loc });
|
|
3781
|
+
for (const arm of source.arms) {
|
|
3782
|
+
const armType = { kind: "record", shapeId: arm.shapeId };
|
|
3783
|
+
const helper = mergeHelper({ value: heldRef, shapeId: arm.shapeId, shape: arm.shape }, armType);
|
|
3784
|
+
stmts.push({
|
|
3785
|
+
kind: "if",
|
|
3786
|
+
cond: {
|
|
3787
|
+
kind: "unionIsTag",
|
|
3788
|
+
unionId: unionType.unionId,
|
|
3789
|
+
tag: arm.tag,
|
|
3790
|
+
negated: false,
|
|
3791
|
+
value: heldRef,
|
|
3792
|
+
type: BOOL,
|
|
3793
|
+
loc,
|
|
3794
|
+
},
|
|
3795
|
+
then: [
|
|
3796
|
+
{
|
|
3797
|
+
kind: "exprStmt",
|
|
3798
|
+
expr: {
|
|
3799
|
+
kind: "call",
|
|
3800
|
+
callee: helper,
|
|
3801
|
+
args: [
|
|
3802
|
+
outRef,
|
|
3803
|
+
{
|
|
3804
|
+
kind: "unionNarrow",
|
|
3805
|
+
unionId: unionType.unionId,
|
|
3806
|
+
tag: arm.tag,
|
|
3807
|
+
value: heldRef,
|
|
3808
|
+
type: armType,
|
|
3809
|
+
loc,
|
|
3810
|
+
},
|
|
3811
|
+
],
|
|
3812
|
+
type,
|
|
3813
|
+
loc,
|
|
3814
|
+
},
|
|
3815
|
+
loc,
|
|
3816
|
+
},
|
|
3817
|
+
],
|
|
3818
|
+
else_: null,
|
|
3819
|
+
loc,
|
|
3820
|
+
});
|
|
3821
|
+
}
|
|
3822
|
+
continue;
|
|
3823
|
+
}
|
|
3824
|
+
const helper = mergeHelper(source, source.value.type);
|
|
3115
3825
|
stmts.push({
|
|
3116
3826
|
kind: "exprStmt",
|
|
3117
3827
|
expr: { kind: "call", callee: helper, args: [outRef, source.value], type, loc },
|
|
@@ -3134,7 +3844,8 @@ function shorthandBuiltinValue(lowerer, prop) {
|
|
|
3134
3844
|
const js = isJsSourceFile(ts.getSourceFileOfNode(prop));
|
|
3135
3845
|
const name = ts.symbolName(symbol);
|
|
3136
3846
|
return ((js ? builtinNamespaceValue(lowerer, name, locOf(prop.name)) : null) ??
|
|
3137
|
-
builtinGlobalValue(name, locOf(prop.name), js)
|
|
3847
|
+
builtinGlobalValue(name, locOf(prop.name), js) ??
|
|
3848
|
+
tsUntypedGlobalValue(lowerer, prop.name, name, locOf(prop.name)));
|
|
3138
3849
|
}
|
|
3139
3850
|
export function lowerShorthandValue(lowerer, prop) {
|
|
3140
3851
|
// 7 types the shorthand's name as PropertyName; it is always an
|