@scriptc/compiler 0.2.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +2 -36
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.test.js +1 -1
- package/dist/backend/cycle-mutability.d.ts +1 -1
- package/dist/backend/cycle-mutability.js +1 -18
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +3 -8
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +1 -1
- package/dist/backend/immutability.js +1 -1
- package/dist/backend/immutability.test.js +1 -1
- package/dist/backend/library-pack.js +0 -2
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/classes.js +3 -9
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +7 -7
- package/dist/backend/llvm/constant-callbacks.d.ts +1 -1
- package/dist/backend/llvm/constant-callbacks.js +3 -3
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +1 -1
- package/dist/backend/llvm/dyn.d.ts +0 -1
- package/dist/backend/llvm/dyn.js +0 -73
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +3 -17
- package/dist/backend/llvm/emitter.js +53 -181
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +3 -3
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-containers.js +12 -8
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +4 -107
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -2
- package/dist/backend/llvm/expr-dispatch.js +0 -41
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +1 -1
- package/dist/backend/llvm/expr-dynamic.js +13 -27
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +2 -2
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/lib-dispatch.js +0 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +0 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +0 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +7 -0
- package/dist/backend/llvm/map-number-lookup.js +16 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.js +7 -1
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +24 -7
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/shapes.js +1 -2
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -3
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +1 -1
- package/dist/backend/may-throw.js +0 -9
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +1 -1
- package/dist/backend/native/artifact-stamps.js +0 -2
- package/dist/backend/native/artifact-stamps.js.map +1 -1
- package/dist/backend/native/cache-warm.d.ts +1 -1
- package/dist/backend/native/cache-warm.js +2 -3
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +1 -1
- package/dist/backend/native/compiler-fingerprint.js +4 -7
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +3 -28
- package/dist/backend/native/driver.js +1 -3
- package/dist/backend/native/driver.js.map +1 -1
- package/dist/backend/native/executable.d.ts +0 -15
- package/dist/backend/native/executable.js +17 -172
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/tool-identity.js +0 -1
- package/dist/backend/native/tool-identity.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-link-info-core.d.ts +0 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +23 -33
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/publication.test.js +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 +1 -2
- package/dist/backend/runtime-pack-core.js +5 -14
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -8
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +22 -19
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +0 -5
- package/dist/backend/target-diagnostics.js +1 -11
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -7
- package/dist/backend/vendor-archives.js +9 -189
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +0 -1
- package/dist/backend/vendor-inputs.js +0 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -5
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +4 -8
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +1 -1
- package/dist/cli/usage.d.ts +1 -5
- package/dist/cli/usage.js +4 -9
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +2 -2
- package/dist/compat/fetch-profile.js +16 -25
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +2 -17
- package/dist/contracts/check.js +2 -6
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.d.ts +5 -22
- package/dist/coverage/report.js +12 -76
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +3 -3
- package/dist/coverage/surface-manifest.js +22 -27
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -3
- package/dist/coverage/verdict-cache.js +2 -7
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -60
- package/dist/diagnostics/diagnostic.js +39 -118
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -4
- package/dist/diagnostics/envelope.js +0 -9
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +0 -3
- package/dist/executable/executable-cache.js +2 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +0 -4
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +5 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +10 -10
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +0 -88
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/dts-paths.d.ts +1 -1
- package/dist/frontend/dts-paths.js +1 -1
- package/dist/frontend/lowering/abstract-equality.js +1 -4
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +4 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.js +0 -13
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +0 -4
- package/dist/frontend/lowering/builtins/crypto.js +0 -4
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +1 -39
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +0 -15
- package/dist/frontend/lowering/builtins/module-resolution.js +5 -44
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +0 -6
- package/dist/frontend/lowering/builtins/numbers.js +6 -57
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +4 -67
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +1 -1
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +1 -37
- package/dist/frontend/lowering/call-arguments.js +11 -94
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +1 -6
- package/dist/frontend/lowering/call-signatures.js +16 -68
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +19 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.js +168 -98
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +44 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +0 -2
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +1 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +5 -35
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +0 -1
- package/dist/frontend/lowering/coercions/state.js +0 -1
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -4
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +2 -12
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.js +0 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +9 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +2 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +10 -54
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +0 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +2 -10
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +1 -6
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +0 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +0 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +2 -10
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +0 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +0 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -8
- package/dist/frontend/lowering/expressions/object-literals.js +8 -35
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +0 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +3 -66
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +0 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +0 -1
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +10 -77
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +1 -10
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +2 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +2 -27
- package/dist/frontend/lowering/lower-calls.js +47 -463
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +11 -49
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js +2 -3
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -8
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +3 -4
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +3 -5
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -8
- package/dist/frontend/lowering/lower-exprs.js +50 -907
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -5
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +1 -50
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +0 -43
- package/dist/frontend/lowering/lower-modules.js +25 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +5 -5
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +0 -30
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +98 -0
- package/dist/frontend/lowering/{lower-island.js → lower-stdlib.js} +97 -1160
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +0 -16
- package/dist/frontend/lowering/lower-stmts.js +58 -1016
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -3
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +17 -151
- package/dist/frontend/lowering/lowerer.js +73 -770
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +4 -51
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.js +1 -1
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/strict-equality.js +1 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -45
- package/dist/frontend/lowering/surfaces.js +5 -65
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +0 -3
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-node.d.ts +0 -7
- package/dist/frontend/npm-node.js +0 -7
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +6 -82
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +1 -1
- package/dist/frontend/npm-static.js +6 -71
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +3 -319
- package/dist/frontend/npm.js +6 -1007
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -197
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js +1 -2
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +3 -11
- package/dist/frontend/pipeline.js +37 -56
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +12 -6
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +0 -34
- package/dist/frontend/program.js +12 -97
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +0 -4
- package/dist/frontend/provenance-core.js +4 -37
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -4
- package/dist/frontend/provenance-registry.js +0 -20
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.d.ts +0 -12
- package/dist/frontend/resolve.js +0 -34
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +2 -2
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/services-node.js +2 -3
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services.d.ts +1 -8
- package/dist/frontend/services.js +2 -22
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +0 -38
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +0 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +2 -27
- package/dist/frontend/type-mapper.js +42 -153
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- 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/builtin-effects.js +0 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +1 -55
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +3 -3
- package/dist/ir/int32-slots.js +5 -19
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/ir.d.ts +12 -284
- package/dist/ir/ir.js +10 -259
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -7
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -30
- package/dist/ir/runtime-features.js +5 -41
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +3 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +0 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.test.js +1 -1
- package/dist/ir/validate.js +9 -207
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +6 -6
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/prepare.js +5 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +0 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.test.js +2 -4
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -4
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +2 -16
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +0 -3
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.js +0 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +80 -88
- package/dist/backend/llvm/expr-island.d.ts +0 -15
- package/dist/backend/llvm/expr-island.js +0 -709
- package/dist/backend/llvm/expr-island.js.map +0 -1
- package/dist/frontend/lowering/coercions/island.d.ts +0 -37
- package/dist/frontend/lowering/coercions/island.js +0 -350
- package/dist/frontend/lowering/coercions/island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.d.ts +0 -229
- package/dist/frontend/lowering/lower-island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.test.d.ts +0 -1
- package/dist/frontend/lowering/lower-island.test.js +0 -56
- package/dist/frontend/lowering/lower-island.test.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.d.ts +0 -17
- package/dist/frontend/npm-fetch-analysis.js +0 -109
- package/dist/frontend/npm-fetch-analysis.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.test.d.ts +0 -1
- package/dist/frontend/npm-fetch-analysis.test.js +0 -130
- package/dist/frontend/npm-fetch-analysis.test.js.map +0 -1
- package/dist/frontend/npm-fetch-node.d.ts +0 -2
- package/dist/frontend/npm-fetch-node.js +0 -12
- package/dist/frontend/npm-fetch-node.js.map +0 -1
- package/dist/frontend/npm-fetch-syntax.d.ts +0 -6
- package/dist/frontend/npm-fetch-syntax.js +0 -202
- package/dist/frontend/npm-fetch-syntax.js.map +0 -1
- package/dist/native/runtime-typescript.d.ts +0 -4
- package/dist/native/runtime-typescript.js +0 -74
- package/dist/native/runtime-typescript.js.map +0 -1
- package/dist/native/runtime-typescript.test.d.ts +0 -1
- package/dist/native/runtime-typescript.test.js +0 -41
- package/dist/native/runtime-typescript.test.js.map +0 -1
|
@@ -14,9 +14,8 @@ import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocke
|
|
|
14
14
|
import { widthCoerce, applyWidthLift, unionRecordWidthHelper, recordWidthHelper, tupleArrayWidthHelper, emptyArrayLiftHelper, arrayWidthHelper, objRecordWidthHelper, recordClassWidthHelper, classStaticsProjection, } from "./coercions/structural.js";
|
|
15
15
|
import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
|
|
16
16
|
import { unionRetagMappable, narrowedRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
|
|
17
|
-
import { jsvalLiftable, jsvalLiftExpr, unionToJsvalHelper, recordToJsvalHelper, arrayToJsvalHelper, arrayToJsvalArrayHelper, } from "./coercions/island.js";
|
|
18
17
|
import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
|
|
19
|
-
import {
|
|
18
|
+
import { transformStmtList } from "../../ir/traverse.js";
|
|
20
19
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
21
20
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
22
21
|
import { NarrowingStability } from "./narrowing-stability.js";
|
|
@@ -57,12 +56,12 @@ import { tsgoPath } from "../dts-paths.js";
|
|
|
57
56
|
import * as ts from "../ts7/adapter.js";
|
|
58
57
|
import { literalValues } from "../literal-values.js";
|
|
59
58
|
import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
|
|
60
|
-
import {
|
|
61
|
-
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn,
|
|
59
|
+
import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
|
|
60
|
+
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
62
61
|
import { provenanceActive } from "../provenance-registry.js";
|
|
63
62
|
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
64
|
-
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType,
|
|
65
|
-
import {
|
|
63
|
+
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
64
|
+
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
66
65
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
67
66
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
68
67
|
import { registerBuiltinErrorClasses, registerBuiltinEmitterClass, registerBuiltinStreamClasses, builtinErrorInfoOf, builtinEmitterInfoOf, builtinStreamInfoOf, analyzeClassDecoration, classIteratorDrainCall, classIteratorNextCall, classIteratorOf, classIteratorOpenCall, classIteratorRestDrainCall, classMemberNameOf, classValueRef, collectClassShape, exactClassOfReceiver, collectClassShapeInner, ctorAbiEquals, findMethodOn, findStaticOn, genericClassInstanceType, isSubclassOf, inHierarchy, overrideBelow, staticShadowBelow, upcastTo, lowerClassMembers, lowerClassCtor, lowerClassExpression, lowerClassExpressionInfo, lowerClassMethodMember, lowerClassValueProperty, lowerStaticMethod, throwingSetterFn, fieldInitStmts, lowerStaticFieldInits, lowerStaticFieldRead, lowerDerivedCtorBody, superCallStmt, lowerSuperMethodCall, superThisRef, lowerSuperAccessorRead, lowerSuperAccessorWrite, inheritsBuiltinErrorCtor, inheritsBuiltinEmitterCtor, errorConstructorArgs, lowerNew, accessorCall, } from "./lower-classes.js";
|
|
@@ -83,7 +82,7 @@ import { lowerEnvToPairsHelper } from "./containers/indexed-objects.js";
|
|
|
83
82
|
import { lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew } from "./containers/bytes.js";
|
|
84
83
|
import { lowerRegexMethodCall, lowerStringMethodCall } from "./containers/string-and-regexp.js";
|
|
85
84
|
import { lowerEmitOverrideSpec, } from "./lower-event-emitter.js";
|
|
86
|
-
import { builtinImportOf,
|
|
85
|
+
import { builtinImportOf, createRequireProgramModuleOf, createRequireSpecOf, fencedBuiltinImportOf, } from "./builtins/module-bindings.js";
|
|
87
86
|
import { stripTypeCasts } from "./builtins/arguments.js";
|
|
88
87
|
import { lowerBuiltinModuleCall } from "./builtins/module-calls.js";
|
|
89
88
|
import { lowerTimersPromisesSetInterval, lowerTimeoutMethodCall } from "./builtins/timers.js";
|
|
@@ -110,7 +109,7 @@ import { lowerDateCall } from "./builtins/dates.js";
|
|
|
110
109
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
111
110
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
112
111
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
113
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember,
|
|
112
|
+
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
114
113
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
115
114
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
116
115
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -118,7 +117,7 @@ import { lowerAssertModuleCall, lowerAssertDirectCall } from "./lower-assert.js"
|
|
|
118
117
|
import { lowerUtilModuleCall } from "./lower-inspect.js";
|
|
119
118
|
import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
|
|
120
119
|
import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
|
|
121
|
-
import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern,
|
|
120
|
+
import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, } from "./lower-stmts.js";
|
|
122
121
|
import { lowerExpr, maybeNarrow, lowerUnitComparison, lowerNullishCoalesce, lowerCondition, ensureBool, requireTruthyUnion, eqComparableUnion, lowerIntrinsicProperty, lowerArrayLiteral, lowerElementAccess, lowerElementWrite, lowerRecordKeyRead, ensureString, lowerTemplate, lowerAsExpression, lowerPrefixUnary, lowerBinary, lowerCaughtTypeofTest, caughtRead, caughtLocalOf, caughtToString, lowerInstanceOf, lowerRegexLiteral, lowerFieldRead, lowerUnionProperty, fieldTarget, fieldGetExpr, fieldSetStmt, lowerFieldCompound, uniqueSymbolKeyOf, } from "./lower-exprs.js";
|
|
123
122
|
import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
|
|
124
123
|
import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
|
|
@@ -139,35 +138,6 @@ export class PoisonError extends Error {
|
|
|
139
138
|
export function own(table, key) {
|
|
140
139
|
return Object.hasOwn(table, key) ? table[key] : undefined;
|
|
141
140
|
}
|
|
142
|
-
/** IrStmt discriminants — the island walk below must not descend into
|
|
143
|
-
* NESTED statements (each is counted individually by its own lowerStmts
|
|
144
|
-
* visit; descending would attribute a nested island statement to every
|
|
145
|
-
* enclosing construct too). The top-level statement object itself is
|
|
146
|
-
* always visited. */
|
|
147
|
-
const IR_STMT_KINDS = new Set([
|
|
148
|
-
"varDecl",
|
|
149
|
-
"assign",
|
|
150
|
-
"exprStmt",
|
|
151
|
-
"if",
|
|
152
|
-
"while",
|
|
153
|
-
"doWhile",
|
|
154
|
-
"switch",
|
|
155
|
-
"arraySet",
|
|
156
|
-
"arraySetLength",
|
|
157
|
-
"arraySetUndefined",
|
|
158
|
-
"arrayDelete",
|
|
159
|
-
"forOf",
|
|
160
|
-
"return",
|
|
161
|
-
"fieldSet",
|
|
162
|
-
"recordSet",
|
|
163
|
-
"break",
|
|
164
|
-
"continue",
|
|
165
|
-
"block",
|
|
166
|
-
"tryCatch",
|
|
167
|
-
"throw",
|
|
168
|
-
"rethrow",
|
|
169
|
-
"runtimeFence",
|
|
170
|
-
]);
|
|
171
141
|
/** Every identifier a binding name binds: the identifier itself, or all
|
|
172
142
|
* identifiers of a (possibly nested) destructuring pattern in source
|
|
173
143
|
* order. */
|
|
@@ -184,28 +154,6 @@ export function boundIdentifiersOf(name) {
|
|
|
184
154
|
}
|
|
185
155
|
return out;
|
|
186
156
|
}
|
|
187
|
-
/** Inspect executable children directly, without boxing the statement tree
|
|
188
|
-
* into checked-dynamic storage just to calculate coverage. */
|
|
189
|
-
export function stmtUsesIsland(stmts) {
|
|
190
|
-
// Keep the accounting boundary at the source statement: nested statement
|
|
191
|
-
// lists are counted by their own lowerStmts invocation.
|
|
192
|
-
const nested = (stmt) => IR_STMT_KINDS.has(stmt.kind) || everyStmtChild(stmt, expr, nested);
|
|
193
|
-
const expr = (node) => {
|
|
194
|
-
if (node.kind === "jsOp" ||
|
|
195
|
-
node.kind === "jsExit" ||
|
|
196
|
-
node.kind === "jsBridgePromise" ||
|
|
197
|
-
(node.kind === "libCall" &&
|
|
198
|
-
(node.fn === "island.eval" ||
|
|
199
|
-
node.fn === "island.import" ||
|
|
200
|
-
node.fn === "island.importDyn" ||
|
|
201
|
-
node.fn === "island.castFail")))
|
|
202
|
-
return false;
|
|
203
|
-
return everyExprChild(node, expr, nested);
|
|
204
|
-
};
|
|
205
|
-
if (Array.isArray(stmts))
|
|
206
|
-
return !stmts.every((stmt) => everyStmtChild(stmt, expr, nested));
|
|
207
|
-
return !everyStmtChild(stmts, expr, nested);
|
|
208
|
-
}
|
|
209
157
|
/** Statements a never-lowered body would have contributed to the coverage
|
|
210
158
|
* totals: every element of a statement list (blocks, case clauses), plus
|
|
211
159
|
* the single-statement bodies of control flow, nested functions included —
|
|
@@ -286,13 +234,12 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
286
234
|
process.stderr.write(`scriptc lowering ${JSON.stringify(event)}\n`);
|
|
287
235
|
phaseLast = now;
|
|
288
236
|
};
|
|
289
|
-
const dynamic = options.dynamic ?? false;
|
|
290
237
|
const targetPlatform = options.targetPlatform ?? process.platform;
|
|
291
238
|
const startupCrash = options.startupCrash ?? null;
|
|
292
239
|
// Modules reachable only through literal import() of the program's own
|
|
293
240
|
// files join the compiled graph here, ONCE, before any
|
|
294
241
|
// pass constructs (nothing calls their %init at startup — the import()
|
|
295
|
-
// site's namespace builder does, on the
|
|
242
|
+
// site's namespace builder does, on the native microtask, Node's
|
|
296
243
|
// evaluation point for them). Inadmissible static cycles inside the
|
|
297
244
|
// added subgraph are minted here and handed to reachable emit after this
|
|
298
245
|
// extension of the shared array; no later pass re-walks the subgraph.
|
|
@@ -321,7 +268,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
321
268
|
const libraryCallbacks = options.libraryCallbacks ?? false;
|
|
322
269
|
const externalTypes = options.externalTypes ?? new Map();
|
|
323
270
|
const externalTypeSpecifiersByFile = options.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(externalTypes);
|
|
324
|
-
const validation = new Lowerer(program, entry, moduleOrder,
|
|
271
|
+
const validation = new Lowerer(program, entry, moduleOrder, {
|
|
325
272
|
frontendServices: options.frontendServices,
|
|
326
273
|
targetPlatform,
|
|
327
274
|
startupCrash,
|
|
@@ -341,7 +288,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
341
288
|
// lowerer because validation is an immediate no-op there.
|
|
342
289
|
const reachableEmit = ffiImports.length === 0
|
|
343
290
|
? validation
|
|
344
|
-
: new Lowerer(program, entry, moduleOrder,
|
|
291
|
+
: new Lowerer(program, entry, moduleOrder, {
|
|
345
292
|
frontendServices: options.frontendServices,
|
|
346
293
|
targetPlatform,
|
|
347
294
|
startupCrash,
|
|
@@ -370,7 +317,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
370
317
|
// historical compiler. This is a rare compatibility fallback; programs
|
|
371
318
|
// without such a settled fence retain checker-backed IR exactly once.
|
|
372
319
|
if (reachableEmit.requiresHistoricalOrderRelower) {
|
|
373
|
-
const emit = new Lowerer(program, entry, moduleOrder,
|
|
320
|
+
const emit = new Lowerer(program, entry, moduleOrder, {
|
|
374
321
|
frontendServices: options.frontendServices,
|
|
375
322
|
reachable,
|
|
376
323
|
targetPlatform,
|
|
@@ -432,7 +379,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
432
379
|
result = { ...result, contracts };
|
|
433
380
|
if (options.coverage !== true)
|
|
434
381
|
return result;
|
|
435
|
-
const remainder = new Lowerer(program, entry, moduleOrder,
|
|
382
|
+
const remainder = new Lowerer(program, entry, moduleOrder, {
|
|
436
383
|
frontendServices: options.frontendServices,
|
|
437
384
|
reachable,
|
|
438
385
|
remainder: true,
|
|
@@ -459,40 +406,13 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
459
406
|
},
|
|
460
407
|
};
|
|
461
408
|
}
|
|
462
|
-
/** The island-handle type a `import(...)` initializer gives a binding
|
|
463
|
-
* whose DECLARED type has no static mapping (`Promise<typeof
|
|
464
|
-
* import("./m")>` — module-namespace types don't map): the direct form
|
|
465
|
-
* holds the static promise-of-handle, the awaited form holds the handle
|
|
466
|
-
* itself. Null for every other initializer shape. */
|
|
467
|
-
export function importCallHandleType(expr) {
|
|
468
|
-
if (!expr)
|
|
469
|
-
return null;
|
|
470
|
-
let e = expr;
|
|
471
|
-
let awaited = false;
|
|
472
|
-
for (;;) {
|
|
473
|
-
if (ts.isParenthesizedExpression(e)) {
|
|
474
|
-
e = e.expression;
|
|
475
|
-
}
|
|
476
|
-
else if (ts.isAwaitExpression(e)) {
|
|
477
|
-
awaited = true;
|
|
478
|
-
e = e.expression;
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
if (ts.isCallExpression(e) && e.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
485
|
-
return awaited ? JSVAL : { kind: "promise", inner: JSVAL };
|
|
486
|
-
}
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
409
|
/** The native namespace type produced by a literal static import() of a
|
|
490
410
|
* compiled program module or supported Node builtin. This syntax-level
|
|
491
411
|
* fallback is used where the checker exposes an anonymous builtin-module
|
|
492
412
|
* object type with no stable module symbol (locals/globals are still
|
|
493
413
|
* represented nominally by the value they actually receive). */
|
|
494
414
|
export function staticImportNamespaceType(lowerer, expr) {
|
|
495
|
-
if (!expr
|
|
415
|
+
if (!expr)
|
|
496
416
|
return null;
|
|
497
417
|
let e = expr;
|
|
498
418
|
let awaited = false;
|
|
@@ -531,48 +451,8 @@ export function staticImportNamespaceType(lowerer, expr) {
|
|
|
531
451
|
const ns = { kind: "moduleNs", moduleId };
|
|
532
452
|
return awaited ? ns : { kind: "promise", inner: ns };
|
|
533
453
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
* (`any` under --dynamic): tsc never checks overload return types against
|
|
537
|
-
* the body — only the implementation signature is checked — so the
|
|
538
|
-
* overload's return is an unverifiable claim about an island value. The
|
|
539
|
-
* binding stores the HANDLE instead of trap-extracting the claimed type
|
|
540
|
-
* (reconcileOverloadReturn keeps the call jsval by the same rule), and
|
|
541
|
-
* uses dispatch to engine ops — exactly the value Node's binding holds.
|
|
542
|
-
* Ambient (.d.ts) declarations never reach this: they have no compiled
|
|
543
|
-
* implementation, so their calls lower through the island/builtin paths
|
|
544
|
-
* whose validated exits keep the checker-trust trap. */
|
|
545
|
-
export function uncheckedOverloadHandleCall(lowerer, expr) {
|
|
546
|
-
if (!lowerer.dynamic || !expr)
|
|
547
|
-
return false;
|
|
548
|
-
let e = expr;
|
|
549
|
-
while (ts.isParenthesizedExpression(e))
|
|
550
|
-
e = e.expression;
|
|
551
|
-
// Tagged templates are calls too (tag(strings, ...values)) and resolve
|
|
552
|
-
// overload sets the same way — foo1`${1}` against a TemplateStringsArray
|
|
553
|
-
// overload of an any-returning implementation stores the handle.
|
|
554
|
-
if (!ts.isCallExpression(e) && !ts.isTaggedTemplateExpression(e))
|
|
555
|
-
return false;
|
|
556
|
-
const rsig = lowerer.checker.getResolvedSignature(e);
|
|
557
|
-
const rdecl = rsig ? lowerer.checker.signatureDeclaration(rsig) : undefined;
|
|
558
|
-
if (!rsig || !rdecl)
|
|
559
|
-
return false;
|
|
560
|
-
if (!(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) || rdecl.body)
|
|
561
|
-
return false;
|
|
562
|
-
const name = rdecl.name;
|
|
563
|
-
const symbol = name ? lowerer.checker.getSymbolAtLocation(name) : undefined;
|
|
564
|
-
if (!symbol)
|
|
565
|
-
return false;
|
|
566
|
-
const impl = lowerer.checker
|
|
567
|
-
.declarationsOf(symbol)
|
|
568
|
-
.find((d) => (ts.isFunctionDeclaration(d) || ts.isMethodDeclaration(d)) &&
|
|
569
|
-
d.body !== undefined);
|
|
570
|
-
if (!impl)
|
|
571
|
-
return false;
|
|
572
|
-
const implSig = lowerer.checker.getSignatureFromDeclaration(impl);
|
|
573
|
-
if (!implSig)
|
|
574
|
-
return false;
|
|
575
|
-
return lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(implSig))?.kind === "jsval";
|
|
454
|
+
export function uncheckedOverloadHandleCall(_lowerer, _expr) {
|
|
455
|
+
return false;
|
|
576
456
|
}
|
|
577
457
|
/** The JavaScript declaration fallback for unmappable binding types (see
|
|
578
458
|
* irTypeOf): `any` and every other inference residue is the checked-
|
|
@@ -628,29 +508,6 @@ export function ladderFenceExpr(lowerer, surface, node, hint) {
|
|
|
628
508
|
loc,
|
|
629
509
|
};
|
|
630
510
|
}
|
|
631
|
-
/** The checked-dynamic declaration fallback for unmappable binding types
|
|
632
|
-
* (see irTypeOf), two gates over one story:
|
|
633
|
-
*
|
|
634
|
-
* JAVASCRIPT files: `any` and every other inference residue is the
|
|
635
|
-
* checked-dynamic 'unknown' kind, and array types keep their array-ness
|
|
636
|
-
* with the fallback applied to the ELEMENT (any[]/never[] evolving arrays
|
|
637
|
-
* become unknown[], so length/push/index still lower).
|
|
638
|
-
*
|
|
639
|
-
* TYPESCRIPT files: genuine checker-`any` residue ONLY — a bare `any`
|
|
640
|
-
* binding (`flags & Any`), or a single-call-signature function type whose
|
|
641
|
-
* only unmappable pieces are `any` (`(value: any) => value is string` —
|
|
642
|
-
* the arrow the binding holds lowers those params to dyn, so the binding
|
|
643
|
-
* keeps its func-ness with the same per-piece fallback). The honest
|
|
644
|
-
* static subset of `any` is a binding whose VALUES are dyn-representable:
|
|
645
|
-
* the binding is 'unknown' storage with the boundary conversions
|
|
646
|
-
* coerceToExpected already applies (dynFrom into the slot, validated
|
|
647
|
-
* dynCheck out) and per-site SC2011 fences for the operations the checked-dynamic tree
|
|
648
|
-
* cannot carry JS-exactly (the island still lifts those). Every OTHER
|
|
649
|
-
* unmappable TS type keeps its own diagnostic — annotations exist there,
|
|
650
|
-
* and the fence names the real blocker. `--dynamic` builds never reach
|
|
651
|
-
* this fallback for `any` (mapType answers jsval first).
|
|
652
|
-
*
|
|
653
|
-
* Null for void (no value exists to represent). */
|
|
654
511
|
export function dynFallbackType(lowerer, node, t) {
|
|
655
512
|
if (t.flags & ts.TypeFlags.Void)
|
|
656
513
|
return null;
|
|
@@ -806,10 +663,7 @@ function jsFallbackFunctionType(lowerer, node, t) {
|
|
|
806
663
|
const optional = decl !== undefined &&
|
|
807
664
|
ts.isParameter(decl) &&
|
|
808
665
|
(decl.questionToken !== undefined || decl.initializer !== undefined);
|
|
809
|
-
if (optional &&
|
|
810
|
-
mapped.kind !== "dyn" &&
|
|
811
|
-
mapped.kind !== "jsval" &&
|
|
812
|
-
!lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
666
|
+
if (optional && mapped.kind !== "dyn" && !lowerer.bareUndefinedArmedUnion(mapped)) {
|
|
813
667
|
mapped = lowerer.withUndefinedArm(mapped);
|
|
814
668
|
}
|
|
815
669
|
return mapped;
|
|
@@ -988,7 +842,6 @@ export class Lowerer {
|
|
|
988
842
|
program;
|
|
989
843
|
entry;
|
|
990
844
|
moduleOrder;
|
|
991
|
-
dynamic;
|
|
992
845
|
frontendServices;
|
|
993
846
|
checker;
|
|
994
847
|
diags = [];
|
|
@@ -1514,7 +1367,7 @@ export class Lowerer {
|
|
|
1514
1367
|
runtimeOptionalType(t) {
|
|
1515
1368
|
if (t.kind === "union")
|
|
1516
1369
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
1517
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
1370
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
1518
1371
|
return t;
|
|
1519
1372
|
return this.withUndefinedArm(t);
|
|
1520
1373
|
}
|
|
@@ -1770,43 +1623,21 @@ export class Lowerer {
|
|
|
1770
1623
|
* falls back through the shared node (collectGlobals registers both). */
|
|
1771
1624
|
globalsByDeclNode = new Map();
|
|
1772
1625
|
globalsList = [];
|
|
1773
|
-
/** npm-import init statements (--dynamic), keyed by file AND import
|
|
1774
|
-
* declaration: the island.import assignments/side-effect loads for that
|
|
1775
|
-
* statement. lowerFileInit splices them into the importing file's %init
|
|
1776
|
-
* header at the statement's position — Node evaluates each imported
|
|
1777
|
-
* module (island packages included) where the import appears, so an
|
|
1778
|
-
* `import "polyfill"` before an `import "./app.js"` runs the package
|
|
1779
|
-
* top-level BEFORE app's init, not after. */
|
|
1780
1626
|
npmInitActions = new Map();
|
|
1781
1627
|
/** Per-file %init PRELUDE statements for JSON imports: bakeable DATA
|
|
1782
1628
|
* assignments with no observable evaluation order of their own —
|
|
1783
1629
|
* prepended by lowerFileInit so the bindings are live before any
|
|
1784
1630
|
* top-level statement runs. */
|
|
1785
1631
|
jsonInitActions = new Map();
|
|
1786
|
-
/** The embedded npm runtime graph (collectNpmImports), attached to the
|
|
1787
|
-
* emitted module. Null without npm imports or without --dynamic. */
|
|
1788
|
-
npmEmbedded = null;
|
|
1789
|
-
npmBuiltins = null;
|
|
1790
|
-
npmLazyTraps = null;
|
|
1791
1632
|
/** Dynamic `import("literal")` resolutions, keyed
|
|
1792
1633
|
* `fileName\u0000specifier` (collectDynamicImports fills it during npm
|
|
1793
1634
|
* collection; lowerDynamicImportCall reads it per site). */
|
|
1794
1635
|
dynImports = new Map();
|
|
1795
|
-
/** createRequire-require resolutions of BARE npm specifiers, keyed
|
|
1796
|
-
* `fileName\u0000specifier` (collectCreateRequires fills it during npm
|
|
1797
|
-
* collection under --dynamic — the require-condition entry key plus its
|
|
1798
|
-
* embedded format; lowerCreateRequireCall reads it per site; "" marks a
|
|
1799
|
-
* failed resolution already reported at collection). */
|
|
1800
1636
|
createRequireImports = new Map();
|
|
1801
1637
|
/** Module → the name of its synthesized namespace-BUILDER function
|
|
1802
1638
|
* (lowerOwnModuleImport): every `import()` of the same program module
|
|
1803
1639
|
* shares one builder. */
|
|
1804
1640
|
dynNsBuilders = new Map();
|
|
1805
|
-
/** Parameters forced to the island-handle type (jsval) regardless of
|
|
1806
|
-
* their checker type: then-handler params whose settled value is an
|
|
1807
|
-
* engine handle (a dynamic import's namespace object) — paramShape's
|
|
1808
|
-
* early-out. */
|
|
1809
|
-
jsvalParamOverrides = new Set();
|
|
1810
1641
|
checkedCallbackParams = new Set();
|
|
1811
1642
|
/** Inline Promise.then parameters whose contextual type is a builtin
|
|
1812
1643
|
* module namespace anonymous object. The settled native token is the
|
|
@@ -1892,7 +1723,6 @@ export class Lowerer {
|
|
|
1892
1723
|
stats = {
|
|
1893
1724
|
statementsTotal: 0,
|
|
1894
1725
|
statementsFailed: 0,
|
|
1895
|
-
statementsIsland: 0,
|
|
1896
1726
|
functionsSkipped: 0,
|
|
1897
1727
|
};
|
|
1898
1728
|
/** Reachability edge sink: every resolution of
|
|
@@ -2026,19 +1856,16 @@ export class Lowerer {
|
|
|
2026
1856
|
return;
|
|
2027
1857
|
let s = this.statsByFile.get(file);
|
|
2028
1858
|
if (!s)
|
|
2029
|
-
this.statsByFile.set(file, (s = { total: 0, failed: 0
|
|
1859
|
+
this.statsByFile.set(file, (s = { total: 0, failed: 0 }));
|
|
2030
1860
|
if (kind === "total")
|
|
2031
1861
|
s.total += 1;
|
|
2032
1862
|
else if (kind === "failed")
|
|
2033
1863
|
s.failed += 1;
|
|
2034
|
-
else
|
|
2035
|
-
s.island += 1;
|
|
2036
1864
|
}
|
|
2037
|
-
constructor(program, entry, moduleOrder,
|
|
1865
|
+
constructor(program, entry, moduleOrder, mode = {}) {
|
|
2038
1866
|
this.program = program;
|
|
2039
1867
|
this.entry = entry;
|
|
2040
1868
|
this.moduleOrder = moduleOrder;
|
|
2041
|
-
this.dynamic = dynamic;
|
|
2042
1869
|
this.frontendServices = mode.frontendServices;
|
|
2043
1870
|
this.reachable = mode.reachable ?? null;
|
|
2044
1871
|
this.remainder = mode.remainder ?? false;
|
|
@@ -2121,7 +1948,6 @@ export class Lowerer {
|
|
|
2121
1948
|
isStdlibFile: this.isStdlibFile,
|
|
2122
1949
|
isNpmFile: this.isNpmFile,
|
|
2123
1950
|
isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
|
|
2124
|
-
dynamic: this.dynamic,
|
|
2125
1951
|
typeMemo: this.typeMemo,
|
|
2126
1952
|
canMemoizeType: () => this.typeParamBindings === null &&
|
|
2127
1953
|
this.typeParamTsBindings === null &&
|
|
@@ -3310,7 +3136,6 @@ export class Lowerer {
|
|
|
3310
3136
|
if (!element ||
|
|
3311
3137
|
element.kind === "void" ||
|
|
3312
3138
|
element.kind === "dyn" ||
|
|
3313
|
-
element.kind === "jsval" ||
|
|
3314
3139
|
element.kind === "generator")
|
|
3315
3140
|
return null;
|
|
3316
3141
|
return e;
|
|
@@ -3344,12 +3169,12 @@ export class Lowerer {
|
|
|
3344
3169
|
return false;
|
|
3345
3170
|
const object = init.arguments[0];
|
|
3346
3171
|
const objectType = object ? this.mapTypeOf(this.typeOf(object)) : null;
|
|
3347
|
-
return objectType?.kind === "dyn"
|
|
3172
|
+
return objectType?.kind === "dyn";
|
|
3348
3173
|
};
|
|
3349
3174
|
const addUndefined = (t) => {
|
|
3350
3175
|
if (t.kind === "union")
|
|
3351
3176
|
return this.armTag(t.unionId, UNDEFINED_T) >= 0 ? t : (this.withUndefinedArmOf(t) ?? t);
|
|
3352
|
-
if (t.kind === "void" || t.kind === "dyn" || t.kind === "
|
|
3177
|
+
if (t.kind === "void" || t.kind === "dyn" || t.kind === "generator")
|
|
3353
3178
|
return t;
|
|
3354
3179
|
return this.withUndefinedArm(t);
|
|
3355
3180
|
};
|
|
@@ -3591,10 +3416,7 @@ export class Lowerer {
|
|
|
3591
3416
|
// checker. The array's element ABI describes every value a
|
|
3592
3417
|
// position may hold after that call, so bind from that type.
|
|
3593
3418
|
const mapped = sourceType.elem;
|
|
3594
|
-
if (mapped &&
|
|
3595
|
-
mapped.kind !== "void" &&
|
|
3596
|
-
mapped.kind !== "dyn" &&
|
|
3597
|
-
mapped.kind !== "jsval") {
|
|
3419
|
+
if (mapped && mapped.kind !== "void" && mapped.kind !== "dyn") {
|
|
3598
3420
|
const widened = mapped.kind === "union"
|
|
3599
3421
|
? this.withUndefinedArmOf(mapped)
|
|
3600
3422
|
: this.withUndefinedArm(mapped);
|
|
@@ -3961,7 +3783,7 @@ export class Lowerer {
|
|
|
3961
3783
|
if (mapped?.kind === "promise")
|
|
3962
3784
|
mapped = mapped.inner;
|
|
3963
3785
|
const anyElements = mapped?.kind === "array"
|
|
3964
|
-
? mapped.elem.kind === "dyn"
|
|
3786
|
+
? mapped.elem.kind === "dyn"
|
|
3965
3787
|
: mapped === null &&
|
|
3966
3788
|
this.checker.isArrayType(checkerType) &&
|
|
3967
3789
|
!this.checker.isTupleType(checkerType) &&
|
|
@@ -4141,7 +3963,6 @@ export class Lowerer {
|
|
|
4141
3963
|
mapped.kind === "record" ||
|
|
4142
3964
|
mapped.kind === "object" ||
|
|
4143
3965
|
mapped.kind === "dyn" ||
|
|
4144
|
-
mapped.kind === "jsval" ||
|
|
4145
3966
|
mapped.kind === "union");
|
|
4146
3967
|
},
|
|
4147
3968
|
restKeys: (call) => {
|
|
@@ -4539,10 +4360,7 @@ export class Lowerer {
|
|
|
4539
4360
|
}
|
|
4540
4361
|
}
|
|
4541
4362
|
}
|
|
4542
|
-
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" ||
|
|
4543
|
-
shape.mode === "dynRest" ||
|
|
4544
|
-
shape.mode === "islandRest" ||
|
|
4545
|
-
shape.mode === "arguments");
|
|
4363
|
+
const restAt = sig.params.findIndex((shape) => shape.mode === "rest" || shape.mode === "dynRest" || shape.mode === "arguments");
|
|
4546
4364
|
node.arguments.forEach((arg, argumentIndex) => {
|
|
4547
4365
|
const i = restAt >= 0 && argumentIndex >= restAt ? restAt : argumentIndex;
|
|
4548
4366
|
const shape = sig.params[i];
|
|
@@ -5038,8 +4856,7 @@ export class Lowerer {
|
|
|
5038
4856
|
}
|
|
5039
4857
|
}
|
|
5040
4858
|
// Each file's top-level statements form its run-once init function.
|
|
5041
|
-
// %main calls only the
|
|
5042
|
-
// runs its dependencies (npm island loads at their import positions),
|
|
4859
|
+
// %main calls only the entry's init. Hoisted imports call their inits;
|
|
5043
4860
|
// inline require statements call theirs mid-body, and the guards make
|
|
5044
4861
|
// revisits cache hits — Node's evaluation order over the WHOLE graph
|
|
5045
4862
|
// falls out of the nesting. The coverage remainder skips them — they
|
|
@@ -5111,7 +4928,7 @@ export class Lowerer {
|
|
|
5111
4928
|
!this.remainder &&
|
|
5112
4929
|
classDispatch.process(this, [...functions, ...this.liftedFns, ...this.implicitFns]);
|
|
5113
4930
|
}
|
|
5114
|
-
classDispatch.finalize();
|
|
4931
|
+
classDispatch.finalize(this);
|
|
5115
4932
|
}
|
|
5116
4933
|
// Lambdas lifted while lowering any of the above (plus synthetic
|
|
5117
4934
|
// array-HOF loop functions, which ride the same list), and the
|
|
@@ -5135,8 +4952,6 @@ export class Lowerer {
|
|
|
5135
4952
|
stats: this.stats,
|
|
5136
4953
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5137
4954
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5138
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5139
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5140
4955
|
};
|
|
5141
4956
|
}
|
|
5142
4957
|
return this.finishModule(functions);
|
|
@@ -5236,14 +5051,13 @@ export class Lowerer {
|
|
|
5236
5051
|
const module = this.diags.length > 0
|
|
5237
5052
|
? null
|
|
5238
5053
|
: {
|
|
5239
|
-
irVersion:
|
|
5054
|
+
irVersion: 16,
|
|
5240
5055
|
sourceFile: this.entry.fileName,
|
|
5241
5056
|
functions,
|
|
5242
5057
|
classes: artifacts.classes,
|
|
5243
5058
|
records: artifacts.records,
|
|
5244
5059
|
unions: artifacts.unions,
|
|
5245
5060
|
globals: this.globalsList,
|
|
5246
|
-
...(this.npmEmbedded ? { embedded: this.npmEmbedded } : {}),
|
|
5247
5061
|
entry: ENTRY_NAME,
|
|
5248
5062
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
5249
5063
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
@@ -5260,8 +5074,6 @@ export class Lowerer {
|
|
|
5260
5074
|
stats: this.stats,
|
|
5261
5075
|
...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
|
|
5262
5076
|
...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
|
|
5263
|
-
...(this.npmBuiltins ? { npmBuiltins: this.npmBuiltins } : {}),
|
|
5264
|
-
...(this.npmLazyTraps ? { npmLazyTraps: this.npmLazyTraps } : {}),
|
|
5265
5077
|
};
|
|
5266
5078
|
}
|
|
5267
5079
|
/** True when `t` (recursively) names a class instance type with no
|
|
@@ -5723,7 +5535,7 @@ export class Lowerer {
|
|
|
5723
5535
|
this.restoreGenericInstanceOrder(instLowered);
|
|
5724
5536
|
this.restoreGenericClassInstanceOrder(clsInstLowered);
|
|
5725
5537
|
}
|
|
5726
|
-
classDispatch.finalize();
|
|
5538
|
+
classDispatch.finalize(this);
|
|
5727
5539
|
const orderedUnits = [...loweredUnits]
|
|
5728
5540
|
.sort(([left], [right]) => units.get(left).order - units.get(right).order)
|
|
5729
5541
|
.map(([, fn]) => fn);
|
|
@@ -5903,22 +5715,13 @@ export class Lowerer {
|
|
|
5903
5715
|
? `values from the '${specifier}' external host module (types supplied by --external-types, but no runtime implementation or scriptc lowering was provided)`
|
|
5904
5716
|
: `the '${specifier}' external host module (types supplied by --external-types, but no runtime implementation or scriptc lowering was provided)`, `the declaration mapping is analysis-only: coverage continues through project code, while executing ${valueUse ? "this value" : "this module"} requires an embedder integration with explicit runtime semantics`);
|
|
5905
5717
|
}
|
|
5906
|
-
/** The dynamic-family fence for an OPERATION on an `any`-origin
|
|
5907
|
-
* checked-dynamic value that only the engine can execute (operators,
|
|
5908
|
-
* iteration, computed member names, ...). Carries SC2011 — the same
|
|
5909
|
-
* code as the `any` type fence — so the coverage report groups it with
|
|
5910
|
-
* the dynamic-capable family and the two-tier retry knows the island
|
|
5911
|
-
* lifts the site. Use exactly when the blocking operand IS dyn-typed
|
|
5912
|
-
* and its checker type is `any`-flavored; genuine `unknown` keeps the
|
|
5913
|
-
* SC1100-family fences (tsc constrains what unknown can do, so those
|
|
5914
|
-
* sites are checker-error territory, not engine territory). */
|
|
5915
5718
|
anyOpFence(feature, node) {
|
|
5916
|
-
this.pushDiag(
|
|
5719
|
+
this.pushDiag(unsupportedAnyOperationDiag(feature, locOf(node)));
|
|
5917
5720
|
throw new PoisonError();
|
|
5918
5721
|
}
|
|
5919
5722
|
/** True when this expression's CHECKER type is `any`-flavored — the
|
|
5920
5723
|
* gate anyOpFence's call sites use to tell `any`-origin dyn values
|
|
5921
|
-
*
|
|
5724
|
+
* with an unsupported operation from genuine `unknown` ones. */
|
|
5922
5725
|
anyOrigin(node) {
|
|
5923
5726
|
return (this.typeOf(node).flags & ts.TypeFlags.Any) !== 0;
|
|
5924
5727
|
}
|
|
@@ -5940,11 +5743,10 @@ export class Lowerer {
|
|
|
5940
5743
|
// SC2012 rather than the generic supported-types recitation. Native
|
|
5941
5744
|
// fetch values map earlier to checked-dynamic handles and do not reach
|
|
5942
5745
|
// here; constructor objects such as Headers still can.
|
|
5943
|
-
if (
|
|
5944
|
-
typeSym &&
|
|
5945
|
-
ISLAND_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5746
|
+
if (typeSym &&
|
|
5747
|
+
FETCH_AMBIENT_TYPES.includes(typeSym.name) &&
|
|
5946
5748
|
this.isStdlibSymbol(typeSym)) {
|
|
5947
|
-
this.pushDiag(
|
|
5749
|
+
this.pushDiag(unsupportedNativeApiDiag(`a value of type '${typeSym.name}'`, locOf(node)));
|
|
5948
5750
|
throw new PoisonError();
|
|
5949
5751
|
}
|
|
5950
5752
|
// ENUM OBJECTS (`typeof e` — a numeric enum's type carries the
|
|
@@ -5983,30 +5785,14 @@ export class Lowerer {
|
|
|
5983
5785
|
this.pushDiag(noLoweringDiag(this.checker.typeToString(type), locOf(node)));
|
|
5984
5786
|
throw new PoisonError();
|
|
5985
5787
|
}
|
|
5986
|
-
// The MEASURED island probe, same mechanism as the general dynamic
|
|
5987
|
-
// reroute below: an index-signature shape the dynamic mapping
|
|
5988
|
-
// accepts (an `any`-valued signature absorbing into an island
|
|
5989
|
-
// object, jsval-entangled members) reports the retry-eligible
|
|
5990
|
-
// SC2011 choice instead of the static recitation.
|
|
5991
|
-
if (!this.dynamic &&
|
|
5992
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
5993
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
5994
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5995
|
-
throw new PoisonError();
|
|
5996
|
-
}
|
|
5997
5788
|
this.pushDiag(indexSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
5998
5789
|
throw new PoisonError();
|
|
5999
5790
|
}
|
|
6000
|
-
//
|
|
6001
|
-
|
|
6002
|
-
// report's one-line-per-package attribution). Under --dynamic these
|
|
6003
|
-
// types map to jsval, so reaching here means the type is genuinely
|
|
6004
|
-
// unrepresentable (a jsval union arm, a jsval array element) — the
|
|
6005
|
-
// generic type message tells that story better.
|
|
6006
|
-
if (!this.dynamic) {
|
|
5791
|
+
// Attribute an unsupported package type to its package.
|
|
5792
|
+
{
|
|
6007
5793
|
const pkg = this.npmPackageOf(widened);
|
|
6008
5794
|
if (pkg) {
|
|
6009
|
-
this.pushDiag(
|
|
5795
|
+
this.pushDiag(unsupportedPackageValueDiag(pkg, locOf(node)));
|
|
6010
5796
|
throw new PoisonError();
|
|
6011
5797
|
}
|
|
6012
5798
|
}
|
|
@@ -6023,24 +5809,6 @@ export class Lowerer {
|
|
|
6023
5809
|
throw new PoisonError();
|
|
6024
5810
|
}
|
|
6025
5811
|
}
|
|
6026
|
-
// A type the DYNAMIC mapping accepts (`any[]`, records/functions with
|
|
6027
|
-
// `any`-typed members, .d.ts-declared shapes whose values are island
|
|
6028
|
-
// handles): the honest per-site story is the dynamic-family choice, not
|
|
6029
|
-
// the supported-types recitation — proved by re-running mapType with
|
|
6030
|
-
// `dynamic: true`, never guessed from the type text. Probing is safe
|
|
6031
|
-
// here: a diagnostic means this build already failed, so anything the
|
|
6032
|
-
// probe interns or registers on the way is never emitted. Checked LAST
|
|
6033
|
-
// so every more specific story above (island ambients, index
|
|
6034
|
-
// signatures, per-package attribution, generic signatures) keeps its
|
|
6035
|
-
// own fence class. Bare `any` is excepted: unsupportedTypeDiag's own
|
|
6036
|
-
// SC2011 arm tells that story with the stronger stay-static remedy
|
|
6037
|
-
// ('unknown' + a checked cast).
|
|
6038
|
-
if (!this.dynamic &&
|
|
6039
|
-
!(widened.flags & ts.TypeFlags.Any) &&
|
|
6040
|
-
mapType(widened, { ...this.typeCtx, dynamic: true }) !== null) {
|
|
6041
|
-
this.pushDiag(requiresDynamicTypeDiag(this.checker.typeToString(type), locOf(node)));
|
|
6042
|
-
throw new PoisonError();
|
|
6043
|
-
}
|
|
6044
5812
|
// STANDARD-LIBRARY nominal provenance, decided once: interface/class
|
|
6045
5813
|
// declarations in the lib's own files (Date, ArrayBuffer, WeakMap, the
|
|
6046
5814
|
// iterator/constructor interfaces). Such types report the SC2020 story
|
|
@@ -6147,12 +5915,6 @@ export class Lowerer {
|
|
|
6147
5915
|
fenceFetchObjectAssignment(target, source) {
|
|
6148
5916
|
return fenceFetchObjectAssignment(this, target, source);
|
|
6149
5917
|
}
|
|
6150
|
-
lowerDynamicHeadersIteratorCall(call, access) {
|
|
6151
|
-
return lowerDynamicHeadersIteratorCall(this, call, access);
|
|
6152
|
-
}
|
|
6153
|
-
lowerDynamicHeadersSpread(node, type) {
|
|
6154
|
-
return lowerDynamicHeadersSpread(this, node, type);
|
|
6155
|
-
}
|
|
6156
5918
|
fenceStaticReadableStreamMember(access, use) {
|
|
6157
5919
|
return fenceStaticReadableStreamMember(this, access, use);
|
|
6158
5920
|
}
|
|
@@ -6344,23 +6106,6 @@ export class Lowerer {
|
|
|
6344
6106
|
bareUndefinedArmedUnion(t) {
|
|
6345
6107
|
return isUndefinedArmedUnion(t, (id) => this.unions.get(id));
|
|
6346
6108
|
}
|
|
6347
|
-
/** canCrossIslandBoundary with this Lowerer's registries — THE test
|
|
6348
|
-
* behind every marshal/exit decision (the implicit coercions, jsvalIn,
|
|
6349
|
-
* the checked island-exit cast). Rejections that follow a false answer
|
|
6350
|
-
* speak through boundaryIntoIslandMsg / boundaryOutOfIslandMsg. */
|
|
6351
|
-
boundarySafe(t) {
|
|
6352
|
-
return canCrossIslandBoundary(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6353
|
-
}
|
|
6354
|
-
/** canExitIslandToType with this Lowerer's registries — the EXIT
|
|
6355
|
-
* direction's slightly wider test (bare undefined-armed unions of
|
|
6356
|
-
* JSON-safe data arms exit; the engine's undefined takes the undefined
|
|
6357
|
-
* arm before the JSON round trip). */
|
|
6358
|
-
boundaryExitSafe(t) {
|
|
6359
|
-
return canExitIslandToType(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
|
|
6360
|
-
}
|
|
6361
|
-
isIslandExpr(node) {
|
|
6362
|
-
return isIslandExpr(this, node);
|
|
6363
|
-
}
|
|
6364
6109
|
/** True when this node's CHECKER type is proven `any[]`/`unknown[]`,
|
|
6365
6110
|
* directly or through the intersection tsc builds for a readonly tuple
|
|
6366
6111
|
* union (`(Model | readonly [Model, Command]) & any[]`; TS7 distributes
|
|
@@ -6492,14 +6237,6 @@ export class Lowerer {
|
|
|
6492
6237
|
}
|
|
6493
6238
|
this.unsupported("SC1101", node);
|
|
6494
6239
|
}
|
|
6495
|
-
// jsval mismatches surviving coerceToExpected involve a type with no
|
|
6496
|
-
// island representation (in) or no validated exit (out).
|
|
6497
|
-
if (actual.kind === "jsval") {
|
|
6498
|
-
this.unsupported("SC1090", node, boundaryOutOfIslandMsg(this.fmt(expected)));
|
|
6499
|
-
}
|
|
6500
|
-
if (expected.kind === "jsval") {
|
|
6501
|
-
this.unsupported("SC1090", node, boundaryIntoIslandMsg(this.fmt(actual)));
|
|
6502
|
-
}
|
|
6503
6240
|
// Class-value mismatches: the pointed stories — a widening whose
|
|
6504
6241
|
// constructor ABIs differ (construction through the slot would
|
|
6505
6242
|
// dispatch a mismatched signature), or a structural flow between
|
|
@@ -6648,98 +6385,12 @@ export class Lowerer {
|
|
|
6648
6385
|
if (adapted)
|
|
6649
6386
|
return adapted;
|
|
6650
6387
|
}
|
|
6651
|
-
// Island boundary, both directions. IN: any static value flowing into
|
|
6652
6388
|
// an any-typed slot marshals implicitly (tsc allows the assignment;
|
|
6653
6389
|
// the marshal is where its semantics live). OUT: an 'any' value
|
|
6654
6390
|
// flowing into a typed slot compiles to a VALIDATED exit — like every
|
|
6655
6391
|
// dyn→static edge, trust-but-verify: a lying `any` throws a catchable
|
|
6656
6392
|
// TypeError instead of corrupting memory (SEMANTICS.md). Unmarshalable
|
|
6657
6393
|
// and unextractable types fall through to requireExactShape's fences.
|
|
6658
|
-
if (expected.kind === "jsval" && expr.type.kind !== "jsval") {
|
|
6659
|
-
// Bare unit literals: the engine's own undefined/null (units have no
|
|
6660
|
-
// other producers, so dropping the operand loses nothing).
|
|
6661
|
-
if (isUnitType(expr.type)) {
|
|
6662
|
-
return {
|
|
6663
|
-
kind: "jsOp",
|
|
6664
|
-
op: expr.type.kind === "undefinedT" ? "undefLit" : "nullLit",
|
|
6665
|
-
args: [],
|
|
6666
|
-
type: JSVAL,
|
|
6667
|
-
loc: expr.loc,
|
|
6668
|
-
};
|
|
6669
|
-
}
|
|
6670
|
-
// A CHECKED-DYNAMIC (dyn/'unknown') value entering the island (the
|
|
6671
|
-
// `isJson ? JSON.parse(text) : islandParser(text)` config ternary):
|
|
6672
|
-
// the dyn tree deep-copies into engine values — data kinds only; a
|
|
6673
|
-
// dyn carrying a boxed function/handle/promise throws the catchable
|
|
6674
|
-
// TypeError at runtime (trust-but-verify, like every boundary).
|
|
6675
|
-
if (expr.type.kind === "dyn") {
|
|
6676
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6677
|
-
}
|
|
6678
|
-
if (this.boundarySafe(expr.type)) {
|
|
6679
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6680
|
-
}
|
|
6681
|
-
// Closures cross as host functions when their signature marshals —
|
|
6682
|
-
// the same shapes jsvalIn admits at call arguments (`const f: any =
|
|
6683
|
-
// (x: number) => x * 3` is the declaration-slot spelling of the
|
|
6684
|
-
// package-callback pattern).
|
|
6685
|
-
if (expr.type.kind === "func" &&
|
|
6686
|
-
canMarshalTypedFuncIntoIsland(expr.type, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
|
|
6687
|
-
return { kind: "jsMarshal", value: expr, type: JSVAL, loc: expr.loc };
|
|
6688
|
-
}
|
|
6689
|
-
// jsval-BEARING composites (a record holding `any` fields, an array
|
|
6690
|
-
// of such records) have no JSON marshal but an honest per-field
|
|
6691
|
-
// island construction — see jsvalLiftExpr.
|
|
6692
|
-
if (this.jsvalLiftable(expr.type)) {
|
|
6693
|
-
return this.jsvalLiftExpr(expr, expr.loc);
|
|
6694
|
-
}
|
|
6695
|
-
// A RegExp flowing into an 'any' slot: the fresh-engine-RegExp
|
|
6696
|
-
// rebuild (see jsvalIn's regex rule); computed regex values fall
|
|
6697
|
-
// through to requireExactShape's fence.
|
|
6698
|
-
if (expr.type.kind === "regex") {
|
|
6699
|
-
const re = islandRegexpOf(expr);
|
|
6700
|
-
if (re)
|
|
6701
|
-
return re;
|
|
6702
|
-
}
|
|
6703
|
-
return expr;
|
|
6704
|
-
}
|
|
6705
|
-
if (expr.type.kind === "jsval" && expected.kind !== "jsval") {
|
|
6706
|
-
// The jsval→dyn crossing (the world unification's engine-handle
|
|
6707
|
-
// kind): an 'any'-typed engine value flowing into an 'unknown'/
|
|
6708
|
-
// 'object'/JS-residue slot wraps BY REFERENCE as the checked-dynamic tree's island
|
|
6709
|
-
// kind — engine scalars normalize to native dyn kinds at wrap time,
|
|
6710
|
-
// typeof/truthiness/String()/=== route to the engine, un-armed dyn
|
|
6711
|
-
// walks fence loudly, and the value unwraps back identity-preserved
|
|
6712
|
-
// (scr_jsval_from_dyn). Monotone under evolution/widening: a value
|
|
6713
|
-
// wraps once at its first dyn edge and stays valid through every
|
|
6714
|
-
// subsequent dyn slot; narrowing never changes representation.
|
|
6715
|
-
// This wrap RETIRES the silent-wrong-answer fence-closure box for
|
|
6716
|
-
// jsval members of dyn object literals (lowerDynObjectLiteral's
|
|
6717
|
-
// coercion lands here first).
|
|
6718
|
-
if (expected.kind === "dyn") {
|
|
6719
|
-
return { kind: "dynFromJsval", value: expr, type: DYN, loc: expr.loc };
|
|
6720
|
-
}
|
|
6721
|
-
// An island value flowing into a PROMISE-typed slot (the inferred
|
|
6722
|
-
// `loadPlugins` return — `Promise.all(...)` lowered engine-side
|
|
6723
|
-
// against a Promise<any[]> inference): the island→static promise
|
|
6724
|
-
// bridge — the engine promise settles a fresh static promise (void
|
|
6725
|
-
// fulfillments drop, `any[]`-declared fulfillments exit
|
|
6726
|
-
// Array.isArray-gated by reference at the settle, 'any' parks as an
|
|
6727
|
-
// island handle). Only inner shapes the bridge can deliver take the
|
|
6728
|
-
// arm; the rest keep the exit fence with the type named.
|
|
6729
|
-
if (expected.kind === "promise" &&
|
|
6730
|
-
(expected.inner.kind === "void" ||
|
|
6731
|
-
expected.inner.kind === "jsval" ||
|
|
6732
|
-
(expected.inner.kind === "array" && expected.inner.elem.kind === "jsval"))) {
|
|
6733
|
-
return { kind: "jsBridgePromise", value: expr, type: expected, loc: expr.loc };
|
|
6734
|
-
}
|
|
6735
|
-
// The exit set: everything round-trippable, plus bare undefined-armed
|
|
6736
|
-
// unions of JSON-safe data arms (the engine's undefined takes the
|
|
6737
|
-
// undefined arm before the JSON detour) — canExitIslandToType.
|
|
6738
|
-
if (this.boundaryExitSafe(expected)) {
|
|
6739
|
-
return { kind: "jsExit", value: expr, type: expected, loc: expr.loc };
|
|
6740
|
-
}
|
|
6741
|
-
return expr;
|
|
6742
|
-
}
|
|
6743
6394
|
// A TYPED value flowing into an 'unknown' slot (`const u: unknown = 5`,
|
|
6744
6395
|
// an unknown-typed param/return, a dyn-valued index slot): the
|
|
6745
6396
|
// static→dyn conversion — dynFrom, a DEEP COPY (the jsMarshal aliasing
|
|
@@ -6822,8 +6473,7 @@ export class Lowerer {
|
|
|
6822
6473
|
// A dyn ('unknown') ACTUAL flowing into a typed slot the checker
|
|
6823
6474
|
// approved (an assertion function's narrowing, the error-any world's
|
|
6824
6475
|
// forgiven chains): the VALIDATED extraction — dynCheck, the
|
|
6825
|
-
// checked-cast machinery, applied automatically.
|
|
6826
|
-
// exactly the island exit's stance: a value that doesn't match the
|
|
6476
|
+
// checked-cast machinery, applied automatically. A value outside the
|
|
6827
6477
|
// slot's type throws a catchable TypeError instead of misreading the
|
|
6828
6478
|
// payload. Only dynCheck's own domain (JSON-representable types,
|
|
6829
6479
|
// undefined-armed unions of those, bytes<u8>, the %Error root)
|
|
@@ -7114,17 +6764,15 @@ export class Lowerer {
|
|
|
7114
6764
|
return this.applyWidthLift(lift, expr, expected, expr.loc);
|
|
7115
6765
|
// Arms OUTSIDE widthLiftPlan's domain keep the historic per-arm
|
|
7116
6766
|
// widthCoerce probe (first match): index-signature record arms (the
|
|
7117
|
-
// overflow CAPTURE helper owns their reshapes)
|
|
7118
|
-
//
|
|
7119
|
-
//
|
|
7120
|
-
// never undone by a first-match fallback.
|
|
6767
|
+
// overflow CAPTURE helper owns their reshapes). Exclude shapes
|
|
6768
|
+
// already owned by the plan so first-match fallback cannot undo
|
|
6769
|
+
// its ambiguity rule for record/array lifts.
|
|
7121
6770
|
{
|
|
7122
6771
|
const def = this.unions.get(expected.unionId);
|
|
7123
6772
|
if (def) {
|
|
7124
6773
|
for (let i = 0; i < def.arms.length; i++) {
|
|
7125
6774
|
const arm = def.arms[i];
|
|
7126
|
-
const boundaryArm =
|
|
7127
|
-
(arm.kind === "array" && arm.elem.kind === "jsval");
|
|
6775
|
+
const boundaryArm = arm.kind === "record" && this.shapes.get(arm.shapeId)?.indexValue !== undefined;
|
|
7128
6776
|
if (!boundaryArm)
|
|
7129
6777
|
continue;
|
|
7130
6778
|
const w = this.widthCoerce(expr, arm);
|
|
@@ -7259,27 +6907,6 @@ export class Lowerer {
|
|
|
7259
6907
|
deferredReadHelper(fromId, target, loc) {
|
|
7260
6908
|
return deferredReadHelper(this, fromId, target, loc);
|
|
7261
6909
|
}
|
|
7262
|
-
jsvalLiftable(t, visiting = new Set()) {
|
|
7263
|
-
return jsvalLiftable(this, t, visiting);
|
|
7264
|
-
}
|
|
7265
|
-
jsvalLiftExpr(e, loc) {
|
|
7266
|
-
return jsvalLiftExpr(this, e, loc);
|
|
7267
|
-
}
|
|
7268
|
-
unionToJsvalHelper(unionId, loc) {
|
|
7269
|
-
return unionToJsvalHelper(this, unionId, loc);
|
|
7270
|
-
}
|
|
7271
|
-
recordToJsvalHelper(shapeId, loc) {
|
|
7272
|
-
return recordToJsvalHelper(this, shapeId, loc);
|
|
7273
|
-
}
|
|
7274
|
-
arrayToJsvalHelper(elem, loc) {
|
|
7275
|
-
return arrayToJsvalHelper(this, elem, loc);
|
|
7276
|
-
}
|
|
7277
|
-
arrayToJsvalArrayHelper(fromElem, loc) {
|
|
7278
|
-
return arrayToJsvalArrayHelper(this, fromElem, loc);
|
|
7279
|
-
}
|
|
7280
|
-
jsvalIn(e, node) {
|
|
7281
|
-
return jsvalIn(this, e, node);
|
|
7282
|
-
}
|
|
7283
6910
|
/** THE coercion path for values flowing into a typed slot: union arms
|
|
7284
6911
|
* wrap implicitly (coerceToExpected), then the exact-type fence runs
|
|
7285
6912
|
* (SC2002 for record shapes, SC2003 for unions). Every slot-directed
|
|
@@ -7341,17 +6968,7 @@ export class Lowerer {
|
|
|
7341
6968
|
}
|
|
7342
6969
|
}
|
|
7343
6970
|
}
|
|
7344
|
-
let e = this.
|
|
7345
|
-
expr.type.kind === "dyn" &&
|
|
7346
|
-
expected.kind === "array" &&
|
|
7347
|
-
expected.elem.kind === "jsval"
|
|
7348
|
-
? {
|
|
7349
|
-
kind: "jsExit",
|
|
7350
|
-
value: this.jsvalIn(expr, node),
|
|
7351
|
-
type: expected,
|
|
7352
|
-
loc: expr.loc,
|
|
7353
|
-
}
|
|
7354
|
-
: this.coerceToExpected(expr, expected);
|
|
6971
|
+
let e = this.coerceToExpected(expr, expected);
|
|
7355
6972
|
// Keep storage intact when ordinary widening already accepts it. Only
|
|
7356
6973
|
// a destination needing a more specific class layout uses the site's
|
|
7357
6974
|
// refinement and checked extraction.
|
|
@@ -7375,24 +6992,6 @@ export class Lowerer {
|
|
|
7375
6992
|
e.value.type.kind === "array") {
|
|
7376
6993
|
e = { ...e, liveRef: true };
|
|
7377
6994
|
}
|
|
7378
|
-
// An 'any' value PROVABLY null/undefined (the unit literal itself, or
|
|
7379
|
-
// a read of a binding nothing ever assigns a non-unit value) flowing
|
|
7380
|
-
// implicitly into a primitive slot: the validated exit refuses units
|
|
7381
|
-
// unconditionally, so every run would throw the boundary TypeError
|
|
7382
|
-
// where Node proceeds silently. A failure certain at compile time is
|
|
7383
|
-
// a fence, not a runtime surprise. Explicit casts keep their runtime
|
|
7384
|
-
// checked-cast semantics (the cast lowering builds its own jsExit
|
|
7385
|
-
// before this runs, so `e !== expr` skips them), and union/composite
|
|
7386
|
-
// targets keep the runtime exit (an undefined-armed union ACCEPTS the
|
|
7387
|
-
// engine's undefined; composite validation is dynCheck's business).
|
|
7388
|
-
if (e !== expr &&
|
|
7389
|
-
e.kind === "jsExit" &&
|
|
7390
|
-
(e.type.kind === "f64" || e.type.kind === "string" || e.type.kind === "bool")) {
|
|
7391
|
-
const unit = this.provenUnitAnyOf(node, e.value);
|
|
7392
|
-
if (unit !== null) {
|
|
7393
|
-
this.unsupported("SC1090", node, `an 'any' value that is always ${unit} flowing into a '${this.fmt(expected)}' slot (nothing in the program gives this value another shape, and the island boundary's validated exit refuses ${unit} — every run would throw a TypeError where Node proceeds silently)`, `give the binding a value other than ${unit} before this use, or keep the slot's type 'any'`);
|
|
7394
|
-
}
|
|
7395
|
-
}
|
|
7396
6995
|
// A closure that just BOXED into dyn takes its best-effort JS name
|
|
7397
6996
|
// from the source node (identifier reads, named function expressions,
|
|
7398
6997
|
// NamedEvaluation through a variable initializer) — inspect prints
|
|
@@ -7428,34 +7027,12 @@ export class Lowerer {
|
|
|
7428
7027
|
}
|
|
7429
7028
|
}
|
|
7430
7029
|
}
|
|
7431
|
-
// A JS FUNC value outside the island marshal set flowing into a
|
|
7432
|
-
// jsval slot (`withPlugins(getSupportInfoWithoutPlugins, 0)` — a
|
|
7433
|
-
// wrapper built at module init around a function the run may never
|
|
7434
|
-
// call): the crossing defers to a call-time fence closure instead of
|
|
7435
|
-
// stopping the statement — jsvalIn's deferral, the implicit-coercion
|
|
7436
|
-
// spelling.
|
|
7437
|
-
if (expected.kind === "jsval" && e.type.kind === "func" && !typeEquals(e.type, expected)) {
|
|
7438
|
-
const diagsBefore = this.diags.length;
|
|
7439
|
-
try {
|
|
7440
|
-
this.requireExactShape(node, e.type, expected);
|
|
7441
|
-
}
|
|
7442
|
-
catch (err) {
|
|
7443
|
-
if (!(err instanceof PoisonError))
|
|
7444
|
-
throw err;
|
|
7445
|
-
const fence = islandFuncValueFence(this, diagsBefore, node);
|
|
7446
|
-
if (fence)
|
|
7447
|
-
return fence;
|
|
7448
|
-
throw err;
|
|
7449
|
-
}
|
|
7450
|
-
return e;
|
|
7451
|
-
}
|
|
7452
7030
|
this.requireExactShape(node, e.type, expected);
|
|
7453
7031
|
return e;
|
|
7454
7032
|
}
|
|
7455
7033
|
/** The unit an 'any' expression PROVABLY holds on every run, or null
|
|
7456
|
-
* when no proof exists.
|
|
7457
|
-
*
|
|
7458
|
-
* or the node is an identifier whose every declaration is a plain,
|
|
7034
|
+
* when no proof exists. The node must be an identifier whose every
|
|
7035
|
+
* declaration is a plain,
|
|
7459
7036
|
* non-ambient `var`/`let`/`const` declarator under a variable STATEMENT
|
|
7460
7037
|
* (catch bindings, for-of/for-in cursors, parameters, and imports all
|
|
7461
7038
|
* fail this shape test — each receives values from elsewhere), each
|
|
@@ -7466,13 +7043,7 @@ export class Lowerer {
|
|
|
7466
7043
|
* bindings are read-only, so cross-file writes don't exist). A hoisted
|
|
7467
7044
|
* `var` read before its unit-initialized statement holds undefined —
|
|
7468
7045
|
* also a unit — so the mixed case reports both names. */
|
|
7469
|
-
provenUnitAnyOf(node,
|
|
7470
|
-
if (value.kind === "jsOp" && value.args.length === 0) {
|
|
7471
|
-
if (value.op === "undefLit")
|
|
7472
|
-
return "undefined";
|
|
7473
|
-
if (value.op === "nullLit")
|
|
7474
|
-
return "null";
|
|
7475
|
-
}
|
|
7046
|
+
provenUnitAnyOf(node, _value) {
|
|
7476
7047
|
let n = node;
|
|
7477
7048
|
while (ts.isParenthesizedExpression(n))
|
|
7478
7049
|
n = n.expression;
|
|
@@ -7580,7 +7151,6 @@ export class Lowerer {
|
|
|
7580
7151
|
const from = this.mapTypeOf(this.typeOf(asserted.expression));
|
|
7581
7152
|
const to = this.mapTypeOf(this.checker.getTypeFromTypeNode(asserted.type));
|
|
7582
7153
|
if (from?.kind === "dyn" ||
|
|
7583
|
-
from?.kind === "jsval" ||
|
|
7584
7154
|
(from?.kind === "record" && to?.kind === "record" && !typeEquals(from, to))) {
|
|
7585
7155
|
this.noLowering("collection key assertion requiring a structural copy or dynamic conversion", asserted, "use the original reference with the same type as the collection key");
|
|
7586
7156
|
}
|
|
@@ -7594,7 +7164,7 @@ export class Lowerer {
|
|
|
7594
7164
|
(from.kind === "object" &&
|
|
7595
7165
|
to.kind === "object" &&
|
|
7596
7166
|
this.isSubclassOf(from.className, to.className))));
|
|
7597
|
-
if (!preservesIdentity || value.kind === "dynCheck"
|
|
7167
|
+
if (!preservesIdentity || value.kind === "dynCheck") {
|
|
7598
7168
|
this.noLowering(`collection key conversion from '${this.fmt(value.type)}' to '${this.fmt(expected)}' requiring a structural copy or dynamic conversion`, node, "use the same reference type for the key and collection; copying a key would change its identity");
|
|
7599
7169
|
}
|
|
7600
7170
|
return this.coerceInto(node, value, expected);
|
|
@@ -7786,11 +7356,6 @@ export class Lowerer {
|
|
|
7786
7356
|
if (value.kind === "unitLit") {
|
|
7787
7357
|
return { kind: "dynFrom", value, type: DYN, loc: value.loc };
|
|
7788
7358
|
}
|
|
7789
|
-
// An ISLAND ('any') value: the by-reference jsval→dyn wrap — the same
|
|
7790
|
-
// edge coerceToExpected converts (dyn slots accept engine values).
|
|
7791
|
-
if (value.type.kind === "jsval") {
|
|
7792
|
-
return { kind: "dynFromJsval", value, type: DYN, loc: value.loc };
|
|
7793
|
-
}
|
|
7794
7359
|
if (!this.dynConvertible(value.type)) {
|
|
7795
7360
|
this.unsupported("SC1100", node, `storing '${this.fmt(value.type)}' values under an 'unknown'-valued index signature (only numbers, strings, booleans, and JSON-safe records/arrays/unions convert)`);
|
|
7796
7361
|
}
|
|
@@ -7987,18 +7552,7 @@ export class Lowerer {
|
|
|
7987
7552
|
}
|
|
7988
7553
|
return { kind: "boolLit", value: true, type: BOOL, loc };
|
|
7989
7554
|
}
|
|
7990
|
-
/** The entry value of a binding JS initializes to `undefined` (an
|
|
7991
|
-
* initializer-less declaration, a hoisted `var` before its statement):
|
|
7992
|
-
* undefined-armed unions hold the interned undefined arm, and 'any'
|
|
7993
|
-
* slots hold the ENGINE's undefined — tsc's definite-assignment
|
|
7994
|
-
* analysis never guards `any` reads, so a jsval slot IS readable before
|
|
7995
|
-
* any assignment and must never stay a C-level NULL (a validated exit
|
|
7996
|
-
* or engine op on NULL is memory-unsafe, not a TypeError). Null for
|
|
7997
|
-
* every other type: tsc rejects their pre-assignment reads. */
|
|
7998
7555
|
unassignedSlotInit(type, loc) {
|
|
7999
|
-
if (type.kind === "jsval") {
|
|
8000
|
-
return { kind: "jsOp", op: "undefLit", args: [], type: JSVAL, loc };
|
|
8001
|
-
}
|
|
8002
7556
|
return this.wrappedUndefined(type, loc);
|
|
8003
7557
|
}
|
|
8004
7558
|
undefinedArgFor(type, loc, blame) {
|
|
@@ -8524,24 +8078,19 @@ export class Lowerer {
|
|
|
8524
8078
|
// identifier-param prologue's ternary), then destructure the
|
|
8525
8079
|
// picked value.
|
|
8526
8080
|
const abi = shape.type;
|
|
8527
|
-
if (abi.kind === "dyn"
|
|
8528
|
-
//
|
|
8529
|
-
//
|
|
8530
|
-
// dynamic dyn): the slot holds its tier's undefined directly,
|
|
8531
|
-
// so the default test is the runtime undefined test — then
|
|
8532
|
-
// the pattern destructures the picked value.
|
|
8081
|
+
if (abi.kind === "dyn") {
|
|
8082
|
+
// The checked-value slot holds native undefined directly.
|
|
8083
|
+
// Test it at runtime, then destructure the selected value.
|
|
8533
8084
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8534
8085
|
const src = this.declareHiddenLocal("%psrc", abi);
|
|
8535
8086
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8536
|
-
const isUndef =
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
}
|
|
8544
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8087
|
+
const isUndef = {
|
|
8088
|
+
kind: "dynTest",
|
|
8089
|
+
test: "undefined",
|
|
8090
|
+
value: inRef(),
|
|
8091
|
+
type: BOOL,
|
|
8092
|
+
loc,
|
|
8093
|
+
};
|
|
8545
8094
|
prologue.push({
|
|
8546
8095
|
kind: "varDecl",
|
|
8547
8096
|
localId: src.id,
|
|
@@ -8641,24 +8190,20 @@ export class Lowerer {
|
|
|
8641
8190
|
const name = decl.name.text;
|
|
8642
8191
|
if (shape.mode === "omittable" && shape.bodyType && decl.initializer) {
|
|
8643
8192
|
const abi = shape.type;
|
|
8644
|
-
if (abi.kind === "dyn"
|
|
8645
|
-
//
|
|
8646
|
-
//
|
|
8647
|
-
// dynamic dyn): the slot holds its tier's undefined directly —
|
|
8648
|
-
// the body local picks the default on the runtime test.
|
|
8193
|
+
if (abi.kind === "dyn") {
|
|
8194
|
+
// The checked-value slot holds native undefined directly;
|
|
8195
|
+
// the body local selects the default with a runtime test.
|
|
8649
8196
|
const loc = locOf(decl);
|
|
8650
8197
|
const slot = this.declareHiddenLocal(name, abi);
|
|
8651
8198
|
params.push({ localId: slot.id, name, type: abi });
|
|
8652
8199
|
const inRef = () => ({ kind: "varRef", localId: slot.id, type: abi, loc });
|
|
8653
|
-
const isUndef =
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
}
|
|
8661
|
-
: { kind: "dynTest", test: "undefined", value: inRef(), type: BOOL, loc };
|
|
8200
|
+
const isUndef = {
|
|
8201
|
+
kind: "dynTest",
|
|
8202
|
+
test: "undefined",
|
|
8203
|
+
value: inRef(),
|
|
8204
|
+
type: BOOL,
|
|
8205
|
+
loc,
|
|
8206
|
+
};
|
|
8662
8207
|
const dflt = defaultValue(decl.initializer, abi);
|
|
8663
8208
|
const body = this.declareLocal(decl.name, name, abi, true);
|
|
8664
8209
|
prologue.push({
|
|
@@ -8841,13 +8386,6 @@ export class Lowerer {
|
|
|
8841
8386
|
resolveThis() {
|
|
8842
8387
|
return this.resolveKey(undefined);
|
|
8843
8388
|
}
|
|
8844
|
-
/** READ-ONLY twin of resolveLocal for PROBES (isIslandExpr): answers
|
|
8845
|
-
* the nearest binding entry without boxing, threading, or predeclaring.
|
|
8846
|
-
* resolveKey mutates capture state as a side effect, and a speculative
|
|
8847
|
-
* island-ness query through a context that takes no captures (a plain
|
|
8848
|
-
* declared function between the origin and the reference) was an ICE —
|
|
8849
|
-
* the REAL lowering path still resolves (and diagnoses) the reference
|
|
8850
|
-
* itself. */
|
|
8851
8389
|
peekLocal(ident) {
|
|
8852
8390
|
let symbol = this.checker.getSymbolAtLocation(ident);
|
|
8853
8391
|
if (ident.parent &&
|
|
@@ -9015,79 +8553,6 @@ export class Lowerer {
|
|
|
9015
8553
|
allowDynObject ||=
|
|
9016
8554
|
srcType.kind === "dyn" && isParseArgsDynCheckerType(this, this.typeOf(pattern));
|
|
9017
8555
|
}
|
|
9018
|
-
// An ISLAND source (`const { readFileSync } = await import("fs")` —
|
|
9019
|
-
// a namespace handle, or any 'any'-typed object): each bound name is
|
|
9020
|
-
// an engine property read, mirroring the island property-read rule —
|
|
9021
|
-
// a member the .d.ts declares as a primitive exits eagerly to the
|
|
9022
|
-
// static type; everything else (including members whose declared
|
|
9023
|
-
// types have no static mapping, like @types/node's function types)
|
|
9024
|
-
// stays a HANDLE, and its use sites dispatch to engine ops. Patterns
|
|
9025
|
-
// the element-wise walk cannot spell — ARRAY patterns (the iterator
|
|
9026
|
-
// protocol), empty patterns (the coercion checks), holes, rest,
|
|
9027
|
-
// defaults — run the REAL pattern in a synthesized engine function
|
|
9028
|
-
// instead (lowerJsvalBindingPattern).
|
|
9029
|
-
const elementWise = srcType.kind === "jsval" &&
|
|
9030
|
-
ts.isObjectBindingPattern(pattern) &&
|
|
9031
|
-
pattern.elements.length > 0 &&
|
|
9032
|
-
pattern.elements.every((el) => !el.dotDotDotToken &&
|
|
9033
|
-
!el.initializer &&
|
|
9034
|
-
el.name !== undefined &&
|
|
9035
|
-
ts.isIdentifier(el.propertyName ?? el.name));
|
|
9036
|
-
if (srcType.kind === "jsval" && !elementWise) {
|
|
9037
|
-
if (lowerJsvalBindingPattern(this, pattern, srcRef, isLet, out))
|
|
9038
|
-
return;
|
|
9039
|
-
// No engine form (computed keys, untransportable defaults): fall
|
|
9040
|
-
// through to the static fences below.
|
|
9041
|
-
}
|
|
9042
|
-
if (srcType.kind === "jsval" && ts.isObjectBindingPattern(pattern)) {
|
|
9043
|
-
for (const el of pattern.elements) {
|
|
9044
|
-
this.checkBindingElement(el);
|
|
9045
|
-
// 7's BindingElement declares name optional (array elisions are
|
|
9046
|
-
// nameless there); object-pattern elements always carry one.
|
|
9047
|
-
if (el.name === undefined)
|
|
9048
|
-
continue;
|
|
9049
|
-
const prop = el.propertyName ?? el.name;
|
|
9050
|
-
if (!ts.isIdentifier(prop)) {
|
|
9051
|
-
this.unsupported("SC1031", el, "destructuring with computed or non-identifier keys");
|
|
9052
|
-
}
|
|
9053
|
-
const loc = locOf(el);
|
|
9054
|
-
const read = {
|
|
9055
|
-
kind: "jsOp",
|
|
9056
|
-
op: "getProp",
|
|
9057
|
-
name: prop.text,
|
|
9058
|
-
args: [srcRef()],
|
|
9059
|
-
type: JSVAL,
|
|
9060
|
-
loc,
|
|
9061
|
-
};
|
|
9062
|
-
if (!ts.isIdentifier(el.name)) {
|
|
9063
|
-
// A nested pattern reads through its own handle temp.
|
|
9064
|
-
const tmp = this.declareHiddenLocal("%destr", JSVAL);
|
|
9065
|
-
out.push({ kind: "varDecl", localId: tmp.id, init: read, loc });
|
|
9066
|
-
this.lowerBindingPattern(el.name, () => ({ kind: "varRef", localId: tmp.id, type: JSVAL, loc }), JSVAL, isLet, out);
|
|
9067
|
-
continue;
|
|
9068
|
-
}
|
|
9069
|
-
const declared = this.mapTypeOf(this.typeOf(el.name));
|
|
9070
|
-
const primitive = declared &&
|
|
9071
|
-
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string");
|
|
9072
|
-
const value = primitive
|
|
9073
|
-
? { kind: "jsExit", value: read, type: declared, loc }
|
|
9074
|
-
: read;
|
|
9075
|
-
const symbol = this.checker.getSymbolAtLocation(el.name);
|
|
9076
|
-
const g = symbol ? this.globalsBySymbol.get(symbol) : undefined;
|
|
9077
|
-
if (g) {
|
|
9078
|
-
out.push({
|
|
9079
|
-
kind: "assign",
|
|
9080
|
-
localId: g.id,
|
|
9081
|
-
value: this.coerceInto(el.name, value, g.type),
|
|
9082
|
-
loc,
|
|
9083
|
-
});
|
|
9084
|
-
continue;
|
|
9085
|
-
}
|
|
9086
|
-
const local = this.declareLocal(el.name, el.name.text, value.type, isLet);
|
|
9087
|
-
out.push({ kind: "varDecl", localId: local.id, init: value, loc });
|
|
9088
|
-
}
|
|
9089
|
-
return;
|
|
9090
|
-
}
|
|
9091
8556
|
return lowerBindingPattern(this, pattern, srcRef, srcType, isLet, out, dynSpell, allowDynObject);
|
|
9092
8557
|
}
|
|
9093
8558
|
checkBindingElement(el, allowDefault = false) {
|
|
@@ -9100,97 +8565,6 @@ export class Lowerer {
|
|
|
9100
8565
|
return lowerVarDeclList(this, list);
|
|
9101
8566
|
}
|
|
9102
8567
|
lowerVarDecl(decl, isLet) {
|
|
9103
|
-
// ISLAND-HANDLE rescue (--dynamic): `const factory = (await
|
|
9104
|
-
// import("./x.mjs")).default` / `const buf = islandReadFileSync(p)` —
|
|
9105
|
-
// a binding whose DECLARED type either has no static mapping or has
|
|
9106
|
-
// one no island value can EXIT to (bytes, functions, promises), but
|
|
9107
|
-
// whose initializer is an island value. The declared type is a .d.ts
|
|
9108
|
-
// surface over an engine value; the binding stays a HANDLE (jsval
|
|
9109
|
-
// local) and typed use sites go through engine ops and validated
|
|
9110
|
-
// exits like any island value. Exit-CAPABLE declared types (numbers,
|
|
9111
|
-
// strings, JSON-safe composites, their undefined-armed unions) keep
|
|
9112
|
-
// the standard path and its validated-exit machinery; so does
|
|
9113
|
-
// everything non-island — including badType here when the
|
|
9114
|
-
// initializer turns out not to be island-typed, which is exactly
|
|
9115
|
-
// what the standard path would have reported.
|
|
9116
|
-
// Only reference-shaped initializers are candidates (awaits, calls,
|
|
9117
|
-
// member reads, identifiers, casts/parens over those): they are the
|
|
9118
|
-
// island producers, and re-lowering one on the fall-through emits
|
|
9119
|
-
// nothing twice — a lambda or literal initializer would (each
|
|
9120
|
-
// lowering mints a fresh %fn), and is never an island value anyway.
|
|
9121
|
-
const islandCandidate = (e) => {
|
|
9122
|
-
let cur = e;
|
|
9123
|
-
while (ts.isParenthesizedExpression(cur) ||
|
|
9124
|
-
ts.isAsExpression(cur) ||
|
|
9125
|
-
ts.isTypeAssertion(cur) ||
|
|
9126
|
-
ts.isNonNullExpression(cur)) {
|
|
9127
|
-
cur = cur.expression;
|
|
9128
|
-
}
|
|
9129
|
-
if (!ts.isAwaitExpression(cur) &&
|
|
9130
|
-
!ts.isCallExpression(cur) &&
|
|
9131
|
-
!ts.isPropertyAccessExpression(cur) &&
|
|
9132
|
-
!ts.isElementAccessExpression(cur) &&
|
|
9133
|
-
!ts.isIdentifier(cur)) {
|
|
9134
|
-
return false;
|
|
9135
|
-
}
|
|
9136
|
-
// A lambda ANYWHERE inside (a call argument) would emit its %fn
|
|
9137
|
-
// twice across the fall-through's re-lowering — skip those.
|
|
9138
|
-
let lambda = false;
|
|
9139
|
-
const scan = (n) => {
|
|
9140
|
-
if (lambda)
|
|
9141
|
-
return;
|
|
9142
|
-
if (ts.isArrowFunction(n) || ts.isFunctionExpression(n)) {
|
|
9143
|
-
lambda = true;
|
|
9144
|
-
return;
|
|
9145
|
-
}
|
|
9146
|
-
ts.forEachChild(n, scan);
|
|
9147
|
-
};
|
|
9148
|
-
scan(cur);
|
|
9149
|
-
return !lambda;
|
|
9150
|
-
};
|
|
9151
|
-
if (this.dynamic &&
|
|
9152
|
-
ts.isIdentifier(decl.name) &&
|
|
9153
|
-
decl.initializer !== undefined &&
|
|
9154
|
-
// `var` stays out: the rescue's block-positioned jsval local can't
|
|
9155
|
-
// model the function-scoped hoisted binding (a redeclaration or an
|
|
9156
|
-
// out-of-block read would split the variable in two) — vars take the
|
|
9157
|
-
// standard path and its own fences.
|
|
9158
|
-
(ts.getCombinedNodeFlags(decl) & ts.NodeFlags.BlockScoped) !== 0 &&
|
|
9159
|
-
islandCandidate(decl.initializer) &&
|
|
9160
|
-
// createRequire's plumbing decls are COMPILE-TIME erasures (the
|
|
9161
|
-
// require binding and its builtin-namespace bindings) — never
|
|
9162
|
-
// island values; the standard path's skips own them.
|
|
9163
|
-
!createRequireBindingDecl(this, decl.name, decl.initializer) &&
|
|
9164
|
-
!createRequireNamespaceDecl(this, decl.name, decl.initializer)) {
|
|
9165
|
-
const mapped = this.mapTypeOf(this.typeOf(decl.name));
|
|
9166
|
-
const handleOnly = mapped === null ||
|
|
9167
|
-
(mapped.kind !== "jsval" &&
|
|
9168
|
-
mapped.kind !== "void" &&
|
|
9169
|
-
!canExitIslandToType(mapped, (id) => this.shapes.get(id), (id) => this.unions.get(id)));
|
|
9170
|
-
const symbol = this.checker.getSymbolAtLocation(decl.name);
|
|
9171
|
-
if (handleOnly && (!symbol || !this.globalsBySymbol.has(symbol))) {
|
|
9172
|
-
const init = this.lowerExpr(decl.initializer);
|
|
9173
|
-
if (init.type.kind === "jsval") {
|
|
9174
|
-
const local = this.declareLocal(decl.name, decl.name.text, JSVAL, isLet);
|
|
9175
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9176
|
-
}
|
|
9177
|
-
// The CHECKED-DYNAMIC twin of the handle rescue (the runtime-world
|
|
9178
|
-
// local rule): an unmappable declared type over a dyn initializer
|
|
9179
|
-
// (`const first = plugins[0]` — the checker spells 'string |
|
|
9180
|
-
// object' while the read is a dyn keyed read) keeps the binding
|
|
9181
|
-
// dyn; typed use sites ride validated extractions and the routed
|
|
9182
|
-
// engine ops, exactly the JSON.parse-binding story.
|
|
9183
|
-
if (mapped === null && init.type.kind === "dyn") {
|
|
9184
|
-
const local = this.declareLocal(decl.name, decl.name.text, DYN, isLet);
|
|
9185
|
-
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
9186
|
-
}
|
|
9187
|
-
if (mapped === null)
|
|
9188
|
-
this.badType(decl.name, this.typeOf(decl.name));
|
|
9189
|
-
// A mappable declared type with a non-island initializer: the
|
|
9190
|
-
// standard path owns it (the initializer lowered clean; re-running
|
|
9191
|
-
// it re-produces the same IR with no duplicate diagnostics).
|
|
9192
|
-
}
|
|
9193
|
-
}
|
|
9194
8568
|
return lowerVarDecl(this, decl, isLet);
|
|
9195
8569
|
}
|
|
9196
8570
|
lowerSwitch(stmt) {
|
|
@@ -9252,13 +8626,6 @@ export class Lowerer {
|
|
|
9252
8626
|
nodeTypesOnlySymbol(sym) {
|
|
9253
8627
|
return nodeTypesOnlySymbol(this, sym);
|
|
9254
8628
|
}
|
|
9255
|
-
/** True for an npm package's shipped declaration files — under
|
|
9256
|
-
* node_modules but NOT the standard library (typescript's own lib files
|
|
9257
|
-
* live under node_modules too), or inside a registered workspace-linked
|
|
9258
|
-
* package (a node_modules symlink whose realpath'd files carry no
|
|
9259
|
-
* node_modules segment — workspace-registry.ts). The provenance half of the npm
|
|
9260
|
-
* typing rule (package types are island handles) and of the per-package
|
|
9261
|
-
* requires-dynamic attribution. */
|
|
9262
8629
|
isNpmFile = (sf) => sf.isDeclarationFile &&
|
|
9263
8630
|
(sf.fileName.includes("/node_modules/") || workspacePackageOfPath(sf.fileName) !== null) &&
|
|
9264
8631
|
!this.isStdlibFile(sf);
|
|
@@ -9372,40 +8739,6 @@ export class Lowerer {
|
|
|
9372
8739
|
return lowerTemplate(this, expr);
|
|
9373
8740
|
}
|
|
9374
8741
|
lowerAsExpression(expr) {
|
|
9375
|
-
// ISLAND value cast to a PROMISE type (`factory(opts) as Promise<Mod>`
|
|
9376
|
-
// — the Node-typed async-API shape): promises never have a validated
|
|
9377
|
-
// exit, so instead of refusing the build the cast DEFERS the failure
|
|
9378
|
-
// to runtime — island.castFail evaluates the value (its side effects
|
|
9379
|
-
// are real) and throws a catchable TypeError naming the target, so
|
|
9380
|
-
// typed-but-never-executed code (a wasm decode path behind a
|
|
9381
|
-
// rejecting import) still compiles and a reached cast fails loudly at
|
|
9382
|
-
// the exact site. Claimed only when the source is island-typed by the
|
|
9383
|
-
// checker (jsval, or a promise whose inner is a handle); a source
|
|
9384
|
-
// that lowers to a real static promise keeps erasure — the standard
|
|
9385
|
-
// path's rule for non-island inners. Static builds keep their
|
|
9386
|
-
// per-site diagnostics.
|
|
9387
|
-
if (this.dynamic) {
|
|
9388
|
-
const srcMapped = this.mapTypeOf(this.typeOf(expr.expression));
|
|
9389
|
-
const island = srcMapped?.kind === "jsval" ||
|
|
9390
|
-
(srcMapped?.kind === "promise" && srcMapped.inner.kind === "jsval");
|
|
9391
|
-
if (island) {
|
|
9392
|
-
const targetTs = this.checker.getTypeFromTypeNode(expr.type);
|
|
9393
|
-
const target = this.mapTypeOf(targetTs);
|
|
9394
|
-
if (target?.kind === "promise") {
|
|
9395
|
-
const inner = this.lowerExpr(expr.expression);
|
|
9396
|
-
if (inner.type.kind !== "jsval")
|
|
9397
|
-
return inner; // static promise: erasure
|
|
9398
|
-
const loc = locOf(expr);
|
|
9399
|
-
const name = {
|
|
9400
|
-
kind: "strLit",
|
|
9401
|
-
value: this.fmt(target),
|
|
9402
|
-
type: STRING,
|
|
9403
|
-
loc,
|
|
9404
|
-
};
|
|
9405
|
-
return { kind: "libCall", fn: "island.castFail", args: [inner, name], type: target, loc };
|
|
9406
|
-
}
|
|
9407
|
-
}
|
|
9408
|
-
}
|
|
9409
8742
|
return lowerAsExpression(this, expr);
|
|
9410
8743
|
}
|
|
9411
8744
|
lowerPrefixUnary(expr) {
|
|
@@ -9537,8 +8870,6 @@ export class Lowerer {
|
|
|
9537
8870
|
}
|
|
9538
8871
|
}
|
|
9539
8872
|
lowerCall(expr) {
|
|
9540
|
-
// Ambient fetch (native in static builds, island-backed under
|
|
9541
|
-
// --dynamic) and dynamic import() claim their calls before the general
|
|
9542
8873
|
// dispatch. The general identifier-call paths have no lowering for a
|
|
9543
8874
|
// promise-returning ambient global, and `import` is a keyword callee no
|
|
9544
8875
|
// identifier path matches.
|
|
@@ -9677,33 +9008,6 @@ export class Lowerer {
|
|
|
9677
9008
|
return inheritsBuiltinEmitterCtor(this, info);
|
|
9678
9009
|
}
|
|
9679
9010
|
lowerNew(expr) {
|
|
9680
|
-
// `new Uint8Array(handle)` (and the other typed-array ctors) over an
|
|
9681
|
-
// ISLAND argument: the construction is an ENGINE operation — the
|
|
9682
|
-
// engine's own constructor over the engine's own value (an Emscripten
|
|
9683
|
-
// factory's `wasmBinary: new Uint8Array(buf)` where buf came off an
|
|
9684
|
-
// island readFileSync) — and the instance stays a handle. The static
|
|
9685
|
-
// bytes ctor cannot claim it (bytes never cross the boundary), so
|
|
9686
|
-
// this preempts only when the single argument is island-typed;
|
|
9687
|
-
// every static form keeps the standard path.
|
|
9688
|
-
if (this.dynamic &&
|
|
9689
|
-
ts.isIdentifier(expr.expression) &&
|
|
9690
|
-
expr.arguments?.length === 1 &&
|
|
9691
|
-
!ts.isSpreadElement(expr.arguments[0]) &&
|
|
9692
|
-
/^(Uint8|Uint8Clamped|Int8|Uint16|Int16|Uint32|Int32|Float32|Float64|BigInt64|BigUint64)Array$/.test(expr.expression.text) &&
|
|
9693
|
-
this.isStdlibSymbol(this.resolveValueSymbol(expr.expression) ?? undefined) &&
|
|
9694
|
-
this.isIslandExpr(expr.arguments[0])) {
|
|
9695
|
-
const loc = locOf(expr);
|
|
9696
|
-
const ctor = {
|
|
9697
|
-
kind: "jsOp",
|
|
9698
|
-
op: "globalGet",
|
|
9699
|
-
name: expr.expression.text,
|
|
9700
|
-
args: [],
|
|
9701
|
-
type: JSVAL,
|
|
9702
|
-
loc,
|
|
9703
|
-
};
|
|
9704
|
-
const arg = this.lowerExpr(expr.arguments[0]);
|
|
9705
|
-
return { kind: "jsOp", op: "construct", args: [ctor, arg], type: JSVAL, loc };
|
|
9706
|
-
}
|
|
9707
9011
|
const builtin = lowerAbortControllerNew(this, expr) ??
|
|
9708
9012
|
lowerFetchWebNew(this, expr) ??
|
|
9709
9013
|
lowerResponseNew(this, expr) ??
|
|
@@ -10343,18 +9647,17 @@ export class Lowerer {
|
|
|
10343
9647
|
lowerNumberStaticProperty(expr) {
|
|
10344
9648
|
return lowerNumberStaticProperty(this, expr);
|
|
10345
9649
|
}
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
return requireDynamicApi(this, feature, node, hint);
|
|
9650
|
+
refuseUnsupportedApi(feature, node, hint) {
|
|
9651
|
+
return refuseUnsupportedApi(this, feature, node, hint);
|
|
10349
9652
|
}
|
|
10350
9653
|
lowerMathProperty(expr) {
|
|
10351
9654
|
return lowerMathProperty(this, expr);
|
|
10352
9655
|
}
|
|
10353
|
-
|
|
10354
|
-
return
|
|
9656
|
+
stdlibGlobalFnOf(ident) {
|
|
9657
|
+
return stdlibGlobalFnOf(this, ident);
|
|
10355
9658
|
}
|
|
10356
|
-
|
|
10357
|
-
return
|
|
9659
|
+
lowerStdlibMethodCall(call, access) {
|
|
9660
|
+
return lowerStdlibMethodCall(this, call, access);
|
|
10358
9661
|
}
|
|
10359
9662
|
}
|
|
10360
9663
|
//# sourceMappingURL=lowerer.js.map
|