@scriptc/compiler 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +35 -5
- package/dist/backend/executable-features.js +7 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.js +3 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +2 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +1 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/array-search.js +3 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +27 -1
- package/dist/backend/llvm/classes.js +115 -22
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -9
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +21 -3
- package/dist/backend/llvm/common.js +50 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +3 -1
- package/dist/backend/llvm/dense-array-access.js +61 -38
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +4 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.js +3 -3
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +9 -0
- package/dist/backend/llvm/dyn.js +62 -6
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +5 -2
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +54 -32
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +3 -2
- package/dist/backend/llvm/emit-statements.js +90 -13
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +20 -9
- package/dist/backend/llvm/emitter.js +42 -31
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +17 -4
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +6 -9
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +46 -4
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +3 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +11 -15
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/integer-clones.js +3 -3
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +18 -0
- package/dist/backend/llvm/js-ic.js +712 -0
- package/dist/backend/llvm/js-ic.js.map +1 -0
- package/dist/backend/llvm/jsval.js +139 -11
- package/dist/backend/llvm/jsval.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +4 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +22 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +40 -31
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -4
- package/dist/backend/llvm/map-number-lookup.js +43 -7
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/narrow-guards.js +64 -0
- package/dist/backend/llvm/narrow-guards.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +36 -17
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/regions.js +2 -2
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/regions.test.js +7 -1
- package/dist/backend/llvm/regions.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +8 -2
- package/dist/backend/llvm/shapes.js +9 -7
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +20 -1
- package/dist/backend/llvm/speculative-integers.js +94 -6
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.test.js +55 -1
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +4 -4
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/thread-slots.test.js +5 -4
- package/dist/backend/llvm/thread-slots.test.js.map +1 -1
- package/dist/backend/mangle.d.ts +5 -0
- package/dist/backend/mangle.js +7 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +20 -0
- package/dist/backend/native/executable.js +20 -3
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +2 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +6 -0
- package/dist/backend/native-codegen.js +19 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +27 -0
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +18 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +32 -0
- package/dist/backend/native-profile.js +39 -0
- package/dist/backend/native-profile.js.map +1 -0
- package/dist/backend/native-profile.test.d.ts +1 -0
- package/dist/backend/native-profile.test.js +58 -0
- package/dist/backend/native-profile.test.js.map +1 -0
- package/dist/backend/native-tools.d.ts +14 -0
- package/dist/backend/native-tools.js +13 -0
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +4 -0
- package/dist/backend/runtime-pack-core.js +4 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +4 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +4 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +7 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +63 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +2 -0
- package/dist/cli/output-options.js +9 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +11 -1
- package/dist/cli/usage.js +23 -0
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +9 -0
- package/dist/contracts/check.js +1 -2
- package/dist/contracts/check.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +10 -0
- package/dist/executable/executable-cache.js +6 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +5 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/arguments-usage.d.ts +8 -0
- package/dist/frontend/arguments-usage.js +98 -0
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/arguments-usage.test.d.ts +1 -0
- package/dist/frontend/arguments-usage.test.js +32 -0
- package/dist/frontend/arguments-usage.test.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.d.ts +24 -0
- package/dist/frontend/builtin-package-aliases.js +133 -0
- package/dist/frontend/builtin-package-aliases.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
- package/dist/frontend/builtin-package-aliases.test.js +48 -0
- package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +4 -0
- package/dist/frontend/dts-paths.js +9 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.d.ts +8 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js +50 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +3 -2
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -0
- package/dist/frontend/lowering/builtins/crypto.js +4 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/ecdh.d.ts +10 -0
- package/dist/frontend/lowering/builtins/ecdh.js +208 -0
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.js +52 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +9 -0
- package/dist/frontend/lowering/builtins/process.js +44 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.d.ts +3 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js +21 -3
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +26 -0
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/timers.js +5 -1
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
- package/dist/frontend/lowering/call-signatures.d.ts +4 -0
- package/dist/frontend/lowering/call-signatures.js +126 -9
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js +34 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +9 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +10 -0
- package/dist/frontend/lowering/class-protocols.js +53 -3
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +6 -1
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +2 -2
- package/dist/frontend/lowering/class-to-primitive.js +6 -3
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
- package/dist/frontend/lowering/coercions/fresh-spread.d.ts +13 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +99 -70
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +22 -19
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +7 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +5 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +9 -0
- package/dist/frontend/lowering/containers/bytes.js +493 -17
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +72 -3
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +49 -13
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +26 -10
- package/dist/frontend/lowering/cycle-initialization.js +152 -35
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +33 -13
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +79 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +13 -6
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +14 -2
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +91 -10
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +17 -2
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +48 -1
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +12 -3
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +5 -0
- package/dist/frontend/lowering/expressions/property-access.js +252 -9
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +49 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +13 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +1 -1
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +191 -1
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +4 -0
- package/dist/frontend/lowering/generic-functions.js +213 -56
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +24 -0
- package/dist/frontend/lowering/handle-properties.js +281 -0
- package/dist/frontend/lowering/handle-properties.js.map +1 -0
- package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
- package/dist/frontend/lowering/iterable-spelling.js +38 -0
- package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +33 -15
- package/dist/frontend/lowering/lower-array-sort.js +117 -21
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +1 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +166 -7
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -0
- package/dist/frontend/lowering/lower-classes.js +59 -7
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +62 -13
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +32 -1
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +4 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +10 -4
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +569 -11
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +11 -3
- package/dist/frontend/lowering/lower-modules.js +212 -67
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +20 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +26 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +28 -9
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +7 -10
- package/dist/frontend/lowering/lower-stmts.js +418 -51
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +17 -1
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +29 -5
- package/dist/frontend/lowering/lowerer.js +172 -25
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/rebindable-functions.d.ts +8 -0
- package/dist/frontend/lowering/rebindable-functions.js +54 -0
- package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +26 -0
- package/dist/frontend/lowering/static-typeof.js +133 -0
- package/dist/frontend/lowering/static-typeof.js.map +1 -0
- package/dist/frontend/lowering/string-index-bounds.js +3 -2
- package/dist/frontend/lowering/string-index-bounds.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +30 -4
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/thenables.d.ts +16 -0
- package/dist/frontend/lowering/thenables.js +124 -0
- package/dist/frontend/lowering/thenables.js.map +1 -0
- package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
- package/dist/frontend/npm-static-builtin-aliases.js +65 -0
- package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.d.ts +8 -1
- package/dist/frontend/npm-static-bundled-chunks.js +173 -2
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +112 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.js +224 -4
- package/dist/frontend/npm-static-bundled-esm.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.test.js +129 -0
- package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -1
- package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
- package/dist/frontend/npm-static-enum-iife.js +280 -0
- package/dist/frontend/npm-static-enum-iife.js.map +1 -0
- package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
- package/dist/frontend/npm-static-enum-iife.test.js +116 -0
- package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +8 -0
- package/dist/frontend/npm-static.js +46 -1
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +13 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +47 -0
- package/dist/frontend/package-shims.js +300 -0
- package/dist/frontend/package-shims.js.map +1 -0
- package/dist/frontend/pipeline.js +67 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +8 -0
- package/dist/frontend/program.js +72 -9
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.js +13 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/services.d.ts +6 -0
- package/dist/frontend/services.js +19 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +6 -5
- package/dist/frontend/ts7/program-host.js +7 -0
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +3 -0
- package/dist/frontend/ts7/semantic-model.js +26 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +19 -4
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/type-mapper.js +201 -15
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +3 -2
- package/dist/ir/array-length-stability.js +15 -2
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +22 -1
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +13 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +46 -4
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +5 -0
- package/dist/ir/integer-loop-facts.js +79 -14
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +10 -1
- package/dist/ir/integer-ranges.js +122 -25
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +191 -1
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.js +8 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +52 -0
- package/dist/ir/js-ic.js +199 -0
- package/dist/ir/js-ic.js.map +1 -0
- package/dist/ir/js-ic.test.d.ts +1 -0
- package/dist/ir/js-ic.test.js +148 -0
- package/dist/ir/js-ic.test.js.map +1 -0
- package/dist/ir/jsval.js +38 -4
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +39 -4
- package/dist/ir/runtime-features.js +229 -99
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/traverse.js +110 -68
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +21 -8
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +15 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cli.js +17 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +33 -4
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.js +3 -0
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.js +3 -0
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +21 -20
- package/shims/fs-extra/core/api.ts +1192 -0
- package/shims/fs-extra/index.ts +9 -0
- package/shims/undici/core/agent.ts +163 -0
- package/shims/undici/core/api.ts +93 -0
- package/shims/undici/core/client.ts +1304 -0
- package/shims/undici/core/connector.ts +157 -0
- package/shims/undici/core/diagnostics-types.ts +68 -0
- package/shims/undici/core/diagnostics.ts +16 -0
- package/shims/undici/core/dispatcher.ts +574 -0
- package/shims/undici/core/errors-v5.ts +22 -0
- package/shims/undici/core/errors-v7.ts +25 -0
- package/shims/undici/core/errors.ts +255 -0
- package/shims/undici/core/fetch.ts +635 -0
- package/shims/undici/core/pool.ts +280 -0
- package/shims/undici/core/readable.ts +268 -0
- package/shims/undici/core/request.ts +313 -0
- package/shims/undici/core/timers.ts +80 -0
- package/shims/undici/core/types.ts +167 -0
- package/shims/undici/core/util.ts +67 -0
- package/shims/undici/v5.ts +119 -0
- package/shims/undici/v7.ts +119 -0
- package/surface-manifest.json +2 -4
|
@@ -101,9 +101,13 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
101
101
|
// reconcile bridge, like the non-generic path).
|
|
102
102
|
{
|
|
103
103
|
const rdecl = rsig ? rsig.declaration : undefined;
|
|
104
|
-
if (
|
|
104
|
+
if (rsig &&
|
|
105
|
+
rdecl &&
|
|
105
106
|
(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) &&
|
|
106
107
|
!rdecl.body) {
|
|
108
|
+
const overload = overloadCallInstance(lowerer, expr, info, rsig, rdecl);
|
|
109
|
+
if (overload)
|
|
110
|
+
return overload;
|
|
107
111
|
lowerer.unsupported("SC1090", expr, `calls selecting an overload signature of a generic ${ts.isMethodDeclaration(rdecl) ? "method" : "function"} (only the implementation signature monomorphizes)`);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -129,14 +133,7 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
129
133
|
fenceGenericSignatureResult(lowerer, expr, retTs);
|
|
130
134
|
lowerer.badType(expr, retTs);
|
|
131
135
|
}
|
|
132
|
-
|
|
133
|
-
// there, as in JavaScript, whatever the declared result says. An async
|
|
134
|
-
// body's promise is always present and settles with undefined there.
|
|
135
|
-
const returnType = lowerer.runtimeOptionalGenericReturns.has(info.decl)
|
|
136
|
-
? mappedReturn.kind === "promise"
|
|
137
|
-
? { kind: "promise", inner: lowerer.runtimeOptionalType(mappedReturn.inner) }
|
|
138
|
-
: lowerer.runtimeOptionalType(mappedReturn)
|
|
139
|
-
: mappedReturn;
|
|
136
|
+
const returnType = runtimeReturnType(lowerer, info, mappedReturn);
|
|
140
137
|
// keyof-constrained type parameters (`K extends keyof T`): the bound
|
|
141
138
|
// LITERAL is semantic — the instance body reads the named field — so
|
|
142
139
|
// the bindings compute EAGERLY (the key needs them) and each literal
|
|
@@ -146,29 +143,112 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
146
143
|
// share one runtime-keyed instance per IR signature, exactly the
|
|
147
144
|
// widened discipline.
|
|
148
145
|
const named = staticNameBindings(lowerer, expr, info);
|
|
149
|
-
|
|
150
|
-
if (keyofTps.size > 0) {
|
|
146
|
+
if (keyofConstrainedTypeParams(info).size > 0) {
|
|
151
147
|
const tsBindings = new Map();
|
|
152
148
|
const bindings = lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings);
|
|
153
|
-
const litKey = info.typeParams
|
|
154
|
-
.filter((tp) => keyofTps.has(tp))
|
|
155
|
-
.map((tp) => {
|
|
156
|
-
const bound = tsBindings.get(tp);
|
|
157
|
-
return bound?.isStringLiteralType()
|
|
158
|
-
? JSON.stringify(bound.value)
|
|
159
|
-
: bound?.isNumberLiteralType()
|
|
160
|
-
? String(bound.value)
|
|
161
|
-
: "*";
|
|
162
|
-
})
|
|
163
|
-
.join(",");
|
|
164
149
|
return internGenericInstance(lowerer, expr, info, params, returnType, () => bindings, {
|
|
165
|
-
extraKey:
|
|
150
|
+
extraKey: `${keyofLiteralKey(info, tsBindings)}${named?.key ?? ""}`,
|
|
166
151
|
tsBindings,
|
|
167
152
|
...(named ? { staticFnNames: named.names } : {}),
|
|
168
153
|
});
|
|
169
154
|
}
|
|
170
155
|
return internGenericInstance(lowerer, expr, info, params, returnType, (tsBindings) => lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings), named ? { extraKey: named.key, staticFnNames: named.names } : undefined);
|
|
171
156
|
}
|
|
157
|
+
/** A call that resolved to an OVERLOAD signature of a generic function
|
|
158
|
+
* or method with an implementation (`request<T>(p: WithHandler<T>):
|
|
159
|
+
* Promise<T>; request(p: Plain): Promise<Res>; request<T>(p: Params<T>)
|
|
160
|
+
* {...}`): the implementation monomorphizes under the bindings the
|
|
161
|
+
* overload's resolved signature proves for its type parameters (the
|
|
162
|
+
* structural unification every generic call uses, run against the
|
|
163
|
+
* overload; unbound parameters take their declared defaults). The
|
|
164
|
+
* instance's parameters and result are the IMPLEMENTATION's under those
|
|
165
|
+
* bindings — the body was checked against them — and the call's
|
|
166
|
+
* arguments and result coerce across, exactly as a non-generic overload
|
|
167
|
+
* call reconciles with its implementation (parameters the overload omits
|
|
168
|
+
* must be optional in the implementation). Null when the overload does
|
|
169
|
+
* not belong to this implementation or the arities do not line up. */
|
|
170
|
+
function overloadCallInstance(lowerer, expr, info, rsig, rdecl) {
|
|
171
|
+
const impl = info.decl;
|
|
172
|
+
if (rdecl.parent !== impl.parent ||
|
|
173
|
+
rdecl.name === undefined ||
|
|
174
|
+
impl.name === undefined ||
|
|
175
|
+
rdecl.name.getText() !== impl.name.getText() ||
|
|
176
|
+
rdecl.parameters.nodes.length > impl.parameters.nodes.length ||
|
|
177
|
+
impl.parameters.nodes
|
|
178
|
+
.slice(rdecl.parameters.nodes.length)
|
|
179
|
+
.some((p) => p.questionToken === undefined && p.initializer === undefined) ||
|
|
180
|
+
rdecl.parameters.nodes.some((p) => p.dotDotDotToken !== undefined))
|
|
181
|
+
return null;
|
|
182
|
+
const declSig = lowerer.checker.getSignatureFromDeclaration(impl);
|
|
183
|
+
if (!declSig)
|
|
184
|
+
return null;
|
|
185
|
+
const tsBindings = new Map();
|
|
186
|
+
const bindings = new Map();
|
|
187
|
+
unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings);
|
|
188
|
+
// Explicit type arguments name the OVERLOAD's type parameters, which
|
|
189
|
+
// need not match the implementation's in order: the resolved overload
|
|
190
|
+
// already carries them, so unification binds first, and an explicit
|
|
191
|
+
// argument binds only a still-unbound implementation parameter of the
|
|
192
|
+
// same name.
|
|
193
|
+
const overloadTps = rdecl.typeParameters?.nodes ?? [];
|
|
194
|
+
expr.typeArguments?.nodes.forEach((ta, i) => {
|
|
195
|
+
const name = overloadTps[i]?.name.text;
|
|
196
|
+
const tp = info.typeParams.find((p) => ts.symbolName(p) === name);
|
|
197
|
+
if (!tp || bindings.has(tp))
|
|
198
|
+
return;
|
|
199
|
+
const taT = lowerer.checker.getTypeFromTypeNode(ta);
|
|
200
|
+
const mapped = lowerer.mapTypeOf(taT);
|
|
201
|
+
if (mapped) {
|
|
202
|
+
bindings.set(tp, mapped);
|
|
203
|
+
tsBindings.set(tp, taT);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
bindDefaultTypeParams(lowerer, info.typeParams, impl.typeParameters?.nodes, bindings, tsBindings);
|
|
207
|
+
// A type parameter the overload never mentions (a handler the overload
|
|
208
|
+
// omits) is `unknown`, the checker's own answer for an uninferred one.
|
|
209
|
+
for (const tp of info.typeParams) {
|
|
210
|
+
if (bindings.has(tp))
|
|
211
|
+
continue;
|
|
212
|
+
bindings.set(tp, DYN);
|
|
213
|
+
tsBindings.set(tp, lowerer.checker.getUnknownType());
|
|
214
|
+
}
|
|
215
|
+
const previous = lowerer.typeParamBindings;
|
|
216
|
+
const previousTs = lowerer.typeParamTsBindings;
|
|
217
|
+
lowerer.typeParamBindings = bindings;
|
|
218
|
+
lowerer.typeParamTsBindings = tsBindings;
|
|
219
|
+
let params;
|
|
220
|
+
let returnType;
|
|
221
|
+
try {
|
|
222
|
+
params = paramShapes(lowerer, impl.parameters.nodes, declSig, (_param, i) => expr.arguments.nodes[i] ?? expr);
|
|
223
|
+
returnType = lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(declSig));
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
lowerer.typeParamBindings = previous;
|
|
227
|
+
lowerer.typeParamTsBindings = previousTs;
|
|
228
|
+
}
|
|
229
|
+
if (!returnType)
|
|
230
|
+
return null;
|
|
231
|
+
// keyof-constrained parameters key their instance on the bound literal,
|
|
232
|
+
// as on the implementation-signature path.
|
|
233
|
+
const runtimeReturn = runtimeReturnType(lowerer, info, returnType);
|
|
234
|
+
return internGenericInstance(lowerer, expr, info, params, runtimeReturn, () => bindings, {
|
|
235
|
+
...(keyofConstrainedTypeParams(info).size > 0
|
|
236
|
+
? { extraKey: keyofLiteralKey(info, tsBindings) }
|
|
237
|
+
: {}),
|
|
238
|
+
tsBindings,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/** An instance's result type: a body that can return an indexed read
|
|
242
|
+
* that misses returns undefined there, as in JavaScript, whatever the
|
|
243
|
+
* declared result says. An async body's promise is always present and
|
|
244
|
+
* settles with undefined there. */
|
|
245
|
+
function runtimeReturnType(lowerer, info, mapped) {
|
|
246
|
+
if (!lowerer.runtimeOptionalGenericReturns.has(info.decl))
|
|
247
|
+
return mapped;
|
|
248
|
+
return mapped.kind === "promise"
|
|
249
|
+
? { kind: "promise", inner: lowerer.runtimeOptionalType(mapped.inner) }
|
|
250
|
+
: lowerer.runtimeOptionalType(mapped);
|
|
251
|
+
}
|
|
172
252
|
/** A generic factory whose result is one of its own local classes
|
|
173
253
|
* (`function base<T>(v: T) { return class { value: T = v }; }`). Each
|
|
174
254
|
* instance has its own class, so the instance is keyed on its bindings and
|
|
@@ -374,6 +454,24 @@ function keyofConstrainedTypeParams(info) {
|
|
|
374
454
|
info.keyofTps = out;
|
|
375
455
|
return out;
|
|
376
456
|
}
|
|
457
|
+
/** The instance-key suffix of the literals bound to `info`'s
|
|
458
|
+
* keyof-constrained type parameters (`@"a"`; `*` for a non-literal
|
|
459
|
+
* binding): two literals can map to one IR signature while their bodies
|
|
460
|
+
* read different fields. */
|
|
461
|
+
function keyofLiteralKey(info, tsBindings) {
|
|
462
|
+
const keyofTps = keyofConstrainedTypeParams(info);
|
|
463
|
+
const literals = info.typeParams
|
|
464
|
+
.filter((tp) => keyofTps.has(tp))
|
|
465
|
+
.map((tp) => {
|
|
466
|
+
const bound = tsBindings.get(tp);
|
|
467
|
+
return bound?.isStringLiteralType()
|
|
468
|
+
? JSON.stringify(bound.value)
|
|
469
|
+
: bound?.isNumberLiteralType()
|
|
470
|
+
? String(bound.value)
|
|
471
|
+
: "*";
|
|
472
|
+
});
|
|
473
|
+
return `@${literals.join(",")}`;
|
|
474
|
+
}
|
|
377
475
|
/** Type-parameter symbol → concrete IR type for one instantiation.
|
|
378
476
|
* Explicit type arguments bind directly; the rest come from structurally
|
|
379
477
|
* matching each DECLARED param/return type (which mentions the type
|
|
@@ -491,6 +589,31 @@ function unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings) {
|
|
|
491
589
|
// too is safe only when no undeclared null arm remains.
|
|
492
590
|
unify(dParts[0], lowerer.checker.getNonNullableType(inst), depth + 1);
|
|
493
591
|
}
|
|
592
|
+
else if (dParts.length > 1 && iParts.length === dParts.length) {
|
|
593
|
+
// `T | Promise<T>` against `Res | Promise<Res>`: each declared
|
|
594
|
+
// part that names a generic target (Promise, an interface, an
|
|
595
|
+
// alias) pairs with the one instantiated part of the same target;
|
|
596
|
+
// a single remaining bare type parameter takes the single
|
|
597
|
+
// remaining instantiated part.
|
|
598
|
+
const remaining = [...iParts];
|
|
599
|
+
const bare = [];
|
|
600
|
+
for (const d of dParts) {
|
|
601
|
+
if (d.flags & ts.TypeFlags.TypeParameter) {
|
|
602
|
+
bare.push(d);
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
const target = d.getSymbol() ?? d.getAliasSymbol();
|
|
606
|
+
if (target === undefined)
|
|
607
|
+
return;
|
|
608
|
+
const matches = remaining.filter((i) => (i.getSymbol() ?? i.getAliasSymbol()) === target);
|
|
609
|
+
if (matches.length !== 1)
|
|
610
|
+
return;
|
|
611
|
+
remaining.splice(remaining.indexOf(matches[0]), 1);
|
|
612
|
+
unify(d, matches[0], depth + 1);
|
|
613
|
+
}
|
|
614
|
+
if (bare.length === 1 && remaining.length === 1)
|
|
615
|
+
unify(bare[0], remaining[0], depth + 1);
|
|
616
|
+
}
|
|
494
617
|
return;
|
|
495
618
|
}
|
|
496
619
|
// Instantiations of the SAME generic ALIAS (Partial<T> vs
|
|
@@ -783,6 +906,12 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
783
906
|
lowerer.noteEdge(inst.name);
|
|
784
907
|
return { kind: "closure", fnName: inst.name, captures: [], type: funcType, loc };
|
|
785
908
|
}
|
|
909
|
+
// Each call of the enclosing function makes a new function object for a
|
|
910
|
+
// binding declared inside it (`make() !== make()` when make returns
|
|
911
|
+
// it), which one shared compiled instance cannot give.
|
|
912
|
+
if (info.functionScoped) {
|
|
913
|
+
lowerer.unsupported("SC1090", ref, `generic arrow/function-expression bindings declared inside functions as values (each call of the enclosing function makes a new '${info.baseName}' function object, while its compiled instances are shared module functions — call '${info.baseName}' directly, or declare it at module scope)`);
|
|
914
|
+
}
|
|
786
915
|
const fenceUnpinned = () => lowerer.unsupported("SC1090", ref, `generic functions as values without a pinned concrete signature (annotate the destination — e.g. 'const f: (x: number) => number = ${info.baseName}' — instantiate explicitly ('${info.baseName}<number>'), or call '${info.baseName}' directly)`);
|
|
787
916
|
// The PINNING type: an instantiation expression's own checker type
|
|
788
917
|
// (explicit type arguments applied), else the reference's contextual
|
|
@@ -1711,28 +1840,50 @@ export function implicitLocalFnNodeOf(lowerer, decl) {
|
|
|
1711
1840
|
return null;
|
|
1712
1841
|
if (!isConst && !bindingNeverReassigned(lowerer, sym, decl))
|
|
1713
1842
|
return null;
|
|
1714
|
-
//
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1843
|
+
// Instances are module functions with no frame.
|
|
1844
|
+
return capturesEnclosingFrame(lowerer, init, decl, init.body) ? null : init;
|
|
1845
|
+
};
|
|
1846
|
+
const node = probe();
|
|
1847
|
+
if (node === null) {
|
|
1848
|
+
lowerer.implicitLocalFns.set(decl, null);
|
|
1849
|
+
return null;
|
|
1850
|
+
}
|
|
1851
|
+
return node;
|
|
1852
|
+
}
|
|
1853
|
+
/** True when `fn`, bound by `decl`, uses its enclosing function's frame
|
|
1854
|
+
* somewhere in `scope`: `this`, `super`, `arguments` or `new.target`, or
|
|
1855
|
+
* a value or type declared in an enclosing function (a local, a parameter,
|
|
1856
|
+
* an enclosing generic's type parameter). Module-scope declarations and
|
|
1857
|
+
* the binding itself are reachable from the module functions the
|
|
1858
|
+
* instances compile to. */
|
|
1859
|
+
function capturesEnclosingFrame(lowerer, fn, decl, scope) {
|
|
1860
|
+
const file = ts.getSourceFileOfNode(decl);
|
|
1861
|
+
const self = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
1862
|
+
let captures = false;
|
|
1863
|
+
const scan = (n) => {
|
|
1864
|
+
if (captures)
|
|
1865
|
+
return;
|
|
1866
|
+
if (n.kind === ts.SyntaxKind.ThisKeyword ||
|
|
1867
|
+
n.kind === ts.SyntaxKind.SuperKeyword ||
|
|
1868
|
+
ts.isMetaProperty(n)) {
|
|
1869
|
+
// Arrow bodies see the ENCLOSING this; function expressions
|
|
1870
|
+
// rebind their own — but a bare `this` there is untyped JS
|
|
1871
|
+
// dynamism either way. Reject both, cheaply and soundly.
|
|
1872
|
+
captures = true;
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
if (ts.isIdentifier(n)) {
|
|
1876
|
+
const s = lowerer.checker.getSymbolAtLocation(n);
|
|
1877
|
+
if (s === undefined) {
|
|
1878
|
+
if (n.text === "arguments")
|
|
1879
|
+
captures = true;
|
|
1725
1880
|
}
|
|
1726
|
-
if (
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
// Declared outside the initializer, in this file: a capture
|
|
1733
|
-
// exactly when some enclosing FUNCTION scope declares it —
|
|
1734
|
-
// module-scope declarations are reachable from any module
|
|
1735
|
-
// function.
|
|
1881
|
+
else if (s !== self) {
|
|
1882
|
+
for (const d of s.declarations) {
|
|
1883
|
+
if (ts.getSourceFileOfNode(d) !== file || (d.pos >= fn.pos && d.end <= fn.end))
|
|
1884
|
+
continue;
|
|
1885
|
+
// Declared outside the function, in this file: a capture
|
|
1886
|
+
// exactly when some enclosing FUNCTION scope declares it.
|
|
1736
1887
|
for (let p = d.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
1737
1888
|
if (ts.isFunctionLike(p)) {
|
|
1738
1889
|
captures = true;
|
|
@@ -1741,17 +1892,11 @@ export function implicitLocalFnNodeOf(lowerer, decl) {
|
|
|
1741
1892
|
}
|
|
1742
1893
|
}
|
|
1743
1894
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
scan(init.body);
|
|
1747
|
-
return captures ? null : init;
|
|
1895
|
+
}
|
|
1896
|
+
ts.forEachChild(n, scan);
|
|
1748
1897
|
};
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
lowerer.implicitLocalFns.set(decl, null);
|
|
1752
|
-
return null;
|
|
1753
|
-
}
|
|
1754
|
-
return node;
|
|
1898
|
+
scan(scope);
|
|
1899
|
+
return captures;
|
|
1755
1900
|
}
|
|
1756
1901
|
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
1757
1902
|
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
@@ -1925,9 +2070,16 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1925
2070
|
const name = decl.name.text;
|
|
1926
2071
|
if (fnNode.asteriskToken)
|
|
1927
2072
|
lowerer.unsupported("SC1071", fnNode);
|
|
2073
|
+
// Inside a function, the compiled instances are module functions, so
|
|
2074
|
+
// the initializer may not use the enclosing frame.
|
|
2075
|
+
let functionScoped = false;
|
|
1928
2076
|
for (let n = decl.parent; n !== undefined && !ts.isSourceFile(n); n = n.parent) {
|
|
1929
2077
|
if (ts.isFunctionLike(n)) {
|
|
1930
|
-
lowerer
|
|
2078
|
+
if (capturesEnclosingFrame(lowerer, fnNode, decl, fnNode)) {
|
|
2079
|
+
lowerer.unsupported("SC1090", fnNode, `generic arrow/function-expression bindings that use the frames of their enclosing functions (the compiled instantiations of '${name}' are module functions and cannot capture its locals, parameters, type parameters or 'this' — pass them as arguments, or declare the binding at module scope)`);
|
|
2080
|
+
}
|
|
2081
|
+
functionScoped = true;
|
|
2082
|
+
break;
|
|
1931
2083
|
}
|
|
1932
2084
|
}
|
|
1933
2085
|
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
@@ -1956,12 +2108,17 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1956
2108
|
}
|
|
1957
2109
|
checkGenericParameterNames(lowerer, fnNode.parameters.nodes, true);
|
|
1958
2110
|
const stmt = decl.parent?.parent; // declarator → list → statement (nsPathPrefix wants the statement)
|
|
2111
|
+
// A binding in a function or block can share its name with another; its
|
|
2112
|
+
// instances take the declaration's position.
|
|
2113
|
+
const topLevel = stmt?.parent !== undefined && (ts.isSourceFile(stmt.parent) || ts.isModuleBlock(stmt.parent));
|
|
1959
2114
|
const info = {
|
|
1960
2115
|
decl: fnNode,
|
|
1961
2116
|
baseName: name,
|
|
1962
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(stmt ?? decl, decl) +
|
|
2117
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(stmt ?? decl, decl) +
|
|
2118
|
+
(topLevel ? name : `${name}%l${ts.tokenStartOfNode(decl)}`)),
|
|
1963
2119
|
typeParams,
|
|
1964
2120
|
instances: new Map(),
|
|
2121
|
+
...(functionScoped ? { functionScoped: true } : {}),
|
|
1965
2122
|
};
|
|
1966
2123
|
lowerer.bindingGenericFns.set(fnNode, info);
|
|
1967
2124
|
lowerer.genericFnsBySymbol.set(sym, info);
|