@scriptc/compiler 0.4.1 → 0.4.3

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 (999) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +977 -113
  2. package/dist/backend/cycle-analysis.d.ts +5 -1
  3. package/dist/backend/cycle-analysis.js +6 -4
  4. package/dist/backend/cycle-analysis.js.map +1 -1
  5. package/dist/backend/cycle-analysis.test.js +55 -0
  6. package/dist/backend/cycle-analysis.test.js.map +1 -1
  7. package/dist/backend/cycle-mutability.d.ts +9 -1
  8. package/dist/backend/cycle-mutability.js +21 -3
  9. package/dist/backend/cycle-mutability.js.map +1 -1
  10. package/dist/backend/executable-features.js +6 -1
  11. package/dist/backend/executable-features.js.map +1 -1
  12. package/dist/backend/immutability.d.ts +7 -3
  13. package/dist/backend/immutability.js +33 -29
  14. package/dist/backend/immutability.js.map +1 -1
  15. package/dist/backend/library-pack.js +5 -0
  16. package/dist/backend/library-pack.js.map +1 -1
  17. package/dist/backend/llvm/alloc.d.ts +23 -4
  18. package/dist/backend/llvm/alloc.js +61 -8
  19. package/dist/backend/llvm/alloc.js.map +1 -1
  20. package/dist/backend/llvm/appended-array-literals.d.ts +2 -1
  21. package/dist/backend/llvm/appended-array-literals.js +44 -36
  22. package/dist/backend/llvm/appended-array-literals.js.map +1 -1
  23. package/dist/backend/llvm/appended-array-literals.test.js +4 -3
  24. package/dist/backend/llvm/appended-array-literals.test.js.map +1 -1
  25. package/dist/backend/llvm/array-search.d.ts +4 -3
  26. package/dist/backend/llvm/array-search.js +23 -10
  27. package/dist/backend/llvm/array-search.js.map +1 -1
  28. package/dist/backend/llvm/blocks.d.ts +1 -1
  29. package/dist/backend/llvm/blocks.js +2 -2
  30. package/dist/backend/llvm/blocks.js.map +1 -1
  31. package/dist/backend/llvm/byte-windows.js +2 -0
  32. package/dist/backend/llvm/byte-windows.js.map +1 -1
  33. package/dist/backend/llvm/bytes-alias.d.ts +6 -1
  34. package/dist/backend/llvm/bytes-alias.js +8 -2
  35. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  36. package/dist/backend/llvm/bytes-loop-versions.d.ts +70 -7
  37. package/dist/backend/llvm/bytes-loop-versions.js +567 -30
  38. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  39. package/dist/backend/llvm/bytes-loop-versions.test.js +389 -2
  40. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  41. package/dist/backend/llvm/checked-value-lifetimes.js +2 -0
  42. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  43. package/dist/backend/llvm/classes.d.ts +74 -1
  44. package/dist/backend/llvm/classes.js +364 -54
  45. package/dist/backend/llvm/classes.js.map +1 -1
  46. package/dist/backend/llvm/classes.test.js +384 -17
  47. package/dist/backend/llvm/classes.test.js.map +1 -1
  48. package/dist/backend/llvm/common.d.ts +10 -6
  49. package/dist/backend/llvm/common.js +10 -6
  50. package/dist/backend/llvm/common.js.map +1 -1
  51. package/dist/backend/llvm/constant-callbacks.d.ts +2 -1
  52. package/dist/backend/llvm/constant-callbacks.js +91 -56
  53. package/dist/backend/llvm/constant-callbacks.js.map +1 -1
  54. package/dist/backend/llvm/constant-callbacks.test.js +4 -4
  55. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  56. package/dist/backend/llvm/counted-loops.d.ts +11 -1
  57. package/dist/backend/llvm/counted-loops.js +80 -23
  58. package/dist/backend/llvm/counted-loops.js.map +1 -1
  59. package/dist/backend/llvm/dense-array-access.d.ts +39 -8
  60. package/dist/backend/llvm/dense-array-access.js +222 -52
  61. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  62. package/dist/backend/llvm/dense-array-access.test.js +36 -0
  63. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  64. package/dist/backend/llvm/dense-array-loops.d.ts +35 -16
  65. package/dist/backend/llvm/dense-array-loops.js +237 -12
  66. package/dist/backend/llvm/dense-array-loops.js.map +1 -1
  67. package/dist/backend/llvm/dense-array-loops.test.js +140 -15
  68. package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
  69. package/dist/backend/llvm/dyn-handle-tags.test.js +6 -1
  70. package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
  71. package/dist/backend/llvm/dyn.d.ts +51 -1
  72. package/dist/backend/llvm/dyn.js +683 -69
  73. package/dist/backend/llvm/dyn.js.map +1 -1
  74. package/dist/backend/llvm/emit-function.js +33 -26
  75. package/dist/backend/llvm/emit-function.js.map +1 -1
  76. package/dist/backend/llvm/emit-journal.d.ts +93 -0
  77. package/dist/backend/llvm/emit-journal.js +170 -0
  78. package/dist/backend/llvm/emit-journal.js.map +1 -0
  79. package/dist/backend/llvm/emit-module.js +208 -34
  80. package/dist/backend/llvm/emit-module.js.map +1 -1
  81. package/dist/backend/llvm/emit-statements.d.ts +0 -27
  82. package/dist/backend/llvm/emit-statements.js +577 -93
  83. package/dist/backend/llvm/emit-statements.js.map +1 -1
  84. package/dist/backend/llvm/emitter-state.d.ts +7 -0
  85. package/dist/backend/llvm/emitter-state.js +14 -0
  86. package/dist/backend/llvm/emitter-state.js.map +1 -0
  87. package/dist/backend/llvm/emitter.d.ts +314 -49
  88. package/dist/backend/llvm/emitter.js +1241 -129
  89. package/dist/backend/llvm/emitter.js.map +1 -1
  90. package/dist/backend/llvm/emitter.test.js +54 -5
  91. package/dist/backend/llvm/emitter.test.js.map +1 -1
  92. package/dist/backend/llvm/expr-async.js +19 -0
  93. package/dist/backend/llvm/expr-async.js.map +1 -1
  94. package/dist/backend/llvm/expr-bytes.d.ts +5 -2
  95. package/dist/backend/llvm/expr-bytes.js +144 -52
  96. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  97. package/dist/backend/llvm/expr-callbacks.js +47 -0
  98. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  99. package/dist/backend/llvm/expr-calls.d.ts +1 -1
  100. package/dist/backend/llvm/expr-calls.js +62 -36
  101. package/dist/backend/llvm/expr-calls.js.map +1 -1
  102. package/dist/backend/llvm/expr-containers.d.ts +14 -2
  103. package/dist/backend/llvm/expr-containers.js +148 -40
  104. package/dist/backend/llvm/expr-containers.js.map +1 -1
  105. package/dist/backend/llvm/expr-context.d.ts +14 -0
  106. package/dist/backend/llvm/expr-control.js +2 -3
  107. package/dist/backend/llvm/expr-control.js.map +1 -1
  108. package/dist/backend/llvm/expr-dynamic.js +71 -16
  109. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  110. package/dist/backend/llvm/expr-primitives.js +126 -36
  111. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  112. package/dist/backend/llvm/expr-primitives.test.js +11 -6
  113. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  114. package/dist/backend/llvm/expr-records.d.ts +12 -0
  115. package/dist/backend/llvm/expr-records.js +106 -0
  116. package/dist/backend/llvm/expr-records.js.map +1 -1
  117. package/dist/backend/llvm/expr-stream-bridges.d.ts +2 -2
  118. package/dist/backend/llvm/expr-stream-bridges.js +225 -64
  119. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  120. package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
  121. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  122. package/dist/backend/llvm/expr-stream-callbacks.d.ts +2 -2
  123. package/dist/backend/llvm/expr-stream-callbacks.js +200 -50
  124. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  125. package/dist/backend/llvm/int32-kind-loops.d.ts +39 -0
  126. package/dist/backend/llvm/int32-kind-loops.js +106 -0
  127. package/dist/backend/llvm/int32-kind-loops.js.map +1 -0
  128. package/dist/backend/llvm/integer-or-nan-indexes.test.d.ts +1 -0
  129. package/dist/backend/llvm/integer-or-nan-indexes.test.js +118 -0
  130. package/dist/backend/llvm/integer-or-nan-indexes.test.js.map +1 -0
  131. package/dist/backend/llvm/integer-values.d.ts +20 -1
  132. package/dist/backend/llvm/integer-values.js +71 -0
  133. package/dist/backend/llvm/integer-values.js.map +1 -1
  134. package/dist/backend/llvm/js-ic.d.ts +1 -1
  135. package/dist/backend/llvm/js-ic.js +1 -1
  136. package/dist/backend/llvm/js-ic.js.map +1 -1
  137. package/dist/backend/llvm/key-orders.d.ts +7 -0
  138. package/dist/backend/llvm/key-orders.js +33 -0
  139. package/dist/backend/llvm/key-orders.js.map +1 -0
  140. package/dist/backend/llvm/lib-connect.js +4 -0
  141. package/dist/backend/llvm/lib-connect.js.map +1 -1
  142. package/dist/backend/llvm/lib-datagram.js +11 -0
  143. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  144. package/dist/backend/llvm/lib-dispatch.js +90 -2
  145. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  146. package/dist/backend/llvm/lib-filesystem.js +65 -4
  147. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  148. package/dist/backend/llvm/lib-http2.d.ts +4 -0
  149. package/dist/backend/llvm/lib-http2.js +24 -17
  150. package/dist/backend/llvm/lib-http2.js.map +1 -1
  151. package/dist/backend/llvm/lib-lookup.js +16 -6
  152. package/dist/backend/llvm/lib-lookup.js.map +1 -1
  153. package/dist/backend/llvm/lib-process.js +65 -14
  154. package/dist/backend/llvm/lib-process.js.map +1 -1
  155. package/dist/backend/llvm/lib-shared.js +126 -3
  156. package/dist/backend/llvm/lib-shared.js.map +1 -1
  157. package/dist/backend/llvm/lib-stream.js +97 -30
  158. package/dist/backend/llvm/lib-stream.js.map +1 -1
  159. package/dist/backend/llvm/lib-tls.js +23 -0
  160. package/dist/backend/llvm/lib-tls.js.map +1 -1
  161. package/dist/backend/llvm/local-array-reads.js +181 -64
  162. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  163. package/dist/backend/llvm/local-array-reads.test.js +28 -0
  164. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  165. package/dist/backend/llvm/loop-state.d.ts +33 -0
  166. package/dist/backend/llvm/loop-state.js +42 -0
  167. package/dist/backend/llvm/loop-state.js.map +1 -0
  168. package/dist/backend/llvm/map-number-lookup.d.ts +26 -8
  169. package/dist/backend/llvm/map-number-lookup.js +91 -31
  170. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  171. package/dist/backend/llvm/map-number-lookup.test.js +55 -0
  172. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  173. package/dist/backend/llvm/map-read-lifetimes.js +4 -2
  174. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  175. package/dist/backend/llvm/nullable-unions.d.ts +2 -1
  176. package/dist/backend/llvm/nullable-unions.js +15 -3
  177. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  178. package/dist/backend/llvm/publish.d.ts +18 -1
  179. package/dist/backend/llvm/publish.js +76 -25
  180. package/dist/backend/llvm/publish.js.map +1 -1
  181. package/dist/backend/llvm/publish.test.js +3 -0
  182. package/dist/backend/llvm/publish.test.js.map +1 -1
  183. package/dist/backend/llvm/receivers.js +7 -2
  184. package/dist/backend/llvm/receivers.js.map +1 -1
  185. package/dist/backend/llvm/record-results.d.ts +1 -9
  186. package/dist/backend/llvm/record-results.js +2 -11
  187. package/dist/backend/llvm/record-results.js.map +1 -1
  188. package/dist/backend/llvm/reference-writes.d.ts +7 -2
  189. package/dist/backend/llvm/reference-writes.js +91 -72
  190. package/dist/backend/llvm/reference-writes.js.map +1 -1
  191. package/dist/backend/llvm/regex-matchers.js +161 -14
  192. package/dist/backend/llvm/regex-matchers.js.map +1 -1
  193. package/dist/backend/llvm/regex-matchers.test.js +18 -0
  194. package/dist/backend/llvm/regex-matchers.test.js.map +1 -1
  195. package/dist/backend/llvm/running-extrema.d.ts +11 -0
  196. package/dist/backend/llvm/running-extrema.js +115 -0
  197. package/dist/backend/llvm/running-extrema.js.map +1 -0
  198. package/dist/backend/llvm/running-extrema.test.d.ts +1 -0
  199. package/dist/backend/llvm/running-extrema.test.js +89 -0
  200. package/dist/backend/llvm/running-extrema.test.js.map +1 -0
  201. package/dist/backend/llvm/shapes.d.ts +79 -21
  202. package/dist/backend/llvm/shapes.js +233 -42
  203. package/dist/backend/llvm/shapes.js.map +1 -1
  204. package/dist/backend/llvm/shapes.test.js +53 -7
  205. package/dist/backend/llvm/shapes.test.js.map +1 -1
  206. package/dist/backend/llvm/speculative-integers.d.ts +6 -0
  207. package/dist/backend/llvm/speculative-integers.js +2 -2
  208. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  209. package/dist/backend/llvm/stack-objects.d.ts +3 -2
  210. package/dist/backend/llvm/stack-objects.js +5 -2
  211. package/dist/backend/llvm/stack-objects.js.map +1 -1
  212. package/dist/backend/llvm/string-lifetimes.test.js +2 -1
  213. package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
  214. package/dist/backend/llvm/string-reads.d.ts +15 -0
  215. package/dist/backend/llvm/string-reads.js +128 -0
  216. package/dist/backend/llvm/string-reads.js.map +1 -1
  217. package/dist/backend/llvm/walk-borrows.d.ts +3 -0
  218. package/dist/backend/llvm/walk-borrows.js +46 -41
  219. package/dist/backend/llvm/walk-borrows.js.map +1 -1
  220. package/dist/backend/llvm/walkers.d.ts +3 -0
  221. package/dist/backend/llvm/walkers.js +88 -65
  222. package/dist/backend/llvm/walkers.js.map +1 -1
  223. package/dist/backend/llvm/wasm-modules.d.ts +6 -5
  224. package/dist/backend/llvm/wasm-modules.js +32 -9
  225. package/dist/backend/llvm/wasm-modules.js.map +1 -1
  226. package/dist/backend/llvm/wrapping-sums.d.ts +16 -1
  227. package/dist/backend/llvm/wrapping-sums.js +126 -0
  228. package/dist/backend/llvm/wrapping-sums.js.map +1 -1
  229. package/dist/backend/mangle.d.ts +3 -0
  230. package/dist/backend/mangle.js +5 -0
  231. package/dist/backend/mangle.js.map +1 -1
  232. package/dist/backend/may-throw.d.ts +8 -10
  233. package/dist/backend/may-throw.js +14 -10
  234. package/dist/backend/may-throw.js.map +1 -1
  235. package/dist/backend/native/contracts.d.ts +27 -4
  236. package/dist/backend/native/executable.js +31 -8
  237. package/dist/backend/native/executable.js.map +1 -1
  238. package/dist/backend/native/library.js +1 -0
  239. package/dist/backend/native/library.js.map +1 -1
  240. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  241. package/dist/backend/native/runtime-inputs.js +1 -0
  242. package/dist/backend/native/runtime-inputs.js.map +1 -1
  243. package/dist/backend/native-codegen.d.ts +11 -6
  244. package/dist/backend/native-codegen.js +36 -9
  245. package/dist/backend/native-codegen.js.map +1 -1
  246. package/dist/backend/native-codegen.test.js +0 -23
  247. package/dist/backend/native-codegen.test.js.map +1 -1
  248. package/dist/backend/native-link-info-core.d.ts +18 -4
  249. package/dist/backend/native-link-info-core.js.map +1 -1
  250. package/dist/backend/optimization.d.ts +2 -2
  251. package/dist/backend/publication.d.ts +12 -1
  252. package/dist/backend/publication.js +37 -14
  253. package/dist/backend/publication.js.map +1 -1
  254. package/dist/backend/publication.test.js +30 -0
  255. package/dist/backend/publication.test.js.map +1 -1
  256. package/dist/backend/result-slots.d.ts +16 -0
  257. package/dist/backend/result-slots.js +23 -0
  258. package/dist/backend/result-slots.js.map +1 -0
  259. package/dist/backend/runtime-abi.d.ts +2 -2
  260. package/dist/backend/runtime-abi.js +2 -2
  261. package/dist/backend/runtime-pack-core.d.ts +2 -1
  262. package/dist/backend/runtime-pack-core.js +2 -1
  263. package/dist/backend/runtime-pack-core.js.map +1 -1
  264. package/dist/backend/runtime-pack-targets.test.js +5 -1
  265. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  266. package/dist/backend/runtime-pack.d.ts +0 -21
  267. package/dist/backend/runtime-pack.js +0 -29
  268. package/dist/backend/runtime-pack.js.map +1 -1
  269. package/dist/backend/runtime-pack.test.js +10 -69
  270. package/dist/backend/runtime-pack.test.js.map +1 -1
  271. package/dist/backend/stack-observations.d.ts +2 -1
  272. package/dist/backend/stack-observations.js +67 -42
  273. package/dist/backend/stack-observations.js.map +1 -1
  274. package/dist/backend/target-diagnostics.js +33 -1
  275. package/dist/backend/target-diagnostics.js.map +1 -1
  276. package/dist/backend/warm-cache.js +4 -0
  277. package/dist/backend/warm-cache.js.map +1 -1
  278. package/dist/cli/command.js +26 -6
  279. package/dist/cli/command.js.map +1 -1
  280. package/dist/cli/usage.d.ts +5 -1
  281. package/dist/cli/usage.js +10 -5
  282. package/dist/cli/usage.js.map +1 -1
  283. package/dist/compat/fetch-profile.js +1 -1
  284. package/dist/compat/fetch-profile.js.map +1 -1
  285. package/dist/contracts/check.js +5 -4
  286. package/dist/contracts/check.js.map +1 -1
  287. package/dist/contracts/int32-elements.js +10 -2
  288. package/dist/contracts/int32-elements.js.map +1 -1
  289. package/dist/coverage/report.d.ts +7 -2
  290. package/dist/coverage/report.js +30 -3
  291. package/dist/coverage/report.js.map +1 -1
  292. package/dist/coverage/verdict-cache.d.ts +1 -0
  293. package/dist/coverage/verdict-cache.js +4 -0
  294. package/dist/coverage/verdict-cache.js.map +1 -1
  295. package/dist/coverage/verdict-semantic.js +4 -0
  296. package/dist/coverage/verdict-semantic.js.map +1 -1
  297. package/dist/diagnostics/diagnostic.d.ts +4 -0
  298. package/dist/diagnostics/diagnostic.js.map +1 -1
  299. package/dist/diagnostics/dynamic-tier.d.ts +40 -0
  300. package/dist/diagnostics/dynamic-tier.js +57 -0
  301. package/dist/diagnostics/dynamic-tier.js.map +1 -0
  302. package/dist/diagnostics/envelope.d.ts +5 -1
  303. package/dist/diagnostics/envelope.js +6 -2
  304. package/dist/diagnostics/envelope.js.map +1 -1
  305. package/dist/executable/executable-cache.d.ts +25 -1
  306. package/dist/executable/executable-cache.js +60 -7
  307. package/dist/executable/executable-cache.js.map +1 -1
  308. package/dist/executable/executable-cache.test.js +46 -3
  309. package/dist/executable/executable-cache.test.js.map +1 -1
  310. package/dist/executable/prepare.js +3 -1
  311. package/dist/executable/prepare.js.map +1 -1
  312. package/dist/frontend/analysis.js +1 -0
  313. package/dist/frontend/analysis.js.map +1 -1
  314. package/dist/frontend/decl-projection.d.ts +41 -0
  315. package/dist/frontend/decl-projection.js +854 -0
  316. package/dist/frontend/decl-projection.js.map +1 -0
  317. package/dist/frontend/decl-projection.test.d.ts +1 -0
  318. package/dist/frontend/decl-projection.test.js +30 -0
  319. package/dist/frontend/decl-projection.test.js.map +1 -0
  320. package/dist/frontend/dispose-hook.d.ts +2 -0
  321. package/dist/frontend/dispose-hook.js +14 -0
  322. package/dist/frontend/dispose-hook.js.map +1 -0
  323. package/dist/frontend/dts-paths.d.ts +15 -0
  324. package/dist/frontend/dts-paths.js +25 -0
  325. package/dist/frontend/dts-paths.js.map +1 -1
  326. package/dist/frontend/input-tracker.d.ts +6 -0
  327. package/dist/frontend/input-tracker.js +51 -28
  328. package/dist/frontend/input-tracker.js.map +1 -1
  329. package/dist/frontend/input-tracker.test.js +19 -0
  330. package/dist/frontend/input-tracker.test.js.map +1 -1
  331. package/dist/frontend/jsx-entities.d.ts +4 -0
  332. package/dist/frontend/jsx-entities.js +259 -0
  333. package/dist/frontend/jsx-entities.js.map +1 -0
  334. package/dist/frontend/jsx-source.d.ts +71 -0
  335. package/dist/frontend/jsx-source.js +781 -0
  336. package/dist/frontend/jsx-source.js.map +1 -0
  337. package/dist/frontend/jsx-source.test.d.ts +1 -0
  338. package/dist/frontend/jsx-source.test.js +200 -0
  339. package/dist/frontend/jsx-source.test.js.map +1 -0
  340. package/dist/frontend/literal-values.test.js +8 -9
  341. package/dist/frontend/literal-values.test.js.map +1 -1
  342. package/dist/frontend/lowering/array-indexed-mutation.js +2 -1
  343. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
  344. package/dist/frontend/lowering/array-values.js +103 -4
  345. package/dist/frontend/lowering/array-values.js.map +1 -1
  346. package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
  347. package/dist/frontend/lowering/binding-analysis.js +2 -2
  348. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  349. package/dist/frontend/lowering/builtins/arguments.d.ts +3 -0
  350. package/dist/frontend/lowering/builtins/arguments.js +30 -15
  351. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  352. package/dist/frontend/lowering/builtins/atomics.js +10 -6
  353. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  354. package/dist/frontend/lowering/builtins/child-process-async.js +2 -1
  355. package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -1
  356. package/dist/frontend/lowering/builtins/child-process-methods.js +46 -15
  357. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  358. package/dist/frontend/lowering/builtins/child-process-sync.js +2 -1
  359. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  360. package/dist/frontend/lowering/builtins/child-process.js +13 -2
  361. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  362. package/dist/frontend/lowering/builtins/crypto.d.ts +4 -2
  363. package/dist/frontend/lowering/builtins/crypto.js +136 -5
  364. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  365. package/dist/frontend/lowering/builtins/date-classes.d.ts +46 -0
  366. package/dist/frontend/lowering/builtins/date-classes.js +477 -0
  367. package/dist/frontend/lowering/builtins/date-classes.js.map +1 -0
  368. package/dist/frontend/lowering/builtins/dates.d.ts +11 -1
  369. package/dist/frontend/lowering/builtins/dates.js +55 -26
  370. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  371. package/dist/frontend/lowering/builtins/dh.d.ts +15 -0
  372. package/dist/frontend/lowering/builtins/dh.js +151 -0
  373. package/dist/frontend/lowering/builtins/dh.js.map +1 -0
  374. package/dist/frontend/lowering/builtins/disposable-stack.js +2 -1
  375. package/dist/frontend/lowering/builtins/disposable-stack.js.map +1 -1
  376. package/dist/frontend/lowering/builtins/ecdh.d.ts +12 -1
  377. package/dist/frontend/lowering/builtins/ecdh.js +7 -7
  378. package/dist/frontend/lowering/builtins/ecdh.js.map +1 -1
  379. package/dist/frontend/lowering/builtins/errors.d.ts +15 -0
  380. package/dist/frontend/lowering/builtins/errors.js +110 -0
  381. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  382. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -1
  383. package/dist/frontend/lowering/builtins/filesystem-calls.js +23 -17
  384. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  385. package/dist/frontend/lowering/builtins/filesystem.js +6 -4
  386. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  387. package/dist/frontend/lowering/builtins/fs-paths.d.ts +15 -0
  388. package/dist/frontend/lowering/builtins/fs-paths.js +209 -0
  389. package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -0
  390. package/dist/frontend/lowering/builtins/global-namespace-keys.d.ts +3 -0
  391. package/dist/frontend/lowering/builtins/global-namespace-keys.js +122 -0
  392. package/dist/frontend/lowering/builtins/global-namespace-keys.js.map +1 -0
  393. package/dist/frontend/lowering/builtins/hash-stream.d.ts +16 -4
  394. package/dist/frontend/lowering/builtins/hash-stream.js +86 -23
  395. package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -1
  396. package/dist/frontend/lowering/builtins/json.js +2 -1
  397. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  398. package/dist/frontend/lowering/builtins/key-object.d.ts +2 -1
  399. package/dist/frontend/lowering/builtins/key-object.js +20 -7
  400. package/dist/frontend/lowering/builtins/key-object.js.map +1 -1
  401. package/dist/frontend/lowering/builtins/module-calls.js +11 -4
  402. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  403. package/dist/frontend/lowering/builtins/numbers.js +18 -6
  404. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  405. package/dist/frontend/lowering/builtins/operating-system.js +4 -3
  406. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  407. package/dist/frontend/lowering/builtins/performance.js +3 -2
  408. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  409. package/dist/frontend/lowering/builtins/process.js +3 -2
  410. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  411. package/dist/frontend/lowering/builtins/promises.d.ts +6 -0
  412. package/dist/frontend/lowering/builtins/promises.js +91 -4
  413. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  414. package/dist/frontend/lowering/builtins/promisify-callback.js +2 -1
  415. package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
  416. package/dist/frontend/lowering/builtins/readline.d.ts +7 -2
  417. package/dist/frontend/lowering/builtins/readline.js +58 -9
  418. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  419. package/dist/frontend/lowering/builtins/strings.js +13 -5
  420. package/dist/frontend/lowering/builtins/strings.js.map +1 -1
  421. package/dist/frontend/lowering/builtins/text-codecs.js +2 -1
  422. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  423. package/dist/frontend/lowering/builtins/timers.js +1 -1
  424. package/dist/frontend/lowering/builtins/timers.js.map +1 -1
  425. package/dist/frontend/lowering/builtins/url.js +28 -4
  426. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  427. package/dist/frontend/lowering/builtins/v8.js +2 -1
  428. package/dist/frontend/lowering/builtins/v8.js.map +1 -1
  429. package/dist/frontend/lowering/builtins/webassembly.js +6 -3
  430. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  431. package/dist/frontend/lowering/builtins/webcrypto.js +39 -20
  432. package/dist/frontend/lowering/builtins/webcrypto.js.map +1 -1
  433. package/dist/frontend/lowering/call-arguments.js +2 -1
  434. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  435. package/dist/frontend/lowering/call-signatures.js +13 -6
  436. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  437. package/dist/frontend/lowering/caught-value-dispatch.d.ts +18 -1
  438. package/dist/frontend/lowering/caught-value-dispatch.js +201 -32
  439. package/dist/frontend/lowering/caught-value-dispatch.js.map +1 -1
  440. package/dist/frontend/lowering/class-assertions.js +3 -2
  441. package/dist/frontend/lowering/class-assertions.js.map +1 -1
  442. package/dist/frontend/lowering/class-callbacks.d.ts +5 -2
  443. package/dist/frontend/lowering/class-callbacks.js +82 -12
  444. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  445. package/dist/frontend/lowering/class-construction.d.ts +6 -2
  446. package/dist/frontend/lowering/class-construction.js +25 -16
  447. package/dist/frontend/lowering/class-construction.js.map +1 -1
  448. package/dist/frontend/lowering/class-descriptors.js +1 -1
  449. package/dist/frontend/lowering/class-descriptors.js.map +1 -1
  450. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +73 -2
  451. package/dist/frontend/lowering/class-dynamic-dispatch.js +1334 -259
  452. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  453. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +124 -0
  454. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  455. package/dist/frontend/lowering/class-iterables.d.ts +2 -1
  456. package/dist/frontend/lowering/class-iterables.js +9 -1
  457. package/dist/frontend/lowering/class-iterables.js.map +1 -1
  458. package/dist/frontend/lowering/class-method-mutations.js +35 -9
  459. package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
  460. package/dist/frontend/lowering/class-method-values.js +1 -1
  461. package/dist/frontend/lowering/class-method-values.js.map +1 -1
  462. package/dist/frontend/lowering/class-protocols.d.ts +7 -0
  463. package/dist/frontend/lowering/class-protocols.js +64 -4
  464. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  465. package/dist/frontend/lowering/class-prototypes.d.ts +5 -0
  466. package/dist/frontend/lowering/class-prototypes.js +67 -5
  467. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  468. package/dist/frontend/lowering/class-runtime-statics.d.ts +9 -3
  469. package/dist/frontend/lowering/class-runtime-statics.js +29 -4
  470. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  471. package/dist/frontend/lowering/class-to-primitive.js +25 -5
  472. package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
  473. package/dist/frontend/lowering/class-unions.js +2 -1
  474. package/dist/frontend/lowering/class-unions.js.map +1 -1
  475. package/dist/frontend/lowering/coercions/function-adapters.js +6 -5
  476. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  477. package/dist/frontend/lowering/coercions/structural-plans.js +48 -1
  478. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  479. package/dist/frontend/lowering/coercions/structural.js +99 -8
  480. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  481. package/dist/frontend/lowering/coercions/unions.js +8 -7
  482. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  483. package/dist/frontend/lowering/collection-ingestion.js +2 -1
  484. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  485. package/dist/frontend/lowering/containers/array-callback-call.js +2 -2
  486. package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
  487. package/dist/frontend/lowering/containers/array-callbacks.d.ts +7 -0
  488. package/dist/frontend/lowering/containers/array-callbacks.js +352 -31
  489. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  490. package/dist/frontend/lowering/containers/array-concat.js +12 -1
  491. package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
  492. package/dist/frontend/lowering/containers/array-construction.js +25 -4
  493. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  494. package/dist/frontend/lowering/containers/array-methods.js +21 -5
  495. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  496. package/dist/frontend/lowering/containers/array-pipelines.js +21 -9
  497. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  498. package/dist/frontend/lowering/containers/bytes.d.ts +1 -1
  499. package/dist/frontend/lowering/containers/bytes.js +131 -29
  500. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  501. package/dist/frontend/lowering/containers/callback-arguments.js +55 -2
  502. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  503. package/dist/frontend/lowering/containers/collection-grouping.js +3 -2
  504. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  505. package/dist/frontend/lowering/containers/collection-methods.js +15 -9
  506. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  507. package/dist/frontend/lowering/containers/filter-predicates.d.ts +6 -0
  508. package/dist/frontend/lowering/containers/filter-predicates.js +205 -0
  509. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -0
  510. package/dist/frontend/lowering/containers/indexed-objects.d.ts +0 -12
  511. package/dist/frontend/lowering/containers/indexed-objects.js +54 -14
  512. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  513. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +32 -1
  514. package/dist/frontend/lowering/containers/iterator-helpers.js +6 -5
  515. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  516. package/dist/frontend/lowering/containers/string-and-regexp.js +87 -14
  517. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  518. package/dist/frontend/lowering/containers/string-replacement.js +45 -20
  519. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  520. package/dist/frontend/lowering/cycle-initialization.js +25 -4
  521. package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
  522. package/dist/frontend/lowering/deferred-module-initializers.d.ts +18 -1
  523. package/dist/frontend/lowering/deferred-module-initializers.js +226 -115
  524. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  525. package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
  526. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  527. package/dist/frontend/lowering/dispatch-sites.d.ts +59 -0
  528. package/dist/frontend/lowering/dispatch-sites.js +218 -0
  529. package/dist/frontend/lowering/dispatch-sites.js.map +1 -0
  530. package/dist/frontend/lowering/dispatch-sites.test.d.ts +1 -0
  531. package/dist/frontend/lowering/dispatch-sites.test.js +59 -0
  532. package/dist/frontend/lowering/dispatch-sites.test.js.map +1 -0
  533. package/dist/frontend/lowering/divergences.js +9 -1
  534. package/dist/frontend/lowering/divergences.js.map +1 -1
  535. package/dist/frontend/lowering/dyn-streams.d.ts +3 -0
  536. package/dist/frontend/lowering/dyn-streams.js +1 -1
  537. package/dist/frontend/lowering/dyn-streams.js.map +1 -1
  538. package/dist/frontend/lowering/dynamic-tier.d.ts +25 -0
  539. package/dist/frontend/lowering/dynamic-tier.js +327 -0
  540. package/dist/frontend/lowering/dynamic-tier.js.map +1 -0
  541. package/dist/frontend/lowering/error-methods.js +51 -2
  542. package/dist/frontend/lowering/error-methods.js.map +1 -1
  543. package/dist/frontend/lowering/expressions/array-literals.js +62 -0
  544. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  545. package/dist/frontend/lowering/expressions/binary.js +81 -5
  546. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  547. package/dist/frontend/lowering/expressions/element-access.js +107 -14
  548. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  549. package/dist/frontend/lowering/expressions/identifiers.js +79 -11
  550. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  551. package/dist/frontend/lowering/expressions/narrowing.js +130 -6
  552. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  553. package/dist/frontend/lowering/expressions/nullish-assignment.js +3 -1
  554. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  555. package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -3
  556. package/dist/frontend/lowering/expressions/object-literals.js +164 -56
  557. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  558. package/dist/frontend/lowering/expressions/optional-chains.js +17 -5
  559. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  560. package/dist/frontend/lowering/expressions/property-access.d.ts +0 -4
  561. package/dist/frontend/lowering/expressions/property-access.js +211 -17
  562. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  563. package/dist/frontend/lowering/expressions/relational.js +267 -30
  564. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  565. package/dist/frontend/lowering/expressions/union-fields.js +4 -0
  566. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  567. package/dist/frontend/lowering/expressions/updates.js +85 -12
  568. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  569. package/dist/frontend/lowering/frozen-records.d.ts +28 -0
  570. package/dist/frontend/lowering/frozen-records.js +322 -0
  571. package/dist/frontend/lowering/frozen-records.js.map +1 -0
  572. package/dist/frontend/lowering/function-returns.js +49 -0
  573. package/dist/frontend/lowering/function-returns.js.map +1 -1
  574. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +6 -1
  575. package/dist/frontend/lowering/generator-dynamic-dispatch.js +20 -30
  576. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
  577. package/dist/frontend/lowering/generic-functions.d.ts +42 -1
  578. package/dist/frontend/lowering/generic-functions.js +455 -20
  579. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  580. package/dist/frontend/lowering/intern-tables.js +2 -1
  581. package/dist/frontend/lowering/intern-tables.js.map +1 -1
  582. package/dist/frontend/lowering/iterable-values.d.ts +49 -0
  583. package/dist/frontend/lowering/iterable-values.js +297 -0
  584. package/dist/frontend/lowering/iterable-values.js.map +1 -0
  585. package/dist/frontend/lowering/iterator-adapters.js +195 -9
  586. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  587. package/dist/frontend/lowering/js-class-fields.d.ts +8 -0
  588. package/dist/frontend/lowering/js-class-fields.js +45 -10
  589. package/dist/frontend/lowering/js-class-fields.js.map +1 -1
  590. package/dist/frontend/lowering/js-dynamic-objects.js +3 -2
  591. package/dist/frontend/lowering/js-dynamic-objects.js.map +1 -1
  592. package/dist/frontend/lowering/json-require.js +2 -1
  593. package/dist/frontend/lowering/json-require.js.map +1 -1
  594. package/dist/frontend/lowering/key-order-witness.d.ts +24 -4
  595. package/dist/frontend/lowering/key-order-witness.js +790 -25
  596. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  597. package/dist/frontend/lowering/key-order-witness.test.js +466 -10
  598. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  599. package/dist/frontend/lowering/lifetime-regions.js +2 -1
  600. package/dist/frontend/lowering/lifetime-regions.js.map +1 -1
  601. package/dist/frontend/lowering/lower-assert.js +6 -5
  602. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  603. package/dist/frontend/lowering/lower-async-iteration.js +7 -2
  604. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  605. package/dist/frontend/lowering/lower-calls.d.ts +11 -0
  606. package/dist/frontend/lowering/lower-calls.js +776 -126
  607. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  608. package/dist/frontend/lowering/lower-classes.d.ts +29 -2
  609. package/dist/frontend/lowering/lower-classes.js +581 -46
  610. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  611. package/dist/frontend/lowering/lower-dgram.js +6 -3
  612. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  613. package/dist/frontend/lowering/lower-event-emitter.d.ts +14 -0
  614. package/dist/frontend/lowering/lower-event-emitter.js +267 -20
  615. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  616. package/dist/frontend/lowering/lower-exprs.d.ts +19 -2
  617. package/dist/frontend/lowering/lower-exprs.js +126 -13
  618. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  619. package/dist/frontend/lowering/lower-functions.d.ts +11 -0
  620. package/dist/frontend/lowering/lower-functions.js +387 -72
  621. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  622. package/dist/frontend/lowering/lower-generators.js +41 -31
  623. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  624. package/dist/frontend/lowering/lower-global-value.js +6 -3
  625. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  626. package/dist/frontend/lowering/lower-inspect.js +28 -12
  627. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  628. package/dist/frontend/lowering/lower-mixins.js +2 -1
  629. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  630. package/dist/frontend/lowering/lower-mock.js +2 -1
  631. package/dist/frontend/lowering/lower-mock.js.map +1 -1
  632. package/dist/frontend/lowering/lower-modules.js +47 -5
  633. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  634. package/dist/frontend/lowering/lower-modules.test.js +2 -2
  635. package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
  636. package/dist/frontend/lowering/lower-namespaces.d.ts +2 -1
  637. package/dist/frontend/lowering/lower-namespaces.js +9 -4
  638. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  639. package/dist/frontend/lowering/lower-server.d.ts +10 -0
  640. package/dist/frontend/lowering/lower-server.js +239 -61
  641. package/dist/frontend/lowering/lower-server.js.map +1 -1
  642. package/dist/frontend/lowering/lower-stdlib.d.ts +5 -0
  643. package/dist/frontend/lowering/lower-stdlib.js +42 -10
  644. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  645. package/dist/frontend/lowering/lower-stmts.d.ts +23 -0
  646. package/dist/frontend/lowering/lower-stmts.js +622 -68
  647. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  648. package/dist/frontend/lowering/lower-stmts.test.js +1 -1
  649. package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
  650. package/dist/frontend/lowering/lower-stream.d.ts +20 -2
  651. package/dist/frontend/lowering/lower-stream.js +2055 -318
  652. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  653. package/dist/frontend/lowering/lower-timers.js +4 -3
  654. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  655. package/dist/frontend/lowering/lowerer.d.ts +197 -29
  656. package/dist/frontend/lowering/lowerer.js +862 -84
  657. package/dist/frontend/lowering/lowerer.js.map +1 -1
  658. package/dist/frontend/lowering/lowerer.test.js +21 -9
  659. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  660. package/dist/frontend/lowering/module-namespace-elements.d.ts +11 -1
  661. package/dist/frontend/lowering/module-namespace-elements.js +82 -5
  662. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  663. package/dist/frontend/lowering/narrowing-stability.js +5 -0
  664. package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
  665. package/dist/frontend/lowering/native-ffi.js +1 -1
  666. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  667. package/dist/frontend/lowering/new-target.d.ts +12 -0
  668. package/dist/frontend/lowering/new-target.js +280 -0
  669. package/dist/frontend/lowering/new-target.js.map +1 -0
  670. package/dist/frontend/lowering/object-enumeration-receiver.js +2 -1
  671. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
  672. package/dist/frontend/lowering/pairs-snapshot.js +2 -1
  673. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  674. package/dist/frontend/lowering/private-brands.d.ts +9 -0
  675. package/dist/frontend/lowering/private-brands.js +66 -15
  676. package/dist/frontend/lowering/private-brands.js.map +1 -1
  677. package/dist/frontend/lowering/promise-executor-adapter.js +2 -1
  678. package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
  679. package/dist/frontend/lowering/require-initialization.js +2 -1
  680. package/dist/frontend/lowering/require-initialization.js.map +1 -1
  681. package/dist/frontend/lowering/runtime-optional-elements.d.ts +5 -0
  682. package/dist/frontend/lowering/runtime-optional-elements.js +17 -1
  683. package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -1
  684. package/dist/frontend/lowering/runtime-optional-records.d.ts +2 -0
  685. package/dist/frontend/lowering/runtime-optional-records.js +18 -5
  686. package/dist/frontend/lowering/runtime-optional-records.js.map +1 -1
  687. package/dist/frontend/lowering/site-dependencies.d.ts +35 -0
  688. package/dist/frontend/lowering/site-dependencies.js +84 -0
  689. package/dist/frontend/lowering/site-dependencies.js.map +1 -0
  690. package/dist/frontend/lowering/site-dependencies.test.d.ts +1 -0
  691. package/dist/frontend/lowering/site-dependencies.test.js +53 -0
  692. package/dist/frontend/lowering/site-dependencies.test.js.map +1 -0
  693. package/dist/frontend/lowering/stable-names.d.ts +11 -0
  694. package/dist/frontend/lowering/stable-names.js +35 -0
  695. package/dist/frontend/lowering/stable-names.js.map +1 -0
  696. package/dist/frontend/lowering/static-typeof.d.ts +2 -2
  697. package/dist/frontend/lowering/static-typeof.js +42 -3
  698. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  699. package/dist/frontend/lowering/strict-equality.js +2 -1
  700. package/dist/frontend/lowering/strict-equality.js.map +1 -1
  701. package/dist/frontend/lowering/structural-positions.d.ts +32 -0
  702. package/dist/frontend/lowering/structural-positions.js +108 -0
  703. package/dist/frontend/lowering/structural-positions.js.map +1 -0
  704. package/dist/frontend/lowering/surfaces.d.ts +3 -0
  705. package/dist/frontend/lowering/surfaces.js +60 -32
  706. package/dist/frontend/lowering/surfaces.js.map +1 -1
  707. package/dist/frontend/lowering/undefined-index.d.ts +27 -0
  708. package/dist/frontend/lowering/undefined-index.js +82 -0
  709. package/dist/frontend/lowering/undefined-index.js.map +1 -0
  710. package/dist/frontend/lowering/var-hoisting.js +66 -16
  711. package/dist/frontend/lowering/var-hoisting.js.map +1 -1
  712. package/dist/frontend/lowering/width-lift.d.ts +18 -0
  713. package/dist/frontend/npm-static-bundled-chunks.js +9 -11
  714. package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
  715. package/dist/frontend/npm-static-bundled-chunks.test.js +6 -5
  716. package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
  717. package/dist/frontend/npm-static-rewrite-syntax.js +9 -1
  718. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  719. package/dist/frontend/npm-static-tsc-helpers.d.ts +5 -0
  720. package/dist/frontend/npm-static-tsc-helpers.js +106 -0
  721. package/dist/frontend/npm-static-tsc-helpers.js.map +1 -0
  722. package/dist/frontend/npm-static-tsc-helpers.test.d.ts +1 -0
  723. package/dist/frontend/npm-static-tsc-helpers.test.js +58 -0
  724. package/dist/frontend/npm-static-tsc-helpers.test.js.map +1 -0
  725. package/dist/frontend/npm-static-type-exports-host.d.ts +8 -0
  726. package/dist/frontend/npm-static-type-exports-host.js +214 -0
  727. package/dist/frontend/npm-static-type-exports-host.js.map +1 -0
  728. package/dist/frontend/npm-static-type-exports-host.test.d.ts +1 -0
  729. package/dist/frontend/npm-static-type-exports-host.test.js +53 -0
  730. package/dist/frontend/npm-static-type-exports-host.test.js.map +1 -0
  731. package/dist/frontend/npm-static-type-exports.d.ts +52 -0
  732. package/dist/frontend/npm-static-type-exports.js +261 -0
  733. package/dist/frontend/npm-static-type-exports.js.map +1 -0
  734. package/dist/frontend/npm-static-type-exports.test.d.ts +1 -0
  735. package/dist/frontend/npm-static-type-exports.test.js +103 -0
  736. package/dist/frontend/npm-static-type-exports.test.js.map +1 -0
  737. package/dist/frontend/npm-static-umd.d.ts +6 -0
  738. package/dist/frontend/npm-static-umd.js +203 -0
  739. package/dist/frontend/npm-static-umd.js.map +1 -0
  740. package/dist/frontend/npm-static-umd.test.d.ts +1 -0
  741. package/dist/frontend/npm-static-umd.test.js +105 -0
  742. package/dist/frontend/npm-static-umd.test.js.map +1 -0
  743. package/dist/frontend/npm-static.d.ts +8 -0
  744. package/dist/frontend/npm-static.js +51 -22
  745. package/dist/frontend/npm-static.js.map +1 -1
  746. package/dist/frontend/package-shims.d.ts +3 -0
  747. package/dist/frontend/package-shims.js +71 -8
  748. package/dist/frontend/package-shims.js.map +1 -1
  749. package/dist/frontend/pipeline.js +18 -10
  750. package/dist/frontend/pipeline.js.map +1 -1
  751. package/dist/frontend/process-fork.d.ts +25 -0
  752. package/dist/frontend/process-fork.js +2 -0
  753. package/dist/frontend/process-fork.js.map +1 -0
  754. package/dist/frontend/program.d.ts +21 -1
  755. package/dist/frontend/program.js +586 -74
  756. package/dist/frontend/program.js.map +1 -1
  757. package/dist/frontend/program.test.js +44 -4
  758. package/dist/frontend/program.test.js.map +1 -1
  759. package/dist/frontend/services.d.ts +6 -0
  760. package/dist/frontend/services.js +18 -0
  761. package/dist/frontend/services.js.map +1 -1
  762. package/dist/frontend/token-equivalence.d.ts +3 -0
  763. package/dist/frontend/token-equivalence.js +409 -0
  764. package/dist/frontend/token-equivalence.js.map +1 -0
  765. package/dist/frontend/token-equivalence.test.d.ts +1 -0
  766. package/dist/frontend/token-equivalence.test.js +67 -0
  767. package/dist/frontend/token-equivalence.test.js.map +1 -0
  768. package/dist/frontend/ts7/ast-node.d.ts +43 -7
  769. package/dist/frontend/ts7/ast-node.js +1176 -129
  770. package/dist/frontend/ts7/ast-node.js.map +1 -1
  771. package/dist/frontend/ts7/ast-node.test.js +84 -0
  772. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  773. package/dist/frontend/ts7/ast-wire.d.ts +29 -3
  774. package/dist/frontend/ts7/ast-wire.js +144 -31
  775. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  776. package/dist/frontend/ts7/ast-wire.test.js +23 -0
  777. package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
  778. package/dist/frontend/ts7/ast.d.ts +23 -2
  779. package/dist/frontend/ts7/ast.js +143 -2
  780. package/dist/frontend/ts7/ast.js.map +1 -1
  781. package/dist/frontend/ts7/checker-backend.d.ts +3 -4
  782. package/dist/frontend/ts7/checker-backend.js +2 -2
  783. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  784. package/dist/frontend/ts7/checker-backend.test.js +5 -9
  785. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  786. package/dist/frontend/ts7/checker.d.ts +17 -1
  787. package/dist/frontend/ts7/checker.js +82 -1
  788. package/dist/frontend/ts7/checker.js.map +1 -1
  789. package/dist/frontend/ts7/checker.test.js +9 -6
  790. package/dist/frontend/ts7/checker.test.js.map +1 -1
  791. package/dist/frontend/ts7/enums.d.ts +3 -3
  792. package/dist/frontend/ts7/enums.generated.d.ts +10 -0
  793. package/dist/frontend/ts7/enums.generated.js +21 -0
  794. package/dist/frontend/ts7/enums.generated.js.map +1 -1
  795. package/dist/frontend/ts7/enums.js +19 -0
  796. package/dist/frontend/ts7/enums.js.map +1 -1
  797. package/dist/frontend/ts7/lib-diagnostics.d.ts +24 -0
  798. package/dist/frontend/ts7/lib-diagnostics.js +307 -0
  799. package/dist/frontend/ts7/lib-diagnostics.js.map +1 -0
  800. package/dist/frontend/ts7/lib-diagnostics.test.d.ts +1 -0
  801. package/dist/frontend/ts7/lib-diagnostics.test.js +199 -0
  802. package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -0
  803. package/dist/frontend/ts7/program-host.d.ts +7 -0
  804. package/dist/frontend/ts7/program-host.js +30 -4
  805. package/dist/frontend/ts7/program-host.js.map +1 -1
  806. package/dist/frontend/ts7/semantic-checker.d.ts +10 -0
  807. package/dist/frontend/ts7/semantic-checker.js +25 -20
  808. package/dist/frontend/ts7/semantic-checker.js.map +1 -1
  809. package/dist/frontend/ts7/semantic-json.d.ts +13 -0
  810. package/dist/frontend/ts7/semantic-json.js +146 -0
  811. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  812. package/dist/frontend/ts7/semantic-json.test.js +57 -1
  813. package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
  814. package/dist/frontend/ts7/semantic-model.d.ts +15 -0
  815. package/dist/frontend/ts7/semantic-model.js +67 -19
  816. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  817. package/dist/frontend/ts7/semantic-model.test.js +3 -2
  818. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  819. package/dist/frontend/ts7/session.d.ts +14 -1
  820. package/dist/frontend/ts7/session.js +23 -1
  821. package/dist/frontend/ts7/session.js.map +1 -1
  822. package/dist/frontend/tsc-codes.d.ts +1 -1
  823. package/dist/frontend/tsc-codes.js +7 -0
  824. package/dist/frontend/tsc-codes.js.map +1 -1
  825. package/dist/frontend/type-mapper.d.ts +51 -7
  826. package/dist/frontend/type-mapper.js +456 -43
  827. package/dist/frontend/type-mapper.js.map +1 -1
  828. package/dist/frontend/type-mapper.test.js +1 -1
  829. package/dist/frontend/type-mapper.test.js.map +1 -1
  830. package/dist/frontend-process-args.d.ts +4 -0
  831. package/dist/frontend-process-args.js +52 -0
  832. package/dist/frontend-process-args.js.map +1 -0
  833. package/dist/frontend-process-args.test.d.ts +1 -0
  834. package/dist/frontend-process-args.test.js +47 -0
  835. package/dist/frontend-process-args.test.js.map +1 -0
  836. package/dist/frontend-process.d.ts +1 -0
  837. package/dist/frontend-process.js +23 -0
  838. package/dist/frontend-process.js.map +1 -0
  839. package/dist/heap-collection.d.ts +16 -0
  840. package/dist/heap-collection.js +42 -0
  841. package/dist/heap-collection.js.map +1 -0
  842. package/dist/heap-collection.test.d.ts +1 -0
  843. package/dist/heap-collection.test.js +59 -0
  844. package/dist/heap-collection.test.js.map +1 -0
  845. package/dist/heap-pressure.d.ts +2 -0
  846. package/dist/heap-pressure.js +12 -0
  847. package/dist/heap-pressure.js.map +1 -0
  848. package/dist/index.d.ts +2 -0
  849. package/dist/index.js +435 -89
  850. package/dist/index.js.map +1 -1
  851. package/dist/ir/analysis.js +5 -3
  852. package/dist/ir/analysis.js.map +1 -1
  853. package/dist/ir/array-length-stability.d.ts +4 -0
  854. package/dist/ir/array-length-stability.js +26 -6
  855. package/dist/ir/array-length-stability.js.map +1 -1
  856. package/dist/ir/array-length-stability.test.js +49 -0
  857. package/dist/ir/array-length-stability.test.js.map +1 -1
  858. package/dist/ir/builtin-effects.d.ts +7 -0
  859. package/dist/ir/builtin-effects.js +80 -0
  860. package/dist/ir/builtin-effects.js.map +1 -1
  861. package/dist/ir/builtin-signatures.d.ts +7 -1
  862. package/dist/ir/builtin-signatures.js +303 -21
  863. package/dist/ir/builtin-signatures.js.map +1 -1
  864. package/dist/ir/callback-specialization.d.ts +2 -1
  865. package/dist/ir/callback-specialization.js +23 -18
  866. package/dist/ir/callback-specialization.js.map +1 -1
  867. package/dist/ir/char-unit-locals.d.ts +19 -0
  868. package/dist/ir/char-unit-locals.js +185 -0
  869. package/dist/ir/char-unit-locals.js.map +1 -0
  870. package/dist/ir/char-unit-locals.test.d.ts +1 -0
  871. package/dist/ir/char-unit-locals.test.js +94 -0
  872. package/dist/ir/char-unit-locals.test.js.map +1 -0
  873. package/dist/ir/final-fields.d.ts +3 -1
  874. package/dist/ir/final-fields.js +15 -17
  875. package/dist/ir/final-fields.js.map +1 -1
  876. package/dist/ir/function-references.d.ts +2 -0
  877. package/dist/ir/function-references.js +2 -0
  878. package/dist/ir/function-references.js.map +1 -1
  879. package/dist/ir/function-references.test.js +5 -0
  880. package/dist/ir/function-references.test.js.map +1 -1
  881. package/dist/ir/initializer-bindings.d.ts +2 -1
  882. package/dist/ir/initializer-bindings.js +27 -20
  883. package/dist/ir/initializer-bindings.js.map +1 -1
  884. package/dist/ir/int32-arrays.d.ts +108 -0
  885. package/dist/ir/int32-arrays.js +831 -0
  886. package/dist/ir/int32-arrays.js.map +1 -0
  887. package/dist/ir/int32-slots.d.ts +36 -6
  888. package/dist/ir/int32-slots.js +370 -171
  889. package/dist/ir/int32-slots.js.map +1 -1
  890. package/dist/ir/int32-slots.test.js +3 -1
  891. package/dist/ir/int32-slots.test.js.map +1 -1
  892. package/dist/ir/integer-loop-facts.d.ts +9 -4
  893. package/dist/ir/integer-loop-facts.js +93 -18
  894. package/dist/ir/integer-loop-facts.js.map +1 -1
  895. package/dist/ir/integer-loops.d.ts +49 -0
  896. package/dist/ir/integer-loops.js +202 -40
  897. package/dist/ir/integer-loops.js.map +1 -1
  898. package/dist/ir/integer-loops.test.js +211 -1
  899. package/dist/ir/integer-loops.test.js.map +1 -1
  900. package/dist/ir/integer-ranges.d.ts +5 -0
  901. package/dist/ir/integer-ranges.js +125 -12
  902. package/dist/ir/integer-ranges.js.map +1 -1
  903. package/dist/ir/integer-ranges.test.js +94 -0
  904. package/dist/ir/integer-ranges.test.js.map +1 -1
  905. package/dist/ir/ir.d.ts +87 -9
  906. package/dist/ir/ir.js +61 -2
  907. package/dist/ir/ir.js.map +1 -1
  908. package/dist/ir/ir.test.js +21 -1
  909. package/dist/ir/ir.test.js.map +1 -1
  910. package/dist/ir/js-ic.d.ts +19 -2
  911. package/dist/ir/js-ic.js +95 -11
  912. package/dist/ir/js-ic.js.map +1 -1
  913. package/dist/ir/js-ic.test.js +188 -0
  914. package/dist/ir/js-ic.test.js.map +1 -1
  915. package/dist/ir/node-index.d.ts +57 -0
  916. package/dist/ir/node-index.js +215 -0
  917. package/dist/ir/node-index.js.map +1 -0
  918. package/dist/ir/paired-while-loops.d.ts +25 -0
  919. package/dist/ir/paired-while-loops.js +335 -0
  920. package/dist/ir/paired-while-loops.js.map +1 -0
  921. package/dist/ir/paired-while-loops.test.d.ts +1 -0
  922. package/dist/ir/paired-while-loops.test.js +163 -0
  923. package/dist/ir/paired-while-loops.test.js.map +1 -0
  924. package/dist/ir/parameter-versions.d.ts +25 -0
  925. package/dist/ir/parameter-versions.js +300 -0
  926. package/dist/ir/parameter-versions.js.map +1 -0
  927. package/dist/ir/runtime-features.d.ts +60 -15
  928. package/dist/ir/runtime-features.js +276 -35
  929. package/dist/ir/runtime-features.js.map +1 -1
  930. package/dist/ir/serialize.d.ts +12 -2
  931. package/dist/ir/serialize.js +16 -3
  932. package/dist/ir/serialize.js.map +1 -1
  933. package/dist/ir/serialize.test.js +17 -0
  934. package/dist/ir/serialize.test.js.map +1 -1
  935. package/dist/ir/tiers.js +1 -0
  936. package/dist/ir/tiers.js.map +1 -1
  937. package/dist/ir/traverse.d.ts +2 -0
  938. package/dist/ir/traverse.js +29 -5
  939. package/dist/ir/traverse.js.map +1 -1
  940. package/dist/ir/validate.js +171 -45
  941. package/dist/ir/validate.js.map +1 -1
  942. package/dist/library/ir-policy.js +12 -0
  943. package/dist/library/ir-policy.js.map +1 -1
  944. package/dist/library/library-cache.d.ts +2 -0
  945. package/dist/library/library-cache.js.map +1 -1
  946. package/dist/library/prepare.js +2 -0
  947. package/dist/library/prepare.js.map +1 -1
  948. package/dist/native/cache.d.ts +6 -1
  949. package/dist/native/cache.js +28 -5
  950. package/dist/native/cache.js.map +1 -1
  951. package/dist/native/cache.test.js +16 -2
  952. package/dist/native/cache.test.js.map +1 -1
  953. package/dist/native/cli.js +26 -1
  954. package/dist/native/cli.js.map +1 -1
  955. package/dist/native/compiler.js +8 -6
  956. package/dist/native/compiler.js.map +1 -1
  957. package/dist/native/executable-cache.d.ts +1 -1
  958. package/dist/native/executable-cache.js +2 -2
  959. package/dist/native/executable-cache.js.map +1 -1
  960. package/dist/native/prepare.d.ts +3 -1
  961. package/dist/native/prepare.js +123 -31
  962. package/dist/native/prepare.js.map +1 -1
  963. package/dist/native/prepare.test.js +78 -18
  964. package/dist/native/prepare.test.js.map +1 -1
  965. package/dist/native/sanitizer.test.js +6 -1
  966. package/dist/native/sanitizer.test.js.map +1 -1
  967. package/dist/native/text-file.d.ts +13 -3
  968. package/dist/native/text-file.js +63 -9
  969. package/dist/native/text-file.js.map +1 -1
  970. package/dist/native/text-file.test.d.ts +1 -0
  971. package/dist/native/text-file.test.js +49 -0
  972. package/dist/native/text-file.test.js.map +1 -0
  973. package/dist/native/toolchain.js +4 -4
  974. package/dist/native/toolchain.js.map +1 -1
  975. package/dist/native/toolchain.test.js +3 -3
  976. package/dist/native/toolchain.test.js.map +1 -1
  977. package/dist/startup-cache.d.ts +1 -0
  978. package/dist/startup-cache.js +1 -0
  979. package/dist/startup-cache.js.map +1 -1
  980. package/dist/text-parts.d.ts +7 -0
  981. package/dist/text-parts.js +44 -0
  982. package/dist/text-parts.js.map +1 -1
  983. package/dist/text-parts.test.d.ts +1 -0
  984. package/dist/text-parts.test.js +46 -0
  985. package/dist/text-parts.test.js.map +1 -0
  986. package/dist/timing.d.ts +9 -2
  987. package/dist/timing.js +7 -4
  988. package/dist/timing.js.map +1 -1
  989. package/dist/wasm/translate.d.ts +4 -0
  990. package/dist/wasm/translate.js +2 -2
  991. package/dist/wasm/translate.js.map +1 -1
  992. package/package.json +21 -21
  993. package/shims/chalk/v5.ts +688 -0
  994. package/shims/hono-node-server/v2.ts +645 -0
  995. package/shims/hot-shots/client.ts +1126 -0
  996. package/shims/hot-shots/v8-unix-dgram.ts +8 -0
  997. package/shims/hot-shots/v8.ts +8 -0
  998. package/shims/undici/core/client.ts +4 -4
  999. package/surface-manifest.json +44 -52
