@scriptc/compiler 0.2.4 → 0.2.5

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.
Files changed (1104) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +915 -215
  2. package/ambient/scriptc-overrides.d.ts +5 -1
  3. package/ambient/scriptc.d.ts +22 -2
  4. package/dist/backend/build-cache.d.ts +4 -0
  5. package/dist/backend/build-cache.js +16 -2
  6. package/dist/backend/build-cache.js.map +1 -1
  7. package/dist/backend/cycle-analysis.js +17 -5
  8. package/dist/backend/cycle-analysis.js.map +1 -1
  9. package/dist/backend/cycle-analysis.test.js +50 -11
  10. package/dist/backend/cycle-analysis.test.js.map +1 -1
  11. package/dist/backend/debug-symbols.js.map +1 -1
  12. package/dist/backend/executable-features.js +2 -1
  13. package/dist/backend/executable-features.js.map +1 -1
  14. package/dist/backend/external-c.d.ts +13 -6
  15. package/dist/backend/external-c.js +15 -3
  16. package/dist/backend/external-c.js.map +1 -1
  17. package/dist/backend/ffi-callbacks.js +6 -9
  18. package/dist/backend/ffi-callbacks.js.map +1 -1
  19. package/dist/backend/library-identity-markers.js.map +1 -1
  20. package/dist/backend/library-pack.d.ts +1 -1
  21. package/dist/backend/library-pack.js +81 -24
  22. package/dist/backend/library-pack.js.map +1 -1
  23. package/dist/backend/link-plan-core.js +9 -2
  24. package/dist/backend/link-plan-core.js.map +1 -1
  25. package/dist/backend/link-plan.d.ts +1 -1
  26. package/dist/backend/link-plan.js +4 -5
  27. package/dist/backend/link-plan.js.map +1 -1
  28. package/dist/backend/linker.d.ts +1 -1
  29. package/dist/backend/linker.js +42 -23
  30. package/dist/backend/linker.js.map +1 -1
  31. package/dist/backend/literals.js +5 -4
  32. package/dist/backend/literals.js.map +1 -1
  33. package/dist/backend/literals.test.js +30 -5
  34. package/dist/backend/literals.test.js.map +1 -1
  35. package/dist/backend/llvm/blocks.test.js +5 -2
  36. package/dist/backend/llvm/blocks.test.js.map +1 -1
  37. package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
  38. package/dist/backend/llvm/borrowed-receivers.js +43 -19
  39. package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
  40. package/dist/backend/llvm/byte-numbers.js +6 -1
  41. package/dist/backend/llvm/byte-numbers.js.map +1 -1
  42. package/dist/backend/llvm/bytes-bounds.js +73 -22
  43. package/dist/backend/llvm/bytes-bounds.js.map +1 -1
  44. package/dist/backend/llvm/call-lifetimes.d.ts +3 -0
  45. package/dist/backend/llvm/call-lifetimes.js +60 -17
  46. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  47. package/dist/backend/llvm/call-lifetimes.test.js +159 -28
  48. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  49. package/dist/backend/llvm/checked-value-lifetimes.d.ts +4 -0
  50. package/dist/backend/llvm/checked-value-lifetimes.js +14 -4
  51. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  52. package/dist/backend/llvm/classes.js +16 -12
  53. package/dist/backend/llvm/classes.js.map +1 -1
  54. package/dist/backend/llvm/common.js +4 -1
  55. package/dist/backend/llvm/common.js.map +1 -1
  56. package/dist/backend/llvm/counted-loops.js +10 -3
  57. package/dist/backend/llvm/counted-loops.js.map +1 -1
  58. package/dist/backend/llvm/debug-info.js +33 -13
  59. package/dist/backend/llvm/debug-info.js.map +1 -1
  60. package/dist/backend/llvm/debug-info.test.js +28 -6
  61. package/dist/backend/llvm/debug-info.test.js.map +1 -1
  62. package/dist/backend/llvm/dyn.js +68 -22
  63. package/dist/backend/llvm/dyn.js.map +1 -1
  64. package/dist/backend/llvm/emitter.d.ts +9 -3
  65. package/dist/backend/llvm/emitter.js +238 -105
  66. package/dist/backend/llvm/emitter.js.map +1 -1
  67. package/dist/backend/llvm/emitter.test.js +233 -42
  68. package/dist/backend/llvm/emitter.test.js.map +1 -1
  69. package/dist/backend/llvm/expr-async.js +25 -6
  70. package/dist/backend/llvm/expr-async.js.map +1 -1
  71. package/dist/backend/llvm/expr-bytes.js +13 -4
  72. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  73. package/dist/backend/llvm/expr-callbacks.js +10 -4
  74. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  75. package/dist/backend/llvm/expr-calls.js +20 -9
  76. package/dist/backend/llvm/expr-calls.js.map +1 -1
  77. package/dist/backend/llvm/expr-containers.d.ts +2 -0
  78. package/dist/backend/llvm/expr-containers.js +92 -33
  79. package/dist/backend/llvm/expr-containers.js.map +1 -1
  80. package/dist/backend/llvm/expr-control.js +1 -3
  81. package/dist/backend/llvm/expr-control.js.map +1 -1
  82. package/dist/backend/llvm/expr-dispatch.js +3 -1
  83. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  84. package/dist/backend/llvm/expr-dynamic.js +19 -4
  85. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  86. package/dist/backend/llvm/expr-island.js +26 -6
  87. package/dist/backend/llvm/expr-island.js.map +1 -1
  88. package/dist/backend/llvm/expr-primitives.js +88 -19
  89. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  90. package/dist/backend/llvm/expr-primitives.test.js +43 -1
  91. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  92. package/dist/backend/llvm/expr-records.js +10 -9
  93. package/dist/backend/llvm/expr-records.js.map +1 -1
  94. package/dist/backend/llvm/expr-stream-bridges.js +44 -26
  95. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  96. package/dist/backend/llvm/expr-stream-bridges.test.js +51 -14
  97. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  98. package/dist/backend/llvm/expr-stream-callbacks.js +34 -14
  99. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  100. package/dist/backend/llvm/integer-values.js +15 -4
  101. package/dist/backend/llvm/integer-values.js.map +1 -1
  102. package/dist/backend/llvm/integer-views.js +23 -7
  103. package/dist/backend/llvm/integer-views.js.map +1 -1
  104. package/dist/backend/llvm/integer-views.test.js +42 -7
  105. package/dist/backend/llvm/integer-views.test.js.map +1 -1
  106. package/dist/backend/llvm/lib-abi.js +13 -4
  107. package/dist/backend/llvm/lib-abi.js.map +1 -1
  108. package/dist/backend/llvm/lib-connect.js +7 -1
  109. package/dist/backend/llvm/lib-connect.js.map +1 -1
  110. package/dist/backend/llvm/lib-datagram.js +35 -10
  111. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  112. package/dist/backend/llvm/lib-dispatch.js +35 -16
  113. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  114. package/dist/backend/llvm/lib-filesystem.js +33 -18
  115. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  116. package/dist/backend/llvm/lib-http2.js +60 -15
  117. package/dist/backend/llvm/lib-http2.js.map +1 -1
  118. package/dist/backend/llvm/lib-lookup.js +12 -5
  119. package/dist/backend/llvm/lib-lookup.js.map +1 -1
  120. package/dist/backend/llvm/lib-network.js +97 -31
  121. package/dist/backend/llvm/lib-network.js.map +1 -1
  122. package/dist/backend/llvm/lib-process.js +57 -14
  123. package/dist/backend/llvm/lib-process.js.map +1 -1
  124. package/dist/backend/llvm/lib-shared.js +107 -31
  125. package/dist/backend/llvm/lib-shared.js.map +1 -1
  126. package/dist/backend/llvm/lib-stream.js +33 -14
  127. package/dist/backend/llvm/lib-stream.js.map +1 -1
  128. package/dist/backend/llvm/lib-test.js +21 -7
  129. package/dist/backend/llvm/lib-test.js.map +1 -1
  130. package/dist/backend/llvm/lib-tls.js +69 -20
  131. package/dist/backend/llvm/lib-tls.js.map +1 -1
  132. package/dist/backend/llvm/local-array-reads.d.ts +1 -0
  133. package/dist/backend/llvm/local-array-reads.js +96 -30
  134. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  135. package/dist/backend/llvm/local-array-reads.test.js +368 -60
  136. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  137. package/dist/backend/llvm/local-union-storage.d.ts +25 -0
  138. package/dist/backend/llvm/local-union-storage.js +109 -0
  139. package/dist/backend/llvm/local-union-storage.js.map +1 -0
  140. package/dist/backend/llvm/local-union-storage.test.d.ts +1 -0
  141. package/dist/backend/llvm/local-union-storage.test.js +210 -0
  142. package/dist/backend/llvm/local-union-storage.test.js.map +1 -0
  143. package/dist/backend/llvm/map-read-lifetimes.d.ts +6 -2
  144. package/dist/backend/llvm/map-read-lifetimes.js +44 -14
  145. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  146. package/dist/backend/llvm/map-read-lifetimes.test.js +89 -17
  147. package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
  148. package/dist/backend/llvm/reference-effects.d.ts +3 -2
  149. package/dist/backend/llvm/reference-effects.js +67 -36
  150. package/dist/backend/llvm/reference-effects.js.map +1 -1
  151. package/dist/backend/llvm/reference-effects.test.js +92 -9
  152. package/dist/backend/llvm/reference-effects.test.js.map +1 -1
  153. package/dist/backend/llvm/shapes.js +60 -17
  154. package/dist/backend/llvm/shapes.js.map +1 -1
  155. package/dist/backend/llvm/shapes.test.js +3 -1
  156. package/dist/backend/llvm/shapes.test.js.map +1 -1
  157. package/dist/backend/llvm/split.js +4 -4
  158. package/dist/backend/llvm/split.js.map +1 -1
  159. package/dist/backend/llvm/split.test.js +14 -6
  160. package/dist/backend/llvm/split.test.js.map +1 -1
  161. package/dist/backend/llvm/stack-unions.js +14 -5
  162. package/dist/backend/llvm/stack-unions.js.map +1 -1
  163. package/dist/backend/llvm/stack-unions.test.js +151 -32
  164. package/dist/backend/llvm/stack-unions.test.js.map +1 -1
  165. package/dist/backend/llvm/string-construction.js.map +1 -1
  166. package/dist/backend/llvm/string-construction.test.js +32 -7
  167. package/dist/backend/llvm/string-construction.test.js.map +1 -1
  168. package/dist/backend/llvm/string-lifetimes.js +14 -8
  169. package/dist/backend/llvm/string-lifetimes.js.map +1 -1
  170. package/dist/backend/llvm/string-lifetimes.test.js +112 -26
  171. package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
  172. package/dist/backend/llvm/switch-dispatch.d.ts +9 -0
  173. package/dist/backend/llvm/switch-dispatch.js +114 -0
  174. package/dist/backend/llvm/switch-dispatch.js.map +1 -0
  175. package/dist/backend/llvm/switch-dispatch.test.d.ts +1 -0
  176. package/dist/backend/llvm/switch-dispatch.test.js +83 -0
  177. package/dist/backend/llvm/switch-dispatch.test.js.map +1 -0
  178. package/dist/backend/llvm/unsupported.js.map +1 -1
  179. package/dist/backend/llvm/walkers.js +6 -3
  180. package/dist/backend/llvm/walkers.js.map +1 -1
  181. package/dist/backend/mangle.js +9 -3
  182. package/dist/backend/mangle.js.map +1 -1
  183. package/dist/backend/may-throw.js +18 -8
  184. package/dist/backend/may-throw.js.map +1 -1
  185. package/dist/backend/may-throw.test.js +118 -22
  186. package/dist/backend/may-throw.test.js.map +1 -1
  187. package/dist/backend/native/artifact-stamps.d.ts +39 -0
  188. package/dist/backend/native/artifact-stamps.js +371 -0
  189. package/dist/backend/native/artifact-stamps.js.map +1 -0
  190. package/dist/backend/native/cache-warm.d.ts +24 -0
  191. package/dist/backend/native/cache-warm.js +80 -0
  192. package/dist/backend/native/cache-warm.js.map +1 -0
  193. package/dist/backend/native/compiler-fingerprint.d.ts +19 -0
  194. package/dist/backend/native/compiler-fingerprint.js +357 -0
  195. package/dist/backend/native/compiler-fingerprint.js.map +1 -0
  196. package/dist/backend/native/contracts.d.ts +314 -0
  197. package/dist/backend/native/contracts.js +2 -0
  198. package/dist/backend/native/contracts.js.map +1 -0
  199. package/dist/backend/native/dependency-files.d.ts +5 -0
  200. package/dist/backend/native/dependency-files.js +83 -0
  201. package/dist/backend/native/dependency-files.js.map +1 -0
  202. package/dist/backend/native/driver.d.ts +50 -0
  203. package/dist/backend/native/driver.js +294 -0
  204. package/dist/backend/native/driver.js.map +1 -0
  205. package/dist/backend/native/executable.d.ts +18 -0
  206. package/dist/backend/native/executable.js +1267 -0
  207. package/dist/backend/native/executable.js.map +1 -0
  208. package/dist/backend/native/library.d.ts +2 -0
  209. package/dist/backend/native/library.js +614 -0
  210. package/dist/backend/native/library.js.map +1 -0
  211. package/dist/backend/native/linker-fingerprint.d.ts +8 -0
  212. package/dist/backend/native/linker-fingerprint.js +174 -0
  213. package/dist/backend/native/linker-fingerprint.js.map +1 -0
  214. package/dist/backend/native/object-merge.d.ts +2 -0
  215. package/dist/backend/native/object-merge.js +154 -0
  216. package/dist/backend/native/object-merge.js.map +1 -0
  217. package/dist/backend/native/process.d.ts +17 -0
  218. package/dist/backend/native/process.js +42 -0
  219. package/dist/backend/native/process.js.map +1 -0
  220. package/dist/backend/native/program-shards.d.ts +21 -0
  221. package/dist/backend/native/program-shards.js +99 -0
  222. package/dist/backend/native/program-shards.js.map +1 -0
  223. package/dist/backend/native/runtime-inputs.d.ts +12 -0
  224. package/dist/backend/native/runtime-inputs.js +163 -0
  225. package/dist/backend/native/runtime-inputs.js.map +1 -0
  226. package/dist/backend/native/runtime-inputs.test.d.ts +1 -0
  227. package/dist/backend/native/runtime-inputs.test.js +64 -0
  228. package/dist/backend/native/runtime-inputs.test.js.map +1 -0
  229. package/dist/backend/native/runtime-objects.d.ts +16 -0
  230. package/dist/backend/native/runtime-objects.js +122 -0
  231. package/dist/backend/native/runtime-objects.js.map +1 -0
  232. package/dist/backend/native/session.d.ts +12 -0
  233. package/dist/backend/native/session.js +31 -0
  234. package/dist/backend/native/session.js.map +1 -0
  235. package/dist/backend/native/tool-identity.d.ts +37 -0
  236. package/dist/backend/native/tool-identity.js +310 -0
  237. package/dist/backend/native/tool-identity.js.map +1 -0
  238. package/dist/backend/native/trace-paths.d.ts +12 -0
  239. package/dist/backend/native/trace-paths.js +73 -0
  240. package/dist/backend/native/trace-paths.js.map +1 -0
  241. package/dist/backend/native/vendor.d.ts +1 -0
  242. package/dist/backend/native/vendor.js +12 -0
  243. package/dist/backend/native/vendor.js.map +1 -0
  244. package/dist/backend/native-codegen-core.js +2 -1
  245. package/dist/backend/native-codegen-core.js.map +1 -1
  246. package/dist/backend/native-codegen.d.ts +1 -1
  247. package/dist/backend/native-codegen.js +24 -13
  248. package/dist/backend/native-codegen.js.map +1 -1
  249. package/dist/backend/native-codegen.test.js +12 -9
  250. package/dist/backend/native-codegen.test.js.map +1 -1
  251. package/dist/backend/native-link-info-core.js +9 -5
  252. package/dist/backend/native-link-info-core.js.map +1 -1
  253. package/dist/backend/native-link-info.js +14 -5
  254. package/dist/backend/native-link-info.js.map +1 -1
  255. package/dist/backend/native-link-info.test.js +58 -13
  256. package/dist/backend/native-link-info.test.js.map +1 -1
  257. package/dist/backend/native-toolchain.d.ts +17 -450
  258. package/dist/backend/native-toolchain.js +17 -3971
  259. package/dist/backend/native-toolchain.js.map +1 -1
  260. package/dist/backend/native-toolchain.test.js +103 -72
  261. package/dist/backend/native-toolchain.test.js.map +1 -1
  262. package/dist/backend/native-tools.js +27 -8
  263. package/dist/backend/native-tools.js.map +1 -1
  264. package/dist/backend/object-localize.js +17 -14
  265. package/dist/backend/object-localize.js.map +1 -1
  266. package/dist/backend/object-localize.test.js +59 -12
  267. package/dist/backend/object-localize.test.js.map +1 -1
  268. package/dist/backend/runtime-pack-core.js +96 -49
  269. package/dist/backend/runtime-pack-core.js.map +1 -1
  270. package/dist/backend/runtime-pack-native.js +5 -3
  271. package/dist/backend/runtime-pack-native.js.map +1 -1
  272. package/dist/backend/runtime-pack-targets.test.js +87 -15
  273. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  274. package/dist/backend/runtime-pack.d.ts +1 -1
  275. package/dist/backend/runtime-pack.js +11 -12
  276. package/dist/backend/runtime-pack.js.map +1 -1
  277. package/dist/backend/runtime-pack.test.js +40 -24
  278. package/dist/backend/runtime-pack.test.js.map +1 -1
  279. package/dist/backend/source-locations.js.map +1 -1
  280. package/dist/backend/source-locations.test.js +7 -2
  281. package/dist/backend/source-locations.test.js.map +1 -1
  282. package/dist/backend/target-diagnostics.js +44 -14
  283. package/dist/backend/target-diagnostics.js.map +1 -1
  284. package/dist/backend/target-diagnostics.test.js +93 -20
  285. package/dist/backend/target-diagnostics.test.js.map +1 -1
  286. package/dist/backend/targets.js +230 -86
  287. package/dist/backend/targets.js.map +1 -1
  288. package/dist/backend/targets.test.js +32 -18
  289. package/dist/backend/targets.test.js.map +1 -1
  290. package/dist/backend/toolchain-environment.js +5 -1
  291. package/dist/backend/toolchain-environment.js.map +1 -1
  292. package/dist/backend/vendor-archives.d.ts +2 -2
  293. package/dist/backend/vendor-archives.js +84 -35
  294. package/dist/backend/vendor-archives.js.map +1 -1
  295. package/dist/backend/vendor-inputs.js +13 -1
  296. package/dist/backend/vendor-inputs.js.map +1 -1
  297. package/dist/backend/warm-cache.d.ts +1 -1
  298. package/dist/backend/warm-cache.js +33 -9
  299. package/dist/backend/warm-cache.js.map +1 -1
  300. package/dist/cli/command.js +39 -9
  301. package/dist/cli/command.js.map +1 -1
  302. package/dist/cli/output-options.js +14 -4
  303. package/dist/cli/output-options.js.map +1 -1
  304. package/dist/cli/paths.js.map +1 -1
  305. package/dist/cli/wasi-runner.js.map +1 -1
  306. package/dist/compat/fetch-profile.js +36 -35
  307. package/dist/compat/fetch-profile.js.map +1 -1
  308. package/dist/coverage/report.js +16 -17
  309. package/dist/coverage/report.js.map +1 -1
  310. package/dist/coverage/surface-manifest.js +112 -26
  311. package/dist/coverage/surface-manifest.js.map +1 -1
  312. package/dist/diagnostics/diagnostic.js +55 -16
  313. package/dist/diagnostics/diagnostic.js.map +1 -1
  314. package/dist/executable/executable-cache.d.ts +1 -1
  315. package/dist/executable/executable-cache.js +78 -48
  316. package/dist/executable/executable-cache.js.map +1 -1
  317. package/dist/executable/executable-cache.test.js +75 -26
  318. package/dist/executable/executable-cache.test.js.map +1 -1
  319. package/dist/executable/prepare.js +2 -2
  320. package/dist/executable/prepare.js.map +1 -1
  321. package/dist/ffi/ffi-manifest.js +78 -20
  322. package/dist/ffi/ffi-manifest.js.map +1 -1
  323. package/dist/ffi/ffi-manifest.test.js +96 -16
  324. package/dist/ffi/ffi-manifest.test.js.map +1 -1
  325. package/dist/format-integer.js.map +1 -1
  326. package/dist/frontend/analysis.js +12 -2
  327. package/dist/frontend/analysis.js.map +1 -1
  328. package/dist/frontend/arguments-usage.js.map +1 -1
  329. package/dist/frontend/binding-source.js +9 -3
  330. package/dist/frontend/binding-source.js.map +1 -1
  331. package/dist/frontend/builtin-modules.js +46 -2
  332. package/dist/frontend/builtin-modules.js.map +1 -1
  333. package/dist/frontend/cjs-resolve.js +40 -17
  334. package/dist/frontend/cjs-resolve.js.map +1 -1
  335. package/dist/frontend/cjs-syntax.js +31 -10
  336. package/dist/frontend/cjs-syntax.js.map +1 -1
  337. package/dist/frontend/comptime-node.test.js +10 -11
  338. package/dist/frontend/comptime-node.test.js.map +1 -1
  339. package/dist/frontend/dts-paths.js +7 -3
  340. package/dist/frontend/dts-paths.js.map +1 -1
  341. package/dist/frontend/fork-target.js +17 -12
  342. package/dist/frontend/fork-target.js.map +1 -1
  343. package/dist/frontend/function-completion.js +11 -6
  344. package/dist/frontend/function-completion.js.map +1 -1
  345. package/dist/frontend/helper-tokens.js +53 -6
  346. package/dist/frontend/helper-tokens.js.map +1 -1
  347. package/dist/frontend/helper-tokens.test.js +18 -2
  348. package/dist/frontend/helper-tokens.test.js.map +1 -1
  349. package/dist/frontend/inferred-js-diagnostics.js +32 -12
  350. package/dist/frontend/inferred-js-diagnostics.js.map +1 -1
  351. package/dist/frontend/inferred-js-diagnostics.test.js +11 -15
  352. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  353. package/dist/frontend/input-tracker.js +11 -11
  354. package/dist/frontend/input-tracker.js.map +1 -1
  355. package/dist/frontend/input-tracker.test.js +4 -1
  356. package/dist/frontend/input-tracker.test.js.map +1 -1
  357. package/dist/frontend/lib-contract.js +38 -9
  358. package/dist/frontend/lib-contract.js.map +1 -1
  359. package/dist/frontend/literal-values.js.map +1 -1
  360. package/dist/frontend/literal-values.test.js +28 -8
  361. package/dist/frontend/literal-values.test.js.map +1 -1
  362. package/dist/frontend/lowering/abstract-equality.js +53 -10
  363. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  364. package/dist/frontend/lowering/array-indexed-mutation.d.ts +1 -1
  365. package/dist/frontend/lowering/array-indexed-mutation.js +108 -106
  366. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
  367. package/dist/frontend/lowering/array-values.js +37 -14
  368. package/dist/frontend/lowering/array-values.js.map +1 -1
  369. package/dist/frontend/lowering/binding-analysis.d.ts +50 -0
  370. package/dist/frontend/lowering/binding-analysis.js +376 -0
  371. package/dist/frontend/lowering/binding-analysis.js.map +1 -0
  372. package/dist/frontend/lowering/builtin-calls.d.ts +9 -0
  373. package/dist/frontend/lowering/builtin-calls.js +60 -0
  374. package/dist/frontend/lowering/builtin-calls.js.map +1 -0
  375. package/dist/frontend/lowering/builtins/arguments.d.ts +43 -0
  376. package/dist/frontend/lowering/builtins/arguments.js +247 -0
  377. package/dist/frontend/lowering/builtins/arguments.js.map +1 -0
  378. package/dist/frontend/lowering/builtins/async-context.d.ts +52 -0
  379. package/dist/frontend/lowering/builtins/async-context.js +436 -0
  380. package/dist/frontend/lowering/builtins/async-context.js.map +1 -0
  381. package/dist/frontend/lowering/builtins/atomics.d.ts +15 -0
  382. package/dist/frontend/lowering/builtins/atomics.js +46 -0
  383. package/dist/frontend/lowering/builtins/atomics.js.map +1 -0
  384. package/dist/frontend/lowering/builtins/callable-aliases.d.ts +13 -0
  385. package/dist/frontend/lowering/builtins/callable-aliases.js +87 -0
  386. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -0
  387. package/dist/frontend/lowering/builtins/child-process-async.d.ts +18 -0
  388. package/dist/frontend/lowering/builtins/child-process-async.js +245 -0
  389. package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -0
  390. package/dist/frontend/lowering/builtins/child-process-methods.d.ts +21 -0
  391. package/dist/frontend/lowering/builtins/child-process-methods.js +362 -0
  392. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -0
  393. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +4 -0
  394. package/dist/frontend/lowering/builtins/child-process-sync.js +639 -0
  395. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -0
  396. package/dist/frontend/lowering/builtins/child-process.d.ts +55 -0
  397. package/dist/frontend/lowering/builtins/child-process.js +669 -0
  398. package/dist/frontend/lowering/builtins/child-process.js.map +1 -0
  399. package/dist/frontend/lowering/builtins/compression.d.ts +7 -0
  400. package/dist/frontend/lowering/builtins/compression.js +115 -0
  401. package/dist/frontend/lowering/builtins/compression.js.map +1 -0
  402. package/dist/frontend/lowering/builtins/console.d.ts +10 -0
  403. package/dist/frontend/lowering/builtins/console.js +38 -0
  404. package/dist/frontend/lowering/builtins/console.js.map +1 -0
  405. package/dist/frontend/lowering/builtins/constants.d.ts +24 -0
  406. package/dist/frontend/lowering/builtins/constants.js +141 -0
  407. package/dist/frontend/lowering/builtins/constants.js.map +1 -0
  408. package/dist/frontend/lowering/builtins/crypto.d.ts +22 -0
  409. package/dist/frontend/lowering/builtins/crypto.js +517 -0
  410. package/dist/frontend/lowering/builtins/crypto.js.map +1 -0
  411. package/dist/frontend/lowering/builtins/dates.d.ts +7 -0
  412. package/dist/frontend/lowering/builtins/dates.js +101 -0
  413. package/dist/frontend/lowering/builtins/dates.js.map +1 -0
  414. package/dist/frontend/lowering/builtins/environment.d.ts +34 -0
  415. package/dist/frontend/lowering/builtins/environment.js +95 -0
  416. package/dist/frontend/lowering/builtins/environment.js.map +1 -0
  417. package/dist/frontend/lowering/builtins/errors.d.ts +14 -0
  418. package/dist/frontend/lowering/builtins/errors.js +83 -0
  419. package/dist/frontend/lowering/builtins/errors.js.map +1 -0
  420. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +32 -0
  421. package/dist/frontend/lowering/builtins/filesystem-calls.js +678 -0
  422. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -0
  423. package/dist/frontend/lowering/builtins/filesystem.d.ts +108 -0
  424. package/dist/frontend/lowering/builtins/filesystem.js +1061 -0
  425. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -0
  426. package/dist/frontend/lowering/builtins/ipc.d.ts +8 -0
  427. package/dist/frontend/lowering/builtins/ipc.js +76 -0
  428. package/dist/frontend/lowering/builtins/ipc.js.map +1 -0
  429. package/dist/frontend/lowering/builtins/json.d.ts +12 -0
  430. package/dist/frontend/lowering/builtins/json.js +387 -0
  431. package/dist/frontend/lowering/builtins/json.js.map +1 -0
  432. package/dist/frontend/lowering/builtins/module-bindings.d.ts +85 -0
  433. package/dist/frontend/lowering/builtins/module-bindings.js +346 -0
  434. package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -0
  435. package/dist/frontend/lowering/builtins/module-calls.d.ts +8 -0
  436. package/dist/frontend/lowering/builtins/module-calls.js +303 -0
  437. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -0
  438. package/dist/frontend/lowering/builtins/module-resolution.d.ts +38 -0
  439. package/dist/frontend/lowering/builtins/module-resolution.js +344 -0
  440. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -0
  441. package/dist/frontend/lowering/builtins/numbers.d.ts +15 -0
  442. package/dist/frontend/lowering/builtins/numbers.js +124 -0
  443. package/dist/frontend/lowering/builtins/numbers.js.map +1 -0
  444. package/dist/frontend/lowering/builtins/operating-system.d.ts +13 -0
  445. package/dist/frontend/lowering/builtins/operating-system.js +148 -0
  446. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -0
  447. package/dist/frontend/lowering/builtins/performance.d.ts +13 -0
  448. package/dist/frontend/lowering/builtins/performance.js +100 -0
  449. package/dist/frontend/lowering/builtins/performance.js.map +1 -0
  450. package/dist/frontend/lowering/builtins/process.d.ts +50 -0
  451. package/dist/frontend/lowering/builtins/process.js +1138 -0
  452. package/dist/frontend/lowering/builtins/process.js.map +1 -0
  453. package/dist/frontend/lowering/builtins/promises.d.ts +14 -0
  454. package/dist/frontend/lowering/builtins/promises.js +356 -0
  455. package/dist/frontend/lowering/builtins/promises.js.map +1 -0
  456. package/dist/frontend/lowering/builtins/properties.d.ts +11 -0
  457. package/dist/frontend/lowering/builtins/properties.js +186 -0
  458. package/dist/frontend/lowering/builtins/properties.js.map +1 -0
  459. package/dist/frontend/lowering/builtins/querystring.d.ts +19 -0
  460. package/dist/frontend/lowering/builtins/querystring.js +150 -0
  461. package/dist/frontend/lowering/builtins/querystring.js.map +1 -0
  462. package/dist/frontend/lowering/builtins/readline.d.ts +13 -0
  463. package/dist/frontend/lowering/builtins/readline.js +138 -0
  464. package/dist/frontend/lowering/builtins/readline.js.map +1 -0
  465. package/dist/frontend/lowering/builtins/receiver-types.d.ts +5 -0
  466. package/dist/frontend/lowering/builtins/receiver-types.js +15 -0
  467. package/dist/frontend/lowering/builtins/receiver-types.js.map +1 -0
  468. package/dist/frontend/lowering/builtins/reflection.d.ts +13 -0
  469. package/dist/frontend/lowering/builtins/reflection.js +95 -0
  470. package/dist/frontend/lowering/builtins/reflection.js.map +1 -0
  471. package/dist/frontend/lowering/builtins/strings.d.ts +14 -0
  472. package/dist/frontend/lowering/builtins/strings.js +121 -0
  473. package/dist/frontend/lowering/builtins/strings.js.map +1 -0
  474. package/dist/frontend/lowering/builtins/text-codecs.d.ts +29 -0
  475. package/dist/frontend/lowering/builtins/text-codecs.js +590 -0
  476. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -0
  477. package/dist/frontend/lowering/builtins/timers.d.ts +22 -0
  478. package/dist/frontend/lowering/builtins/timers.js +180 -0
  479. package/dist/frontend/lowering/builtins/timers.js.map +1 -0
  480. package/dist/frontend/lowering/builtins/url.d.ts +37 -0
  481. package/dist/frontend/lowering/builtins/url.js +596 -0
  482. package/dist/frontend/lowering/builtins/url.js.map +1 -0
  483. package/dist/frontend/lowering/builtins/util-types.d.ts +7 -0
  484. package/dist/frontend/lowering/builtins/util-types.js +31 -0
  485. package/dist/frontend/lowering/builtins/util-types.js.map +1 -0
  486. package/dist/frontend/lowering/call-arguments.d.ts +72 -0
  487. package/dist/frontend/lowering/call-arguments.js +618 -0
  488. package/dist/frontend/lowering/call-arguments.js.map +1 -0
  489. package/dist/frontend/lowering/call-signatures.d.ts +115 -0
  490. package/dist/frontend/lowering/call-signatures.js +719 -0
  491. package/dist/frontend/lowering/call-signatures.js.map +1 -0
  492. package/dist/frontend/lowering/callback-arg.js.map +1 -1
  493. package/dist/frontend/lowering/checked-iterable-spread.js +53 -10
  494. package/dist/frontend/lowering/checked-iterable-spread.js.map +1 -1
  495. package/dist/frontend/lowering/checked-promise-all.js +41 -9
  496. package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
  497. package/dist/frontend/lowering/class-callbacks.d.ts +1 -1
  498. package/dist/frontend/lowering/class-callbacks.js +130 -27
  499. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  500. package/dist/frontend/lowering/class-construction.d.ts +1 -1
  501. package/dist/frontend/lowering/class-construction.js +247 -50
  502. package/dist/frontend/lowering/class-construction.js.map +1 -1
  503. package/dist/frontend/lowering/class-descriptors.js +109 -29
  504. package/dist/frontend/lowering/class-descriptors.js.map +1 -1
  505. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -1
  506. package/dist/frontend/lowering/class-dynamic-dispatch.js +2471 -465
  507. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  508. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +284 -44
  509. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  510. package/dist/frontend/lowering/class-instance-constructor.js +17 -5
  511. package/dist/frontend/lowering/class-instance-constructor.js.map +1 -1
  512. package/dist/frontend/lowering/class-method-values.js +199 -51
  513. package/dist/frontend/lowering/class-method-values.js.map +1 -1
  514. package/dist/frontend/lowering/class-prototypes.js +345 -86
  515. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  516. package/dist/frontend/lowering/class-runtime-statics.d.ts +1 -1
  517. package/dist/frontend/lowering/class-runtime-statics.js +80 -17
  518. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  519. package/dist/frontend/lowering/class-static-data.js +76 -16
  520. package/dist/frontend/lowering/class-static-data.js.map +1 -1
  521. package/dist/frontend/lowering/coercions/builders.d.ts +13 -0
  522. package/dist/frontend/lowering/coercions/builders.js +77 -0
  523. package/dist/frontend/lowering/coercions/builders.js.map +1 -0
  524. package/dist/frontend/lowering/coercions/function-adapters.d.ts +58 -0
  525. package/dist/frontend/lowering/coercions/function-adapters.js +430 -0
  526. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -0
  527. package/dist/frontend/lowering/coercions/island.d.ts +37 -0
  528. package/dist/frontend/lowering/coercions/island.js +350 -0
  529. package/dist/frontend/lowering/coercions/island.js.map +1 -0
  530. package/dist/frontend/lowering/coercions/state.d.ts +14 -0
  531. package/dist/frontend/lowering/coercions/state.js +16 -0
  532. package/dist/frontend/lowering/coercions/state.js.map +1 -0
  533. package/dist/frontend/lowering/coercions/structural-plans.d.ts +40 -0
  534. package/dist/frontend/lowering/coercions/structural-plans.js +447 -0
  535. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -0
  536. package/dist/frontend/lowering/coercions/structural.d.ts +63 -0
  537. package/dist/frontend/lowering/coercions/structural.js +616 -0
  538. package/dist/frontend/lowering/coercions/structural.js.map +1 -0
  539. package/dist/frontend/lowering/coercions/unions.d.ts +65 -0
  540. package/dist/frontend/lowering/coercions/unions.js +318 -0
  541. package/dist/frontend/lowering/coercions/unions.js.map +1 -0
  542. package/dist/frontend/lowering/collection-ingestion.js +355 -72
  543. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  544. package/dist/frontend/lowering/containers/array-callbacks.d.ts +92 -0
  545. package/dist/frontend/lowering/containers/array-callbacks.js +1646 -0
  546. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -0
  547. package/dist/frontend/lowering/containers/array-construction.d.ts +42 -0
  548. package/dist/frontend/lowering/containers/array-construction.js +1044 -0
  549. package/dist/frontend/lowering/containers/array-construction.js.map +1 -0
  550. package/dist/frontend/lowering/containers/array-iteration.d.ts +16 -0
  551. package/dist/frontend/lowering/containers/array-iteration.js +95 -0
  552. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -0
  553. package/dist/frontend/lowering/containers/array-methods.d.ts +27 -0
  554. package/dist/frontend/lowering/containers/array-methods.js +1854 -0
  555. package/dist/frontend/lowering/containers/array-methods.js.map +1 -0
  556. package/dist/frontend/lowering/containers/bytes.d.ts +17 -17
  557. package/dist/frontend/lowering/containers/bytes.js +419 -105
  558. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  559. package/dist/frontend/lowering/containers/callback-arguments.d.ts +26 -0
  560. package/dist/frontend/lowering/containers/callback-arguments.js +179 -0
  561. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -0
  562. package/dist/frontend/lowering/containers/collection-grouping.d.ts +19 -0
  563. package/dist/frontend/lowering/containers/collection-grouping.js +297 -0
  564. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -0
  565. package/dist/frontend/lowering/containers/collection-methods.d.ts +57 -0
  566. package/dist/frontend/lowering/containers/collection-methods.js +1314 -0
  567. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -0
  568. package/dist/frontend/lowering/containers/dynamic-receivers.d.ts +18 -0
  569. package/dist/frontend/lowering/containers/dynamic-receivers.js +114 -0
  570. package/dist/frontend/lowering/containers/dynamic-receivers.js.map +1 -0
  571. package/dist/frontend/lowering/containers/for-of.d.ts +60 -0
  572. package/dist/frontend/lowering/containers/for-of.js +643 -0
  573. package/dist/frontend/lowering/containers/for-of.js.map +1 -0
  574. package/dist/frontend/lowering/containers/indexed-objects.d.ts +132 -0
  575. package/dist/frontend/lowering/containers/indexed-objects.js +1743 -0
  576. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -0
  577. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +20 -0
  578. package/dist/frontend/lowering/containers/iterator-helpers.js +809 -0
  579. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -0
  580. package/dist/frontend/lowering/containers/string-and-regexp.js +580 -158
  581. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  582. package/dist/frontend/lowering/containers/string-replacement.js +213 -63
  583. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  584. package/dist/frontend/lowering/crypto-tables.js +263 -64
  585. package/dist/frontend/lowering/crypto-tables.js.map +1 -1
  586. package/dist/frontend/lowering/deferred-module-initializers.js +172 -68
  587. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  588. package/dist/frontend/lowering/deferred-module-initializers.test.js +41 -8
  589. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  590. package/dist/frontend/lowering/error-methods.js +339 -65
  591. package/dist/frontend/lowering/error-methods.js.map +1 -1
  592. package/dist/frontend/lowering/expressions/evaluation-safety.js +3 -2
  593. package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
  594. package/dist/frontend/lowering/expressions/global-symbols.js +2 -1
  595. package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -1
  596. package/dist/frontend/lowering/expressions/native-proxy.js +11 -5
  597. package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
  598. package/dist/frontend/lowering/expressions/nullish-assignment.js +67 -13
  599. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  600. package/dist/frontend/lowering/expressions/object-literals.js +589 -162
  601. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  602. package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
  603. package/dist/frontend/lowering/expressions/optional-chains.js +68 -17
  604. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  605. package/dist/frontend/lowering/expressions/union-field-write.js +45 -18
  606. package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
  607. package/dist/frontend/lowering/function-context.js +5 -1
  608. package/dist/frontend/lowering/function-context.js.map +1 -1
  609. package/dist/frontend/lowering/function-returns.d.ts +67 -0
  610. package/dist/frontend/lowering/function-returns.js +392 -0
  611. package/dist/frontend/lowering/function-returns.js.map +1 -0
  612. package/dist/frontend/lowering/generator-delegation.d.ts +1 -1
  613. package/dist/frontend/lowering/generator-delegation.js +171 -39
  614. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  615. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +1 -1
  616. package/dist/frontend/lowering/generator-dynamic-dispatch.js +176 -36
  617. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
  618. package/dist/frontend/lowering/generic-functions.d.ts +274 -0
  619. package/dist/frontend/lowering/generic-functions.js +1727 -0
  620. package/dist/frontend/lowering/generic-functions.js.map +1 -0
  621. package/dist/frontend/lowering/import-meta.d.ts +1 -1
  622. package/dist/frontend/lowering/import-meta.js +37 -14
  623. package/dist/frontend/lowering/import-meta.js.map +1 -1
  624. package/dist/frontend/lowering/indexed-comparison.js +6 -2
  625. package/dist/frontend/lowering/indexed-comparison.js.map +1 -1
  626. package/dist/frontend/lowering/iterator-consumption.d.ts +9 -0
  627. package/dist/frontend/lowering/iterator-consumption.js +91 -0
  628. package/dist/frontend/lowering/iterator-consumption.js.map +1 -0
  629. package/dist/frontend/lowering/lib-boundary.js +40 -17
  630. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  631. package/dist/frontend/lowering/lib-boundary.test.js +49 -11
  632. package/dist/frontend/lowering/lib-boundary.test.js.map +1 -1
  633. package/dist/frontend/lowering/lower-array-sort.d.ts +0 -19
  634. package/dist/frontend/lowering/lower-array-sort.js +331 -566
  635. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  636. package/dist/frontend/lowering/lower-assert.js +248 -43
  637. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  638. package/dist/frontend/lowering/lower-async-iteration.js +71 -16
  639. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  640. package/dist/frontend/lowering/lower-builtin-values.js +420 -71
  641. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  642. package/dist/frontend/lowering/lower-calls.d.ts +39 -558
  643. package/dist/frontend/lowering/lower-calls.js +2593 -5667
  644. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  645. package/dist/frontend/lowering/lower-classes.d.ts +243 -242
  646. package/dist/frontend/lowering/lower-classes.js +1701 -724
  647. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  648. package/dist/frontend/lowering/lower-comptime.d.ts +35 -35
  649. package/dist/frontend/lowering/lower-comptime.js +39 -37
  650. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  651. package/dist/frontend/lowering/lower-dgram.js +59 -31
  652. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  653. package/dist/frontend/lowering/lower-enums.js +5 -2
  654. package/dist/frontend/lowering/lower-enums.js.map +1 -1
  655. package/dist/frontend/lowering/lower-event-emitter.js +322 -85
  656. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  657. package/dist/frontend/lowering/lower-expando.js +19 -7
  658. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  659. package/dist/frontend/lowering/lower-exprs.d.ts +194 -194
  660. package/dist/frontend/lowering/lower-exprs.js +3446 -1154
  661. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  662. package/dist/frontend/lowering/lower-functions.d.ts +23 -0
  663. package/dist/frontend/lowering/lower-functions.js +449 -0
  664. package/dist/frontend/lowering/lower-functions.js.map +1 -0
  665. package/dist/frontend/lowering/lower-generators.js +121 -32
  666. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  667. package/dist/frontend/lowering/lower-global-value.js +15 -4
  668. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  669. package/dist/frontend/lowering/lower-inspect.js +479 -89
  670. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  671. package/dist/frontend/lowering/lower-island.d.ts +79 -79
  672. package/dist/frontend/lowering/lower-island.js +365 -273
  673. package/dist/frontend/lowering/lower-island.js.map +1 -1
  674. package/dist/frontend/lowering/lower-island.test.js +7 -2
  675. package/dist/frontend/lowering/lower-island.test.js.map +1 -1
  676. package/dist/frontend/lowering/lower-mixins.js +17 -8
  677. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  678. package/dist/frontend/lowering/lower-modules.d.ts +94 -94
  679. package/dist/frontend/lowering/lower-modules.js +612 -321
  680. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  681. package/dist/frontend/lowering/lower-modules.test.js +91 -20
  682. package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
  683. package/dist/frontend/lowering/lower-namespaces.js +25 -8
  684. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  685. package/dist/frontend/lowering/lower-node-module.js +115 -34
  686. package/dist/frontend/lowering/lower-node-module.js.map +1 -1
  687. package/dist/frontend/lowering/lower-server.js +1210 -290
  688. package/dist/frontend/lowering/lower-server.js.map +1 -1
  689. package/dist/frontend/lowering/lower-stmts.d.ts +148 -148
  690. package/dist/frontend/lowering/lower-stmts.js +2312 -984
  691. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  692. package/dist/frontend/lowering/lower-stmts.test.js +13 -5
  693. package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
  694. package/dist/frontend/lowering/lower-stream.js +362 -90
  695. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  696. package/dist/frontend/lowering/lower-system-errors.js +30 -8
  697. package/dist/frontend/lowering/lower-system-errors.js.map +1 -1
  698. package/dist/frontend/lowering/lower-test.js +40 -13
  699. package/dist/frontend/lowering/lower-test.js.map +1 -1
  700. package/dist/frontend/lowering/lower-timers.d.ts +31 -0
  701. package/dist/frontend/lowering/lower-timers.js +336 -0
  702. package/dist/frontend/lowering/lower-timers.js.map +1 -0
  703. package/dist/frontend/lowering/lower-url.d.ts +1 -1
  704. package/dist/frontend/lowering/lower-url.js +46 -13
  705. package/dist/frontend/lowering/lower-url.js.map +1 -1
  706. package/dist/frontend/lowering/lowerer.d.ts +21 -351
  707. package/dist/frontend/lowering/lowerer.js +1024 -2704
  708. package/dist/frontend/lowering/lowerer.js.map +1 -1
  709. package/dist/frontend/lowering/lowerer.test.js +85 -17
  710. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  711. package/dist/frontend/lowering/module-namespace-elements.js +43 -8
  712. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  713. package/dist/frontend/lowering/native-ffi.d.ts +21 -1
  714. package/dist/frontend/lowering/native-ffi.js +487 -18
  715. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  716. package/dist/frontend/lowering/object-enumeration-receiver.js +55 -10
  717. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
  718. package/dist/frontend/lowering/object-factory-new.d.ts +1 -1
  719. package/dist/frontend/lowering/object-factory-new.js +36 -11
  720. package/dist/frontend/lowering/object-factory-new.js.map +1 -1
  721. package/dist/frontend/lowering/optional-arguments.js +49 -20
  722. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  723. package/dist/frontend/lowering/pairs-snapshot.js +66 -14
  724. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  725. package/dist/frontend/lowering/runtime-optional-locals.js +3 -1
  726. package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -1
  727. package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -1
  728. package/dist/frontend/lowering/sanitize-class-types.js +4 -1
  729. package/dist/frontend/lowering/sanitize-class-types.js.map +1 -1
  730. package/dist/frontend/lowering/sanitize-class-types.test.js +86 -18
  731. package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -1
  732. package/dist/frontend/lowering/static-this.js +13 -6
  733. package/dist/frontend/lowering/static-this.js.map +1 -1
  734. package/dist/frontend/lowering/string-index.js +32 -10
  735. package/dist/frontend/lowering/string-index.js.map +1 -1
  736. package/dist/frontend/lowering/surfaces.d.ts +42 -42
  737. package/dist/frontend/lowering/surfaces.js +1094 -249
  738. package/dist/frontend/lowering/surfaces.js.map +1 -1
  739. package/dist/frontend/lowering/symbol-fields.js +40 -15
  740. package/dist/frontend/lowering/symbol-fields.js.map +1 -1
  741. package/dist/frontend/lowering/symbol-methods.js.map +1 -1
  742. package/dist/frontend/lowering/text-decoder-encoding.js +236 -24
  743. package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -1
  744. package/dist/frontend/lowering/text-decoder-encoding.test.js +84 -12
  745. package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -1
  746. package/dist/frontend/lowering/union-narrow.js +59 -16
  747. package/dist/frontend/lowering/union-narrow.js.map +1 -1
  748. package/dist/frontend/lowering/union-narrow.test.js +24 -7
  749. package/dist/frontend/lowering/union-narrow.test.js.map +1 -1
  750. package/dist/frontend/lowering/union-retag.js +155 -40
  751. package/dist/frontend/lowering/union-retag.js.map +1 -1
  752. package/dist/frontend/lowering/union-retag.test.js +131 -33
  753. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  754. package/dist/frontend/lowering/unregistered-class-types.js.map +1 -1
  755. package/dist/frontend/lowering/unregistered-class-types.test.js +34 -8
  756. package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -1
  757. package/dist/frontend/module-syntax.js +21 -8
  758. package/dist/frontend/module-syntax.js.map +1 -1
  759. package/dist/frontend/module-syntax.test.js +37 -13
  760. package/dist/frontend/module-syntax.test.js.map +1 -1
  761. package/dist/frontend/npm-fetch-analysis.js +13 -4
  762. package/dist/frontend/npm-fetch-analysis.js.map +1 -1
  763. package/dist/frontend/npm-fetch-analysis.test.js +33 -10
  764. package/dist/frontend/npm-fetch-analysis.test.js.map +1 -1
  765. package/dist/frontend/npm-fetch-node.js.map +1 -1
  766. package/dist/frontend/npm-fetch-syntax.js +4 -9
  767. package/dist/frontend/npm-fetch-syntax.js.map +1 -1
  768. package/dist/frontend/npm-node.js +3 -1
  769. package/dist/frontend/npm-node.js.map +1 -1
  770. package/dist/frontend/npm-static-bundled-cjs.js +88 -29
  771. package/dist/frontend/npm-static-bundled-cjs.js.map +1 -1
  772. package/dist/frontend/npm-static-bundled-cjs.test.js +29 -10
  773. package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -1
  774. package/dist/frontend/npm-static-declaration-syntax.js +148 -56
  775. package/dist/frontend/npm-static-declaration-syntax.js.map +1 -1
  776. package/dist/frontend/npm-static-declarations.d.ts +1 -1
  777. package/dist/frontend/npm-static-declarations.js.map +1 -1
  778. package/dist/frontend/npm-static-declarations.test.js +33 -7
  779. package/dist/frontend/npm-static-declarations.test.js.map +1 -1
  780. package/dist/frontend/npm-static-prune.js +26 -12
  781. package/dist/frontend/npm-static-prune.js.map +1 -1
  782. package/dist/frontend/npm-static-prune.test.js +17 -3
  783. package/dist/frontend/npm-static-prune.test.js.map +1 -1
  784. package/dist/frontend/npm-static-rewrite-host.js +2 -3
  785. package/dist/frontend/npm-static-rewrite-host.js.map +1 -1
  786. package/dist/frontend/npm-static-rewrite-syntax.js +64 -21
  787. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  788. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  789. package/dist/frontend/npm-static-subtyping.js +9 -4
  790. package/dist/frontend/npm-static-subtyping.js.map +1 -1
  791. package/dist/frontend/npm-static-subtyping.test.js +30 -6
  792. package/dist/frontend/npm-static-subtyping.test.js.map +1 -1
  793. package/dist/frontend/npm-static.js +15 -4
  794. package/dist/frontend/npm-static.js.map +1 -1
  795. package/dist/frontend/npm.js +122 -36
  796. package/dist/frontend/npm.js.map +1 -1
  797. package/dist/frontend/npm.test.js +30 -10
  798. package/dist/frontend/npm.test.js.map +1 -1
  799. package/dist/frontend/pipeline-native.js.map +1 -1
  800. package/dist/frontend/pipeline.js +25 -8
  801. package/dist/frontend/pipeline.js.map +1 -1
  802. package/dist/frontend/pipeline.test.js +21 -7
  803. package/dist/frontend/pipeline.test.js.map +1 -1
  804. package/dist/frontend/program-node.js +5 -3
  805. package/dist/frontend/program-node.js.map +1 -1
  806. package/dist/frontend/program.d.ts +2 -2
  807. package/dist/frontend/program.js +234 -101
  808. package/dist/frontend/program.js.map +1 -1
  809. package/dist/frontend/program.test.js +27 -27
  810. package/dist/frontend/program.test.js.map +1 -1
  811. package/dist/frontend/provenance-core.js +8 -4
  812. package/dist/frontend/provenance-core.js.map +1 -1
  813. package/dist/frontend/provenance-registry.js +1 -4
  814. package/dist/frontend/provenance-registry.js.map +1 -1
  815. package/dist/frontend/resolve.js +32 -20
  816. package/dist/frontend/resolve.js.map +1 -1
  817. package/dist/frontend/resolve.test.js +1 -1
  818. package/dist/frontend/resolve.test.js.map +1 -1
  819. package/dist/frontend/runtime-resolve.js +13 -4
  820. package/dist/frontend/runtime-resolve.js.map +1 -1
  821. package/dist/frontend/runtime-resolve.test.js +25 -9
  822. package/dist/frontend/runtime-resolve.test.js.map +1 -1
  823. package/dist/frontend/services-node.js +6 -2
  824. package/dist/frontend/services-node.js.map +1 -1
  825. package/dist/frontend/services-node.test.js +18 -6
  826. package/dist/frontend/services-node.test.js.map +1 -1
  827. package/dist/frontend/services.js +8 -4
  828. package/dist/frontend/services.js.map +1 -1
  829. package/dist/frontend/services.test.js +6 -2
  830. package/dist/frontend/services.test.js.map +1 -1
  831. package/dist/frontend/ts7/api.js +12 -4
  832. package/dist/frontend/ts7/api.js.map +1 -1
  833. package/dist/frontend/ts7/ast-bytes.js +10 -3
  834. package/dist/frontend/ts7/ast-bytes.js.map +1 -1
  835. package/dist/frontend/ts7/ast-bytes.test.js +23 -4
  836. package/dist/frontend/ts7/ast-bytes.test.js.map +1 -1
  837. package/dist/frontend/ts7/ast-guards.test.js +14 -5
  838. package/dist/frontend/ts7/ast-guards.test.js.map +1 -1
  839. package/dist/frontend/ts7/ast-node.d.ts +6 -1
  840. package/dist/frontend/ts7/ast-node.js +484 -164
  841. package/dist/frontend/ts7/ast-node.js.map +1 -1
  842. package/dist/frontend/ts7/ast-node.test.js +109 -36
  843. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  844. package/dist/frontend/ts7/ast-text.js +13 -3
  845. package/dist/frontend/ts7/ast-text.js.map +1 -1
  846. package/dist/frontend/ts7/ast-text.test.js.map +1 -1
  847. package/dist/frontend/ts7/ast-types.js.map +1 -1
  848. package/dist/frontend/ts7/ast-wire.d.ts +1 -1
  849. package/dist/frontend/ts7/ast-wire.js +55 -20
  850. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  851. package/dist/frontend/ts7/ast-wire.test.js +53 -8
  852. package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
  853. package/dist/frontend/ts7/ast.js +47 -28
  854. package/dist/frontend/ts7/ast.js.map +1 -1
  855. package/dist/frontend/ts7/census-check.js +1 -1
  856. package/dist/frontend/ts7/census-check.js.map +1 -1
  857. package/dist/frontend/ts7/checker-cache.js.map +1 -1
  858. package/dist/frontend/ts7/checker.js +5 -3
  859. package/dist/frontend/ts7/checker.js.map +1 -1
  860. package/dist/frontend/ts7/checker.test.js +54 -17
  861. package/dist/frontend/ts7/checker.test.js.map +1 -1
  862. package/dist/frontend/ts7/enums.test.js +9 -4
  863. package/dist/frontend/ts7/enums.test.js.map +1 -1
  864. package/dist/frontend/ts7/native-api.js.map +1 -1
  865. package/dist/frontend/ts7/native-host.js.map +1 -1
  866. package/dist/frontend/ts7/native-process.js +9 -3
  867. package/dist/frontend/ts7/native-process.js.map +1 -1
  868. package/dist/frontend/ts7/program-adapter.js +1 -1
  869. package/dist/frontend/ts7/program-adapter.js.map +1 -1
  870. package/dist/frontend/ts7/program-host.js +7 -4
  871. package/dist/frontend/ts7/program-host.js.map +1 -1
  872. package/dist/frontend/ts7/program-host.test.js +43 -11
  873. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  874. package/dist/frontend/ts7/rpc-api.js +3 -1
  875. package/dist/frontend/ts7/rpc-api.js.map +1 -1
  876. package/dist/frontend/ts7/rpc-client.js +15 -5
  877. package/dist/frontend/ts7/rpc-client.js.map +1 -1
  878. package/dist/frontend/ts7/rpc-client.test.js +26 -8
  879. package/dist/frontend/ts7/rpc-client.test.js.map +1 -1
  880. package/dist/frontend/ts7/rpc-filesystem.js.map +1 -1
  881. package/dist/frontend/ts7/rpc-filesystem.test.js +43 -10
  882. package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -1
  883. package/dist/frontend/ts7/rpc-process.js +16 -6
  884. package/dist/frontend/ts7/rpc-process.js.map +1 -1
  885. package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
  886. package/dist/frontend/ts7/rpc-wire.d.ts +1 -0
  887. package/dist/frontend/ts7/rpc-wire.js +41 -14
  888. package/dist/frontend/ts7/rpc-wire.js.map +1 -1
  889. package/dist/frontend/ts7/rpc-wire.test.js +36 -6
  890. package/dist/frontend/ts7/rpc-wire.test.js.map +1 -1
  891. package/dist/frontend/ts7/semantic-checker.js +209 -68
  892. package/dist/frontend/ts7/semantic-checker.js.map +1 -1
  893. package/dist/frontend/ts7/semantic-checker.test.js +29 -14
  894. package/dist/frontend/ts7/semantic-checker.test.js.map +1 -1
  895. package/dist/frontend/ts7/semantic-json.js +7 -1
  896. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  897. package/dist/frontend/ts7/semantic-json.test.js +17 -3
  898. package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
  899. package/dist/frontend/ts7/semantic-model.js +147 -51
  900. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  901. package/dist/frontend/ts7/semantic-model.test.js +72 -19
  902. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  903. package/dist/frontend/ts7/semantic-types.d.ts +2 -2
  904. package/dist/frontend/ts7/session-cache.js +10 -3
  905. package/dist/frontend/ts7/session-cache.js.map +1 -1
  906. package/dist/frontend/ts7/session-cache.test.js +13 -4
  907. package/dist/frontend/ts7/session-cache.test.js.map +1 -1
  908. package/dist/frontend/ts7/session-path.js +25 -10
  909. package/dist/frontend/ts7/session-path.js.map +1 -1
  910. package/dist/frontend/ts7/session-path.test.js +47 -4
  911. package/dist/frontend/ts7/session-path.test.js.map +1 -1
  912. package/dist/frontend/ts7/session-timing.js +22 -3
  913. package/dist/frontend/ts7/session-timing.js.map +1 -1
  914. package/dist/frontend/ts7/session-timing.test.js +12 -3
  915. package/dist/frontend/ts7/session-timing.test.js.map +1 -1
  916. package/dist/frontend/ts7/session.d.ts +1 -0
  917. package/dist/frontend/ts7/session.js +109 -35
  918. package/dist/frontend/ts7/session.js.map +1 -1
  919. package/dist/frontend/ts7/session.test.js +69 -15
  920. package/dist/frontend/ts7/session.test.js.map +1 -1
  921. package/dist/frontend/ts7/source-parser.js +17 -6
  922. package/dist/frontend/ts7/source-parser.js.map +1 -1
  923. package/dist/frontend/ts7/source-parser.test.js +32 -9
  924. package/dist/frontend/ts7/source-parser.test.js.map +1 -1
  925. package/dist/frontend/tsc-codes.js +56 -11
  926. package/dist/frontend/tsc-codes.js.map +1 -1
  927. package/dist/frontend/tsc-codes.test.d.ts +1 -0
  928. package/dist/frontend/tsc-codes.test.js +16 -0
  929. package/dist/frontend/tsc-codes.test.js.map +1 -0
  930. package/dist/frontend/type-mapper.js +545 -204
  931. package/dist/frontend/type-mapper.js.map +1 -1
  932. package/dist/frontend/type-mapper.test.js +108 -33
  933. package/dist/frontend/type-mapper.test.js.map +1 -1
  934. package/dist/frontend/union-discriminants.js +8 -2
  935. package/dist/frontend/union-discriminants.js.map +1 -1
  936. package/dist/frontend/union-discriminants.test.js +77 -20
  937. package/dist/frontend/union-discriminants.test.js.map +1 -1
  938. package/dist/index.d.ts +9 -8
  939. package/dist/index.js +150 -81
  940. package/dist/index.js.map +1 -1
  941. package/dist/ir/analysis.js +95 -38
  942. package/dist/ir/analysis.js.map +1 -1
  943. package/dist/ir/analysis.test.js +91 -15
  944. package/dist/ir/analysis.test.js.map +1 -1
  945. package/dist/ir/api.d.ts +4 -0
  946. package/dist/ir/api.js +6 -0
  947. package/dist/ir/api.js.map +1 -0
  948. package/dist/ir/build.d.ts +7 -0
  949. package/dist/ir/build.js +27 -1
  950. package/dist/ir/build.js.map +1 -1
  951. package/dist/ir/builtin-effects.d.ts +9 -0
  952. package/dist/ir/builtin-effects.js +631 -0
  953. package/dist/ir/builtin-effects.js.map +1 -0
  954. package/dist/ir/builtin-signatures.d.ts +15 -0
  955. package/dist/ir/builtin-signatures.js +3396 -0
  956. package/dist/ir/builtin-signatures.js.map +1 -0
  957. package/dist/ir/byte-numbers.js +67 -16
  958. package/dist/ir/byte-numbers.js.map +1 -1
  959. package/dist/ir/byte-numbers.test.js +17 -4
  960. package/dist/ir/byte-numbers.test.js.map +1 -1
  961. package/dist/ir/constant-tables.js +13 -5
  962. package/dist/ir/constant-tables.js.map +1 -1
  963. package/dist/ir/constant-tables.test.js +47 -7
  964. package/dist/ir/constant-tables.test.js.map +1 -1
  965. package/dist/ir/control-flow.js +2 -1
  966. package/dist/ir/control-flow.js.map +1 -1
  967. package/dist/ir/control-flow.test.js +35 -11
  968. package/dist/ir/control-flow.test.js.map +1 -1
  969. package/dist/ir/initializer-bindings.d.ts +9 -0
  970. package/dist/ir/initializer-bindings.js +115 -0
  971. package/dist/ir/initializer-bindings.js.map +1 -0
  972. package/dist/ir/initializer-bindings.test.d.ts +1 -0
  973. package/dist/ir/initializer-bindings.test.js +118 -0
  974. package/dist/ir/initializer-bindings.test.js.map +1 -0
  975. package/dist/ir/integer-loop-facts.d.ts +12 -0
  976. package/dist/ir/integer-loop-facts.js +137 -0
  977. package/dist/ir/integer-loop-facts.js.map +1 -0
  978. package/dist/ir/integer-loops.js +85 -30
  979. package/dist/ir/integer-loops.js.map +1 -1
  980. package/dist/ir/integer-loops.test.js +76 -13
  981. package/dist/ir/integer-loops.test.js.map +1 -1
  982. package/dist/ir/integer-ranges.js +93 -21
  983. package/dist/ir/integer-ranges.js.map +1 -1
  984. package/dist/ir/integer-ranges.test.js +199 -21
  985. package/dist/ir/integer-ranges.test.js.map +1 -1
  986. package/dist/ir/intrinsic-signatures.d.ts +20 -0
  987. package/dist/ir/intrinsic-signatures.js +57 -0
  988. package/dist/ir/intrinsic-signatures.js.map +1 -0
  989. package/dist/ir/ir.d.ts +6 -2150
  990. package/dist/ir/ir.js +160 -1396
  991. package/dist/ir/ir.js.map +1 -1
  992. package/dist/ir/ir.test.js +98 -77
  993. package/dist/ir/ir.test.js.map +1 -1
  994. package/dist/ir/runtime-features.d.ts +221 -0
  995. package/dist/ir/runtime-features.js +551 -0
  996. package/dist/ir/runtime-features.js.map +1 -0
  997. package/dist/ir/runtime-features.test.d.ts +1 -0
  998. package/dist/ir/runtime-features.test.js +98 -0
  999. package/dist/ir/runtime-features.test.js.map +1 -0
  1000. package/dist/ir/scalar-records.js +130 -40
  1001. package/dist/ir/scalar-records.js.map +1 -1
  1002. package/dist/ir/scalar-records.test.js +146 -27
  1003. package/dist/ir/scalar-records.test.js.map +1 -1
  1004. package/dist/ir/serialize.js +4 -2
  1005. package/dist/ir/serialize.js.map +1 -1
  1006. package/dist/ir/serialize.test.js +44 -9
  1007. package/dist/ir/serialize.test.js.map +1 -1
  1008. package/dist/ir/traverse.js +156 -43
  1009. package/dist/ir/traverse.js.map +1 -1
  1010. package/dist/ir/traverse.test.js +99 -24
  1011. package/dist/ir/traverse.test.js.map +1 -1
  1012. package/dist/ir/validate.d.ts +1 -31
  1013. package/dist/ir/validate.js +782 -1889
  1014. package/dist/ir/validate.js.map +1 -1
  1015. package/dist/ir/validate.test.js +610 -114
  1016. package/dist/ir/validate.test.js.map +1 -1
  1017. package/dist/library/cache-primitives.js +9 -10
  1018. package/dist/library/cache-primitives.js.map +1 -1
  1019. package/dist/library/cache-reset.test.js +2 -1
  1020. package/dist/library/cache-reset.test.js.map +1 -1
  1021. package/dist/library/compiler-self-identity.js +11 -5
  1022. package/dist/library/compiler-self-identity.js.map +1 -1
  1023. package/dist/library/compiler-self-identity.test.js +10 -3
  1024. package/dist/library/compiler-self-identity.test.js.map +1 -1
  1025. package/dist/library/fence-eval.js +24 -7
  1026. package/dist/library/fence-eval.js.map +1 -1
  1027. package/dist/library/fence-eval.test.js +31 -7
  1028. package/dist/library/fence-eval.test.js.map +1 -1
  1029. package/dist/library/int-infer.js +199 -59
  1030. package/dist/library/int-infer.js.map +1 -1
  1031. package/dist/library/int-infer.test.js +133 -57
  1032. package/dist/library/int-infer.test.js.map +1 -1
  1033. package/dist/library/ir-policy.d.ts +27 -0
  1034. package/dist/library/ir-policy.js +232 -0
  1035. package/dist/library/ir-policy.js.map +1 -0
  1036. package/dist/library/library-cache.js +40 -17
  1037. package/dist/library/library-cache.js.map +1 -1
  1038. package/dist/library/library-cache.test.js +24 -13
  1039. package/dist/library/library-cache.test.js.map +1 -1
  1040. package/dist/library/library-profile.js +68 -13
  1041. package/dist/library/library-profile.js.map +1 -1
  1042. package/dist/library/prepare.js +48 -20
  1043. package/dist/library/prepare.js.map +1 -1
  1044. package/dist/library/semantic-source.js +16 -14
  1045. package/dist/library/semantic-source.js.map +1 -1
  1046. package/dist/library/semantic-source.test.js +9 -14
  1047. package/dist/library/semantic-source.test.js.map +1 -1
  1048. package/dist/library/sidecar-validate.js +53 -12
  1049. package/dist/library/sidecar-validate.js.map +1 -1
  1050. package/dist/library/sidecar.js +85 -24
  1051. package/dist/library/sidecar.js.map +1 -1
  1052. package/dist/library/trap-teaching.js +11 -2
  1053. package/dist/library/trap-teaching.js.map +1 -1
  1054. package/dist/native/cache.js +10 -4
  1055. package/dist/native/cache.js.map +1 -1
  1056. package/dist/native/cli.js +34 -9
  1057. package/dist/native/cli.js.map +1 -1
  1058. package/dist/native/compiler.js +167 -43
  1059. package/dist/native/compiler.js.map +1 -1
  1060. package/dist/native/compiler.test.js +129 -32
  1061. package/dist/native/compiler.test.js.map +1 -1
  1062. package/dist/native/comptime.js +23 -7
  1063. package/dist/native/comptime.js.map +1 -1
  1064. package/dist/native/comptime.test.js +26 -6
  1065. package/dist/native/comptime.test.js.map +1 -1
  1066. package/dist/native/executable-cache.js +77 -27
  1067. package/dist/native/executable-cache.js.map +1 -1
  1068. package/dist/native/executable-cache.test.js +41 -6
  1069. package/dist/native/executable-cache.test.js.map +1 -1
  1070. package/dist/native/file-identity.js +9 -2
  1071. package/dist/native/file-identity.js.map +1 -1
  1072. package/dist/native/file-identity.test.js.map +1 -1
  1073. package/dist/native/library.js +50 -12
  1074. package/dist/native/library.js.map +1 -1
  1075. package/dist/native/prepare.js +119 -34
  1076. package/dist/native/prepare.js.map +1 -1
  1077. package/dist/native/prepare.test.js +22 -6
  1078. package/dist/native/prepare.test.js.map +1 -1
  1079. package/dist/native/runtime-typescript.js +24 -11
  1080. package/dist/native/runtime-typescript.js.map +1 -1
  1081. package/dist/native/runtime-typescript.test.js.map +1 -1
  1082. package/dist/native/sanitizer.js +71 -18
  1083. package/dist/native/sanitizer.js.map +1 -1
  1084. package/dist/native/sanitizer.test.js +77 -20
  1085. package/dist/native/sanitizer.test.js.map +1 -1
  1086. package/dist/native/task.js.map +1 -1
  1087. package/dist/native/task.test.js +7 -2
  1088. package/dist/native/task.test.js.map +1 -1
  1089. package/dist/native/toolchain.js +68 -26
  1090. package/dist/native/toolchain.js.map +1 -1
  1091. package/dist/native/toolchain.test.js +59 -20
  1092. package/dist/native/toolchain.test.js.map +1 -1
  1093. package/dist/startup-cache.d.ts +1 -1
  1094. package/dist/startup-cache.js +1 -1
  1095. package/dist/startup-cache.js.map +1 -1
  1096. package/dist/timing.js.map +1 -1
  1097. package/package.json +20 -20
  1098. package/surface-manifest.json +1 -1
  1099. package/dist/frontend/lowering/lower-builtins.d.ts +0 -601
  1100. package/dist/frontend/lowering/lower-builtins.js +0 -8986
  1101. package/dist/frontend/lowering/lower-builtins.js.map +0 -1
  1102. package/dist/frontend/lowering/lower-containers.d.ts +0 -382
  1103. package/dist/frontend/lowering/lower-containers.js +0 -7344
  1104. package/dist/frontend/lowering/lower-containers.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { dynUndefinedExpr } from "../../ir/build.js";