@@ -1,4 +1,9 @@
1
- import { onlyForwarded } from "./typed-arguments.js";
1
+ import { isDeclBoundaryFile } from "../decl-projection.js";
2
+ import { relieveHeapPressure } from "../../heap-pressure.js";
3
+ import { moduleNamespaceObject } from "./module-namespace-elements.js";
4
+ import { keyedHelperName } from "./stable-names.js";
5
+ import { positionTag, StructuralPositions } from "./structural-positions.js";
6
+ import { onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
2
7
  import { needsGeneralNodeStreams, noteUntypedStreamFlow, stdioIntoGeneralStream, } from "./general-streams.js";
3
8
  import { extendAssertedRecordMembers } from "./assertion-members.js";
4
9
  import { jsDynamicDeclarations } from "./js-dynamic-objects.js";
@@ -14,6 +19,8 @@ import { checkRequireBindingAccesses, } from "./require-initialization.js";
14
19
  import { identityPreservingWidening } from "./coercions/identity.js";
15
20
  import { scanDivergences } from "./divergences.js";
16
21
  import { applyKeyOrderWitnesses, KeyOrderNotes } from "./key-order-witness.js";
22
+ import { exprFunctionReference } from "../../ir/function-references.js";
23
+ import { everyStmtList, observeRecordLiteralRebuilds } from "../../ir/traverse.js";
17
24
  import { checkedClassAssertion } from "./class-assertions.js";
18
25
  import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
19
26
  import { isOptionalProcessStreamProperty, isOptionalProcessVersionsRead, } from "./builtins/process.js";
@@ -28,11 +35,13 @@ import { encodeBase64 } from "../../wasm/base64.js";
28
35
  import { resolveRequireRuntime } from "../runtime-resolve.js";
29
36
  import { lowerKeyObjectCall } from "./builtins/key-object.js";
30
37
  import { isEcdhType, lowerEcdhCall } from "./builtins/ecdh.js";
38
+ import { isDiffieHellmanType, lowerDiffieHellmanCall } from "./builtins/dh.js";
31
39
  import { fenceWebCryptoMember, lowerWebCryptoCall } from "./builtins/webcrypto.js";
32
- import { hashStreamOf } from "./builtins/hash-stream.js";
40
+ import { valueStreamOf } from "./builtins/hash-stream.js";
33
41
  import { lowerNetAddressCall, lowerNetAddressNew } from "./builtins/net-address.js";
34
42
  import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
35
43
  import { iteratorSlotAdapter } from "./iterator-adapters.js";
44
+ import { iterableSlotValue } from "./iterable-values.js";
36
45
  import { lowerBuiltinCall } from "./builtin-calls.js";
37
46
  import { CoercionState } from "./coercions/state.js";
38
47
  import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocker, objToRecordPlan, recordToClassPlan, } from "./coercions/structural-plans.js";
@@ -49,6 +58,7 @@ import { ArrayElementStates } from "./runtime-optional-elements.js";
49
58
  import { indexReadInBounds } from "./runtime-optional-bounds.js";
50
59
  import { ArrayOwnership } from "./runtime-optional-ownership.js";
51
60
  import { RecordFlowClasses } from "./runtime-optional-records.js";
61
+ import { SiteDependencies } from "./site-dependencies.js";
52
62
  import { StringIndexBounds } from "./string-index-bounds.js";
53
63
  import { NanCodedReads } from "./nan-coded-reads.js";
54
64
  import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
@@ -61,11 +71,13 @@ import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optio
61
71
  import {} from "./class-protocol-dispatch.js";
62
72
  import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
63
73
  import { guardClassAttributeWrites } from "./class-attributes.js";
74
+ import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
64
75
  import { applyHandleProperties } from "./handle-properties.js";
65
76
  import { ClassProtocols } from "./class-protocols.js";
66
77
  import { earlyReadVarSymbols } from "./var-hoisting.js";
67
78
  import { recordTextCodecClass } from "../../ir/ir.js";
68
79
  import { assignLegacyTiers } from "../../ir/tiers.js";
80
+ import { dynamicTierWarning } from "./dynamic-tier.js";
69
81
  import { promoteJsvals } from "../../ir/jsval.js";