1
2
  import { everyStmtList, everyTypeChild } from "../../ir/traverse.js";
2
3
  import { InternalCompilerError } from "../../errors.js";
3
4
  /* Module-graph lowering: splitting each source file into its parts, the
@@ -7,26 +8,30 @@ import { InternalCompilerError } from "../../errors.js";
7
8
  import * as ts from "../ts7/adapter.js";
8
9
  import { bindingSource } from "../binding-source.js";
9
10
  import { dirname as dirnamePath, isAbsolute, resolve as resolvePath } from "node:path";
10
- import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal } from "../npm.js";
11
+ import { NpmGraphBuilder, packageNameOfPath, probeNodeImportRefusal, probeNodeRequireRefusal, } from "../npm.js";
11
12
  import { isNpmStaticPackage } from "../npm-static.js";
12
13
  import { isJsSourceFileName } from "../tsc-codes.js";
13
14
  import { isRelativeSpecifier } from "../workspace-registry.js";
14
- import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport } from "../program.js";
15
- import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag } from "../../diagnostics/diagnostic.js";
16
- import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType } from "../../ir/ir.js";
17
- import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, dynUndefinedExpr, importCallHandleType, newFnCtx, staticImportNamespaceType, uncheckedOverloadHandleCall } from "./lowerer.js";
18
- import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf, isPromisifyCall, registerBuiltinCallableAlias, stripTypeCasts } from "./lower-builtins.js";
19
- import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, bindingNeverReassigned, deadUnmappableBinding, funcTypeFromParamShapes, implicitLocalFnInfoOf, implicitLocalFnNodeOf, nullishGenericBindingUnitOf, registerOverloadedCallableAlias } from "./lower-calls.js";
20
- import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl } from "./lower-stmts.js";
15
+ import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport, } from "../program.js";
16
+ import { invalidJsonModuleDiag, npmEmbedFailedDiag, requiresDynamicImportDiag, } from "../../diagnostics/diagnostic.js";
17
+ import { BOOL, DYN, F64, JSVAL, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType, } from "../../ir/ir.js";
18
+ import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, importCallHandleType, newFnCtx, staticImportNamespaceType, uncheckedOverloadHandleCall, } from "./lowerer.js";
19
+ import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, createRequireSpecOf, } from "./builtins/module-bindings.js";
20
+ import { isPromisifyCall, registerBuiltinCallableAlias } from "./builtins/callable-aliases.js";
21
+ import { stripTypeCasts } from "./builtins/arguments.js";
22
+ import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, implicitLocalFnInfoOf, implicitLocalFnNodeOf, } from "./generic-functions.js";
23
+ import { bindingNeverReassigned, deadUnmappableBinding, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
24
+ import { funcTypeFromParamShapes, registerOverloadedCallableAlias } from "./call-signatures.js";
25
+ import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl, } from "./lower-stmts.js";
21
26
  import { objectFactoryGlobalType } from "./object-factory-new.js";
22
27
  import { streamClassAliasDecl } from "./lower-stream.js";
23
28
  import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
24
29
  import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
25
- import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf } from "./lower-namespaces.js";
30
+ import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
26
31
  import { collectExpandoMembers } from "./lower-expando.js";
27
32
  import { recordTextCodecClass } from "../../ir/ir.js";
28
33
  import { isUnitOnlyTsType, unitOnlyUnion } from "../type-mapper.js";
29
- import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType } from "./lower-classes.js";
34
+ import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType, } from "./lower-classes.js";
30
35
  import { isMixinFnBinding, mixinResultBindingClassOf } from "./lower-mixins.js";
31
36
  import { cjsModuleRef, cjsModuleRegistryPrelude } from "./lower-node-module.js";
32
37
  import { forkTargetPaths } from "../fork-target.js";
@@ -88,10 +93,10 @@ export function appendForkModules(program, order, targets, onCycle) {
88
93
  order.splice(order.length - 1, 0, ...added);
89
94
  }
90
95
  /** Splits each file into function/class declarations and the top-level
91
- * statements that form its init body. Node's evaluation order (depth-first
92
- * postorder, entry last), computed by preflight. Single-file programs
93
- * (tests, coverage on broken files) may arrive with an empty order — fall
94
- * back to the entry alone. */
96
+ * statements that form its init body. Node's evaluation order (depth-first
97
+ * postorder, entry last), computed by preflight. Single-file programs
98
+ * (tests, coverage on broken files) may arrive with an empty order — fall
99
+ * back to the entry alone. */
95
100
  export function splitFiles(lowerer) {
96
101
  const files = lowerer.moduleOrder.length > 0 ? lowerer.moduleOrder : [lowerer.entry];
97
102
  return files.map((sf) => {
@@ -123,10 +128,10 @@ export function splitFiles(lowerer) {
123
128
  });
124
129
  }
125
130
  /** A source file dynamic `import("<project specifier>")` can host as a COMPILED
126
- * module namespace (lowerOwnModuleImport): a non-declaration program file
127
- * that is not JSON and not CommonJS-flavored (a CJS namespace is built
128
- * from module.exports through Node's lexer — a different surface with no
129
- * static story here). Null for everything else. */
131
+ * module namespace (lowerOwnModuleImport): a non-declaration program file
132
+ * that is not JSON and not CommonJS-flavored (a CJS namespace is built
133
+ * from module.exports through Node's lexer — a different surface with no
134
+ * static story here). Null for everything else. */
130
135
  function dynamicImportProgramTargetOf(program, sf, spec) {
131
136
  const dep = resolveImport(program, sf, spec);
132
137
  if (!dep || dep.isDeclarationFile)
@@ -138,7 +143,7 @@ function dynamicImportProgramTargetOf(program, sf, spec) {
138
143
  return dep;
139
144
  }
140
145
  /** Every distinct program module a file's `import("literal")` sites name
141
- * (source order, deduped). */
146
+ * (source order, deduped). */
142
147
  function dynamicProgramImportsOf(program, sf) {
143
148
  const out = [];
144
149
  const seen = new Set();
@@ -157,21 +162,21 @@ function dynamicProgramImportsOf(program, sf) {
157
162
  return out;
158
163
  }
159
164
  /** --dynamic builds: program modules reachable ONLY through dynamic
160
- * `import()` join the compiled module graph — appended to `order` (before
161
- * the entry, which stays last) in depth-first postorder over their own
162
- * static import edges, exactly like preflight ordered the static graph.
163
- * NOTHING calls their %init at startup (%main runs only the entry's init,
164
- * and no static import header names these), so a dynamic-only module
165
- * still evaluates exactly when Node evaluates it: the import() site's
166
- * namespace builder calls the guarded init on the engine microtask.
167
- * Fixpoint: an added module's own import() sites are scanned too. Static
168
- * cycles inside the added subgraph ride preflight's own admission engine
169
- * (makeCycleAdmission — preflight only walked the entry's static graph,
170
- * so it never judged these): benign back edges are Node cache hits the
171
- * run-once init guards reproduce, and inadmissible ones get preflight's
172
- * SC1016 with the same narrowed reason via `onCycle`. Idempotent —
173
- * re-running on an already-extended order adds nothing (both lowering
174
- * passes share one array). */
165
+ * `import()` join the compiled module graph — appended to `order` (before
166
+ * the entry, which stays last) in depth-first postorder over their own
167
+ * static import edges, exactly like preflight ordered the static graph.
168
+ * NOTHING calls their %init at startup (%main runs only the entry's init,
169
+ * and no static import header names these), so a dynamic-only module
170
+ * still evaluates exactly when Node evaluates it: the import() site's
171
+ * namespace builder calls the guarded init on the engine microtask.
172
+ * Fixpoint: an added module's own import() sites are scanned too. Static
173
+ * cycles inside the added subgraph ride preflight's own admission engine
174
+ * (makeCycleAdmission — preflight only walked the entry's static graph,
175
+ * so it never judged these): benign back edges are Node cache hits the
176
+ * run-once init guards reproduce, and inadmissible ones get preflight's
177
+ * SC1016 with the same narrowed reason via `onCycle`. Idempotent —
178
+ * re-running on an already-extended order adds nothing (both lowering
179
+ * passes share one array). */
175
180
  export function appendDynamicImportModules(program, order, onCycle) {
176
181
  if (order.length === 0)
177
182
  return; // no preflight order — sites keep their fences
@@ -224,10 +229,10 @@ export function appendDynamicImportModules(program, order, onCycle) {
224
229
  order.splice(order.length - 1, 0, ...added);
225
230
  }
226
231
  /** Collect pass over the WHOLE program: signatures, class shapes, and
227
- * file-scope globals visible everywhere → hoisting, mutual recursion, and
228
- * cross-module references fall out for free. Runs in both passes —
229
- * signatures are cheap and calls resolve against them; only BODY lowering
230
- * is reachability-gated. */
232
+ * file-scope globals visible everywhere → hoisting, mutual recursion, and
233
+ * cross-module references fall out for free. Runs in both passes —
234
+ * signatures are cheap and calls resolve against them; only BODY lowering
235
+ * is reachability-gated. */
231
236
  export function collectProgram(lowerer, parts) {
232
237
  const computed = new Set();
233
238
  for (const fp of parts)
@@ -238,7 +243,9 @@ export function collectProgram(lowerer, parts) {
238
243
  }
239
244
  // Descendants need the computed ancestor's completed layout before
240
245
  // their own fields and inherited methods can be collected.
241
- const computedSymbols = new Set([...computed].map((decl) => declSymbolOf(lowerer, decl)).filter((symbol) => symbol !== undefined));
246
+ const computedSymbols = new Set([...computed]
247
+ .map((decl) => declSymbolOf(lowerer, decl))
248
+ .filter((symbol) => symbol !== undefined));
242
249
  let expanded = true;
243
250
  while (expanded) {
244
251
  expanded = false;
@@ -312,18 +319,39 @@ export function collectProgram(lowerer, parts) {
312
319
  if (value.type.kind === "dyn" || value.type.kind === "func") {
313
320
  const name = `%class.base.${lowerer.classNamer(decl)}`;
314
321
  const loc = locOf(expression);
315
- lowerer.liftedFns.push({ name, params: [], returnType: value.type, locals: context.locals,
316
- body: [{ kind: "return", value, loc }], loc });
317
- lowerer.computedCallableBases.set(decl, { kind: "call", callee: name, args: [], type: value.type, loc });
322
+ lowerer.liftedFns.push({
323
+ name,
324
+ params: [],
325
+ returnType: value.type,
326
+ locals: context.locals,
327
+ body: [{ kind: "return", value, loc }],
328
+ loc,
329
+ });
330
+ lowerer.computedCallableBases.set(decl, {
331
+ kind: "call",
332
+ callee: name,
333
+ args: [],
334
+ type: value.type,
335
+ loc,
336
+ });
318
337
  }
319
338
  if (value.type.kind === "classval") {
320
339
  const classInfo = lowerer.classes.get(value.type.className);
321
340
  if (classInfo) {
322
341
  const name = `%class.base.${lowerer.classNamer(decl)}`;
323
342
  const loc = locOf(expression);
324
- lowerer.liftedFns.push({ name, params: [], returnType: value.type, locals: context.locals,
325
- body: [{ kind: "return", value, loc }], loc });
326
- lowerer.computedClassBases.set(lowerer.classNamer(decl), { value: { kind: "call", callee: name, args: [], type: value.type, loc }, classInfo });
343
+ lowerer.liftedFns.push({
344
+ name,
345
+ params: [],
346
+ returnType: value.type,
347
+ locals: context.locals,
348
+ body: [{ kind: "return", value, loc }],
349
+ loc,
350
+ });
351
+ lowerer.computedClassBases.set(lowerer.classNamer(decl), {
352
+ value: { kind: "call", callee: name, args: [], type: value.type, loc },
353
+ classInfo,
354
+ });
327
355
  }
328
356
  }
329
357
  }
@@ -343,25 +371,28 @@ export function collectProgram(lowerer, parts) {
343
371
  lowerer.diagSink = previousSink;
344
372
  }
345
373
  if (symbol && deferred.length) {
346
- lowerer.deferredDiags.set(symbol, [...(lowerer.deferredDiags.get(symbol) ?? []), ...deferred]);
374
+ lowerer.deferredDiags.set(symbol, [
375
+ ...(lowerer.deferredDiags.get(symbol) ?? []),
376
+ ...deferred,
377
+ ]);
347
378
  lowerer.deferredClassByName.set(lowerer.classNamer(decl), symbol);
348
379
  }
349
380
  lowerer.collecting = wasCollecting;
350
381
  }
351
382
  }
352
383
  /** The npm-import chokepoint, run once per pass during collection (so
353
- * bodies lowered in ANY pass resolve the bindings). In a static build
354
- * every value-importing npm import reports the requires-dynamic
355
- * diagnostic naming the package — the package's shipped JS has exactly
356
- * one execution home, the embedded engine. Under --dynamic each value
357
- * binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
358
- * importing the same export share one global) and initialized at the
359
- * top of the importing module's %init by island.import — the engine's
360
- * module registry caches, so re-imports are lookups, not re-evaluations.
361
- * The runtime graph (the package entry plus everything it reaches)
362
- * builds here too; its failures are ordinary diagnostics at the import
363
- * site. Type-only imports are free either way: the .d.ts is a type
364
- * surface, not code. */
384
+ * bodies lowered in ANY pass resolve the bindings). In a static build
385
+ * every value-importing npm import reports the requires-dynamic
386
+ * diagnostic naming the package — the package's shipped JS has exactly
387
+ * one execution home, the embedded engine. Under --dynamic each value
388
+ * binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
389
+ * importing the same export share one global) and initialized at the
390
+ * top of the importing module's %init by island.import — the engine's
391
+ * module registry caches, so re-imports are lookups, not re-evaluations.
392
+ * The runtime graph (the package entry plus everything it reaches)
393
+ * builds here too; its failures are ordinary diagnostics at the import
394
+ * site. Type-only imports are free either way: the .d.ts is a type
395
+ * surface, not code. */
365
396
  export function collectNpmImports(lowerer, parts) {
366
397
  const services = lowerer.frontendServices;
367
398
  if (lowerer.dynamic && services === undefined)
@@ -386,9 +417,12 @@ export function collectNpmImports(lowerer, parts) {
386
417
  !stmt.moduleSpecifier.text.startsWith("#")
387
418
  ? stmt.exportClause
388
419
  : null;
389
- if (reexport === null && (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
420
+ if (reexport === null &&
421
+ (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)))
390
422
  continue;
391
- const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt) ? stmt.moduleSpecifier : undefined;
423
+ const specNode = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt)
424
+ ? stmt.moduleSpecifier
425
+ : undefined;
392
426
  if (specNode === undefined || !ts.isStringLiteral(specNode))
393
427
  continue;
394
428
  const clause = ts.isImportDeclaration(stmt) ? stmt.importClause : undefined;
@@ -559,18 +593,18 @@ export function collectNpmImports(lowerer, parts) {
559
593
  }
560
594
  }
561
595
  /** Literal dynamic-import collection: every
562
- * `import("literal")` in the file — whatever body it sits in — resolves
563
- * and embeds AT COLLECTION time, so the per-site lowering later just
564
- * looks its key up (the emitted tables are assembled once, here; a
565
- * site lowered in any pass finds its module embedded). Resolution
566
- * In static builds this records compiled program modules and supported
567
- * builtins without constructing an npm graph. Dynamic package-resolution
568
- * failures and unshimmed builtins are diagnostics HERE, at the import
569
- * expression, exactly like static npm imports at their statements; the
570
- * lowering poisons those sites without re-reporting. Non-literal
571
- * specifiers are skipped — the lowering owns that fence (the module
572
- * graph is a build-time artifact; there is nothing to embed for a
573
- * runtime-computed name). */
596
+ * `import("literal")` in the file — whatever body it sits in — resolves
597
+ * and embeds AT COLLECTION time, so the per-site lowering later just
598
+ * looks its key up (the emitted tables are assembled once, here; a
599
+ * site lowered in any pass finds its module embedded). Resolution
600
+ * In static builds this records compiled program modules and supported
601
+ * builtins without constructing an npm graph. Dynamic package-resolution
602
+ * failures and unshimmed builtins are diagnostics HERE, at the import
603
+ * expression, exactly like static npm imports at their statements; the
604
+ * lowering poisons those sites without re-reporting. Non-literal
605
+ * specifiers are skipped — the lowering owns that fence (the module
606
+ * graph is a build-time artifact; there is nothing to embed for a
607
+ * runtime-computed name). */
574
608
  function collectDynamicImports(lowerer, builder, sf) {
575
609
  ts.walkPreorder(sf, (node) => {
576
610
  if (ts.isCallExpression(node) &&
@@ -590,7 +624,10 @@ function collectDynamicImports(lowerer, builder, sf) {
590
624
  // says so. Only non-declaration source files count; a sibling
591
625
  // .d.mts typing shipped JS is the EMBED case, not this one.
592
626
  const modSym = lowerer.checker.getSymbolAtLocation(node.arguments[0]);
593
- const ownModule = modSym !== undefined && lowerer.checker.declarationsOf(modSym).some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
627
+ const ownModule = modSym !== undefined &&
628
+ lowerer.checker
629
+ .declarationsOf(modSym)
630
+ .some((d) => ts.isSourceFile(d) && !d.isDeclarationFile);
594
631
  const builtin = canonicalBuiltinModule(spec);
595
632
  const res = ownModule
596
633
  ? { kind: "program-module" }
@@ -613,14 +650,14 @@ function collectDynamicImports(lowerer, builder, sf) {
613
650
  });
614
651
  }
615
652
  /** The createRequire half of the npm chokepoint (--dynamic only): every
616
- * `require("bare-literal")` through a createRequire binding — whatever
617
- * body it sits in — resolves under Node's "require" condition and
618
- * embeds AT COLLECTION time, so the per-site lowering later just looks
619
- * its entry up (lowerCreateRequireCall). Builtins, relative documents,
620
- * "#" specifiers, --npm-static opt-ins, and Node-refused bare names
621
- * are the lowering's own arms — only resolvable installed packages
622
- * register here; resolution failures are diagnostics at the call
623
- * expression, exactly like static npm imports at their statements. */
653
+ * `require("bare-literal")` through a createRequire binding — whatever
654
+ * body it sits in — resolves under Node's "require" condition and
655
+ * embeds AT COLLECTION time, so the per-site lowering later just looks
656
+ * its entry up (lowerCreateRequireCall). Builtins, relative documents,
657
+ * "#" specifiers, --npm-static opt-ins, and Node-refused bare names
658
+ * are the lowering's own arms — only resolvable installed packages
659
+ * register here; resolution failures are diagnostics at the call
660
+ * expression, exactly like static npm imports at their statements. */
624
661
  function collectCreateRequires(lowerer, builder, sf) {
625
662
  const visit = (node) => {
626
663
  if (ts.isCallExpression(node)) {
@@ -654,17 +691,17 @@ function collectCreateRequires(lowerer, builder, sf) {
654
691
  visit(sf);
655
692
  }
656
693
  /** JSON module default imports (`import pkg from "../package.json"`):
657
- * the document is DATA known at build time, so the binding bakes into a
658
- * record global — the checker's structural type for the module (thanks
659
- * to resolveJsonModule) maps to a record shape, the JSON text parses in
660
- * the compiler, and comptimeValueToIr turns the value into literal IR
661
- * assigned in the importing module's %init prelude (evaluation order:
662
- * imports before the importer's body, like npm bindings). Two importers
663
- * of the same document share one global (keyed by the ALIASED symbol).
664
- * Shapes outside the bakeable surface (null-valued fields, mixed
665
- * arrays, ...) report the standard unsupported-type diagnostic at the
666
- * import site. Preflight already fenced named/namespace JSON imports
667
- * and kept .json files out of the module order. */
694
+ * the document is DATA known at build time, so the binding bakes into a
695
+ * record global — the checker's structural type for the module (thanks
696
+ * to resolveJsonModule) maps to a record shape, the JSON text parses in
697
+ * the compiler, and comptimeValueToIr turns the value into literal IR
698
+ * assigned in the importing module's %init prelude (evaluation order:
699
+ * imports before the importer's body, like npm bindings). Two importers
700
+ * of the same document share one global (keyed by the ALIASED symbol).
701
+ * Shapes outside the bakeable surface (null-valued fields, mixed
702
+ * arrays, ...) report the standard unsupported-type diagnostic at the
703
+ * import site. Preflight already fenced named/namespace JSON imports
704
+ * and kept .json files out of the module order. */
668
705
  export function collectJsonImports(lowerer, parts) {
669
706
  for (const fp of parts) {
670
707
  for (const stmt of fp.sf.statements) {
@@ -723,14 +760,14 @@ export function collectJsonImports(lowerer, parts) {
723
760
  }
724
761
  }
725
762
  /** The classes, records, and unions the emitted module carries: exactly
726
- * what the lowered functions and globals reference, closed transitively
727
- * over record fields, union arms, class field types, base chains, and
728
- * constructible descendants and their base chains. Registry entries interned while collecting
729
- * signatures nothing reaches stay out — an unreached type leaves no
730
- * trace. A referenced class with no registration had its collection
731
- * deferred: the reference flushes those diagnostics. Methods whose
732
- * bodies were not lowered leave the def's method list, so vtable slots
733
- * exist exactly for emitted overrides. */
763
+ * what the lowered functions and globals reference, closed transitively
764
+ * over record fields, union arms, class field types, base chains, and
765
+ * constructible descendants and their base chains. Registry entries interned while collecting
766
+ * signatures nothing reaches stay out — an unreached type leaves no
767
+ * trace. A referenced class with no registration had its collection
768
+ * deferred: the reference flushes those diagnostics. Methods whose
769
+ * bodies were not lowered leave the def's method list, so vtable slots
770
+ * exist exactly for emitted overrides. */
734
771
  export function moduleArtifacts(lowerer, functions) {
735
772
  const valueInstanceOfRoots = new Set();
736
773
  const classNames = new Set();
@@ -741,23 +778,30 @@ export function moduleArtifacts(lowerer, functions) {
741
778
  const pendingUnions = [];
742
779
  const boxedChild = (type, seen = new Set()) => {
743
780
  switch (type.kind) {
744
- case "child": return true;
781
+ case "child":
782
+ return true;
745
783
  case "array":
746
- case "set": return boxedChild(type.elem, seen);
747
- case "promise": return boxedChild(type.inner, seen);
748
- case "map": return boxedChild(type.key, seen) || boxedChild(type.value, seen);
749
- case "func": return boxedChild(type.ret, seen);
784
+ case "set":
785
+ return boxedChild(type.elem, seen);
786
+ case "promise":
787
+ return boxedChild(type.inner, seen);
788
+ case "map":
789
+ return boxedChild(type.key, seen) || boxedChild(type.value, seen);
790
+ case "func":
791
+ return boxedChild(type.ret, seen);
750
792
  case "record":
751
793
  if (seen.has(type.shapeId))
752
794
  return false;
753
795
  seen.add(type.shapeId);
754
- return lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ?? false;
796
+ return (lowerer.shapes.get(type.shapeId)?.fields.some((field) => boxedChild(field.type, seen)) ??
797
+ false);
755
798
  case "union":
756
799
  if (seen.has(type.unionId))
757
800
  return false;
758
801
  seen.add(type.unionId);
759
802
  return lowerer.unions.get(type.unionId)?.arms.some((arm) => boxedChild(arm, seen)) ?? false;
760
- default: return false;
803
+ default:
804
+ return false;
761
805
  }
762
806
  };
763
807
  const visitClass = (name) => {
@@ -903,9 +947,7 @@ export function moduleArtifacts(lowerer, functions) {
903
947
  pendingClasses.push(name);
904
948
  }
905
949
  }
906
- while (pendingClasses.length > 0 ||
907
- pendingShapes.length > 0 ||
908
- pendingUnions.length > 0) {
950
+ while (pendingClasses.length > 0 || pendingShapes.length > 0 || pendingUnions.length > 0) {
909
951
  while (pendingShapes.length > 0) {
910
952
  // Declared fields AND the index-signature value type: an
911
953
  // overflow-valued shape (`{ [key: string]: {script?: string} }`)
@@ -987,14 +1029,14 @@ export function moduleArtifacts(lowerer, functions) {
987
1029
  };
988
1030
  }
989
1031
  /** Registers every DIRECT top-level `const`/`let` of a file as a module
990
- * global (stable storage: cross-module live bindings, and functions can
991
- * reference them without capture). Block-scoped vars inside nested
992
- * statements keep their different symbols and stay locals. */
1032
+ * global (stable storage: cross-module live bindings, and functions can
1033
+ * reference them without capture). Block-scoped vars inside nested
1034
+ * statements keep their different symbols and stay locals. */
993
1035
  /** JS collection failures defer to runtime fences: the registration's
994
- * diagnostics move off the build (into lowerer.runtimeFences) — the declaring
995
- * statement re-fails during init lowering and compiles to the
996
- * runtimeFence trap there, and every use site cascades to its own trap.
997
- * TypeScript files keep eager collection reports. */
1036
+ * diagnostics move off the build (into lowerer.runtimeFences) — the declaring
1037
+ * statement re-fails during init lowering and compiles to the
1038
+ * runtimeFence trap there, and every use site cascades to its own trap.
1039
+ * TypeScript files keep eager collection reports. */
998
1040
  function deferJsCollectionDiags(lowerer, sf, diagsBefore) {
999
1041
  if (!isJsSourceFile(sf))
1000
1042
  return;
@@ -1027,12 +1069,14 @@ function cjsScalarLiteral(e) {
1027
1069
  function checkedGlobalReference(lowerer, expression) {
1028
1070
  if (ts.isIdentifier(expression))
1029
1071
  return lowerer.globalOf(expression)?.type.kind === "dyn";
1030
- if (!ts.isPropertyAccessExpression(expression) || !ts.isIdentifier(expression.name) || !ts.isIdentifier(expression.expression))
1072
+ if (!ts.isPropertyAccessExpression(expression) ||
1073
+ !ts.isIdentifier(expression.name) ||
1074
+ !ts.isIdentifier(expression.expression))
1031
1075
  return false;
1032
1076
  const root = lowerer.checker.getSymbolAtLocation(expression.expression);
1033
1077
  const namespace = root && lowerer.checker.declarationsOf(root).some(ts.isNamespaceImport);
1034
- return (namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
1035
- lowerer.globalOf(expression.name)?.type.kind === "dyn";
1078
+ return ((namespace || lowerer.cjsLocalModuleBindingOf(expression.expression)) &&
1079
+ lowerer.globalOf(expression.name)?.type.kind === "dyn");
1036
1080
  }
1037
1081
  function jsDynHoldableInitializer(lowerer, init) {
1038
1082
  if (init === undefined)
@@ -1044,15 +1088,18 @@ function jsDynHoldableInitializer(lowerer, init) {
1044
1088
  e = e.expression;
1045
1089
  if (checkedGlobalReference(lowerer, e))
1046
1090
  return true;
1047
- if (ts.isCallExpression(e) && ts.isPropertyAccessExpression(e.expression) &&
1091
+ if (ts.isCallExpression(e) &&
1092
+ ts.isPropertyAccessExpression(e.expression) &&
1048
1093
  ["freeze", "seal", "preventExtensions"].includes(e.expression.name.text) &&
1049
- lowerer.stdlibGlobalMember(e.expression, "Object") !== null && e.arguments[0] &&
1094
+ lowerer.stdlibGlobalMember(e.expression, "Object") !== null &&
1095
+ e.arguments[0] &&
1050
1096
  ts.isArrayLiteralExpression(e.arguments[0]))
1051
1097
  return true;
1052
1098
  // The built-in Array constructor can create an evolving array whose
1053
1099
  // inferred element type has no native mapping. Its checked reference
1054
1100
  // must remain shared with separately declared functions and aliases.
1055
- if ((ts.isCallExpression(e) || ts.isNewExpression(e)) && lowerer.isStdlibGlobal(e.expression, "Array"))
1101
+ if ((ts.isCallExpression(e) || ts.isNewExpression(e)) &&
1102
+ lowerer.isStdlibGlobal(e.expression, "Array"))
1056
1103
  return true;
1057
1104
  // JavaScript process streams lower to native checked handles even when
1058
1105
  // their declared method overloads prevent a structural type mapping.
@@ -1061,7 +1108,8 @@ function jsDynHoldableInitializer(lowerer, init) {
1061
1108
  const member = lowerer.stdlibGlobalMember(e, "process");
1062
1109
  if (member === "stdin" || member === "stdout" || member === "stderr")
1063
1110
  return true;
1064
- if (e.name.text === "constructor" && lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
1111
+ if (e.name.text === "constructor" &&
1112
+ lowerer.checker.getCallSignatures(lowerer.typeOf(e.expression)).length > 0)
1065
1113
  return true;
1066
1114
  }
1067
1115
  if (e.kind === ts.SyntaxKind.NullKeyword)
@@ -1069,45 +1117,60 @@ function jsDynHoldableInitializer(lowerer, init) {
1069
1117
  if (ts.isIdentifier(e) && e.text === "undefined")
1070
1118
  return true;
1071
1119
  if (ts.isConditionalExpression(e)) {
1072
- return jsDynHoldableInitializer(lowerer, e.whenTrue) && jsDynHoldableInitializer(lowerer, e.whenFalse);
1120
+ return (jsDynHoldableInitializer(lowerer, e.whenTrue) &&
1121
+ jsDynHoldableInitializer(lowerer, e.whenFalse));
1073
1122
  }
1074
- if (ts.isBinaryExpression(e) && (e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
1075
- e.operatorToken.kind === ts.SyntaxKind.BarBarToken || e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
1123
+ if (ts.isBinaryExpression(e) &&
1124
+ (e.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken ||
1125
+ e.operatorToken.kind === ts.SyntaxKind.BarBarToken ||
1126
+ e.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken)) {
1076
1127
  return jsDynHoldableInitializer(lowerer, e.left) && jsDynHoldableInitializer(lowerer, e.right);
1077
1128
  }
1078
1129
  // A member of a checked module value is itself checked, including a
1079
1130
  // callable whose inferred overloads cannot describe one native ABI.
1080
1131
  if ((ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e)) &&
1081
- ts.isIdentifier(e.expression) && lowerer.globalOf(e.expression)?.type.kind === "dyn")
1132
+ ts.isIdentifier(e.expression) &&
1133
+ lowerer.globalOf(e.expression)?.type.kind === "dyn")
1082
1134
  return true;
1083
1135
  if (ts.isPropertyAccessExpression(e)) {
1084
1136
  const member = nsMemberIdentOf(lowerer, e);
1085
- if (member && (lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
1137
+ if (member &&
1138
+ (lowerer.globalOf(member)?.type.kind === "dyn" || lowerer.genericFnOf(member)?.implicitParams))
1086
1139
  return true;
1087
1140
  }
1088
1141
  // Optional callable reads (for example descriptor?.get) can be held in
1089
1142
  // the same checked slot as a callable. Their nullish arm must remain
1090
1143
  // observable by functions declared outside the module initializer.
1091
- if (ts.isPropertyAccessExpression(e) || ts.isElementAccessExpression(e) || ts.isCallExpression(e)) {
1144
+ if (ts.isPropertyAccessExpression(e) ||
1145
+ ts.isElementAccessExpression(e) ||
1146
+ ts.isCallExpression(e)) {
1092
1147
  const fallback = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
1093
- if (fallback?.kind === "func" && canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1148
+ if (fallback?.kind === "func" &&
1149
+ canBoxFuncIntoDyn(fallback, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1094
1150
  return true;
1095
1151
  const arms = fallback?.kind === "union" ? lowerer.unions.get(fallback.unionId)?.arms : undefined;
1096
- if (arms?.some(arm => arm.kind === "func") && arms.every(arm => isUnitType(arm) || (arm.kind === "func" && canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
1152
+ if (arms?.some((arm) => arm.kind === "func") &&
1153
+ arms.every((arm) => isUnitType(arm) ||
1154
+ (arm.kind === "func" &&
1155
+ canBoxFuncIntoDyn(arm, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))))
1097
1156
  return true;
1098
1157
  }
1099
- if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) && !e.typeParameters?.length && isJsSourceFile(e.getSourceFile()))
1158
+ if ((ts.isFunctionExpression(e) || ts.isArrowFunction(e)) &&
1159
+ !e.typeParameters?.length &&
1160
+ isJsSourceFile(e.getSourceFile()))
1100
1161
  return true;
1101
1162
  if (ts.isIdentifier(e) || ts.isArrowFunction(e) || ts.isFunctionExpression(e)) {
1102
1163
  if (ts.isIdentifier(e)) {
1103
1164
  if (lowerer.globalOf(e)?.type.kind === "dyn")
1104
1165
  return true;
1105
1166
  const signature = lowerer.isTopLevelFnSymbol(e) ? lowerer.fnSigOf(e) : null;
1106
- if (signature && canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1167
+ if (signature &&
1168
+ canBoxFuncIntoDyn(funcTypeFromParamShapes(signature.params, signature.returnType), (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1107
1169
  return true;
1108
1170
  }
1109
1171
  const type = lowerer.mapTypeOf(lowerer.typeOf(e)) ?? dynFallbackType(lowerer, e, lowerer.typeOf(e));
1110
- if (type?.kind === "func" && canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1172
+ if (type?.kind === "func" &&
1173
+ canBoxFuncIntoDyn(type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
1111
1174
  return true;
1112
1175
  }
1113
1176
  if ((ts.isCallExpression(e) || ts.isPropertyAccessExpression(e) || ts.isIdentifier(e)) &&
@@ -1192,9 +1255,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
1192
1255
  let inner = stmt.expression;
1193
1256
  while (ts.isParenthesizedExpression(inner))
1194
1257
  inner = inner.expression;
1195
- if (ts.isClassExpression(inner) && !isJsSourceFile(sf) &&
1258
+ if (ts.isClassExpression(inner) &&
1259
+ !isJsSourceFile(sf) &&
1196
1260
  inner.typeParameters === undefined &&
1197
- (decoratorNodesOf(inner).length > 0 || inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
1261
+ (decoratorNodesOf(inner).length > 0 ||
1262
+ inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
1198
1263
  guaranteedDecorationThrow(lowerer, inner) !== null) {
1199
1264
  continue;
1200
1265
  }
@@ -1214,7 +1279,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
1214
1279
  lowerer.badType(stmt.expression, tsType);
1215
1280
  // Inferred JavaScript factory exports keep their original value,
1216
1281
  // including callable objects decorated with Object.assign.
1217
- if (isJsSourceFile(sf) && ts.isCallExpression(stmt.expression) && type.kind === "record" && lowerer.dynConvertible(type))
1282
+ if (isJsSourceFile(sf) &&
1283
+ ts.isCallExpression(stmt.expression) &&
1284
+ type.kind === "record" &&
1285
+ lowerer.dynConvertible(type))
1218
1286
  type = DYN;
1219
1287
  // `export default undefined` — the unit-only union, like any
1220
1288
  // unit-only binding (`export default null` maps via mapType).
@@ -1253,7 +1321,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
1253
1321
  // tsgo answers no symbol at the attachment site's NAME (no
1254
1322
  // expando synthesis); the module symbol's exports table still
1255
1323
  // names the member — the same identity use sites resolve.
1256
- const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ?? lowerer.cjsModuleExportSymbol(sf, name);
1324
+ const symbol = lowerer.checker.getSymbolAtLocation(nameNode) ??
1325
+ lowerer.cjsModuleExportSymbol(sf, name);
1257
1326
  if (!symbol || lowerer.globalsBySymbol.has(symbol))
1258
1327
  return;
1259
1328
  // JS exports whose strict type has no mapping take the
@@ -1281,7 +1350,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1281
1350
  lowerer.globalsByDeclNode.set(d, vG);
1282
1351
  return;
1283
1352
  }
1284
- const g = { id: `%g.${tag}%export.${name}`, name, type: vG.type, mutable: false };
1353
+ const g = {
1354
+ id: `%g.${tag}%export.${name}`,
1355
+ name,
1356
+ type: vG.type,
1357
+ mutable: false,
1358
+ };
1285
1359
  lowerer.globalsBySymbol.set(symbol, g);
1286
1360
  for (const d of lowerer.checker.declarationsOf(symbol))
1287
1361
  lowerer.globalsByDeclNode.set(d, g);
@@ -1358,7 +1432,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1358
1432
  if (factoryValued && t?.kind === "record" && lowerer.dynConvertible(t))
1359
1433
  t = DYN;
1360
1434
  if (t && t.kind !== "void") {
1361
- const g = { id: `%g.${tag}exports`, name: "exports", type: t, mutable: false };
1435
+ const g = {
1436
+ id: `%g.${tag}exports`,
1437
+ name: "exports",
1438
+ type: t,
1439
+ mutable: false,
1440
+ };
1362
1441
  lowerer.globalsByDeclNode.set(cjs.expr, g);
1363
1442
  lowerer.globalsList.push(g);
1364
1443
  }
@@ -1399,7 +1478,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
1399
1478
  if (ts.isExternalModuleReference(stmt.moduleReference) || stmt.isTypeOnly)
1400
1479
  continue;
1401
1480
  const aliasSym = lowerer.checker.getSymbolAtLocation(stmt.name);
1402
- if (!aliasSym || !(aliasSym.flags & ts.SymbolFlags.Alias) || lowerer.globalsBySymbol.has(aliasSym))
1481
+ if (!aliasSym ||
1482
+ !(aliasSym.flags & ts.SymbolFlags.Alias) ||
1483
+ lowerer.globalsBySymbol.has(aliasSym))
1403
1484
  continue;
1404
1485
  const target = lowerer.checker.getAliasedSymbol(aliasSym);
1405
1486
  const vd = lowerer.checker.valueDeclarationOf(target);
@@ -1450,10 +1531,10 @@ export function collectGlobals(lowerer, sf, topStmts) {
1450
1531
  // require('node:process')` aliases the global process
1451
1532
  // (stdlibGlobalAliasDecl's require form) so reads through the
1452
1533
  // binding lower via the process surface.
1453
- if (isRequireStatement(stmt) && !(ts.isVariableStatement(stmt) &&
1454
- stmt.declarationList.declarations.some(decl => isNativeFfiRequire(lowerer, decl.initializer)))) {
1455
- if (ts.isVariableStatement(stmt) &&
1456
- (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
1534
+ if (isRequireStatement(stmt) &&
1535
+ !(ts.isVariableStatement(stmt) &&
1536
+ stmt.declarationList.declarations.some((decl) => isNativeFfiRequire(lowerer, decl.initializer)))) {
1537
+ if (ts.isVariableStatement(stmt) && (stmt.declarationList.flags & ts.NodeFlags.Const) !== 0) {
1457
1538
  for (const decl of stmt.declarationList.declarations) {
1458
1539
  stdlibGlobalAliasDecl(lowerer, decl.name, decl.initializer);
1459
1540
  }
@@ -1657,7 +1738,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
1657
1738
  // statement lowering skips the declaration by the same check. A
1658
1739
  // bad promisify target reports here (recorded once; the statement
1659
1740
  // lowering poisons too, like every collectGlobals failure).
1660
- if (ts.isIdentifier(decl.name) && decl.initializer && isPromisifyCall(lowerer, decl.initializer)) {
1741
+ if (ts.isIdentifier(decl.name) &&
1742
+ decl.initializer &&
1743
+ isPromisifyCall(lowerer, decl.initializer)) {
1661
1744
  try {
1662
1745
  lowerer.registerPromisifiedBuiltinDecl(decl.name, decl.initializer);
1663
1746
  }
@@ -1728,13 +1811,22 @@ export function collectGlobals(lowerer, sf, topStmts) {
1728
1811
  // Checked JavaScript factories can expose inferred callables by
1729
1812
  // destructuring. Keep each exported binding in module storage so
1730
1813
  // separately lowered functions see the initialized value.
1731
- if (isJsSourceFile(sf) && !ts.isIdentifier(decl.name) && decl.initializer &&
1732
- !decl.type && !hasJsTypeAnnotation(decl) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
1814
+ if (isJsSourceFile(sf) &&
1815
+ !ts.isIdentifier(decl.name) &&
1816
+ decl.initializer &&
1817
+ !decl.type &&
1818
+ !hasJsTypeAnnotation(decl) &&
1819
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode))) {
1733
1820
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1734
1821
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1735
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1736
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
1737
- ...(!isVarDeclared(decl) ? { tdz: true } : {}) };
1822
+ const g = {
1823
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1824
+ name: nameNode.text,
1825
+ type: DYN,
1826
+ mutable: isLet,
1827
+ source: bindingSource(nameNode),
1828
+ ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1829
+ };
1738
1830
  lowerer.globalsBySymbol.set(symbol, g);
1739
1831
  lowerer.globalsList.push(g);
1740
1832
  if (isVarDeclared(decl))
@@ -1746,16 +1838,25 @@ export function collectGlobals(lowerer, sf, topStmts) {
1746
1838
  // callable ABI. Preserve checked-native values in shared storage;
1747
1839
  // adapting the loader to (string) would replace its validation.
1748
1840
  const initializer = decl.initializer ? stripTypeCasts(decl.initializer) : undefined;
1749
- if (isJsSourceFile(sf) && nameNode === decl.name && initializer &&
1841
+ if (isJsSourceFile(sf) &&
1842
+ nameNode === decl.name &&
1843
+ initializer &&
1750
1844
  (isNativeBuiltinValueInitializer(lowerer, initializer) ||
1751
- (!decl.type && !hasJsTypeAnnotation(decl) && lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
1752
- (!decl.type && !hasJsTypeAnnotation(decl) && checkedGlobalReference(lowerer, initializer)) ||
1845
+ (!decl.type &&
1846
+ !hasJsTypeAnnotation(decl) &&
1847
+ lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
1848
+ (!decl.type &&
1849
+ !hasJsTypeAnnotation(decl) &&
1850
+ checkedGlobalReference(lowerer, initializer)) ||
1753
1851
  (!lowerer.dynamic && stdlibGlobalNameOf(lowerer, initializer) === "globalThis"))) {
1754
1852
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1755
1853
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1756
1854
  const g = {
1757
- id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1758
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
1855
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1856
+ name: nameNode.text,
1857
+ type: DYN,
1858
+ mutable: isLet,
1859
+ source: bindingSource(nameNode),
1759
1860
  ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1760
1861
  };
1761
1862
  lowerer.globalsBySymbol.set(symbol, g);
@@ -1774,12 +1875,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
1774
1875
  // storage instead of fencing per reference. Identifier
1775
1876
  // declarations only: a destructured array literal binds its
1776
1877
  // pieces, not the array.
1777
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1778
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1779
- decl.initializer !== undefined && ts.isArrayLiteralExpression(decl.initializer)) {
1878
+ if (isJsSourceFile(sf) &&
1879
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1880
+ ts.isIdentifier(decl.name) &&
1881
+ nameNode === decl.name &&
1882
+ decl.initializer !== undefined &&
1883
+ ts.isArrayLiteralExpression(decl.initializer)) {
1780
1884
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1781
1885
  if (symbol) {
1782
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1886
+ const g = {
1887
+ id: `%g.${tag}${nameNode.text}`,
1888
+ name: nameNode.text,
1889
+ type: DYN,
1890
+ mutable: isLet,
1891
+ source: bindingSource(nameNode),
1892
+ };
1783
1893
  lowerer.globalsBySymbol.set(symbol, g);
1784
1894
  lowerer.globalsList.push(g);
1785
1895
  }
@@ -1789,14 +1899,26 @@ export function collectGlobals(lowerer, sf, topStmts) {
1789
1899
  // Methods and computed properties require live checked storage:
1790
1900
  // symbol identity and a method's receiver cannot be reconstructed
1791
1901
  // from a copied, inferred record shape.
1792
- if (isJsSourceFile(sf) && ts.isIdentifier(decl.name) && nameNode === decl.name &&
1793
- decl.initializer && ts.isObjectLiteralExpression(decl.initializer) &&
1902
+ if (isJsSourceFile(sf) &&
1903
+ ts.isIdentifier(decl.name) &&
1904
+ nameNode === decl.name &&
1905
+ decl.initializer &&
1906
+ ts.isObjectLiteralExpression(decl.initializer) &&
1794
1907
  decl.initializer.properties.some((p) => !ts.isSpreadAssignment(p) &&
1795
- (ts.isMethodDeclaration(p) || ts.isAccessor(p) || ts.isComputedPropertyName(p.name) ||
1796
- ts.isShorthandPropertyAssignment(p) && lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0))) {
1908
+ (ts.isMethodDeclaration(p) ||
1909
+ ts.isAccessor(p) ||
1910
+ ts.isComputedPropertyName(p.name) ||
1911
+ (ts.isShorthandPropertyAssignment(p) &&
1912
+ lowerer.checker.getCallSignatures(lowerer.typeOf(p.name)).length > 0)))) {
1797
1913
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1798
1914
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1799
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1915
+ const g = {
1916
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1917
+ name: nameNode.text,
1918
+ type: DYN,
1919
+ mutable: isLet,
1920
+ source: bindingSource(nameNode),
1921
+ };
1800
1922
  lowerer.globalsBySymbol.set(symbol, g);
1801
1923
  lowerer.globalsList.push(g);
1802
1924
  if (isVarDeclared(decl))
@@ -1821,21 +1943,31 @@ export function collectGlobals(lowerer, sf, topStmts) {
1821
1943
  // Spreads from an existing checked dictionary stay checked too;
1822
1944
  // copying its entries must not extract nested callable records.
1823
1945
  if (isJsSourceFile(sf) &&
1824
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1825
- decl.initializer !== undefined && ts.isObjectLiteralExpression(decl.initializer) &&
1946
+ ts.isIdentifier(decl.name) &&
1947
+ nameNode === decl.name &&
1948
+ decl.initializer !== undefined &&
1949
+ ts.isObjectLiteralExpression(decl.initializer) &&
1826
1950
  decl.initializer.properties.every((p) => {
1827
1951
  if (ts.isSpreadAssignment(p)) {
1828
- return ts.isIdentifier(p.expression) && lowerer.globalOf(p.expression)?.type.kind === "dyn";
1952
+ return (ts.isIdentifier(p.expression) &&
1953
+ lowerer.globalOf(p.expression)?.type.kind === "dyn");
1829
1954
  }
1830
1955
  if (!ts.isPropertyAssignment(p) || ts.isComputedPropertyName(p.name))
1831
1956
  return false;
1832
1957
  const mt = lowerer.mapTypeOf(lowerer.typeOf(p.initializer));
1833
- return mt === null || mt.kind === "dyn" ||
1834
- canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id));
1958
+ return (mt === null ||
1959
+ mt.kind === "dyn" ||
1960
+ canConvertToDyn(mt, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)));
1835
1961
  })) {
1836
1962
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1837
1963
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1838
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1964
+ const g = {
1965
+ id: `%g.${tag}${nameNode.text}`,
1966
+ name: nameNode.text,
1967
+ type: DYN,
1968
+ mutable: isLet,
1969
+ source: bindingSource(nameNode),
1970
+ };
1839
1971
  lowerer.globalsBySymbol.set(symbol, g);
1840
1972
  lowerer.globalsList.push(g);
1841
1973
  }
@@ -1854,13 +1986,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
1854
1986
  // decl keeps as an %init local) stay OUT: forcing those into
1855
1987
  // the checked-dynamic tree would trade their working typed representation for
1856
1988
  // fences.
1857
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1858
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1989
+ if (isJsSourceFile(sf) &&
1990
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1991
+ ts.isIdentifier(decl.name) &&
1992
+ nameNode === decl.name &&
1859
1993
  jsDynHoldableInitializer(lowerer, decl.initializer) &&
1860
1994
  dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode))?.kind === "dyn") {
1861
1995
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1862
1996
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1863
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: DYN, mutable: isLet, source: bindingSource(nameNode) };
1997
+ const g = {
1998
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
1999
+ name: nameNode.text,
2000
+ type: DYN,
2001
+ mutable: isLet,
2002
+ source: bindingSource(nameNode),
2003
+ };
1864
2004
  lowerer.globalsBySymbol.set(symbol, g);
1865
2005
  lowerer.globalsList.push(g);
1866
2006
  // Mutable dyn globals hold the dyn undefined from module
@@ -1879,13 +2019,23 @@ export function collectGlobals(lowerer, sf, topStmts) {
1879
2019
  // the binding holds the HANDLE — a jsval global, so exports
1880
2020
  // and separately-declared functions reach the same engine
1881
2021
  // object.
1882
- if (lowerer.dynamic && isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1883
- ts.isIdentifier(decl.name) && nameNode === decl.name &&
1884
- decl.initializer !== undefined && ts.isObjectLiteralExpression(decl.initializer) &&
2022
+ if (lowerer.dynamic &&
2023
+ isJsSourceFile(sf) &&
2024
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
2025
+ ts.isIdentifier(decl.name) &&
2026
+ nameNode === decl.name &&
2027
+ decl.initializer !== undefined &&
2028
+ ts.isObjectLiteralExpression(decl.initializer) &&
1885
2029
  decl.initializer.properties.some((p) => ts.isGetAccessorDeclaration(p))) {
1886
2030
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1887
2031
  if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
1888
- const g = { id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text, type: JSVAL, mutable: isLet, source: bindingSource(nameNode) };
2032
+ const g = {
2033
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
2034
+ name: nameNode.text,
2035
+ type: JSVAL,
2036
+ mutable: isLet,
2037
+ source: bindingSource(nameNode),
2038
+ };
1889
2039
  lowerer.globalsBySymbol.set(symbol, g);
1890
2040
  lowerer.globalsList.push(g);
1891
2041
  }
@@ -1896,23 +2046,37 @@ export function collectGlobals(lowerer, sf, topStmts) {
1896
2046
  // that closure in a checked-value global so class methods and
1897
2047
  // other module functions see its declaration-position assignment.
1898
2048
  // A var starts undefined; lexical bindings retain the TDZ guard.
1899
- if (isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
1900
- ts.isIdentifier(decl.name) && nameNode === decl.name && decl.initializer &&
2049
+ if (isJsSourceFile(sf) &&
2050
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
2051
+ ts.isIdentifier(decl.name) &&
2052
+ nameNode === decl.name &&
2053
+ decl.initializer &&
1901
2054
  jsDynHoldableInitializer(lowerer, decl.initializer)) {
1902
2055
  const initializer = decl.initializer;
1903
- const member = ts.isPropertyAccessExpression(initializer) ? nsMemberIdentOf(lowerer, initializer) : null;
2056
+ const member = ts.isPropertyAccessExpression(initializer)
2057
+ ? nsMemberIdentOf(lowerer, initializer)
2058
+ : null;
1904
2059
  const generic = member && lowerer.genericFnOf(member);
1905
- const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) && !initializer.typeParameters?.length
2060
+ const fallback = (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)) &&
2061
+ !initializer.typeParameters?.length
1906
2062
  ? lowerer.lambdaSignature(initializer).funcType
1907
- : member && lowerer.globalOf(member)?.type.kind === "dyn" ? DYN
1908
- : member && generic?.implicitParams ? lowerer.lowerGenericFnValue(member, generic).type
2063
+ : member && lowerer.globalOf(member)?.type.kind === "dyn"
2064
+ ? DYN
2065
+ : member && generic?.implicitParams
2066
+ ? lowerer.lowerGenericFnValue(member, generic).type
1909
2067
  : dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode));
1910
2068
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
1911
- if (symbol && fallback && (fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") && lowerer.dynConvertible(fallback)) {
2069
+ if (symbol &&
2070
+ fallback &&
2071
+ (fallback.kind === "dyn" || fallback.kind === "func" || fallback.kind === "union") &&
2072
+ lowerer.dynConvertible(fallback)) {
1912
2073
  if (!lowerer.globalsBySymbol.has(symbol)) {
1913
2074
  const g = {
1914
- id: `%g.${tag}${nsPrefix}${nameNode.text}`, name: nameNode.text,
1915
- type: DYN, mutable: isLet, source: bindingSource(nameNode),
2075
+ id: `%g.${tag}${nsPrefix}${nameNode.text}`,
2076
+ name: nameNode.text,
2077
+ type: DYN,
2078
+ mutable: isLet,
2079
+ source: bindingSource(nameNode),
1916
2080
  ...(!isVarDeclared(decl) ? { tdz: true } : {}),
1917
2081
  };
1918
2082
  lowerer.globalsBySymbol.set(symbol, g);
@@ -1930,37 +2094,63 @@ export function collectGlobals(lowerer, sf, topStmts) {
1930
2094
  // and closures created in the init body capture it normally.
1931
2095
  // References from separately-declared functions cascade to
1932
2096
  // their own per-site runtime fences.
1933
- const factoryType = !isLet && isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
1934
- ts.isIdentifier(decl.name) && nameNode === decl.name && decl.initializer && ts.isNewExpression(decl.initializer)
1935
- ? objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined : undefined;
2097
+ const factoryType = !isLet &&
2098
+ isJsSourceFile(sf) &&
2099
+ !decl.type &&
2100
+ !hasJsTypeAnnotation(decl) &&
2101
+ ts.isIdentifier(decl.name) &&
2102
+ nameNode === decl.name &&
2103
+ decl.initializer &&
2104
+ ts.isNewExpression(decl.initializer)
2105
+ ? (objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined)
2106
+ : undefined;
1936
2107
  // `var p1 = import("./m")` at file scope: the global holds the
1937
2108
  // island promise/handle — the import expression's only
1938
2109
  // production — whatever the checker's namespace type mapped to
1939
2110
  // (lowerVarDecl's rule at module scope; the init body assigns
1940
2111
  // it).
1941
2112
  const handleT = ts.isIdentifier(decl.name) && nameNode === decl.name
1942
- ? (isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
1943
- (lowerer.dynamic ? importCallHandleType(decl.initializer) : staticImportNamespaceType(lowerer, decl.initializer)) ??
1944
- (lowerer.dynamic ?
1945
- // An unchecked-overload call result stores the handle,
1946
- // exactly the local rule (uncheckedOverloadHandleCall).
1947
- (uncheckedOverloadHandleCall(lowerer, decl.initializer) ? JSVAL : null) : null)
2113
+ ? ((isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
2114
+ (lowerer.dynamic
2115
+ ? importCallHandleType(decl.initializer)
2116
+ : staticImportNamespaceType(lowerer, decl.initializer)) ??
2117
+ (lowerer.dynamic
2118
+ ? // An unchecked-overload call result stores the handle,
2119
+ // exactly the local rule (uncheckedOverloadHandleCall).
2120
+ uncheckedOverloadHandleCall(lowerer, decl.initializer)
2121
+ ? JSVAL
2122
+ : null
2123
+ : null))
1948
2124
  : null;
1949
2125
  // JavaScript factory results with unmappable annotations still
1950
2126
  // need shared storage. Unannotated callable unions also use a
1951
2127
  // checked slot; mappable authored annotations keep their layout.
1952
2128
  const unannotatedCall = !decl.type && !hasJsTypeAnnotation(decl);
1953
- const callSignature = (isJsSourceFile(sf) || unannotatedCall) && decl.initializer && ts.isCallExpression(decl.initializer)
1954
- ? lowerer.checker.getResolvedSignature(decl.initializer) : undefined;
2129
+ const callSignature = (isJsSourceFile(sf) || unannotatedCall) &&
2130
+ decl.initializer &&
2131
+ ts.isCallExpression(decl.initializer)
2132
+ ? lowerer.checker.getResolvedSignature(decl.initializer)
2133
+ : undefined;
1955
2134
  const callDeclaration = callSignature && lowerer.checker.signatureDeclaration(callSignature);
1956
2135
  const callType = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile())
1957
- ? lowerer.mapTypeOf(lowerer.typeOf(nameNode)) : null;
1958
- const inferredJsCall = callDeclaration && isJsSourceFile(callDeclaration.getSourceFile()) &&
1959
- (!callType || unannotatedCall && callType.kind === "union" && lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func"));
1960
- if (!factoryType && !inferredJsCall && isJsSourceFile(sf) && !lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
2136
+ ? lowerer.mapTypeOf(lowerer.typeOf(nameNode))
2137
+ : null;
2138
+ const inferredJsCall = callDeclaration &&
2139
+ isJsSourceFile(callDeclaration.getSourceFile()) &&
2140
+ (!callType ||
2141
+ (unannotatedCall &&
2142
+ callType.kind === "union" &&
2143
+ lowerer.unions.get(callType.unionId)?.arms.some((arm) => arm.kind === "func")));
2144
+ if (!factoryType &&
2145
+ !inferredJsCall &&
2146
+ isJsSourceFile(sf) &&
2147
+ !lowerer.mapTypeOf(lowerer.typeOf(nameNode)))
1961
2148
  continue;
1962
2149
  let type = handleT ?? factoryType ?? (inferredJsCall ? DYN : lowerer.irTypeOf(nameNode));
1963
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && decl.initializer &&
2150
+ if (isJsSourceFile(sf) &&
2151
+ !decl.type &&
2152
+ !hasJsTypeAnnotation(decl) &&
2153
+ decl.initializer &&
1964
2154
  (ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer)) &&
1965
2155
  !decl.initializer.typeParameters?.length) {
1966
2156
  type = lowerer.lambdaSignature(decl.initializer).funcType;
@@ -1968,8 +2158,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1968
2158
  // Namespace aliases of inferred helpers carry the helper's
1969
2159
  // settled callable, whose return can differ from checker inference.
1970
2160
  // Keep a shared checked slot before any consumer specializes it.
1971
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "func" &&
1972
- decl.initializer && ts.isPropertyAccessExpression(decl.initializer)) {
2161
+ if (isJsSourceFile(sf) &&
2162
+ !decl.type &&
2163
+ !hasJsTypeAnnotation(decl) &&
2164
+ type.kind === "func" &&
2165
+ decl.initializer &&
2166
+ ts.isPropertyAccessExpression(decl.initializer)) {
1973
2167
  const member = nsMemberIdentOf(lowerer, decl.initializer);
1974
2168
  if (member && lowerer.genericFnOf(member)?.implicitParams)
1975
2169
  type = DYN;
@@ -1979,24 +2173,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
1979
2173
  type = source.type;
1980
2174
  }
1981
2175
  }
1982
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
1983
- decl.initializer && ts.isCallExpression(decl.initializer) && type.kind === "union") {
2176
+ if (isJsSourceFile(sf) &&
2177
+ !decl.type &&
2178
+ !hasJsTypeAnnotation(decl) &&
2179
+ decl.initializer &&
2180
+ ts.isCallExpression(decl.initializer) &&
2181
+ type.kind === "union") {
1984
2182
  const arms = lowerer.unions.get(type.unionId)?.arms;
1985
- if (arms?.some((arm) => arm.kind === "record") && arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
2183
+ if (arms?.some((arm) => arm.kind === "record") &&
2184
+ arms.every((arm) => isUnitType(arm) || arm.kind === "record"))
1986
2185
  type = DYN;
1987
2186
  }
1988
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && decl.initializer &&
1989
- ts.isNewExpression(decl.initializer) && lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
1990
- !(ts.isIdentifier(decl.initializer.expression) && lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
2187
+ if (isJsSourceFile(sf) &&
2188
+ !decl.type &&
2189
+ !hasJsTypeAnnotation(decl) &&
2190
+ decl.initializer &&
2191
+ ts.isNewExpression(decl.initializer) &&
2192
+ lowerer.mapTypeOf(lowerer.typeOf(decl.initializer.expression))?.kind === "dyn" &&
2193
+ !(ts.isIdentifier(decl.initializer.expression) &&
2194
+ lowerer.isStdlibSymbol(lowerer.checker.getSymbolAtLocation(decl.initializer.expression))))
1991
2195
  type = DYN;
1992
2196
  // Calls through checked function values retain their object
1993
2197
  // identity, including symbol keys absent from inferred records.
1994
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "record" &&
1995
- decl.initializer && ts.isCallExpression(decl.initializer) && lowerer.dynConvertible(type)) {
2198
+ if (isJsSourceFile(sf) &&
2199
+ !decl.type &&
2200
+ !hasJsTypeAnnotation(decl) &&
2201
+ type.kind === "record" &&
2202
+ decl.initializer &&
2203
+ ts.isCallExpression(decl.initializer) &&
2204
+ lowerer.dynConvertible(type)) {
1996
2205
  type = DYN;
1997
2206
  }
1998
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "record" &&
1999
- decl.initializer && ts.isCallExpression(decl.initializer) &&
2207
+ if (isJsSourceFile(sf) &&
2208
+ !decl.type &&
2209
+ !hasJsTypeAnnotation(decl) &&
2210
+ type.kind === "record" &&
2211
+ decl.initializer &&
2212
+ ts.isCallExpression(decl.initializer) &&
2000
2213
  ts.isPropertyAccessExpression(decl.initializer.expression) &&
2001
2214
  lowerer.stdlibGlobalMember(decl.initializer.expression, "Object") === "assign" &&
2002
2215
  decl.initializer.arguments.some((arg) => ts.isIdentifier(arg) && lowerer.globalOf(arg)?.type.kind === "dyn")) {
@@ -2005,24 +2218,43 @@ export function collectGlobals(lowerer, sf, topStmts) {
2005
2218
  // Runtime-arity JavaScript callables can be returned by a
2006
2219
  // checked factory. Keep that callable boxed instead of asking
2007
2220
  // a fixed-signature adapter to reconstruct its hidden rest ABI.
2008
- if (!decl.type && !hasJsTypeAnnotation(decl) && type.kind === "func" && type.rest === true && type.restAbi === undefined)
2221
+ if (!decl.type &&
2222
+ !hasJsTypeAnnotation(decl) &&
2223
+ type.kind === "func" &&
2224
+ type.rest === true &&
2225
+ type.restAbi === undefined)
2009
2226
  type = DYN;
2010
- if (isJsSourceFile(sf) && isLet && !decl.type && !hasJsTypeAnnotation(decl) &&
2227
+ if (isJsSourceFile(sf) &&
2228
+ isLet &&
2229
+ !decl.type &&
2230
+ !hasJsTypeAnnotation(decl) &&
2011
2231
  (type.kind === "object" || jsBindingHasOpenWrites(lowerer, decl)))
2012
2232
  type = DYN;
2013
2233
  // JavaScript call results may retain a checked array supplied by
2014
2234
  // the caller. A typed global here would copy it on extraction.
2015
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) && type.kind === "array" &&
2016
- decl.initializer && ts.isCallExpression(decl.initializer))
2235
+ if (isJsSourceFile(sf) &&
2236
+ !decl.type &&
2237
+ !hasJsTypeAnnotation(decl) &&
2238
+ type.kind === "array" &&
2239
+ decl.initializer &&
2240
+ ts.isCallExpression(decl.initializer))
2017
2241
  type = DYN;
2018
- if (!lowerer.dynamic && isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
2019
- decl.initializer && ts.isNewExpression(decl.initializer) && lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
2242
+ if (!lowerer.dynamic &&
2243
+ isJsSourceFile(sf) &&
2244
+ !decl.type &&
2245
+ !hasJsTypeAnnotation(decl) &&
2246
+ decl.initializer &&
2247
+ ts.isNewExpression(decl.initializer) &&
2248
+ lowerer.isStdlibGlobal(decl.initializer.expression, "Array") &&
2020
2249
  (type.kind !== "array" || type.elem.kind === "dyn"))
2021
2250
  type = DYN;
2022
2251
  // Unannotated JavaScript aliases retain an existing native
2023
2252
  // checked object instead of copying it into an inferred record.
2024
- if (isJsSourceFile(sf) && !decl.type && !hasJsTypeAnnotation(decl) &&
2025
- decl.initializer && ts.isIdentifier(decl.initializer) &&
2253
+ if (isJsSourceFile(sf) &&
2254
+ !decl.type &&
2255
+ !hasJsTypeAnnotation(decl) &&
2256
+ decl.initializer &&
2257
+ ts.isIdentifier(decl.initializer) &&
2026
2258
  (type.kind === "record" || type.kind === "func")) {
2027
2259
  const source = lowerer.globalOf(decl.initializer);
2028
2260
  if (source?.type.kind === "dyn")
@@ -2030,10 +2262,15 @@ export function collectGlobals(lowerer, sf, topStmts) {
2030
2262
  }
2031
2263
  // JavaScript bind inference can leave an artificial tuple-rest
2032
2264
  // signature. Keep the returned callable's runtime arity intact.
2033
- if (isJsSourceFile(sf) && type.kind === "func" && decl.initializer &&
2034
- ts.isCallExpression(decl.initializer) && ts.isPropertyAccessExpression(decl.initializer.expression) &&
2035
- decl.initializer.expression.name.text === "bind" && lowerer.isStdlibMember(decl.initializer.expression) &&
2036
- decl.type === undefined && !hasJsTypeAnnotation(decl)) {
2265
+ if (isJsSourceFile(sf) &&
2266
+ type.kind === "func" &&
2267
+ decl.initializer &&
2268
+ ts.isCallExpression(decl.initializer) &&
2269
+ ts.isPropertyAccessExpression(decl.initializer.expression) &&
2270
+ decl.initializer.expression.name.text === "bind" &&
2271
+ lowerer.isStdlibMember(decl.initializer.expression) &&
2272
+ decl.type === undefined &&
2273
+ !hasJsTypeAnnotation(decl)) {
2037
2274
  type = DYN;
2038
2275
  }
2039
2276
  // An evolving-`any` array's DERIVED file-scope binding under
@@ -2046,9 +2283,13 @@ export function collectGlobals(lowerer, sf, topStmts) {
2046
2283
  // element array (lowerVarDecl's adoption, the file-scope
2047
2284
  // face). Annotated declarations keep the validated-boundary
2048
2285
  // fence.
2049
- if (lowerer.dynamic && ts.isIdentifier(decl.name) && nameNode === decl.name &&
2050
- decl.type === undefined && decl.initializer !== undefined &&
2051
- type.kind === "array" && type.elem.kind !== "jsval" &&
2286
+ if (lowerer.dynamic &&
2287
+ ts.isIdentifier(decl.name) &&
2288
+ nameNode === decl.name &&
2289
+ decl.type === undefined &&
2290
+ decl.initializer !== undefined &&
2291
+ type.kind === "array" &&
2292
+ type.elem.kind !== "jsval" &&
2052
2293
  handleArrayPreservingCall(lowerer, decl.initializer)) {
2053
2294
  type = arrayOf(JSVAL);
2054
2295
  }
@@ -2057,7 +2298,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
2057
2298
  // representation (the record shape maps empty and the width
2058
2299
  // copy would drop the class the generic-method calls
2059
2300
  // monomorphize against) — see genericIfaceBindingKeepsClass.
2060
- if (type.kind === "record" && ts.isIdentifier(decl.name) && nameNode === decl.name &&
2301
+ if (type.kind === "record" &&
2302
+ ts.isIdentifier(decl.name) &&
2303
+ nameNode === decl.name &&
2061
2304
  genericIfaceBindingKeepsClass(lowerer, decl, type)) {
2062
2305
  const initT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
2063
2306
  if (initT?.kind === "object")
@@ -2073,8 +2316,11 @@ export function collectGlobals(lowerer, sf, topStmts) {
2073
2316
  if (lowerer.dynamic && !ts.isIdentifier(decl.name) && decl.initializer !== undefined) {
2074
2317
  const srcT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
2075
2318
  const island = srcT !== null &&
2076
- (srcT.kind === "jsval" || srcT.kind === "f64" || srcT.kind === "bool" ||
2077
- srcT.kind === "string" || isUnitType(srcT));
2319
+ (srcT.kind === "jsval" ||
2320
+ srcT.kind === "f64" ||
2321
+ srcT.kind === "bool" ||
2322
+ srcT.kind === "string" ||
2323
+ isUnitType(srcT));
2078
2324
  if (island && type.kind !== "f64" && type.kind !== "bool" && type.kind !== "string") {
2079
2325
  type = JSVAL;
2080
2326
  }
@@ -2096,7 +2342,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
2096
2342
  // adapter would re-copy at the assignment.
2097
2343
  if (isJsSourceFile(sf) &&
2098
2344
  type.kind === "func" &&
2099
- (type.ret.kind === "date" || type.ret.kind === "record" && lowerer.dynConvertible(type.ret)) &&
2345
+ (type.ret.kind === "date" ||
2346
+ (type.ret.kind === "record" && lowerer.dynConvertible(type.ret))) &&
2100
2347
  decl.initializer !== undefined &&
2101
2348
  (ts.isFunctionExpression(decl.initializer) || ts.isArrowFunction(decl.initializer)) &&
2102
2349
  decl.initializer.type === undefined &&
@@ -2115,13 +2362,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
2115
2362
  // Module vars hold real undefined until their declaration runs.
2116
2363
  // Unannotated JS function values need that state too: callers
2117
2364
  // before the initializer must see undefined and a TypeError.
2118
- if (isJsSourceFile(sf) && isVarDeclared(decl) && type.kind === "func" && lowerer.dynConvertible(type))
2365
+ if (isJsSourceFile(sf) &&
2366
+ isVarDeclared(decl) &&
2367
+ type.kind === "func" &&
2368
+ lowerer.dynConvertible(type))
2119
2369
  type = DYN;
2120
2370
  // Codec records keep that state in the ordinary optional union;
2121
2371
  // lexical codec declarations retain their separate TDZ guard.
2122
- const codec = type.kind === "record" && recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
2372
+ const codec = type.kind === "record" &&
2373
+ recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null;
2123
2374
  if (codec && isVarDeclared(decl)) {
2124
- type = { kind: "union", unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]) };
2375
+ type = {
2376
+ kind: "union",
2377
+ unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
2378
+ };
2125
2379
  }
2126
2380
  else if (codec && !decl.initializer) {
2127
2381
  lowerer.noLowering("uninitialized lexical codec bindings", decl, "initialize let or const TextEncoder/TextDecoder bindings at their declaration");
@@ -2141,7 +2395,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
2141
2395
  // A function pointer must not be dereferenced before a lexical
2142
2396
  // declaration assigns it. The shared pointer TDZ guard handles
2143
2397
  // these bindings like stored codec records.
2144
- ...(((codec || type.kind === "func") && !isVarDeclared(decl)) ? { tdz: true } : {}),
2398
+ ...((codec || type.kind === "func") && !isVarDeclared(decl)
2399
+ ? { tdz: true }
2400
+ : {}),
2145
2401
  };
2146
2402
  lowerer.globalsBySymbol.set(symbol, g);
2147
2403
  lowerer.globalsList.push(g);
@@ -2167,19 +2423,20 @@ export function collectGlobals(lowerer, sf, topStmts) {
2167
2423
  }
2168
2424
  }
2169
2425
  /** True iff this initializer's VALUE is a jsval-element array from a
2170
- * module global already registered as one (the evolving-`any` binding
2171
- * under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
2172
- * array-method call chain over it (filter/slice/splice/concat — each
2173
- * answers the receiver's own array type). Registration runs in source
2174
- * order, so the root's global — declared above, TDZ-guaranteed — is
2175
- * already in the table. */
2426
+ * module global already registered as one (the evolving-`any` binding
2427
+ * under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
2428
+ * array-method call chain over it (filter/slice/splice/concat — each
2429
+ * answers the receiver's own array type). Registration runs in source
2430
+ * order, so the root's global — declared above, TDZ-guaranteed — is
2431
+ * already in the table. */
2176
2432
  function handleArrayPreservingCall(lowerer, e) {
2177
2433
  const PRESERVING = new Set(["filter", "slice", "splice", "concat"]);
2178
2434
  let cur = e;
2179
2435
  for (;;) {
2180
2436
  while (ts.isParenthesizedExpression(cur))
2181
2437
  cur = cur.expression;
2182
- if (ts.isCallExpression(cur) && ts.isPropertyAccessExpression(cur.expression) &&
2438
+ if (ts.isCallExpression(cur) &&
2439
+ ts.isPropertyAccessExpression(cur.expression) &&
2183
2440
  PRESERVING.has(cur.expression.name.text)) {
2184
2441
  cur = cur.expression.expression;
2185
2442
  continue;
@@ -2193,14 +2450,14 @@ function handleArrayPreservingCall(lowerer, e) {
2193
2450
  return g?.type.kind === "array" && g.type.elem.kind === "jsval";
2194
2451
  }
2195
2452
  /** Registers the entry-init note for a `var` module global: JS hoists
2196
- * module vars to `undefined` at module entry, so an undefined-armed slot
2197
- * must hold the interned undefined arm BEFORE the body runs (a function
2198
- * called above the declaration statement may read it — lowerFileInit
2199
- * emits the assigns right after the run-once guard). Checked-dynamic
2200
- * slots hold the dyn undefined the same way (a NULL dyn is a trap, not
2201
- * a value). Other types need nothing: tsc's flow analysis rejects their
2202
- * direct early reads, and closure reads share let's documented
2203
- * zero/NULL divergence window. */
2453
+ * module vars to `undefined` at module entry, so an undefined-armed slot
2454
+ * must hold the interned undefined arm BEFORE the body runs (a function
2455
+ * called above the declaration statement may read it — lowerFileInit
2456
+ * emits the assigns right after the run-once guard). Checked-dynamic
2457
+ * slots hold the dyn undefined the same way (a NULL dyn is a trap, not
2458
+ * a value). Other types need nothing: tsc's flow analysis rejects their
2459
+ * direct early reads, and closure reads share let's documented
2460
+ * zero/NULL divergence window. */
2204
2461
  function noteVarGlobalEntryInit(lowerer, sf, g) {
2205
2462
  // 'any' globals need the entry init exactly like undefined-armed
2206
2463
  // unions: tsc never guards `any` reads, so `var x: any;` is readable
@@ -2215,25 +2472,31 @@ function noteVarGlobalEntryInit(lowerer, sf, g) {
2215
2472
  lowerer.varGlobalEntryInits.set(sf, inits);
2216
2473
  }
2217
2474
  /** The nested half of module-scope `var` hoisting: a `var` inside a
2218
- * top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
2219
- * JS — other functions in the file read the same binding — so it must
2220
- * be a module global like its top-level siblings. Walks a top-level
2221
- * statement's insides for var-flagged declaration lists (statement and
2222
- * for/for-in/for-of initializer positions), never descending into
2223
- * function-likes, classes, or static blocks (each hoists to its own
2224
- * scope). Registration mirrors the main path's identifier story:
2225
- * JS-unmappable types register nothing (per-site fences own the
2226
- * references), everything else gets a mutable global. */
2475
+ * top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
2476
+ * JS — other functions in the file read the same binding — so it must
2477
+ * be a module global like its top-level siblings. Walks a top-level
2478
+ * statement's insides for var-flagged declaration lists (statement and
2479
+ * for/for-in/for-of initializer positions), never descending into
2480
+ * function-likes, classes, or static blocks (each hoists to its own
2481
+ * scope). Registration mirrors the main path's identifier story:
2482
+ * JS-unmappable types register nothing (per-site fences own the
2483
+ * references), everything else gets a mutable global. */
2227
2484
  function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2228
2485
  const lists = [];
2229
2486
  // Iterative walk (walkPreorder): this sweep sees every non-var top-level
2230
2487
  // statement whole — the binderBinaryExpressionStress bare ~6500-term
2231
2488
  // chain sat within ~50 terms of overflowing the recursive form.
2232
2489
  ts.walkPreorder(stmt, (node) => {
2233
- if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) ||
2234
- ts.isMethodDeclaration(node) || ts.isConstructorDeclaration(node) ||
2235
- ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node) ||
2236
- ts.isClassStaticBlockDeclaration(node) || ts.isClassDeclaration(node) || ts.isClassExpression(node) ||
2490
+ if (ts.isFunctionDeclaration(node) ||
2491
+ ts.isFunctionExpression(node) ||
2492
+ ts.isArrowFunction(node) ||
2493
+ ts.isMethodDeclaration(node) ||
2494
+ ts.isConstructorDeclaration(node) ||
2495
+ ts.isGetAccessorDeclaration(node) ||
2496
+ ts.isSetAccessorDeclaration(node) ||
2497
+ ts.isClassStaticBlockDeclaration(node) ||
2498
+ ts.isClassDeclaration(node) ||
2499
+ ts.isClassExpression(node) ||
2237
2500
  ts.isModuleDeclaration(node)) {
2238
2501
  return "skip";
2239
2502
  }
@@ -2263,13 +2526,23 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2263
2526
  if (shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple)
2264
2527
  type = DYN;
2265
2528
  }
2266
- if (type.kind === "record" && recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
2267
- type = { kind: "union", unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]) };
2529
+ if (type.kind === "record" &&
2530
+ recordTextCodecClass(lowerer.shapes.get(type.shapeId)) !== null) {
2531
+ type = {
2532
+ kind: "union",
2533
+ unionId: lowerer.unions.intern([type, { kind: "undefinedT" }]),
2534
+ };
2268
2535
  }
2269
2536
  const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
2270
2537
  if (!symbol || lowerer.globalsBySymbol.has(symbol))
2271
2538
  continue;
2272
- const g = { id: `%g.${tag}${nameNode.text}`, name: nameNode.text, type, mutable: true, source: bindingSource(nameNode) };
2539
+ const g = {
2540
+ id: `%g.${tag}${nameNode.text}`,
2541
+ name: nameNode.text,
2542
+ type,
2543
+ mutable: true,
2544
+ source: bindingSource(nameNode),
2545
+ };
2273
2546
  lowerer.globalsBySymbol.set(symbol, g);
2274
2547
  lowerer.globalsList.push(g);
2275
2548
  noteVarGlobalEntryInit(lowerer, sf, g);
@@ -2284,21 +2557,21 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
2284
2557
  }
2285
2558
  }
2286
2559
  /** The checker's symbol for a module's default export — the symbol a
2287
- * default import of this module aliases to (getAliasedSymbol), so keying
2288
- * the default's global by it makes every importer resolve to the same
2289
- * storage through the ordinary globalOf path. Null for modules without
2290
- * a default export (or non-module files). */
2560
+ * default import of this module aliases to (getAliasedSymbol), so keying
2561
+ * the default's global by it makes every importer resolve to the same
2562
+ * storage through the ordinary globalOf path. Null for modules without
2563
+ * a default export (or non-module files). */
2291
2564
  export function defaultExportSymbolOf(lowerer, sf) {
2292
2565
  const moduleSym = lowerer.checker.getSymbolAtLocation(sf);
2293
2566
  return moduleSym?.getExports().get(ts.InternalSymbolName.Default) ?? null;
2294
2567
  }
2295
2568
  /** The declaration symbol of a top-level function/class declaration,
2296
- * covering the one legal NAMELESS form: `export default function () {}` /
2297
- * `export default class {}`. A named declaration answers through its
2298
- * name node; the anonymous default IS the module's `default` export
2299
- * symbol (the binder declares it there), so collection, reachability,
2300
- * and body lowering all key that one identity — which is also what a
2301
- * default import's alias chain resolves to. */
2569
+ * covering the one legal NAMELESS form: `export default function () {}` /
2570
+ * `export default class {}`. A named declaration answers through its
2571
+ * name node; the anonymous default IS the module's `default` export
2572
+ * symbol (the binder declares it there), so collection, reachability,
2573
+ * and body lowering all key that one identity — which is also what a
2574
+ * default import's alias chain resolves to. */
2302
2575
  export function declSymbolOf(lowerer, decl) {
2303
2576
  if (decl.name)
2304
2577
  return lowerer.checker.getSymbolAtLocation(decl.name);
@@ -2310,18 +2583,18 @@ export function declSymbolOf(lowerer, decl) {
2310
2583
  return sym ?? undefined;
2311
2584
  }
2312
2585
  /** `export default <expr>` in a module's init body: the first (and only)
2313
- * assignment of the pre-registered `default` global — evaluated at the
2314
- * statement's source position, exactly where Node runs it (Node's
2315
- * expression defaults snapshot exactly once, here). ENTITY-NAME defaults
2316
- * of immutable targets are alias plumbing with no storage of their own:
2317
- * the statement lowers to nothing — importers' alias-resolved reads
2318
- * equal the snapshot. MUTABLE entity-name defaults registered snapshot
2319
- * storage in collection and assign it here like any expression default
2320
- * (the identifier read takes the let's value at this statement's
2321
- * position — Node's snapshot). A NON-alias default whose type had no
2322
- * registration (collection reported the blocker) re-lowers the
2323
- * expression so the expression's OWN diagnostic wins when it has one,
2324
- * then poisons. */
2586
+ * assignment of the pre-registered `default` global — evaluated at the
2587
+ * statement's source position, exactly where Node runs it (Node's
2588
+ * expression defaults snapshot exactly once, here). ENTITY-NAME defaults
2589
+ * of immutable targets are alias plumbing with no storage of their own:
2590
+ * the statement lowers to nothing — importers' alias-resolved reads
2591
+ * equal the snapshot. MUTABLE entity-name defaults registered snapshot
2592
+ * storage in collection and assign it here like any expression default
2593
+ * (the identifier read takes the let's value at this statement's
2594
+ * position — Node's snapshot). A NON-alias default whose type had no
2595
+ * registration (collection reported the blocker) re-lowers the
2596
+ * expression so the expression's OWN diagnostic wins when it has one,
2597
+ * then poisons. */
2325
2598
  export function lowerDefaultExport(lowerer, stmt) {
2326
2599
  const symbol = defaultExportSymbolOf(lowerer, stmt.getSourceFile());
2327
2600
  if (symbol && symbol.flags & ts.SymbolFlags.Alias && !lowerer.globalsBySymbol.has(symbol))
@@ -2335,9 +2608,11 @@ export function lowerDefaultExport(lowerer, stmt) {
2335
2608
  let inner = stmt.expression;
2336
2609
  while (ts.isParenthesizedExpression(inner))
2337
2610
  inner = inner.expression;
2338
- if (ts.isClassExpression(inner) && !isJsSourceFile(stmt.getSourceFile()) &&
2611
+ if (ts.isClassExpression(inner) &&
2612
+ !isJsSourceFile(stmt.getSourceFile()) &&
2339
2613
  inner.typeParameters === undefined &&
2340
- (decoratorNodesOf(inner).length > 0 || inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
2614
+ (decoratorNodesOf(inner).length > 0 ||
2615
+ inner.members.some((m) => decoratorNodesOf(m).length > 0)) &&
2341
2616
  guaranteedDecorationThrow(lowerer, inner) !== null) {
2342
2617
  return { kind: "exprStmt", expr: lowerer.lowerExpr(stmt.expression), loc: locOf(stmt) };
2343
2618
  }
@@ -2349,19 +2624,19 @@ export function lowerDefaultExport(lowerer, stmt) {
2349
2624
  return { kind: "assign", localId: g.id, value, loc: locOf(stmt) };
2350
2625
  }
2351
2626
  /** One file's top-level statements as its init function — RUN-ONCE like a
2352
- * Node module body: non-entry inits open with a guard flag test (already
2353
- * ran → return) and set the flag before anything else, so every caller —
2354
- * hoisted import headers, inline require statements, diamonds, cache-hit
2355
- * re-requires — gets Node's module-cache semantics from the same call.
2356
- * After the guard comes the file's HOISTED module-edge header: one
2357
- * guarded %init call per imported user module and the island loads for
2358
- * npm imports, in import order (Node evaluates every imported module
2359
- * before the importer's body — depth-first postorder falls out of the
2360
- * nesting). CommonJS requires are NOT in the header: Node runs them at
2361
- * their statements, so the statement lowering emits their %init calls
2362
- * inline in the body. JSON-import bindings (pure data) load next; then
2363
- * the body. Top-level var statements assign the pre-registered globals
2364
- * instead of declaring locals. */
2627
+ * Node module body: non-entry inits open with a guard flag test (already
2628
+ * ran → return) and set the flag before anything else, so every caller —
2629
+ * hoisted import headers, inline require statements, diamonds, cache-hit
2630
+ * re-requires — gets Node's module-cache semantics from the same call.
2631
+ * After the guard comes the file's HOISTED module-edge header: one
2632
+ * guarded %init call per imported user module and the island loads for
2633
+ * npm imports, in import order (Node evaluates every imported module
2634
+ * before the importer's body — depth-first postorder falls out of the
2635
+ * nesting). CommonJS requires are NOT in the header: Node runs them at
2636
+ * their statements, so the statement lowering emits their %init calls
2637
+ * inline in the body. JSON-import bindings (pure data) load next; then
2638
+ * the body. Top-level var statements assign the pre-registered globals
2639
+ * instead of declaring locals. */
2365
2640
  export function lowerFileInit(lowerer, sf, stmts, name) {
2366
2641
  const isAsync = lowerer.asyncInitFiles.has(sf);
2367
2642
  const ctx = newFnCtx(false, null, null, VOID);
@@ -2519,8 +2794,16 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2519
2794
  // that evaluates them. MIXIN instantiations join by their CALL
2520
2795
  // SITE's position instead (below) — their inner class node may
2521
2796
  // even live in another file.
2522
- c.decl && ts.isClassDeclaration(c.decl) && !c.mixinInstance && c.decl.getSourceFile() === sf &&
2523
- (c.callableBase !== undefined || c.def.baseValueGlobal !== undefined || c.runtimeStatics !== undefined || c.staticFields.length > 0 || (c.staticBlocks?.length ?? 0) > 0 || c.classDecorators !== undefined))
2797
+ c.decl &&
2798
+ ts.isClassDeclaration(c.decl) &&
2799
+ !c.mixinInstance &&
2800
+ c.decl.getSourceFile() === sf &&
2801
+ (c.callableBase !== undefined ||
2802
+ c.def.baseValueGlobal !== undefined ||
2803
+ c.runtimeStatics !== undefined ||
2804
+ c.staticFields.length > 0 ||
2805
+ (c.staticBlocks?.length ?? 0) > 0 ||
2806
+ c.classDecorators !== undefined))
2524
2807
  .map((c) => ({ pos: c.decl.getStart(), info: c }));
2525
2808
  // Statics-bearing MIXIN instantiations whose call evaluates in THIS
2526
2809
  // file: their declaration-time code runs when the call does — the
@@ -2581,12 +2864,14 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2581
2864
  loc: loc0,
2582
2865
  },
2583
2866
  ...(guardId !== undefined
2584
- ? [{
2867
+ ? [
2868
+ {
2585
2869
  kind: "assign",
2586
2870
  localId: guardId,
2587
2871
  value: { kind: "boolLit", value: false, type: BOOL, loc: loc0 },
2588
2872
  loc: loc0,
2589
- }]
2873
+ },
2874
+ ]
2590
2875
  : []),
2591
2876
  { kind: "rethrow", localId: catchLocal.id, loc: loc0 },
2592
2877
  ],
@@ -2615,11 +2900,11 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
2615
2900
  }
2616
2901
  }
2617
2902
  /** %main is just the entry's %init call: Node's whole module evaluation
2618
- * order lives in the init functions themselves — each file's hoisted
2619
- * import header runs its dependencies first (depth-first postorder by
2620
- * nesting), CommonJS require statements call dependency inits inline in
2621
- * their bodies, and the run-once guards turn every revisit (diamonds,
2622
- * re-imports, re-requires) into a cache hit. */
2903
+ * order lives in the init functions themselves — each file's hoisted
2904
+ * import header runs its dependencies first (depth-first postorder by
2905
+ * nesting), CommonJS require statements call dependency inits inline in
2906
+ * their bodies, and the run-once guards turn every revisit (diamonds,
2907
+ * re-imports, re-requires) into a cache hit. */
2623
2908
  export function buildMain(lowerer) {
2624
2909
  const loc = { file: lowerer.entry.fileName, start: 0, end: 0 };
2625
2910
  const body = [...cjsModuleRegistryPrelude(lowerer, loc)];
@@ -2637,11 +2922,13 @@ export function buildMain(lowerer) {
2637
2922
  type: rootAsync ? { kind: "promise", inner: VOID } : VOID,
2638
2923
  loc,
2639
2924
  };
2640
- return [{
2925
+ return [
2926
+ {
2641
2927
  kind: "exprStmt",
2642
2928
  expr: rootAsync ? { kind: "awaitExpr", value: call, type: VOID, loc } : call,
2643
2929
  loc,
2644
- }];
2930
+ },
2931
+ ];
2645
2932
  };
2646
2933
  const locals = [];
2647
2934
  if (lowerer.forkTargets.length === 0) {
@@ -2665,7 +2952,8 @@ export function buildMain(lowerer) {
2665
2952
  const selector = () => ({ kind: "varRef", localId: targetId, type: F64, loc });
2666
2953
  let workerBranch = null;
2667
2954
  for (let id = lowerer.forkTargets.length - 1; id >= 0; id--) {
2668
- workerBranch = [{
2955
+ workerBranch = [
2956
+ {
2669
2957
  kind: "if",
2670
2958
  cond: {
2671
2959
  kind: "bin",
@@ -2678,7 +2966,8 @@ export function buildMain(lowerer) {
2678
2966
  then: callRoot(lowerer.forkTargets[id]),
2679
2967
  else_: workerBranch,
2680
2968
  loc,
2681
- }];
2969
+ },
2970
+ ];
2682
2971
  }
2683
2972
  body.push({
2684
2973
  kind: "if",
@@ -2710,7 +2999,9 @@ export function buildMain(lowerer) {
2710
2999
  value: {
2711
3000
  kind: "libCall",
2712
3001
  fn: "error.new",
2713
- args: [{ kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc }],
3002
+ args: [
3003
+ { kind: "strLit", value: lowerer.startupCrash.message, type: STRING, loc: crashLoc },
3004
+ ],
2714
3005
  type: { kind: "object", className: lowerer.startupCrash.className },
2715
3006
  loc: crashLoc,
2716
3007
  },