70
82
  import { analyzeTiers, dynamicStatementCount, } from "../tier-analysis.js";
71
83
  import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
@@ -87,16 +99,16 @@ export { newFnCtx } from "./function-context.js";
87
99
  * - Lexical scoping is resolved here: locals get function-unique ids
88
100
  * ("x.0", "x.1" for shadowing); the IR is scope-flat.
89
101
  */
90
- import { resolve } from "node:path";
102
+ import { dirname, relative, resolve } from "node:path";
91
103
  import { bindingSource } from "../binding-source.js";
92
- import { tsgoPath } from "../dts-paths.js";
104
+ import { compilerOwnedFileName, tsgoPath } from "../dts-paths.js";
93
105
  import * as ts from "../ts7/adapter.js";
94
106
  import { isBundledShimForwarder } from "../package-shims.js";
95
107
  import { erasedTypeOnlyImport } from "../type-only-imports.js";
96
108
  import { literalValues } from "../literal-values.js";
97
109
  import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
98
110
  import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
99
- import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
111
+ import { arrayOf, BOOL, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
100
112
  import { provenanceActive } from "../provenance-registry.js";
101
113
  import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
102
114
  import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, erasedOverloadMemberType, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isOverloadedCallableMemberType, isUnitOnlyTsType, isWorkerHandleType, isFetchHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
@@ -119,7 +131,7 @@ import { completeArgs, wrappedUndefined, undefinedArgFor } from "./call-argument
119
131
  import { bodyReturnType, declaredReturnType } from "./function-returns.js";
120
132
  import { lowerCall, lowerPromiseMethodCall, lowerFilterNarrowCall } from "./lower-calls.js";
121
133
  import { lowerFfiCall, validateFfiImports } from "./native-ffi.js";
122
- import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, } from "./lower-functions.js";
134
+ import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, blockedBodyDiagnostics, } from "./lower-functions.js";
123
135
  import { lowerArrayMethodCall } from "./containers/array-methods.js";
124
136
  import { fuseArrayPipelines } from "./containers/array-pipelines.js";
125
137
  import { lowerMapMethodCall, lowerMapForEachCall, lowerSetMethodCall, lowerSetForEachCall, } from "./containers/collection-methods.js";
@@ -144,10 +156,11 @@ import { lowerBuiltinExtraProperty } from "./builtins/properties.js";
144
156
  import { registerPromisifiedBuiltinDecl } from "./builtins/callable-aliases.js";
145
157
  import { lowerExecFileAsyncCall } from "./builtins/child-process-async.js";
146
158
  import { lowerStringDecoderMethodCall, lowerTextCodecCall } from "./builtins/text-codecs.js";
147
- import { lowerReadlineMethodCall } from "./builtins/readline.js";
159
+ import { isOptionalReadlineCursorRead, lowerReadlineMethodCall } from "./builtins/readline.js";
148
160
  import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
149
161
  import { lowerDisposableStackNew } from "./builtins/disposable-stack.js";
150
- import { lowerErrorCodeProperty } from "./builtins/errors.js";
162
+ import { lowerErrorCodeProperty, lowerErrorFunctionCall } from "./builtins/errors.js";
163
+ import { noteDateClassMethods } from "./builtins/date-classes.js";
151
164
  import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
152
165
  import { consoleCallMember, consoleMethodMember, isConsoleLog, } from "./builtins/console.js";
153
166
  import { lowerConsoleNew } from "./lower-console.js";
@@ -156,7 +169,7 @@ import { dateJsonType, isDateJsonSource, lowerDateCall } from "./builtins/dates.
156
169
  import { fsConstantMemberRead, fsConstantsObject, lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
157
170
  import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
158
171
  import { lowerPromiseStaticCall } from "./builtins/promises.js";
159
- import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
172
+ import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticTransformStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
160
173
  import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
161
174
  import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
162
175
  import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
@@ -164,7 +177,7 @@ import { lowerAssertModuleCall, lowerAssertDirectCall } from "./lower-assert.js"
164
177
  import { lowerUtilModuleCall } from "./lower-inspect.js";
165
178
  import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
166
179
  import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
167
- import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, } from "./lower-stmts.js";
180
+ import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, holdsEvolvingArray, } from "./lower-stmts.js";
168
181
  import { lowerExpr, maybeNarrow, lowerUnitComparison, lowerNullishCoalesce, lowerCondition, ensureBool, requireTruthyUnion, eqComparableUnion, lowerIntrinsicProperty, lowerArrayLiteral, lowerElementAccess, lowerElementWrite, lowerRecordKeyRead, ensureString, lowerTemplate, lowerAsExpression, lowerPrefixUnary, lowerBinary, lowerCaughtTypeofTest, caughtRead, caughtLocalOf, caughtToString, lowerInstanceOf, lowerRegexLiteral, lowerFieldRead, lowerUnionProperty, fieldTarget, fieldGetExpr, fieldSetStmt, lowerFieldCompound, uniqueSymbolKeyOf, matchCallbackParamGroupsOf, } from "./lower-exprs.js";
169
182
  import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
170
183
  import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
@@ -247,6 +260,33 @@ function directExternalTypeSpecifiersByFile(externalTypes) {
247
260
  }
248
261
  return out;
249
262
  }
263
+ /** Debugging aid: SCRIPTC_LOWER_SHUFFLE_SEED=<n> lowers each wave of
264
+ * reachable bodies in an order drawn from that seed instead of discovery
265
+ * order. Output assembly is ordered independently of it, so any IR
266
+ * difference between seeds is state one body's lowering leaves for another
267
+ * (scripts/lowering-order.mjs). */
268
+ function lowerShuffle() {
269
+ const raw = process.env["SCRIPTC_LOWER_SHUFFLE_SEED"];
270
+ if (raw === undefined || raw === "")
271
+ return null;
272
+ // mulberry32
273
+ let state = Number.parseInt(raw, 10) >>> 0;
274
+ const next = () => {
275
+ state = (state + 0x6d2b79f5) >>> 0;
276
+ let t = state;
277
+ t = Math.imul(t ^ (t >>> 15), t | 1);
278
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
279
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
280
+ };
281
+ return (wave) => {
282
+ for (let index = wave.length - 1; index > 0; index--) {
283
+ const other = Math.floor(next() * (index + 1));
284
+ const swap = wave[index];
285
+ wave[index] = wave[other];
286
+ wave[other] = swap;
287
+ }
288
+ };
289
+ }
250
290
  /** Build lowering runs as a reachability worklist over the ts.Program:
251
291
  *
252
292
  * 1. REACHABLE EMIT — a worklist computes the set of reachable bodies.
@@ -264,6 +304,10 @@ function directExternalTypeSpecifiersByFile(externalTypes) {
264
304
  * the bodies reachable emit did NOT mark (plus deferred collection
265
305
  * diagnostics nothing flushed), reported separately: whole-program analysis without
266
306
  * letting unreached code fail builds. */
307
+ /** The closure root of an emit-override specialization body. */
308
+ function emitSpecRoot(spec) {
309
+ return `%emit.${spec.info.def.name}.${spec.event}.${spec.ordinal}`;
310
+ }
267
311
  export function lowerToIr(program, entry, moduleOrder, options = {}) {
268
312
  const phaseTiming = process.env["SCRIPTC_TIMING"] === "1";
269
313
  const phaseStarted = performance.now();
@@ -453,6 +497,14 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
453
497
  timing("divergence-scan", { found: divergences.length });
454
498
  if (divergences.length > 0)
455
499
  result = { ...result, divergences };
500
+ // The performance warning (SC6101): likely-hot functions of the program
501
+ // that compile to the dynamic tier because the source leaves them untyped.
502
+ if (result.module !== null && resultLowerer.dynamicFunctions.length > 0) {
503
+ const hotDynamic = dynamicTierWarning(resultLowerer, result.module, dirname(entry.fileName));
504
+ timing("dynamic-tier-scan", { found: hotDynamic === null ? 0 : 1 });
505
+ if (hotDynamic !== null)
506
+ result = { ...result, performance: [hotDynamic] };
507
+ }
456
508
  // Contract types (@scriptc/types): written annotations, checked against
457
509
  // the IR by the compile pipeline (contracts/check.ts).
458
510
  // Acyclic object types name the IR unit the program lowered them to; a
@@ -498,18 +550,28 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
498
550
  });
499
551
  // A program that uses the WebAssembly API carries every module the build
500
552
  // can see and translate (wasm/translate.ts); the rest fail at run time
501
- // with the CompileError for untranslated bytes.
553
+ // with a CompileError, which names the reason for the modules the build
554
+ // saw but does not translate.
502
555
  if (result.module !== null && resultLowerer.usesWebAssembly) {
503
556
  const bytesByHash = new Map();
504
557
  const reports = discoverModules((sha256, bytes) => bytesByHash.set(sha256, bytes));
505
558
  const wasmModules = [];
559
+ const wasmUntranslated = [];
506
560
  for (const report of reports) {
507
561
  const bytes = bytesByHash.get(report.sha256);
508
- if (report.status !== "valid" || bytes === undefined)
562
+ if (bytes === undefined)
509
563
  continue;
510
- wasmModules.push({ sha256: report.sha256, bytes: encodeBase64(bytes) });
564
+ if (report.status === "valid") {
565
+ wasmModules.push({ sha256: report.sha256, bytes: encodeBase64(bytes) });
566
+ continue;
567
+ }
568
+ const reason = report.status === "unsupported"
569
+ ? `it uses ${report.unsupported.join(", ")}, outside the translated WebAssembly feature set`
570
+ : `it is not a valid module: ${report.error ?? report.status}`;
571
+ wasmUntranslated.push({ sha256: report.sha256, size: bytes.length, reason });
511
572
  }
512
573
  result.module.wasmModules = wasmModules;
574
+ result.module.wasmUntranslated = wasmUntranslated;
513
575
  if (resultLowerer.usesWasmCustomSections)
514
576
  result.module.wasmCustomSections = true;
515
577
  timing("wasm-discovery", { modules: wasmModules.length });
@@ -571,6 +633,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
571
633
  // travel with them: a failed statement is never left unexplained.
572
634
  const covered = {
573
635
  ...result,
636
+ diagnostics: [...result.diagnostics, ...remainder.reachedBlockedBodyDiagnostics],
574
637
  stats: { ...result.stats, statementsDynamic },
575
638
  unreached: {
576
639
  diagnostics: rem.diagnostics,
@@ -1061,6 +1124,10 @@ function monomorphizedImplicit(lowerer, fn) {
1061
1124
  return implicitLocalFnNodeOf(lowerer, binding) !== null;
1062
1125
  return true;
1063
1126
  }
1127
+ /** `fns` sorted by name; functions of one name keep their order. */
1128
+ function byName(fns) {
1129
+ return [...fns].sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
1130
+ }
1064
1131
  export class Lowerer {
1065
1132
  program;
1066
1133
  entry;
@@ -1091,6 +1158,12 @@ export class Lowerer {
1091
1158
  * pinned values resolve through genericFnOf exactly like top-level
1092
1159
  * generic function declarations (bindingGenericFnInfoOf). */
1093
1160
  bindingGenericFns = new Map();
1161
+ /** Identifiers by spelling, per file, for the generic bindings' use
1162
+ * ordering (runsAfterDeclaration). */
1163
+ bindingIdentifiers = new Map();
1164
+ /** Per JavaScript file, the declarations of the bindings it assigns an
1165
+ * own `toString` (jsAssignsOwnToString in lower-calls.ts). */
1166
+ ownToStringTargets = new Map();
1094
1167
  /** Per-symbol result of the never-reassigned file scan
1095
1168
  * (bindingNeverReassigned — object-literal generic-method receivers). */
1096
1169
  neverReassignedCache = new Map();
@@ -1242,6 +1315,35 @@ export class Lowerer {
1242
1315
  });
1243
1316
  this.genericClassInstances.splice(from, tail.length, ...tail);
1244
1317
  }
1318
+ /** The classes in table order. Generic instances are added as bodies
1319
+ * demand them, so they keep the slots they hold and fill them in the
1320
+ * order of their settled demand ranks. */
1321
+ classesInTableOrder() {
1322
+ const all = [...this.classes.values()];
1323
+ const slots = all.flatMap((info, index) => this.genericClassDemandPriority.has(info) ? [index] : []);
1324
+ const ranked = slots
1325
+ .map((index) => all[index])
1326
+ .sort((left, right) => {
1327
+ const a = this.genericClassDemandPriority.get(left).rank;
1328
+ const b = this.genericClassDemandPriority.get(right).rank;
1329
+ return a[0] - b[0] || a[1] - b[1];
1330
+ });
1331
+ slots.forEach((slot, index) => (all[slot] = ranked[index]));
1332
+ return all;
1333
+ }
1334
+ /** The globals in table order. A class's prototype data globals are
1335
+ * added when a body first reads that prototype, so they keep the slots
1336
+ * they hold and fill them in id order. */
1337
+ globalsInTableOrder() {
1338
+ const all = [...this.globalsList];
1339
+ const prototypeData = (global) => global.id.startsWith("%g.%prototype.data.");
1340
+ const slots = all.flatMap((global, index) => (prototypeData(global) ? [index] : []));
1341
+ const sorted = slots
1342
+ .map((index) => all[index])
1343
+ .sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
1344
+ slots.forEach((slot, index) => (all[slot] = sorted[index]));
1345
+ return all;
1346
+ }
1245
1347
  settleGenericDemandPriorities() {
1246
1348
  const functionQueue = [];
1247
1349
  const classQueue = [];
@@ -1320,9 +1422,18 @@ export class Lowerer {
1320
1422
  * and erased instances). */
1321
1423
  erasingDepth = 0;
1322
1424
  localClassInstantiations = [];
1425
+ /** The function-local classes of the program with an `extends` clause, whether lowering collected
1426
+ * them yet or not (new-target.ts); found on first use. */
1427
+ functionLocalSubclasses = undefined;
1323
1428
  /** Instance types (by checker type id) of the local classes generic
1324
1429
  * factory calls return, and the per-instance class each names. */
1325
1430
  localClassInstanceTypes = new Map();
1431
+ /** A generic factory's instantiated result type → the class value of the
1432
+ * local class it returns (TypeMapperCtx.localClassValue). */
1433
+ localClassValueTypes = new Map();
1434
+ /** While a generic factory instance lowers: its declared result type → the
1435
+ * class value of the local class it returns. */
1436
+ instanceResultClass = null;
1326
1437
  /** The ts-level twin of typeParamBindings, non-null while a CALL-keyed
1327
1438
  * instance body lowers: type-parameter symbol → the bound CHECKER type,
1328
1439
  * consulted where the mapped IrType has already widened away information
@@ -1531,6 +1642,47 @@ export class Lowerer {
1531
1642
  }
1532
1643
  return fallback ?? null;
1533
1644
  }
1645
+ /** A fresh TypeScript data literal (`{ message: "m" }`) passed to a
1646
+ * checked-dynamic parameter of a callee implemented in JavaScript, whose
1647
+ * contract lets it reshape the object: a call through an untyped value, an
1648
+ * untyped parameter of a JavaScript function, or a package-declared
1649
+ * parameter type (a non-library `.d.ts`) that makes one of the literal's
1650
+ * properties optional (zod's `normalizeParams` deletes `params.message`).
1651
+ * No typed alias of a fresh literal exists, so it is built as the plain
1652
+ * object the callee receives instead of a view whose record layout refuses
1653
+ * that delete. Standard-library and TypeScript callees, and literals with
1654
+ * methods or accessors, keep their native storage. */
1655
+ reshapeableContextualLiteral(literal, contextual) {
1656
+ const call = literal.parent;
1657
+ if (call === undefined ||
1658
+ !(ts.isCallExpression(call) || ts.isNewExpression(call)) ||
1659
+ !call.arguments?.nodes.includes(literal) ||
1660
+ literal.properties.nodes.length === 0 ||
1661
+ !literal.properties.nodes.every((prop) => (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&
1662
+ (ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name))))
1663
+ return false;
1664
+ const declaration = this.checker.getResolvedSignature(call)?.declaration;
1665
+ const file = declaration ? ts.getSourceFileOfNode(declaration) : undefined;
1666
+ const untyped = contextual.some((part) => part.flags & ts.TypeFlags.Any);
1667
+ if (file === undefined)
1668
+ return untyped;
1669
+ if (isJsSourceFile(file))
1670
+ return untyped;
1671
+ if (!file.isDeclarationFile || this.isStdlibFile(file))
1672
+ return false;
1673
+ if (untyped)
1674
+ return true;
1675
+ const objects = contextual.filter((part) => part.flags & ts.TypeFlags.Object);
1676
+ if (objects.length === 0)
1677
+ return false;
1678
+ return literal.properties.nodes.some((prop) => {
1679
+ const name = prop.name.text;
1680
+ return objects.every((part) => {
1681
+ const symbol = this.checker.getPropertyOfType(part, name);
1682
+ return symbol !== undefined && (symbol.flags & ts.SymbolFlags.Optional) !== 0;
1683
+ });
1684
+ });
1685
+ }
1534
1686
  /** A TypeScript object literal handed to a JavaScript checked-value
1535
1687
  * parameter whose inferred type is open (`constructor({ factory, ...options
1536
1688
  * } = {})` — the rest element admits any property): the literal names a
@@ -1857,6 +2009,19 @@ export class Lowerer {
1857
2009
  /** True while re-lowering a base function's 2nd+ instance: the same source
1858
2010
  * statements were already counted for the first instance. */
1859
2011
  suppressStats = false;
2012
+ /** Callback literals passed straight to an error-first zlib or crypto
2013
+ * function: only that function's callback adapter calls them
2014
+ * (lowerUndefinedResultBody). */
2015
+ errorFirstLiterals = new Set();
2016
+ /** Parameters read as `any` in the error-path copy of an error-first
2017
+ * callback. */
2018
+ anySymbols = new Set();
2019
+ /** Error parameters of an error-first callback with a known value in
2020
+ * the copy being lowered: true while it holds an Error, false while it
2021
+ * holds null (staticCondition folds conditions on them). */
2022
+ knownErrors = new Map();
2023
+ /** The number of error-path callback copies being lowered. */
2024
+ errorPathCopies = 0;
1860
2025
  /** Comparisons interned by operand representations and equality semantics. */
1861
2026
  equalityHelpers = new Map();
1862
2027
  /** Synthetic array-HOF loop functions (map/filter/forEach desugar),
@@ -1907,6 +2072,8 @@ export class Lowerer {
1907
2072
  /** Generated value helpers, keyed by operation and type. Callers own
1908
2073
  * their key prefixes; this includes more than structural conversions. */
1909
2074
  valueHelpers = new Map();
2075
+ /** Each name keyedHelperName made, with a second hash of its key. */
2076
+ keyedNameKeys = new Map();
1910
2077
  /** structuralNarrowing's assignable classes, keyed by static and
1911
2078
  * narrowed class name. */
1912
2079
  structuralClassPeers = new Map();
@@ -2021,13 +2188,38 @@ export class Lowerer {
2021
2188
  * `doneLocalId` is sticky: once next() observes the end, later source
2022
2189
  * changes do not revive the exhausted iterator, exactly like Node. */
2023
2190
  numericIterators = new Map();
2024
- chainCounter = 0;
2025
2191
  /** Keyed by program-wide qualified class name (what IR object types carry). */
2026
2192
  classes = new Map();
2027
2193
  classBySymbol = new Map();
2028
2194
  /** Named method slots observed before class collection need a callable
2029
2195
  * ABI and shared prototype descriptors instead of call-site specialization. */
2030
2196
  prototypeMethodAccesses = new Map();
2197
+ /** Every site the census found for a name in prototypeMethodAccesses (which
2198
+ * keeps one): reads of the method and writes that may replace it. The
2199
+ * key-order witness asks which replacements can return records. */
2200
+ methodAccessSites = new Map();
2201
+ /** Marks `name` as a method the program may read or replace at `site`. */
2202
+ noteMethodAccess(name, site) {
2203
+ this.prototypeMethodAccesses.set(name, site);
2204
+ this.noteMethodSite(name, site);
2205
+ }
2206
+ /** Records a site for `name` without changing its prototypeMethodAccesses entry. */
2207
+ noteMethodSite(name, site) {
2208
+ const sites = this.methodAccessSites.get(name);
2209
+ if (sites === undefined)
2210
+ this.methodAccessSites.set(name, [site]);
2211
+ else
2212
+ sites.push(site);
2213
+ }
2214
+ /** Whether the program reads `Error.prototype`, the checked-dynamic
2215
+ * object an ES5 constructor function can inherit from, or has a class
2216
+ * whose heritage is evaluated at run time (`extends (Base ?? Error)`):
2217
+ * only then can a value that is not an Error instance be
2218
+ * `instanceof Error`. */
2219
+ errorPrototypeValues = false;
2220
+ /** The property names the program assigns on the global object
2221
+ * (property-access.ts), collected on first use. */
2222
+ globalThisWrittenNames = null;
2031
2223
  /** Well-known symbol methods (`sym:iterator`) the program may replace
2032
2224
  * through a symbol-keyed write: an instance or prototype property, or a
2033
2225
  * reflection call. */
@@ -2092,10 +2284,16 @@ export class Lowerer {
2092
2284
  /** Inline Promise.then parameters whose contextual type is a builtin
2093
2285
  * module namespace anonymous object. The settled native token is the
2094
2286
  * ABI truth even when the checker type has no stable module symbol. */
2095
- /** Receivers of a stream call on a Hash or Hmac (lowerHashStreamCall):
2096
- * for the duration of that call, the receiver lowers to the Transform of
2097
- * the value held in the named local. */
2098
- hashStreamReceivers = new Map();
2287
+ /** Receivers of a stream call on a Hash, Hmac, Cipheriv or Decipheriv
2288
+ * (lowerHashStreamCall): for the duration of that call, the receiver
2289
+ * lowers to the Transform of the value held in the named local. */
2290
+ valueStreamReceivers = new Map();
2291
+ /** fs call arguments evaluated ahead of a URL path's conversion
2292
+ * (builtins/fs-paths.ts): each lowers to the hidden local that holds its
2293
+ * value, which is null until the path's lowering has saved it. */
2294
+ stagedArguments = new Map();
2295
+ /** The staged arguments that follow each such URL path, in order. */
2296
+ stagedAfterPath = new Map();
2099
2297
  moduleNsParamOverrides = new Map();
2100
2298
  /** File → qualifier prefix: "" for the entry, "%mI." otherwise. */
2101
2299
  fileTag = new Map();
@@ -2209,7 +2407,17 @@ export class Lowerer {
2209
2407
  // Stack of function contexts (bottom = the function being declared at
2210
2408
  // top level, top = the innermost nested function currently lowering).
2211
2409
  fnStack = [];
2410
+ /** Source ranges of record writes in sloppy-mode code, and of the
2411
+ * absent-state writes of `delete r.f` (markSloppyRecordWrites). */
2412
+ sloppyRecordWrites = new Set();
2413
+ recordFieldDeletes = new Set();
2414
+ /** typeKeys of the array types the program may freeze (IrModule.freezableArrays). */
2415
+ freezableArrays = new Set();
2212
2416
  liftedFns = [];
2417
+ /** The first lifted function of each name (liftedFnNamed), for the
2418
+ * liftedFns indexed so far. liftedFns only grows. */
2419
+ liftedFnsByName = new Map();
2420
+ liftedFnsIndexed = 0;
2213
2421
  /** Runtime-provided classes used as values (defineClassValueConstruct),
2214
2422
  * by IR class name. */
2215
2423
  runtimeClassValues = new Map();
@@ -2217,7 +2425,57 @@ export class Lowerer {
2217
2425
  * dispatch revision needs no weak-key identity or process-global state. */
2218
2426
  errorMethodDispatchRevision = null;
2219
2427
  errorPropertyDispatchRevision = null;
2220
- lambdaCounter = 0;
2428
+ /** The program defines properties by reflection on an untyped or
2429
+ * Error-shaped target, so an own accessor may replace an error's `name`
2430
+ * or `message`: typed reads and writes of those slots check for one.
2431
+ * Holds the first such call's location. */
2432
+ errorAccessorReflection = null;
2433
+ /** Structural source positions (structural-positions.ts) for names that
2434
+ * stay the same when unrelated code moves. */
2435
+ /** Files are named by their path relative to the entry's directory, so
2436
+ * names do not depend on where the program sits, default library files
2437
+ * by their base name (two checkers install them in different
2438
+ * directories), and the files scriptc ships by their name inside scriptc,
2439
+ * so names do not depend on where scriptc is installed either. */
2440
+ positions = new StructuralPositions((sf) => this.program.isSourceFileDefaultLibrary(sf)
2441
+ ? `lib:${sf.fileName.slice(sf.fileName.lastIndexOf("/") + 1)}`
2442
+ : (compilerOwnedFileName(sf.fileName) ?? relative(dirname(this.entry.fileName), sf.fileName)));
2443
+ /** The outermost node whose token span is exactly `loc`, or null. */
2444
+ nodeAtLoc(loc) {
2445
+ const sf = this.program.getSourceFile(loc.file);
2446
+ return sf === undefined ? null : (ts.nodeAtSpan(sf, loc.start, loc.end) ?? null);
2447
+ }
2448
+ /** The lowering unit whose name scopes the closures it lifts. */
2449
+ closureRoot = "%pre";
2450
+ closureNameCounts = new Map();
2451
+ /** Runs `fn` with the closures it lifts named under `root`. */
2452
+ withClosureRoot(root, fn) {
2453
+ const previous = this.closureRoot;
2454
+ this.closureRoot = root;
2455
+ try {
2456
+ return fn();
2457
+ }
2458
+ finally {
2459
+ this.closureRoot = previous;
2460
+ }
2461
+ }
2462
+ /** The name of a closure (or wrapper) lifted for the source at `loc`:
2463
+ * `<prefix>.<hash>` of the current lowering unit, the location and
2464
+ * `suffix`, then `suffix`. A unit that lifts several functions for the same
2465
+ * location and suffix numbers them in the order it lifts them, so a
2466
+ * closure's name depends only on its unit, not on which units lowered
2467
+ * before it. */
2468
+ closureName(loc, suffix = "", prefix = "%fn") {
2469
+ const node = this.nodeAtLoc(loc);
2470
+ const where = node === null
2471
+ ? `${compilerOwnedFileName(loc.file) ?? loc.file}:${loc.start}:${loc.end}`
2472
+ : this.positions.of(node);
2473
+ const key = `${prefix}|${this.closureRoot}|${where}|${suffix}`;
2474
+ const first = keyedHelperName(this, prefix, key);
2475
+ const seen = this.closureNameCounts.get(first) ?? 0;
2476
+ this.closureNameCounts.set(first, seen + 1);
2477
+ return (seen === 0 ? first : keyedHelperName(this, prefix, `${key}|${seen}`)) + suffix;
2478
+ }
2221
2479
  preparedClassFactories = new Map();
2222
2480
  preparingClassFactories = new Set();
2223
2481
  /** Statement lists currently mid-lowering, innermost last: the forward-
@@ -2269,6 +2527,13 @@ export class Lowerer {
2269
2527
  * can contain any retained descendant, but importing its declaration
2270
2528
  * alone does not make every descendant constructible. */
2271
2529
  constructedClasses = null;
2530
+ /** Classes added to some ClassInfo's subclasses (lower-classes.ts). With
2531
+ * the class and constructed-class counts, it tells caches over the class
2532
+ * graph when the graph changed. */
2533
+ subclassLinks = 0;
2534
+ /** Function-local classes by the class node they extend, built on first
2535
+ * use (localSubclassesOf in lower-classes.ts). */
2536
+ localSubclassIndex = null;
2272
2537
  /** Set while a subclass constructor's super() call notes its base
2273
2538
  * constructor edge: that edge does not instantiate the base exactly. */
2274
2539
  superConstructorEdge = false;
@@ -2282,6 +2547,149 @@ export class Lowerer {
2282
2547
  info.genericInstance !== undefined ||
2283
2548
  info.mixinInstance !== undefined);
2284
2549
  }
2550
+ /** How many classes classCanBeConstructed admits by name, or -1 while
2551
+ * it admits every class. The count only grows. */
2552
+ constructedClassCount() {
2553
+ return this.constructedClasses?.size ?? -1;
2554
+ }
2555
+ /** Helpers that every site asking for them shares (shareHelper). */
2556
+ sharedHelpers = new Set();
2557
+ sharedHelperNames = new Set();
2558
+ /** Marks a helper, or the lifted helpers of a name, as shared by every
2559
+ * site that asks for it. A shared helper is built for whichever site asks
2560
+ * first, so once lowering finishes its locations are replaced by one that
2561
+ * names no site. */
2562
+ shareHelper(helper) {
2563
+ if (typeof helper === "string")
2564
+ this.sharedHelperNames.add(helper);
2565
+ else
2566
+ this.sharedHelpers.add(helper);
2567
+ }
2568
+ /** Gives each shared helper (those marked by shareHelper, and those
2569
+ * interned by key in the helper tables) one location for all its nodes:
2570
+ * the earliest site in `functions` that uses it, by file and position, so
2571
+ * reports such as --explain-dynamic point at a use whatever order bodies
2572
+ * lowered in. A helper used only by other shared helpers takes their
2573
+ * location; one with no use takes the entry file's start. */
2574
+ settleSharedHelperLocations(functions) {
2575
+ const interned = new Set([...this.sharedHelperNames, ...this.classMethodValueHelpers]);
2576
+ for (const table of [
2577
+ this.equalityHelpers,
2578
+ this.arrHofHelpers,
2579
+ this.unionCallHelpers,
2580
+ this.valueHelpers,
2581
+ this.assertHelpers,
2582
+ this.inspectHelpers,
2583
+ this.iterDrainHelpers,
2584
+ this.mapHofHelpers,
2585
+ this.setHofHelpers,
2586
+ this.spHofHelpers,
2587
+ this.primitiveCtorFns,
2588
+ this.builtinCallableValueFns,
2589
+ this.regionRunHelpers,
2590
+ this.internTableHelpers,
2591
+ this.coercions.retags,
2592
+ this.coercions.narrows,
2593
+ ])
2594
+ for (const name of table.values())
2595
+ interned.add(name);
2596
+ for (const fn of [...this.liftedFns, ...this.implicitFns])
2597
+ if (interned.has(fn.name))
2598
+ this.sharedHelpers.add(fn);
2599
+ if (this.sharedHelpers.size === 0)
2600
+ return;
2601
+ const shared = new Map([...this.sharedHelpers].map((fn) => [fn.name, fn]));
2602
+ // Files scriptc ships compare by their name inside scriptc, so the
2603
+ // choice does not depend on where scriptc is installed.
2604
+ const fileKeys = new Map();
2605
+ const fileKey = (file) => {
2606
+ let key = fileKeys.get(file);
2607
+ if (key === undefined)
2608
+ fileKeys.set(file, (key = compilerOwnedFileName(file) ?? file));
2609
+ return key;
2610
+ };
2611
+ const earlier = (left, right) => {
2612
+ if (left.file === right.file)
2613
+ return left.start < right.start;
2614
+ return fileKey(left.file) < fileKey(right.file);
2615
+ };
2616
+ // The earliest use of each shared helper outside the shared helpers, and
2617
+ // which shared helpers each shared helper uses.
2618
+ const uses = new Map();
2619
+ const usedBy = new Map();
2620
+ for (const fn of functions) {
2621
+ const inShared = shared.has(fn.name) ? fn.name : undefined;
2622
+ everyStmtList(fn.body, {
2623
+ stmt: () => true,
2624
+ expr: (expr) => {
2625
+ const name = expr.kind === "call" ? expr.callee : exprFunctionReference(expr);
2626
+ if (name === undefined || name === inShared || !shared.has(name))
2627
+ return true;
2628
+ if (inShared !== undefined) {
2629
+ let users = usedBy.get(name);
2630
+ if (users === undefined)
2631
+ usedBy.set(name, (users = new Set()));
2632
+ users.add(inShared);
2633
+ }
2634
+ else {
2635
+ const current = uses.get(name);
2636
+ if (current === undefined || earlier(expr.loc, current))
2637
+ uses.set(name, expr.loc);
2638
+ }
2639
+ return true;
2640
+ },
2641
+ });
2642
+ }
2643
+ // Helpers reached only through other shared helpers take the earliest
2644
+ // location among those, to a fixed point.
2645
+ for (let changed = true; changed;) {
2646
+ changed = false;
2647
+ for (const [name, users] of usedBy) {
2648
+ for (const user of users) {
2649
+ const loc = uses.get(user);
2650
+ const current = uses.get(name);
2651
+ if (loc !== undefined && (current === undefined || earlier(loc, current))) {
2652
+ uses.set(name, loc);
2653
+ changed = true;
2654
+ }
2655
+ }
2656
+ }
2657
+ }
2658
+ const fallback = { file: this.entry.fileName, start: 0, end: 0 };
2659
+ for (const fn of this.sharedHelpers) {
2660
+ const use = uses.get(fn.name) ?? fallback;
2661
+ const loc = { file: use.file, start: use.start, end: use.end };
2662
+ const seen = new Set();
2663
+ const visit = (node) => {
2664
+ if (typeof node !== "object" || node === null || seen.has(node))
2665
+ return;
2666
+ seen.add(node);
2667
+ if (Array.isArray(node)) {
2668
+ for (const item of node)
2669
+ visit(item);
2670
+ return;
2671
+ }
2672
+ const record = node;
2673
+ for (const key of Object.keys(record)) {
2674
+ if (key === "loc")
2675
+ record[key] = loc;
2676
+ else if (key !== "type")
2677
+ visit(record[key]);
2678
+ }
2679
+ };
2680
+ visit(fn);
2681
+ }
2682
+ }
2683
+ /** The first lifted function named `name`, the one
2684
+ * `liftedFns.find((fn) => fn.name === name)` returns. */
2685
+ liftedFnNamed(name) {
2686
+ for (; this.liftedFnsIndexed < this.liftedFns.length; this.liftedFnsIndexed++) {
2687
+ const fn = this.liftedFns[this.liftedFnsIndexed];
2688
+ if (!this.liftedFnsByName.has(fn.name))
2689
+ this.liftedFnsByName.set(fn.name, fn);
2690
+ }
2691
+ return name === undefined ? undefined : this.liftedFnsByName.get(name);
2692
+ }
2285
2693
  /** Coverage remainder mode: the reachability gate inverts (see wantBody)
2286
2694
  * and no module is built. */
2287
2695
  remainder;
@@ -2401,6 +2809,20 @@ export class Lowerer {
2401
2809
  else if (kind === "failed")
2402
2810
  s.failed += 1;
2403
2811
  }
2812
+ /** The program holds the declaration-typed boundary's projection
2813
+ * (decl-projection.ts): user-file record and array values crossing into
2814
+ * dynamic slots (package parameters) box as live capsules, so a value
2815
+ * that comes back through a boundary cast keeps its identity. */
2816
+ declBoundaryMemo = null;
2817
+ get declBoundary() {
2818
+ this.declBoundaryMemo ??= this.program
2819
+ .getSourceFiles()
2820
+ .some((sf) => isDeclBoundaryFile(sf.fileName));
2821
+ return this.declBoundaryMemo;
2822
+ }
2823
+ /** Tracked classes' bag initializers over a typed `this`
2824
+ * (class-dynamic-dispatch.ts recordBagInitializers). */
2825
+ classBagInitializers = new Map();
2404
2826
  constructor(program, entry, moduleOrder, mode = {}) {
2405
2827
  this.program = program;
2406
2828
  this.entry = entry;
@@ -2435,6 +2857,7 @@ export class Lowerer {
2435
2857
  this.checker = program.getTypeChecker();
2436
2858
  this.typeCtx = {
2437
2859
  checker: this.checker,
2860
+ positionOf: (node) => this.positions.of(node),
2438
2861
  shapes: this.shapes,
2439
2862
  unions: this.unions,
2440
2863
  classNamer: this.classNamer,
@@ -2443,6 +2866,9 @@ export class Lowerer {
2443
2866
  isErasing: () => this.erasingDepth > 0,
2444
2867
  genericClassInstance: (decl, ref, mapArgument) => this.genericClassInstanceType(decl, ref, mapArgument),
2445
2868
  runtimeClassValue: (type) => runtimeClassValueOfType(this, type),
2869
+ localClassValue: (type) => this.instanceResultClass !== null && this.instanceResultClass.declared === type.id
2870
+ ? this.instanceResultClass.value
2871
+ : (this.localClassValueTypes.get(type.id) ?? null),
2446
2872
  mixinClassInstance: (decl) => this.mixinTypeContext && this.mixinTypeContext.classNode === decl
2447
2873
  ? { kind: "object", className: this.mixinTypeContext.className }
2448
2874
  : null,
@@ -2500,7 +2926,10 @@ export class Lowerer {
2500
2926
  classImplementedProtocol: (type) => this.classImplementedProtocol(type),
2501
2927
  isStdlibFile: this.isStdlibFile,
2502
2928
  isNpmFile: this.isNpmFile,
2503
- isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
2929
+ // The declaration-typed boundary's generated types (decl-projection.ts)
2930
+ // describe data, like an explicitly mapped external type surface.
2931
+ isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))) ||
2932
+ isDeclBoundaryFile(sf.fileName),
2504
2933
  typeMemo: this.typeMemo,
2505
2934
  ...(this.generalNodeStreams ? { generalNodeStreams: true } : {}),
2506
2935
  ...(this.dynNodeStreams ? { dynNodeStreams: true } : {}),
@@ -2561,16 +2990,16 @@ export class Lowerer {
2561
2990
  * is `unknown` or `object` (also with `null` or `undefined`, or an array
2562
2991
  * of those), names checked protocol identity, is an owned runtime
2563
2992
  * handle (a Worker or MessagePort, a fetch Headers/Request/Response, or
2564
- * a node:crypto ECDH), or is a WeakMap/WeakSet (native weak collections
2565
- * live in checked-dynamic storage, as locals of those types do); `any`
2566
- * fields stay refused. */
2993
+ * a node:crypto ECDH, DiffieHellman or DiffieHellmanGroup), or is a
2994
+ * WeakMap/WeakSet (native weak collections live in checked-dynamic
2995
+ * storage, as locals of those types do); `any` fields stay refused. */
2567
2996
  classFieldStoresDyn(type) {
2568
2997
  return (this.opaqueValueType(type) ||
2569
2998
  this.classImplementedProtocol(type) ||
2570
2999
  isWorkerHandleType(type, this.typeCtx) ||
2571
3000
  isFetchHandleType(type, this.typeCtx) ||
2572
3001
  this.weakCollectionType(type) ||
2573
- this.stdlibHandleType(type, (part) => isEcdhType(this, part)));
3002
+ this.stdlibHandleType(type, (part) => isEcdhType(this, part) || isDiffieHellmanType(this, part)));
2574
3003
  }
2575
3004
  /** A stdlib WeakMap or WeakSet, alone or with `null`/`undefined`. */
2576
3005
  weakCollectionType(type) {
@@ -2670,8 +3099,8 @@ export class Lowerer {
2670
3099
  }
2671
3100
  return false;
2672
3101
  })()
2673
- ? this.qualify(ts.getSourceFileOfNode(decl), `%cx${ts.tokenStartOfNode(decl)}.${decl.name?.text ?? ""}`)
2674
- : this.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(decl) + (decl.name ? decl.name.text : "%anon"));
3102
+ ? this.qualify(ts.getSourceFileOfNode(decl), `%cx${positionTag(this, decl)}.${decl.name?.text ?? ""}`)
3103
+ : this.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(this, decl) + (decl.name ? decl.name.text : "%anon"));
2675
3104
  for (let index = this.localClassInstantiations.length - 1; index >= 0; index--) {
2676
3105
  const entry = this.localClassInstantiations[index];
2677
3106
  for (let parent = decl.parent; parent && !ts.isSourceFile(parent); parent = parent.parent) {
@@ -3760,11 +4189,16 @@ export class Lowerer {
3760
4189
  // resolveValueSymbol also flushes deferred diagnostics and applies
3761
4190
  // merged-namespace fences, whose authority remains ordinary lowering.
3762
4191
  this.checker.prefetchSymbolRoots(sourceFiles, true);
4192
+ // The facts each fixed-point site reads, by the symbols, nodes and
4193
+ // element keys they belong to (created with the site list below).
4194
+ let siteDependencies = null;
3763
4195
  const symbolOf = (node) => {
3764
4196
  const s = this.checker.getSymbolAtLocation(node);
3765
4197
  if (!s)
3766
4198
  return null;
3767
- return s.flags & ts.SymbolFlags.Alias ? this.checker.getAliasedSymbol(s) : s;
4199
+ const symbol = s.flags & ts.SymbolFlags.Alias ? this.checker.getAliasedSymbol(s) : s;
4200
+ siteDependencies?.read(symbol);
4201
+ return symbol;
3768
4202
  };
3769
4203
  const signatureOf = (node) => {
3770
4204
  const symbol = symbolOf(node);
@@ -3932,8 +4366,11 @@ export class Lowerer {
3932
4366
  const callableSymbols = new Map();
3933
4367
  const callableSymbolOf = (node) => {
3934
4368
  const cached = callableSymbols.get(node);
3935
- if (cached !== undefined)
4369
+ if (cached !== undefined) {
4370
+ if (cached !== null)
4371
+ siteDependencies?.read(cached);
3936
4372
  return cached;
4373
+ }
3937
4374
  let symbol = symbolOf(ts.isPropertyAccessExpression(node) ? node.name : node);
3938
4375
  if (symbol === null || signatureBySymbol.has(symbol)) {
3939
4376
  callableSymbols.set(node, symbol);
@@ -4235,14 +4672,19 @@ export class Lowerer {
4235
4672
  return true;
4236
4673
  if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
4237
4674
  return true;
4675
+ if (ts.isPropertyAccessExpression(e) && isOptionalReadlineCursorRead(this, e))
4676
+ return true;
4238
4677
  if (isOptionalProcessVersionsRead(this, e))
4239
4678
  return true;
4240
4679
  if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
4241
4680
  return true;
4242
4681
  if (ts.isPropertyAccessExpression(e) && isOsConstantsSymbol(symbolOf(e.expression), this))
4243
4682
  return true;
4244
- if (ts.isCallExpression(e) && this.runtimeOptionalReduceTypes.has(e))
4245
- return true;
4683
+ if (ts.isCallExpression(e)) {
4684
+ siteDependencies?.read(e);
4685
+ if (this.runtimeOptionalReduceTypes.has(e))
4686
+ return true;
4687
+ }
4246
4688
  if (ts.isCallExpression(e) &&
4247
4689
  e.arguments.nodes.length === 0 &&
4248
4690
  ts.isPropertyAccessExpression(e.expression) &&
@@ -4747,6 +5189,7 @@ export class Lowerer {
4747
5189
  if (fnType?.kind === "func" && bodyReturnsOptional(fn)) {
4748
5190
  const widenedReturn = this.runtimeOptionalType(fnType.ret);
4749
5191
  provenance?.note("callback-return", fn, provenanceSite);
5192
+ siteDependencies?.read(fn);
4750
5193
  const previousReturn = this.runtimeOptionalFunctionReturnType(fn, fnType.ret);
4751
5194
  this.runtimeOptionalFunctionReturns.set(fn, widenedReturn);
4752
5195
  if (!typeEquals(previousReturn, widenedReturn))
@@ -4989,8 +5432,11 @@ export class Lowerer {
4989
5432
  const key = typeKey(arm.elem);
4990
5433
  if (arm.elem.kind === "union"
4991
5434
  ? this.armTag(arm.elem.unionId, UNDEFINED_T) >= 0
4992
- : isUnitType(arm.elem) || arm.elem.kind === "void")
5435
+ : isUnitType(arm.elem) || arm.elem.kind === "void") {
5436
+ if (!optionalElementKeys.has(key))
5437
+ siteDependencies?.changed(key);
4993
5438
  optionalElementKeys.add(key);
5439
+ }
4994
5440
  keys.push(key);
4995
5441
  }
4996
5442
  return keys;
@@ -5102,7 +5548,10 @@ export class Lowerer {
5102
5548
  return keys;
5103
5549
  };
5104
5550
  const elementStates = new ArrayElementStates({
5105
- elementAdmitsUndefined: (key) => optionalElementKeys.has(key),
5551
+ elementAdmitsUndefined: (key) => {
5552
+ siteDependencies?.read(key);
5553
+ return optionalElementKeys.has(key);
5554
+ },
5106
5555
  ownerOf: (node) => ownership.ownerOf(node),
5107
5556
  allocationOwner: (node) => ownership.allocationOwner(node),
5108
5557
  arrayKeys: arrayKeysOf,
@@ -5177,6 +5626,8 @@ export class Lowerer {
5177
5626
  note: provenance
5178
5627
  ? (fact, key, site) => provenance.note(`element-${fact}`, site, site, key)
5179
5628
  : null,
5629
+ read: (fact) => siteDependencies?.read(fact),
5630
+ changed: (fact) => siteDependencies?.changed(fact),
5180
5631
  });
5181
5632
  // Each pass revisits every array callback site; the last visit holds
5182
5633
  // the decision at the fixed point.
@@ -5404,7 +5855,10 @@ export class Lowerer {
5404
5855
  }
5405
5856
  if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
5406
5857
  const callbackIndices = hofCallbackIndices(node.expression.name.text, node.arguments.nodes.length >= 2);
5407
- const callback = node.arguments.nodes[0];
5858
+ // `xs.map(((x) => x))`: the parenthesized callback is the arrow.
5859
+ let callback = node.arguments.nodes[0];
5860
+ while (callback !== undefined && ts.isParenthesizedExpression(callback))
5861
+ callback = callback.expression;
5408
5862
  if (callbackIndices !== null && callback !== undefined && !ts.isSpreadElement(callback)) {
5409
5863
  const receiverNode = node.expression.expression;
5410
5864
  const receiverTs = this.typeOf(receiverNode);
@@ -5455,12 +5909,27 @@ export class Lowerer {
5455
5909
  presentSites.set(node, elementsPresent && !reduce);
5456
5910
  if (elementsPresent && reduce && retypeInlineCallback(callback, callbackIndices))
5457
5911
  changed = true;
5458
- if ((method === "reduce" || method === "reduceRight") &&
5459
- ((!elementsPresent && node.arguments.nodes.length < 2) ||
5460
- callbackReturnsOptional(callback))) {
5461
- if (promoteHofCallback(callback, [0, 1]))
5912
+ // The accumulator holds undefined when the callback can return
5913
+ // it, when an initial value can be missing, or when elements can
5914
+ // be absent and there is no initial value. It holds another
5915
+ // primitive when the callback's result can be one at run time
5916
+ // (`missing[0] ?? "fallback"`).
5917
+ const initial = node.arguments.nodes[1];
5918
+ const optional = (!elementsPresent && initial === undefined) ||
5919
+ (initial !== undefined && !ts.isSpreadElement(initial) && mayBeOptional(initial)) ||
5920
+ callbackReturnsOptional(callback);
5921
+ const arithmetic = reduce && (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback))
5922
+ ? lambdaArithmeticReturn(callback)
5923
+ : null;
5924
+ if (reduce && (optional || arithmetic !== null)) {
5925
+ if (optional && promoteHofCallback(callback, [0, 1]))
5462
5926
  changed = true;
5463
- const result = this.runtimeOptionalType(this.irTypeOf(node));
5927
+ let result = this.irTypeOf(node);
5928
+ if (arithmetic !== null)
5929
+ result = joinPrimitiveTypes([result, arithmetic]) ?? result;
5930
+ if (optional)
5931
+ result = this.runtimeOptionalType(result);
5932
+ siteDependencies?.read(node);
5464
5933
  const previous = this.runtimeOptionalReduceTypes.get(node);
5465
5934
  if (!previous || !typeEquals(previous, result)) {
5466
5935
  this.runtimeOptionalReduceTypes.set(node, result);
@@ -5518,6 +5987,7 @@ export class Lowerer {
5518
5987
  (this.typeOf(arg).flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Void)) === 0)
5519
5988
  continue;
5520
5989
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
5990
+ siteDependencies?.read(target);
5521
5991
  const shape = signatureBySymbol.get(target)?.params[i];
5522
5992
  if (!shape || shape.mode !== "required")
5523
5993
  continue;
@@ -5557,6 +6027,7 @@ export class Lowerer {
5557
6027
  if (!ts.isSpreadElement(arg) && shape && i !== restAt && fieldsOfValue(arg)) {
5558
6028
  const fields = fieldsOfValue(arg);
5559
6029
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
6030
+ siteDependencies?.read(target);
5560
6031
  const parameterShape = signatureBySymbol.get(target)?.params[i];
5561
6032
  const parameter = functionDeclBySymbol.get(target)?.parameters?.nodes[i];
5562
6033
  if (!parameterShape || parameterShape.type.kind !== "record")
@@ -5608,6 +6079,7 @@ export class Lowerer {
5608
6079
  // argument can make its elements undefined, not the pack.
5609
6080
  // Keep every virtual implementation on the same array ABI.
5610
6081
  for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
6082
+ siteDependencies?.read(target);
5611
6083
  const rest = signatureBySymbol.get(target)?.params[i];
5612
6084
  if (rest?.mode !== "rest" || rest.type.kind !== "array")
5613
6085
  continue;
@@ -5632,6 +6104,7 @@ export class Lowerer {
5632
6104
  // downstream calls and returns see the same optional value.
5633
6105
  const family = familyBySymbol.get(symbol);
5634
6106
  for (const target of family ?? [symbol]) {
6107
+ siteDependencies?.read(target);
5635
6108
  const parameterShape = signatureBySymbol.get(target)?.params[i];
5636
6109
  if (!parameterShape)
5637
6110
  continue;
@@ -5658,9 +6131,23 @@ export class Lowerer {
5658
6131
  });
5659
6132
  }
5660
6133
  };
5661
- for (const node of sitesOf(sf))
5662
- scan(node);
5663
- return changed;
6134
+ // A site whose facts are unchanged since its last visit would compute
6135
+ // that visit's result again, except in a full pass.
6136
+ const base = siteBase.get(sf);
6137
+ const dependencies = siteDependencies;
6138
+ const sites = sitesOf(sf);
6139
+ let fileChanged = false;
6140
+ for (let i = 0; i < sites.length; i++) {
6141
+ if (!fullPass && !dependencies.isStale(base + i))
6142
+ continue;
6143
+ changed = false;
6144
+ dependencies.begin(base + i);
6145
+ scan(sites[i]);
6146
+ dependencies.end(changed);
6147
+ if (changed)
6148
+ fileChanged = true;
6149
+ }
6150
+ return fileChanged;
5664
6151
  };
5665
6152
  const scanReturns = (symbol, decl) => {
5666
6153
  let changed = false;
@@ -5711,12 +6198,26 @@ export class Lowerer {
5711
6198
  optionalSymbols.add(symbol);
5712
6199
  this.earlyReadVars.add(symbol);
5713
6200
  }
5714
- let changed = true;
5715
- while (changed) {
6201
+ // Number the sites of every file. The first and the last pass visit
6202
+ // every site; the passes between visit only the sites whose facts
6203
+ // changed (SiteDependencies). When such a pass changes nothing, a full
6204
+ // pass confirms the fixed point, and the iteration resumes if it
6205
+ // changes a fact after all.
6206
+ const siteBase = new Map();
6207
+ let siteCount = 0;
6208
+ for (const sf of sourceFiles) {
6209
+ siteBase.set(sf, siteCount);
6210
+ siteCount += sitesOf(sf).length;
6211
+ }
6212
+ siteDependencies = new SiteDependencies(siteCount);
6213
+ let fullPass = true;
6214
+ for (let changed = true, first = true; changed || !fullPass; first = false) {
6215
+ fullPass = first || !changed;
5716
6216
  changed = false;
5717
6217
  for (const [symbol, field] of staticFieldsBySymbol) {
5718
6218
  if (!optionalSymbols.has(symbol) && mayBeOptional(field.initializer)) {
5719
6219
  optionalSymbols.add(symbol);
6220
+ siteDependencies.changed(symbol);
5720
6221
  provenance?.note("static-field", field.initializer.parent, field.initializer);
5721
6222
  changed = true;
5722
6223
  }
@@ -5724,15 +6225,19 @@ export class Lowerer {
5724
6225
  for (const sf of sourceFiles)
5725
6226
  if (scanFile(sf))
5726
6227
  changed = true;
5727
- for (const [symbol, decl] of functionDeclBySymbol)
5728
- if (scanReturns(symbol, decl))
5729
- changed = true;
6228
+ for (const [symbol, decl] of functionDeclBySymbol) {
6229
+ if (!scanReturns(symbol, decl))
6230
+ continue;
6231
+ siteDependencies.changed(symbol);
6232
+ changed = true;
6233
+ }
5730
6234
  const noteGenericReturn = (symbol, decl) => {
5731
6235
  if (optionalReturns.has(symbol) || isJsSourceFile(ts.getSourceFileOfNode(decl)))
5732
6236
  return;
5733
6237
  if (!returnsOf(decl).some(genericMayBeOptional))
5734
6238
  return;
5735
6239
  optionalReturns.add(symbol);
6240
+ siteDependencies.changed(symbol);
5736
6241
  this.runtimeOptionalGenericReturns.add(decl);
5737
6242
  provenance?.note("return", decl.name ?? decl, decl);
5738
6243
  changed = true;
@@ -5770,6 +6275,7 @@ export class Lowerer {
5770
6275
  : previous;
5771
6276
  if (!typeEquals(previous, next)) {
5772
6277
  this.runtimeOptionalFunctionReturns.set(fn, next);
6278
+ siteDependencies.changed(fn);
5773
6279
  provenance?.note("lambda-return", fn, fn.body);
5774
6280
  changed = true;
5775
6281
  }
@@ -5785,11 +6291,13 @@ export class Lowerer {
5785
6291
  if (symbol && next.kind === "union" && this.armTag(next.unionId, UNDEFINED_T) >= 0) {
5786
6292
  if (!optionalReturns.has(symbol)) {
5787
6293
  optionalReturns.add(symbol);
6294
+ siteDependencies.changed(symbol);
5788
6295
  changed = true;
5789
6296
  }
5790
6297
  }
5791
6298
  else if (symbol && !arithmeticReturns.has(symbol)) {
5792
6299
  arithmeticReturns.set(symbol, next);
6300
+ siteDependencies.changed(symbol);
5793
6301
  changed = true;
5794
6302
  }
5795
6303
  }
@@ -5808,6 +6316,7 @@ export class Lowerer {
5808
6316
  : this.runtimeOptionalType(previous);
5809
6317
  if (!typeEquals(previous, next)) {
5810
6318
  this.runtimeOptionalFunctionReturns.set(fn, next);
6319
+ siteDependencies.changed(fn);
5811
6320
  changed = true;
5812
6321
  }
5813
6322
  }
@@ -5822,6 +6331,7 @@ export class Lowerer {
5822
6331
  for (const symbol of optional ? family : []) {
5823
6332
  if (!optionalReturns.has(symbol)) {
5824
6333
  optionalReturns.add(symbol);
6334
+ siteDependencies.changed(symbol);
5825
6335
  provenance?.note("return", functionDeclBySymbol.get(symbol), undefined, "(override family)");
5826
6336
  changed = true;
5827
6337
  }
@@ -5838,10 +6348,14 @@ export class Lowerer {
5838
6348
  if (previous && typeEquals(previous, joined))
5839
6349
  continue;
5840
6350
  arithmeticReturns.set(symbol, joined);
6351
+ siteDependencies.changed(symbol);
5841
6352
  changed = true;
5842
6353
  }
5843
6354
  }
5844
6355
  }
6356
+ // The site facts serve only the fixed point; release them for the rest
6357
+ // of lowering.
6358
+ siteDependencies = null;
5845
6359
  // NaN-coded slots convert optional values on entry instead of holding
5846
6360
  // the union, so promotion never applies to them.
5847
6361
  for (const symbol of [...optionalSymbols])
@@ -6189,13 +6703,16 @@ export class Lowerer {
6189
6703
  const fn = this.lowerFunction(decl);
6190
6704
  if (fn)
6191
6705
  functions.push(fn);
6192
- else if (this.countsSkips())
6706
+ else if (this.countsSkips()) {
6193
6707
  this.countSkippedBody(decl);
6708
+ if (this.remainder)
6709
+ this.reportBlockedBody(decl);
6710
+ }
6194
6711
  }
6195
6712
  for (const decl of fp.classDecls) {
6196
6713
  const info = this.classes.get(this.classNamer(decl));
6197
6714
  if (info)
6198
- functions.push(...this.lowerClassMembers(info));
6715
+ functions.push(...this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)));
6199
6716
  else if (this.countsSkips())
6200
6717
  this.countSkippedBody(decl);
6201
6718
  }
@@ -6208,7 +6725,8 @@ export class Lowerer {
6208
6725
  // are reachable by definition, already counted by reachable emit.
6209
6726
  if (!this.remainder) {
6210
6727
  for (const fp of parts) {
6211
- functions.push(this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf)));
6728
+ const initName = this.initNameOf.get(fp.sf);
6729
+ functions.push(this.withClosureRoot(initName, () => this.lowerFileInit(fp.sf, fp.topStmts, initName)));
6212
6730
  }
6213
6731
  functions.push(this.buildMain());
6214
6732
  }
@@ -6248,7 +6766,7 @@ export class Lowerer {
6248
6766
  // default): the diagnostic is recorded — the instance skips
6249
6767
  // like a signature-blocked function (lowerFunction's rule).
6250
6768
  try {
6251
- functions.push(this.lowerGenericInstance(info, inst));
6769
+ functions.push(this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)));
6252
6770
  }
6253
6771
  catch (e) {
6254
6772
  if (!(e instanceof PoisonError))
@@ -6260,7 +6778,8 @@ export class Lowerer {
6260
6778
  // instances of its own; the joint fixpoint covers both).
6261
6779
  while (es < this.emitSpecQueue.length) {
6262
6780
  try {
6263
- const fn = lowerEmitOverrideSpec(this, this.emitSpecQueue[es++]);
6781
+ const spec = this.emitSpecQueue[es++];
6782
+ const fn = this.withClosureRoot(emitSpecRoot(spec), () => lowerEmitOverrideSpec(this, spec));
6264
6783
  if (fn)
6265
6784
  functions.push(fn);
6266
6785
  }
@@ -6278,6 +6797,7 @@ export class Lowerer {
6278
6797
  // Lambdas lifted while lowering any of the above (plus synthetic
6279
6798
  // array-HOF loop functions, which ride the same list), and the
6280
6799
  // implicit-any instances lowered eagerly at their first call sites.
6800
+ this.settleSharedHelperLocations([...functions, ...this.liftedFns, ...this.implicitFns]);
6281
6801
  functions.push(...this.liftedFns);
6282
6802
  functions.push(...this.implicitFns);
6283
6803
  functions.push(...runtimeClassConstructs(this, functions));
@@ -6311,6 +6831,7 @@ export class Lowerer {
6311
6831
  finalizePrivateBrands(this, functions);
6312
6832
  trackClassFieldCreation(this, functions);
6313
6833
  guardClassAttributeWrites(this, functions);
6834
+ guardFrozenWrites(this, functions);
6314
6835
  applyHandleProperties(this, functions);
6315
6836
  // Globals typed by a class that never REGISTERED (a JS class whose
6316
6837
  // collection fenced — Symbol-keyed fields, an unsupported base): the
@@ -6409,13 +6930,17 @@ export class Lowerer {
6409
6930
  classes: artifacts.classes,
6410
6931
  records: artifacts.records,
6411
6932
  unions: artifacts.unions,
6412
- globals: this.globalsList,
6933
+ globals: this.globalsInTableOrder(),
6413
6934
  entry: ENTRY_NAME,
6414
6935
  ...(this.usesWorkers ? { workers: true } : {}),
6415
6936
  ...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
6937
+ ...(this.declBoundary ? { declBoundary: true } : {}),
6416
6938
  ...(this.threadSlotKeys.size > 0
6417
6939
  ? { threadSlotKeys: [...this.threadSlotKeys].sort() }
6418
6940
  : {}),
6941
+ ...(this.freezableArrays.size > 0
6942
+ ? { freezableArrays: [...this.freezableArrays].sort() }
6943
+ : {}),
6419
6944
  ...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
6420
6945
  ...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
6421
6946
  };
@@ -6516,6 +7041,20 @@ export class Lowerer {
6516
7041
  this.bumpFileStat(file, "failed");
6517
7042
  }
6518
7043
  }
7044
+ /** Coverage remainder: the body diagnostics of a function whose
7045
+ * signature blocked (blockedBodyDiagnostics). A function reachable emit
7046
+ * reached (its signature's diagnostics flushed there) reports them with
7047
+ * the reached diagnostics; any other reports them as unreached. */
7048
+ reachedBlockedBodyDiagnostics = [];
7049
+ reportBlockedBody(decl) {
7050
+ const diags = blockedBodyDiagnostics(this, decl);
7051
+ const symbol = declSymbolOf(this, decl);
7052
+ if (symbol && this.alreadyFlushed.has(symbol))
7053
+ this.reachedBlockedBodyDiagnostics.push(...diags);
7054
+ else
7055
+ for (const d of diags)
7056
+ this.pushDiag(d);
7057
+ }
6519
7058
  /** Whether run() counts a signature-blocked declaration in
6520
7059
  * stats.functionsSkipped: whole-program passes and the coverage
6521
7060
  * remainder do; an externally-gated emit pass leaves the counting to the
@@ -6538,6 +7077,10 @@ export class Lowerer {
6538
7077
  * body; both fire edges through the same hooks and are not units
6539
7078
  * themselves. */
6540
7079
  emitReachable(extraRoots) {
7080
+ // Frontend passes below rewrite function bodies through the IR mapper
7081
+ // (caught-value and class dispatch); key-order notes follow the record
7082
+ // literals they rebuild until the witness pass has read them.
7083
+ observeRecordLiteralRebuilds((from, to) => this.keyOrder.follow(from, to));
6541
7084
  this.deferredModuleInitializers = new DeferredModuleInitializers();
6542
7085
  const parts = this.splitFiles();
6543
7086
  this.narrowing.setFiles(parts.map((fp) => fp.sf));
@@ -6790,7 +7333,8 @@ export class Lowerer {
6790
7333
  rank: [4, instanceMetadataOrder++],
6791
7334
  };
6792
7335
  this.genericClassDemandPriority.set(info, ref);
6793
- instanceFunctions.push(...this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.lowerClassMembers(info))));
7336
+ instanceFunctions.push(...this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.withClosureRoot(info.def.name, () => this.lowerClassMembers(info)))));
7337
+ relieveHeapPressure();
6794
7338
  }
6795
7339
  }
6796
7340
  while (instLowered < this.instantiationQueue.length) {
@@ -6809,7 +7353,8 @@ export class Lowerer {
6809
7353
  // Body-level poisons skip the instance after retaining the
6810
7354
  // diagnostic and every edge fired before poisoning.
6811
7355
  try {
6812
- instanceFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.lowerGenericInstance(info, inst))));
7356
+ instanceFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(ref, () => this.withClosureRoot(inst.name, () => this.lowerGenericInstance(info, inst)))));
7357
+ relieveHeapPressure();
6813
7358
  }
6814
7359
  catch (e) {
6815
7360
  if (!(e instanceof PoisonError))
@@ -6822,12 +7367,21 @@ export class Lowerer {
6822
7367
  // exactly like generic instances.
6823
7368
  while (specLowered < this.emitSpecQueue.length) {
6824
7369
  const waveEnd = this.emitSpecQueue.length;
7370
+ // A wave's specializations lower by class and event, not in the
7371
+ // order bodies asked for them.
7372
+ const wave = this.emitSpecQueue.slice(specLowered, waveEnd);
7373
+ const specKey = ({ info, event }) => `${info.def.name}\0${event}`;
7374
+ wave.sort((left, right) => specKey(left) < specKey(right) ? -1 : specKey(left) > specKey(right) ? 1 : 0);
7375
+ this.emitSpecQueue.splice(specLowered, wave.length, ...wave);
6825
7376
  this.checker.prefetchRoots(this.emitSpecQueue
6826
7377
  .slice(specLowered, waveEnd)
6827
7378
  .flatMap(({ info }) => info.emitOverride ? functionRoots(info.emitOverride.decl) : []));
6828
7379
  while (specLowered < waveEnd) {
6829
7380
  try {
6830
- const fn = this.shapes.withDeclaredOrderPriority([4, instanceMetadataOrder++], () => lowerEmitOverrideSpec(this, this.emitSpecQueue[specLowered++]));
7381
+ const fn = this.shapes.withDeclaredOrderPriority([4, instanceMetadataOrder++], () => {
7382
+ const spec = this.emitSpecQueue[specLowered++];
7383
+ return this.withClosureRoot(emitSpecRoot(spec), () => lowerEmitOverrideSpec(this, spec));
7384
+ });
6831
7385
  if (fn)
6832
7386
  instanceFunctions.push(fn);
6833
7387
  }
@@ -6854,7 +7408,7 @@ export class Lowerer {
6854
7408
  parts.forEach((fp, index) => {
6855
7409
  const priority = [2, index];
6856
7410
  const owner = demandOwner(priority);
6857
- initFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf)))));
7411
+ initFunctions.push(this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(this.initNameOf.get(fp.sf), () => this.lowerFileInit(fp.sf, fp.topStmts, this.initNameOf.get(fp.sf))))));
6858
7412
  });
6859
7413
  // LIBRARY mode's extra reachability roots (LowerOptions.libRoots): the
6860
7414
  // profile-mapped exports are called from outside the graph, so they
@@ -6862,9 +7416,11 @@ export class Lowerer {
6862
7416
  // (the export-map resolution reports them as SC4002 later).
6863
7417
  for (const root of extraRoots ?? [])
6864
7418
  this.onEdge?.(root);
7419
+ const shuffle = lowerShuffle();
6865
7420
  const drainUnits = () => {
6866
7421
  while (queue.length > 0) {
6867
7422
  const wave = queue.splice(0);
7423
+ shuffle?.(wave);
6868
7424
  this.checker.prefetchRoots(wave.flatMap((name) => units.get(name).roots));
6869
7425
  for (const name of wave) {
6870
7426
  // A body-level poison outside the per-statement catches (a fenced
@@ -6875,9 +7431,10 @@ export class Lowerer {
6875
7431
  const unit = units.get(name);
6876
7432
  const priority = metadataPriority.get(name) ?? [3, expressionMetadataOrder++];
6877
7433
  const owner = demandOwner(priority);
6878
- const fn = this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, unit.lower));
7434
+ const fn = this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(name, unit.lower)));
6879
7435
  if (fn)
6880
7436
  loweredUnits.set(name, fn);
7437
+ relieveHeapPressure();
6881
7438
  }
6882
7439
  catch (e) {
6883
7440
  if (!(e instanceof PoisonError))
@@ -6893,22 +7450,29 @@ export class Lowerer {
6893
7450
  // turn queue more instances. Continue to the joint fixpoint; the initial
6894
7451
  // queue above is the only portion whose discovery order differed from
6895
7452
  // historical emit order.
7453
+ noteDateClassMethods(this);
6896
7454
  const classDispatch = new ClassDynamicDispatch(extraRoots !== undefined);
7455
+ // Units in declaration order, so the passes below meet functions, and the
7456
+ // classes they collect, in an order that does not depend on lowering order.
7457
+ const unitsInOrder = () => [...loweredUnits]
7458
+ .sort(([left], [right]) => units.get(left).order - units.get(right).order)
7459
+ .map(([, fn]) => fn);
6897
7460
  for (;;) {
6898
7461
  drainInstances();
7462
+ const declared = unitsInOrder();
6899
7463
  const initializerChanged = this.deferredModuleInitializers.process(this, [
6900
- ...loweredUnits.values(),
7464
+ ...declared,
6901
7465
  ...initFunctions,
6902
7466
  ...instanceFunctions,
6903
- ...this.liftedFns,
6904
- ...this.implicitFns,
6905
- ]);
7467
+ ...byName(this.liftedFns),
7468
+ ...byName(this.implicitFns),
7469
+ ], (fn) => classDispatch.sites.forget(fn));
6906
7470
  const dispatchChanged = classDispatch.process(this, [
6907
- ...loweredUnits.values(),
7471
+ ...declared,
6908
7472
  ...initFunctions,
6909
7473
  ...instanceFunctions,
6910
- ...this.liftedFns,
6911
- ...this.implicitFns,
7474
+ ...byName(this.liftedFns),
7475
+ ...byName(this.implicitFns),
6912
7476
  ]);
6913
7477
  if (queue.length === 0 && !dispatchChanged && !initializerChanged)
6914
7478
  break;
@@ -6917,9 +7481,7 @@ export class Lowerer {
6917
7481
  this.restoreGenericClassInstanceOrder(clsInstLowered);
6918
7482
  }
6919
7483
  classDispatch.finalize(this);
6920
- const orderedUnits = [...loweredUnits]
6921
- .sort(([left], [right]) => units.get(left).order - units.get(right).order)
6922
- .map(([, fn]) => fn);
7484
+ const orderedUnits = unitsInOrder();
6923
7485
  this.settleGenericDemandPriorities();
6924
7486
  this.shapes.settleDeclaredOrderPriorities();
6925
7487
  for (const finalize of this.shapeOrderMetadataFinalizers)
@@ -6931,15 +7493,25 @@ export class Lowerer {
6931
7493
  ...this.liftedFns,
6932
7494
  ...this.implicitFns,
6933
7495
  ]);
7496
+ observeRecordLiteralRebuilds(null);
6934
7497
  for (const finalize of this.shapeOrderHelperFinalizers)
6935
7498
  finalize();
6936
- const functions = [
7499
+ this.settleSharedHelperLocations([
6937
7500
  ...orderedUnits,
6938
7501
  ...initFunctions,
6939
- this.buildMain(),
6940
7502
  ...instanceFunctions,
6941
7503
  ...this.liftedFns,
6942
7504
  ...this.implicitFns,
7505
+ ]);
7506
+ // Lifted and implicit functions are created in lowering order; they
7507
+ // are assembled by name.
7508
+ const functions = [
7509
+ ...orderedUnits,
7510
+ ...initFunctions,
7511
+ this.buildMain(),
7512
+ ...instanceFunctions,
7513
+ ...byName(this.liftedFns),
7514
+ ...byName(this.implicitFns),
6943
7515
  ];
6944
7516
  functions.push(...runtimeClassConstructs(this, functions));
6945
7517
  if (this.regexGroupResults)
@@ -7323,7 +7895,36 @@ export class Lowerer {
7323
7895
  fenceStaticReadableStreamMember(access, use) {
7324
7896
  return fenceStaticReadableStreamMember(this, access, use);
7325
7897
  }
7898
+ /** Whether `node` reads an anySymbols parameter, or a member, element or
7899
+ * call result of one: the error-path copy of a callback reads those as
7900
+ * `any`. */
7901
+ readsAnySymbol(node) {
7902
+ let base = node;
7903
+ for (;;) {
7904
+ if (ts.isPropertyAccessExpression(base) ||
7905
+ ts.isElementAccessExpression(base) ||
7906
+ ts.isNonNullExpression(base) ||
7907
+ ts.isParenthesizedExpression(base)) {
7908
+ base = base.expression;
7909
+ }
7910
+ else if (ts.isCallExpression(base) && ts.isPropertyAccessExpression(base.expression)) {
7911
+ base = base.expression.expression;
7912
+ }
7913
+ else {
7914
+ break;
7915
+ }
7916
+ }
7917
+ if (!ts.isIdentifier(base))
7918
+ return false;
7919
+ const parent = base.parent;
7920
+ const symbol = parent !== undefined && ts.isShorthandPropertyAssignment(parent) && parent.name === base
7921
+ ? this.checker.getShorthandAssignmentValueSymbol(parent)
7922
+ : this.checker.getSymbolAtLocation(base);
7923
+ return symbol !== undefined && this.anySymbols.has(symbol);
7924
+ }
7326
7925
  typeOf(node) {
7926
+ if (this.anySymbols.size > 0 && this.readsAnySymbol(node))
7927
+ return this.checker.getAnyType();
7327
7928
  if (ts.isPropertyAccessExpression(node) && isJsSourceFile(ts.getSourceFileOfNode(node))) {
7328
7929
  const receiver = node.expression.kind === ts.SyntaxKind.ThisKeyword && this.fnStack.length > 0
7329
7930
  ? this.resolveThis()?.type
@@ -7598,8 +8199,9 @@ export class Lowerer {
7598
8199
  /** The ts-level twin of typeParamResolver: the bound CHECKER type of a
7599
8200
  * type parameter in the current instantiation (typeParamTsBindings), for
7600
8201
  * the resolutions where mapType's widening already dropped what the body
7601
- * needs (indexed accesses over literal-bound keys). Inert outside
7602
- * call-keyed generic instantiation. */
8202
+ * needs (indexed accesses over literal-bound keys, conditional types
8203
+ * over literal arguments). Inert outside generic function and class
8204
+ * instantiation. */
7603
8205
  typeParamTsResolver = (t) => {
7604
8206
  if (!this.typeParamTsBindings || !(t.flags & ts.TypeFlags.TypeParameter))
7605
8207
  return null;
@@ -7750,6 +8352,22 @@ export class Lowerer {
7750
8352
  * type-mapper.ts's chalk-shape mapping — call paths and func-slot coercions
7751
8353
  * share it. */
7752
8354
  hybridCallUnwrap(expr) {
8355
+ // A callable CLASS instance: a class whose merged interface carries a
8356
+ // call signature stores its call behavior in a `%call` field (the
8357
+ // chalk package shim's builder). Calls read the field.
8358
+ if (expr.type.kind === "object") {
8359
+ const callType = this.classes.get(expr.type.className)?.fields.get("%call");
8360
+ if (callType === undefined || callType.kind !== "func")
8361
+ return expr;
8362
+ return {
8363
+ kind: "fieldGet",
8364
+ obj: expr,
8365
+ className: expr.type.className,
8366
+ field: "%call",
8367
+ type: callType,
8368
+ loc: expr.loc,
8369
+ };
8370
+ }
7753
8371
  if (expr.type.kind !== "record")
7754
8372
  return expr;
7755
8373
  const shape = this.shapes.get(expr.type.shapeId);
@@ -7832,6 +8450,20 @@ export class Lowerer {
7832
8450
  }
7833
8451
  if (expr.type.kind === "void" && expected.kind !== "void" && this.neverValued.has(expr))
7834
8452
  return this.divergentValue(expr, expected);
8453
+ // A builtin error constructor global stored in a slot of its class value
8454
+ // type (`{ Parent: Error }`): the class value itself, which a checked
8455
+ // cast of the dynamic constructor value could not produce.
8456
+ if (expected.kind === "classval" &&
8457
+ expr.kind === "libCall" &&
8458
+ expr.fn === "dyn.globalConstructor" &&
8459
+ expr.args[0]?.kind === "strLit" &&
8460
+ `%${expr.args[0].value}` === expected.className) {
8461
+ const info = this.classes.get(expected.className);
8462
+ if (info?.builtinError && info.valueCtorParams !== undefined) {
8463
+ this.defineClassValueConstruct(info);
8464
+ return { kind: "classRef", className: info.def.name, type: expected, loc: expr.loc };
8465
+ }
8466
+ }
7835
8467
  // process.stdout/stderr into a general Writable slot (general-streams.ts).
7836
8468
  const stdioStream = stdioIntoGeneralStream(this, expr, expected);
7837
8469
  if (stdioStream)
@@ -7843,6 +8475,12 @@ export class Lowerer {
7843
8475
  if (adapted)
7844
8476
  return adapted;
7845
8477
  }
8478
+ // Iterable-typed slots: other iterators enter the generator arm.
8479
+ if (expected.kind === "union" && !typeEquals(expr.type, expected)) {
8480
+ const iterable = iterableSlotValue(this, expr, expected);
8481
+ if (iterable)
8482
+ return iterable;
8483
+ }
7846
8484
  // an any-typed slot marshals implicitly (tsc allows the assignment;
7847
8485
  // the marshal is where its semantics live). OUT: an 'any' value
7848
8486
  // flowing into a typed slot compiles to a VALIDATED exit — like every
@@ -7923,6 +8561,11 @@ export class Lowerer {
7923
8561
  // constructor. `require("events")` is the EventEmitter class itself,
7924
8562
  // so its module binding is too (`ReleaseEmitter = EventEmitter` over
7925
8563
  // `const EventEmitter = require("events")`).
8564
+ if (expr.type.kind === "moduleNs" && isJsSourceFileName(expr.loc.file)) {
8565
+ const object = moduleNamespaceObject(this, expr);
8566
+ if (object)
8567
+ return object;
8568
+ }
7926
8569
  if (expr.type.kind === "moduleNs" &&
7927
8570
  expr.type.moduleId === "builtin:events" &&
7928
8571
  isJsSourceFileName(expr.loc.file)) {
@@ -8030,10 +8673,19 @@ export class Lowerer {
8030
8673
  // A HYBRID (function-with-properties) record flowing into a plain
8031
8674
  // func slot extracts its reserved %call field — the chalk shape's
8032
8675
  // "the value IS callable" half (type-mapper.ts's hybrid mapping).
8033
- if (expected.kind === "func" && expr.type.kind === "record") {
8676
+ if (expected.kind === "func" && (expr.type.kind === "record" || expr.type.kind === "object")) {
8034
8677
  const un = this.hybridCallUnwrap(expr);
8035
8678
  if (un !== expr && typeEquals(un.type, expected))
8036
8679
  return un;
8680
+ // A callable class instance (the chalk shim's variadic builder) in a
8681
+ // narrower function slot: its call closure crosses the checked
8682
+ // function boundary, which adapts the arity.
8683
+ if (un !== expr &&
8684
+ expr.type.kind === "object" &&
8685
+ un.type.kind === "func" &&
8686
+ canBoxFuncIntoDyn(un.type, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
8687
+ return this.coerceToExpected({ kind: "dynFrom", value: un, type: DYN, loc: un.loc }, expected);
8688
+ }
8037
8689
  }
8038
8690
  // A zero-param function whose RETURN is a wider record array than the
8039
8691
  // slot's (`getRoutes: () => cachedRoutes` against `() => Narrow[]`):
@@ -8453,6 +9105,19 @@ export class Lowerer {
8453
9105
  * directly when the expression was already lowered. */
8454
9106
  coerceInto(node, expr, expected) {
8455
9107
  refuseInferredCallbackDrops(this, node, expr.type, expected);
9108
+ // An assertion's scalar check whose value goes straight back into a
9109
+ // checked-dynamic slot (`process.loadEnvFile({} as unknown as string)`)
9110
+ // keeps the original value: JavaScript erases assertions, so the check
9111
+ // could only add a TypeError Node does not throw, and the slot holds
9112
+ // the value either way.
9113
+ if (expected.kind === "dyn" && expr.kind === "dynCheck" && expr.value.type.kind === "dyn") {
9114
+ let source = node;
9115
+ while (ts.isParenthesizedExpression(source))
9116
+ source = source.expression;
9117
+ if ((ts.isAsExpression(source) || ts.isTypeAssertion(source)) &&
9118
+ (expr.type.kind === "string" || expr.type.kind === "f64" || expr.type.kind === "bool"))
9119
+ return expr.value;
9120
+ }
8456
9121
  // A union destination can accept the binding's tagged storage directly.
8457
9122
  // The checker's single-arm flow type can be stale after a callback writes
8458
9123
  // the binding. Extracting that arm and wrapping it again would discard the
@@ -8717,6 +9382,40 @@ export class Lowerer {
8717
9382
  }
8718
9383
  return this.coerceInto(node, value, expected);
8719
9384
  }
9385
+ /** The right side of a write to a member of a typed view of the global
9386
+ * object (`(globalThis as typeof globalThis & { k?: T }).k = value`, also
9387
+ * through `??=` and `||=`) that is `value` itself or wraps only it in
9388
+ * parentheses or `satisfies`; null when `value` is not in such a write. */
9389
+ globalViewSlot(value) {
9390
+ let operand = value;
9391
+ while (operand.parent !== undefined &&
9392
+ (ts.isParenthesizedExpression(operand.parent) || ts.isSatisfiesExpression(operand.parent)))
9393
+ operand = operand.parent;
9394
+ const write = operand.parent;
9395
+ if (write === undefined ||
9396
+ !ts.isBinaryExpression(write) ||
9397
+ write.right !== operand ||
9398
+ (write.operatorToken.kind !== ts.SyntaxKind.EqualsToken &&
9399
+ write.operatorToken.kind !== ts.SyntaxKind.QuestionQuestionEqualsToken &&
9400
+ write.operatorToken.kind !== ts.SyntaxKind.BarBarEqualsToken))
9401
+ return null;
9402
+ let target = write.left;
9403
+ while (ts.isParenthesizedExpression(target))
9404
+ target = target.expression;
9405
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target))
9406
+ return null;
9407
+ const receiver = this.typeOf(target.expression);
9408
+ const isGlobal = (type) => {
9409
+ const symbol = type.getSymbol();
9410
+ return (symbol !== undefined &&
9411
+ ts.symbolName(symbol) === "globalThis" &&
9412
+ symbol.declarations.length === 0);
9413
+ };
9414
+ return isGlobal(receiver) ||
9415
+ (receiver.isIntersectionType() && ts.constituentTypes(receiver).some(isGlobal))
9416
+ ? operand
9417
+ : null;
9418
+ }
8720
9419
  /** Lower for a known destination, then apply ordinary value coercion.
8721
9420
  * Fresh arrays and records use the destination layout directly. */
8722
9421
  lowerExprExpecting(node, expected) {
@@ -8725,6 +9424,9 @@ export class Lowerer {
8725
9424
  // retain their own checked conversion and must not be erased here.
8726
9425
  while (ts.isParenthesizedExpression(node) || ts.isSatisfiesExpression(node))
8727
9426
  node = node.expression;
9427
+ const staged = this.stagedArgument(node);
9428
+ if (staged)
9429
+ return expected ? this.coerceInto(node, staged, expected) : staged;
8728
9430
  if (expected) {
8729
9431
  if (ts.isConditionalExpression(node))
8730
9432
  return lowerTernary(this, node, expected);
@@ -8781,6 +9483,20 @@ export class Lowerer {
8781
9483
  // belong to the array the program keeps, rather than a typed snapshot.
8782
9484
  if (ts.isArrayLiteralExpression(x) &&
8783
9485
  x.elements.nodes.every((element) => !ts.isSpreadElement(element) && !ts.isOmittedExpression(element))) {
9486
+ // A checked slot that the program declares as a native array (a
9487
+ // member of a typed view of the global object, `typeof globalThis &
9488
+ // { cache?: number[] }`) is read back through that declaration. Build
9489
+ // the native array and store it boxed: every typed read then extracts
9490
+ // that same array (a dynamic literal would be copied on each read,
9491
+ // losing writes such as push).
9492
+ const slot = this.globalViewSlot(x);
9493
+ const slotType = slot ? this.checker.getContextualType(slot) : undefined;
9494
+ const declared = slotType && this.checker.getNonNullableType(slotType);
9495
+ const native = declared && !(declared.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
9496
+ ? this.mapTypeOf(declared)
9497
+ : null;
9498
+ if (native?.kind === "array")
9499
+ return this.coerceInto(node, this.lowerArrayLiteral(x, native), DYN);
8784
9500
  return {
8785
9501
  kind: "dynArrLit",
8786
9502
  elems: x.elements.nodes.map((element) => this.lowerExprExpecting(element, DYN)),
@@ -8807,7 +9523,9 @@ export class Lowerer {
8807
9523
  builtinOption("UrlObject") ||
8808
9524
  builtinOption("URLFormatOptions") ||
8809
9525
  !this.mapTypeOf(this.typeOf(x)) ||
8810
- this.excessJsContextualProperty(x, parts)) {
9526
+ this.excessJsContextualProperty(x, parts) ||
9527
+ this.reshapeableContextualLiteral(x, parts) ||
9528
+ holdsEvolvingArray(this, x)) {
8811
9529
  return lowerDynObjectLiteral(this, x);
8812
9530
  }
8813
9531
  }
@@ -8986,8 +9704,27 @@ export class Lowerer {
8986
9704
  // must not force an intermediate record with incompatible field slots.
8987
9705
  if (this.returnsLiteralIntoDyn(node, expected))
8988
9706
  return this.lowerExprExpecting(node, expected);
9707
+ if (this.returnsFreshCollection(node) && expected.kind !== "void")
9708
+ return this.lowerExprExpecting(node, expected);
8989
9709
  return this.asyncReturnValueOf(node, this.lowerExpr(node), expected);
8990
9710
  }
9711
+ /** An array literal or a `new Map(...)`, `new Set(...)` or `new
9712
+ * Array(...)` of the builtins: a fresh collection, never a thenable, so
9713
+ * an async return takes the declared result type as its construction
9714
+ * layout the way a synchronous return does (`return []` in a function
9715
+ * whose inferred result is `Promise<string[]>`). */
9716
+ returnsFreshCollection(node) {
9717
+ let e = node;
9718
+ while (ts.isParenthesizedExpression(e))
9719
+ e = e.expression;
9720
+ if (ts.isArrayLiteralExpression(e))
9721
+ return true;
9722
+ return (ts.isNewExpression(e) &&
9723
+ ts.isIdentifier(e.expression) &&
9724
+ (this.isStdlibGlobal(e.expression, "Map") ||
9725
+ this.isStdlibGlobal(e.expression, "Set") ||
9726
+ this.isStdlibGlobal(e.expression, "Array")));
9727
+ }
8991
9728
  /** A fresh JS object literal returned into a checked-native (dyn) result,
8992
9729
  * which lowers straight into that storage. */
8993
9730
  returnsLiteralIntoDyn(node, expected) {
@@ -9113,7 +9850,9 @@ export class Lowerer {
9113
9850
  loc,
9114
9851
  };
9115
9852
  }
9116
- if (this.adoptsReturnedPromise() && !this.returnsLiteralIntoDyn(node, expected)) {
9853
+ if (this.adoptsReturnedPromise() &&
9854
+ !this.returnsLiteralIntoDyn(node, expected) &&
9855
+ !this.returnsFreshCollection(node)) {
9117
9856
  // The async return lowers its operand untyped first (a promise
9118
9857
  // adopts before its payload converts); a maybe-promise union needs
9119
9858
  // the statement form, which branches between adoption and fulfillment.
@@ -9499,8 +10238,8 @@ export class Lowerer {
9499
10238
  throw e;
9500
10239
  }
9501
10240
  }
9502
- lowerClassExpression(expr) {
9503
- return lowerClassExpression(this, expr);
10241
+ lowerClassExpression(expr, binding) {
10242
+ return lowerClassExpression(this, expr, binding);
9504
10243
  }
9505
10244
  /* ── the class graph (single inheritance) ─────────────────────────── */
9506
10245
  findMethodOn(info, name) {
@@ -10453,10 +11192,23 @@ export class Lowerer {
10453
11192
  }
10454
11193
  /* ── expressions ──────────────────────────────────────────────────── */
10455
11194
  lowerExpr(expr) {
10456
- const hash = this.hashStreamReceivers.get(expr);
10457
- if (hash)
10458
- return hashStreamOf(varRef(hash.localId, hash.type, locOf(expr)));
10459
- return lowerExpr(this, expr);
11195
+ const streamValue = this.valueStreamReceivers.get(expr);
11196
+ if (streamValue)
11197
+ return valueStreamOf(varRef(streamValue.localId, streamValue.type, locOf(expr)));
11198
+ return this.stagedArgument(expr) ?? lowerExpr(this, expr);
11199
+ }
11200
+ /** The saved value of a staged fs argument (stagedArguments, keyed
11201
+ * without type-only wrappers), or null for every other expression. */
11202
+ stagedArgument(node) {
11203
+ if (this.stagedArguments.size === 0)
11204
+ return null;
11205
+ node = stripTypeWrappers(node);
11206
+ if (!this.stagedArguments.has(node))
11207
+ return null;
11208
+ const slot = this.stagedArguments.get(node);
11209
+ if (!slot)
11210
+ throw new InternalCompilerError("an fs argument lowered before the URL path it follows");
11211
+ return varRef(slot.localId, slot.type, locOf(node));
10460
11212
  }
10461
11213
  lowerIntrinsicProperty(expr) {
10462
11214
  // The builtin-spoke property extensions (Stats.mtimeMs,
@@ -10586,7 +11338,7 @@ export class Lowerer {
10586
11338
  return lowerRecordKeyRead(this, expr, shapeId, shape, includeUndefined);
10587
11339
  }
10588
11340
  lowerElementWrite(expr) {
10589
- return lowerElementWrite(this, expr);
11341
+ return markSloppyRecordWrites(this, lowerElementWrite(this, expr), expr);
10590
11342
  }
10591
11343
  lowerLiveWebValue(node) {
10592
11344
  return lowerLiveWebValue(this, node);
@@ -10715,6 +11467,25 @@ export class Lowerer {
10715
11467
  return lower();
10716
11468
  return this.withExpressionOverride(node, this.checkedNarrowCall(helper, optional.value, optional.present, locOf(node)), lower);
10717
11469
  }
11470
+ /** withExpressionOverride for several nodes at once. */
11471
+ withExpressionOverrides(overrides, lower) {
11472
+ const previous = overrides.map((override) => this.chainRecvByNode.get(override.node));
11473
+ for (const override of overrides)
11474
+ this.chainRecvByNode.set(override.node, override.value);
11475
+ try {
11476
+ return lower();
11477
+ }
11478
+ finally {
11479
+ for (let i = overrides.length - 1; i >= 0; i--) {
11480
+ const node = overrides[i].node;
11481
+ const value = previous[i];
11482
+ if (value)
11483
+ this.chainRecvByNode.set(node, value);
11484
+ else
11485
+ this.chainRecvByNode.delete(node);
11486
+ }
11487
+ }
11488
+ }
10718
11489
  withExpressionOverride(node, value, lower) {
10719
11490
  const previous = this.chainRecvByNode.get(node);
10720
11491
  this.chainRecvByNode.set(node, value);
@@ -10736,7 +11507,8 @@ export class Lowerer {
10736
11507
  if (webAssembly !== null)
10737
11508
  return webAssembly;
10738
11509
  refuseWebAssemblyUse(this, expr.expression);
10739
- return (lowerLifetimeRegionCall(this, expr) ??
11510
+ return (lowerErrorFunctionCall(this, expr) ??
11511
+ lowerLifetimeRegionCall(this, expr) ??
10740
11512
  lowerInternTableCall(this, expr) ??
10741
11513
  lowerThreadSlotsCall(this, expr) ??
10742
11514
  lowerFfiCall(this, expr) ??
@@ -10752,6 +11524,7 @@ export class Lowerer {
10752
11524
  lowerWebCryptoCall(this, expr) ??
10753
11525
  lowerKeyObjectCall(this, expr) ??
10754
11526
  lowerEcdhCall(this, expr) ??
11527
+ lowerDiffieHellmanCall(this, expr) ??
10755
11528
  lowerNetAddressCall(this, expr) ??
10756
11529
  lowerFetchElementMethodCall(this, expr) ??
10757
11530
  lowerDynamicImportCall(this, expr) ??
@@ -10864,7 +11637,7 @@ export class Lowerer {
10864
11637
  : null;
10865
11638
  }
10866
11639
  fieldSetStmt(target, value, loc, blame) {
10867
- return fieldSetStmt(this, target, value, loc, blame);
11640
+ return markSloppyRecordWrites(this, fieldSetStmt(this, target, value, loc, blame), blame);
10868
11641
  }
10869
11642
  lowerFieldCompound(access, op, rhsNode, loc) {
10870
11643
  return lowerFieldCompound(this, access, op, rhsNode, loc);
@@ -10894,6 +11667,7 @@ export class Lowerer {
10894
11667
  lowerBlobNew(this, expr) ??
10895
11668
  lowerNetAddressNew(this, expr) ??
10896
11669
  lowerStaticReadableStreamNew(this, expr) ??
11670
+ lowerStaticTransformStreamNew(this, expr) ??
10897
11671
  lowerConsoleNew(this, expr);
10898
11672
  return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
10899
11673
  }
@@ -11259,6 +12033,10 @@ export class Lowerer {
11259
12033
  if (callable)
11260
12034
  return callable;
11261
12035
  }
12036
+ // node:crypto's webcrypto is the WebCrypto global's object.
12037
+ if (bi.module === "crypto" && bi.member === "webcrypto") {
12038
+ return { kind: "libCall", fn: "webcrypto.object", args: [], type: DYN, loc };
12039
+ }
11262
12040
  // node:stream/web's exports are the web stream globals themselves: in
11263
12041
  // JavaScript sources the same identity token as the global spelling
11264
12042
  // (`require("stream/web").ReadableStream === globalThis.ReadableStream`).
@@ -11328,7 +12106,7 @@ export class Lowerer {
11328
12106
  const key = `${fn.valueFn ?? fn.fn}:${typeKey(funcType)}:${adapterShape}`;
11329
12107
  let fnName = this.builtinCallableValueFns.get(key);
11330
12108
  if (!fnName) {
11331
- fnName = `%builtin.value.${fn.valueFn ?? fn.fn}.${this.builtinCallableValueFns.size}`;
12109
+ fnName = keyedHelperName(this, `%builtin.value.${fn.valueFn ?? fn.fn}`, key);
11332
12110
  this.builtinCallableValueFns.set(key, fnName);
11333
12111
  this.builtinCallableValueNames.set(fnName, display.slice(display.lastIndexOf(".") + 1));
11334
12112
  const params = funcType.params.map((type, index) => ({