@scriptc/compiler 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1082) hide show
  1. package/ambient/node-fallback/child_process.d.ts +71 -22
  2. package/ambient/node-fallback/crypto.d.ts +15 -7
  3. package/ambient/node-fallback/events.d.ts +29 -6
  4. package/ambient/node-fallback/fs-promises.d.ts +1 -1
  5. package/ambient/node-fallback/fs.d.ts +57 -12
  6. package/ambient/node-fallback/http.d.ts +26 -18
  7. package/ambient/node-fallback/https.d.ts +5 -2
  8. package/ambient/node-fallback/net.d.ts +25 -0
  9. package/ambient/node-fallback/os.d.ts +11 -1
  10. package/ambient/node-fallback/path-posix.d.ts +6 -0
  11. package/ambient/node-fallback/path-win32.d.ts +5 -0
  12. package/ambient/node-fallback/path.d.ts +2 -0
  13. package/ambient/node-fallback/querystring.d.ts +3 -3
  14. package/ambient/node-fallback/zlib.d.ts +31 -2
  15. package/ambient/scriptc-node-fallback.d.ts +95 -20
  16. package/ambient/scriptc.d.ts +7 -2
  17. package/dist/backend/executable-features.js +22 -1
  18. package/dist/backend/executable-features.js.map +1 -1
  19. package/dist/backend/immutability.d.ts +12 -1
  20. package/dist/backend/immutability.js +50 -4
  21. package/dist/backend/immutability.js.map +1 -1
  22. package/dist/backend/immutability.test.js +95 -1
  23. package/dist/backend/immutability.test.js.map +1 -1
  24. package/dist/backend/library-pack.d.ts +6 -0
  25. package/dist/backend/library-pack.js +18 -5
  26. package/dist/backend/library-pack.js.map +1 -1
  27. package/dist/backend/library-pack.test.d.ts +1 -0
  28. package/dist/backend/library-pack.test.js +28 -0
  29. package/dist/backend/library-pack.test.js.map +1 -0
  30. package/dist/backend/linker.d.ts +20 -2
  31. package/dist/backend/linker.js +221 -35
  32. package/dist/backend/linker.js.map +1 -1
  33. package/dist/backend/lld.d.ts +15 -6
  34. package/dist/backend/lld.js +24 -16
  35. package/dist/backend/lld.js.map +1 -1
  36. package/dist/backend/lld.test.js +13 -5
  37. package/dist/backend/lld.test.js.map +1 -1
  38. package/dist/backend/llvm/alloc.d.ts +15 -2
  39. package/dist/backend/llvm/alloc.js +172 -36
  40. package/dist/backend/llvm/alloc.js.map +1 -1
  41. package/dist/backend/llvm/alloc.test.js +69 -1
  42. package/dist/backend/llvm/alloc.test.js.map +1 -1
  43. package/dist/backend/llvm/arenas.d.ts +17 -4
  44. package/dist/backend/llvm/arenas.js +105 -10
  45. package/dist/backend/llvm/arenas.js.map +1 -1
  46. package/dist/backend/llvm/arenas.test.js +229 -0
  47. package/dist/backend/llvm/arenas.test.js.map +1 -1
  48. package/dist/backend/llvm/bytes-alias.js +10 -1
  49. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  50. package/dist/backend/llvm/bytes-headers.js +6 -0
  51. package/dist/backend/llvm/bytes-headers.js.map +1 -1
  52. package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
  53. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  54. package/dist/backend/llvm/call-lifetimes.js +10 -0
  55. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  56. package/dist/backend/llvm/classes.d.ts +16 -9
  57. package/dist/backend/llvm/classes.js +142 -37
  58. package/dist/backend/llvm/classes.js.map +1 -1
  59. package/dist/backend/llvm/classes.test.js +42 -0
  60. package/dist/backend/llvm/classes.test.js.map +1 -1
  61. package/dist/backend/llvm/constant-callbacks.test.js +50 -1
  62. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  63. package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
  64. package/dist/backend/llvm/cpu-dispatch.js +34 -9
  65. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  66. package/dist/backend/llvm/dyn.d.ts +64 -3
  67. package/dist/backend/llvm/dyn.js +251 -15
  68. package/dist/backend/llvm/dyn.js.map +1 -1
  69. package/dist/backend/llvm/emit-function.js +68 -5
  70. package/dist/backend/llvm/emit-function.js.map +1 -1
  71. package/dist/backend/llvm/emit-module.js +226 -77
  72. package/dist/backend/llvm/emit-module.js.map +1 -1
  73. package/dist/backend/llvm/emit-module.test.d.ts +1 -0
  74. package/dist/backend/llvm/emit-module.test.js +52 -0
  75. package/dist/backend/llvm/emit-module.test.js.map +1 -0
  76. package/dist/backend/llvm/emit-statements.js +138 -34
  77. package/dist/backend/llvm/emit-statements.js.map +1 -1
  78. package/dist/backend/llvm/emitter.d.ts +142 -10
  79. package/dist/backend/llvm/emitter.js +523 -73
  80. package/dist/backend/llvm/emitter.js.map +1 -1
  81. package/dist/backend/llvm/emitter.test.js +31 -3
  82. package/dist/backend/llvm/emitter.test.js.map +1 -1
  83. package/dist/backend/llvm/expr-async.js +19 -1
  84. package/dist/backend/llvm/expr-async.js.map +1 -1
  85. package/dist/backend/llvm/expr-bytes.js +16 -1
  86. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  87. package/dist/backend/llvm/expr-calls.d.ts +4 -1
  88. package/dist/backend/llvm/expr-calls.js +38 -6
  89. package/dist/backend/llvm/expr-calls.js.map +1 -1
  90. package/dist/backend/llvm/expr-dynamic.js +237 -23
  91. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  92. package/dist/backend/llvm/expr-primitives.js +123 -12
  93. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  94. package/dist/backend/llvm/expr-records.d.ts +1 -1
  95. package/dist/backend/llvm/expr-records.js +124 -56
  96. package/dist/backend/llvm/expr-records.js.map +1 -1
  97. package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
  98. package/dist/backend/llvm/expr-stream-bridges.js +59 -2
  99. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  100. package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
  101. package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
  102. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  103. package/dist/backend/llvm/integer-values.d.ts +2 -0
  104. package/dist/backend/llvm/integer-values.js +6 -0
  105. package/dist/backend/llvm/integer-values.js.map +1 -1
  106. package/dist/backend/llvm/js-groups.d.ts +21 -0
  107. package/dist/backend/llvm/js-groups.js +277 -0
  108. package/dist/backend/llvm/js-groups.js.map +1 -0
  109. package/dist/backend/llvm/js-ic.d.ts +57 -1
  110. package/dist/backend/llvm/js-ic.js +389 -22
  111. package/dist/backend/llvm/js-ic.js.map +1 -1
  112. package/dist/backend/llvm/lib-dispatch.js +152 -1
  113. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  114. package/dist/backend/llvm/lib-filesystem.js +116 -11
  115. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  116. package/dist/backend/llvm/lib-network.js +33 -6
  117. package/dist/backend/llvm/lib-network.js.map +1 -1
  118. package/dist/backend/llvm/lib-process.js +180 -27
  119. package/dist/backend/llvm/lib-process.js.map +1 -1
  120. package/dist/backend/llvm/lib-shared.js +139 -2
  121. package/dist/backend/llvm/lib-shared.js.map +1 -1
  122. package/dist/backend/llvm/lib-stream.js +67 -0
  123. package/dist/backend/llvm/lib-stream.js.map +1 -1
  124. package/dist/backend/llvm/local-union-storage.test.js +32 -0
  125. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  126. package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
  127. package/dist/backend/llvm/loop-entry-versions.js +43 -21
  128. package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
  129. package/dist/backend/llvm/loop-state.d.ts +7 -1
  130. package/dist/backend/llvm/loop-state.js +26 -3
  131. package/dist/backend/llvm/loop-state.js.map +1 -1
  132. package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
  133. package/dist/backend/llvm/map-entry-fusion.js +3 -3
  134. package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
  135. package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
  136. package/dist/backend/llvm/map-number-lookup.js +7 -3
  137. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  138. package/dist/backend/llvm/map-number-lookup.test.js +58 -17
  139. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  140. package/dist/backend/llvm/nullable-unions.js +7 -6
  141. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  142. package/dist/backend/llvm/nullable-unions.test.js +4 -1
  143. package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
  144. package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
  145. package/dist/backend/llvm/receiver-brackets.test.js +68 -0
  146. package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
  147. package/dist/backend/llvm/receivers.js +3 -0
  148. package/dist/backend/llvm/receivers.js.map +1 -1
  149. package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
  150. package/dist/backend/llvm/record-entry-fusion.js +217 -0
  151. package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
  152. package/dist/backend/llvm/record-results.d.ts +5 -2
  153. package/dist/backend/llvm/record-results.js +13 -12
  154. package/dist/backend/llvm/record-results.js.map +1 -1
  155. package/dist/backend/llvm/record-views.d.ts +22 -2
  156. package/dist/backend/llvm/record-views.js +147 -12
  157. package/dist/backend/llvm/record-views.js.map +1 -1
  158. package/dist/backend/llvm/record-views.test.js +76 -0
  159. package/dist/backend/llvm/record-views.test.js.map +1 -1
  160. package/dist/backend/llvm/reference-effects.js +1 -0
  161. package/dist/backend/llvm/reference-effects.js.map +1 -1
  162. package/dist/backend/llvm/reference-writes.js +4 -0
  163. package/dist/backend/llvm/reference-writes.js.map +1 -1
  164. package/dist/backend/llvm/region-ir.js +1 -0
  165. package/dist/backend/llvm/region-ir.js.map +1 -1
  166. package/dist/backend/llvm/region-sites.d.ts +18 -0
  167. package/dist/backend/llvm/region-sites.js +79 -1
  168. package/dist/backend/llvm/region-sites.js.map +1 -1
  169. package/dist/backend/llvm/runtime-registries.test.js +53 -6
  170. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  171. package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
  172. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  173. package/dist/backend/llvm/shapes.d.ts +36 -3
  174. package/dist/backend/llvm/shapes.js +201 -16
  175. package/dist/backend/llvm/shapes.js.map +1 -1
  176. package/dist/backend/llvm/shapes.test.js +4 -0
  177. package/dist/backend/llvm/shapes.test.js.map +1 -1
  178. package/dist/backend/llvm/speculative-integers.d.ts +10 -1
  179. package/dist/backend/llvm/speculative-integers.js +59 -8
  180. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  181. package/dist/backend/llvm/stack-objects.d.ts +1 -2
  182. package/dist/backend/llvm/stack-objects.js +8 -5
  183. package/dist/backend/llvm/stack-objects.js.map +1 -1
  184. package/dist/backend/llvm/unwind-abi.d.ts +3 -3
  185. package/dist/backend/llvm/unwind-abi.js +8 -3
  186. package/dist/backend/llvm/unwind-abi.js.map +1 -1
  187. package/dist/backend/llvm/walkers.d.ts +12 -0
  188. package/dist/backend/llvm/walkers.js +47 -3
  189. package/dist/backend/llvm/walkers.js.map +1 -1
  190. package/dist/backend/may-throw.js +12 -2
  191. package/dist/backend/may-throw.js.map +1 -1
  192. package/dist/backend/may-throw.test.js +13 -0
  193. package/dist/backend/may-throw.test.js.map +1 -1
  194. package/dist/backend/native/contracts.d.ts +94 -0
  195. package/dist/backend/native/executable.js +134 -10
  196. package/dist/backend/native/executable.js.map +1 -1
  197. package/dist/backend/native/helper-identity-record.d.ts +11 -0
  198. package/dist/backend/native/helper-identity-record.js +76 -0
  199. package/dist/backend/native/helper-identity-record.js.map +1 -0
  200. package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
  201. package/dist/backend/native/helper-identity-record.test.js +101 -0
  202. package/dist/backend/native/helper-identity-record.test.js.map +1 -0
  203. package/dist/backend/native/library.js +10 -2
  204. package/dist/backend/native/library.js.map +1 -1
  205. package/dist/backend/native/runtime-inputs.js +8 -1
  206. package/dist/backend/native/runtime-inputs.js.map +1 -1
  207. package/dist/backend/native/vendor.d.ts +1 -1
  208. package/dist/backend/native/vendor.js +1 -1
  209. package/dist/backend/native/vendor.js.map +1 -1
  210. package/dist/backend/native-codegen-core.d.ts +13 -10
  211. package/dist/backend/native-codegen-core.js +26 -13
  212. package/dist/backend/native-codegen-core.js.map +1 -1
  213. package/dist/backend/native-codegen.js +30 -8
  214. package/dist/backend/native-codegen.js.map +1 -1
  215. package/dist/backend/native-codegen.test.js +110 -14
  216. package/dist/backend/native-codegen.test.js.map +1 -1
  217. package/dist/backend/native-link-info-core.d.ts +72 -0
  218. package/dist/backend/native-link-info-core.js.map +1 -1
  219. package/dist/backend/native-link-info.js +1 -0
  220. package/dist/backend/native-link-info.js.map +1 -1
  221. package/dist/backend/native-profile.d.ts +4 -1
  222. package/dist/backend/native-profile.js +12 -1
  223. package/dist/backend/native-profile.js.map +1 -1
  224. package/dist/backend/native-profile.test.js +10 -0
  225. package/dist/backend/native-profile.test.js.map +1 -1
  226. package/dist/backend/publication.d.ts +4 -1
  227. package/dist/backend/publication.js +4 -2
  228. package/dist/backend/publication.js.map +1 -1
  229. package/dist/backend/runtime-abi.d.ts +2 -2
  230. package/dist/backend/runtime-abi.js +2 -2
  231. package/dist/backend/runtime-pack-core.d.ts +46 -7
  232. package/dist/backend/runtime-pack-core.js +37 -2
  233. package/dist/backend/runtime-pack-core.js.map +1 -1
  234. package/dist/backend/runtime-pack-native.d.ts +18 -1
  235. package/dist/backend/runtime-pack-native.js +138 -29
  236. package/dist/backend/runtime-pack-native.js.map +1 -1
  237. package/dist/backend/runtime-pack-native.test.js +166 -4
  238. package/dist/backend/runtime-pack-native.test.js.map +1 -1
  239. package/dist/backend/runtime-pack-targets.test.js +3 -1
  240. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  241. package/dist/backend/runtime-pack.d.ts +7 -0
  242. package/dist/backend/runtime-pack.js +25 -3
  243. package/dist/backend/runtime-pack.js.map +1 -1
  244. package/dist/backend/runtime-pack.test.js +213 -12
  245. package/dist/backend/runtime-pack.test.js.map +1 -1
  246. package/dist/backend/tree-classes.d.ts +42 -0
  247. package/dist/backend/tree-classes.js +723 -0
  248. package/dist/backend/tree-classes.js.map +1 -0
  249. package/dist/backend/tree-classes.test.d.ts +1 -0
  250. package/dist/backend/tree-classes.test.js +338 -0
  251. package/dist/backend/tree-classes.test.js.map +1 -0
  252. package/dist/backend/vendor-archives.d.ts +8 -1
  253. package/dist/backend/vendor-archives.js +313 -8
  254. package/dist/backend/vendor-archives.js.map +1 -1
  255. package/dist/backend/vendor-inputs.d.ts +60 -3
  256. package/dist/backend/vendor-inputs.js +109 -3
  257. package/dist/backend/vendor-inputs.js.map +1 -1
  258. package/dist/backend/vendor-inputs.test.js +62 -1
  259. package/dist/backend/vendor-inputs.test.js.map +1 -1
  260. package/dist/backend/warm-cache.js +2 -0
  261. package/dist/backend/warm-cache.js.map +1 -1
  262. package/dist/compat/fetch-profile.d.ts +7 -1
  263. package/dist/compat/fetch-profile.js +25 -12
  264. package/dist/compat/fetch-profile.js.map +1 -1
  265. package/dist/compile-types.d.ts +7 -0
  266. package/dist/contracts/check.d.ts +3 -0
  267. package/dist/contracts/check.js +18 -5
  268. package/dist/contracts/check.js.map +1 -1
  269. package/dist/coverage/report.js +47 -0
  270. package/dist/coverage/report.js.map +1 -1
  271. package/dist/coverage/surface-manifest.js +1 -1
  272. package/dist/coverage/surface-manifest.js.map +1 -1
  273. package/dist/diagnostics/codes.d.ts +14 -0
  274. package/dist/diagnostics/codes.js +14 -0
  275. package/dist/diagnostics/codes.js.map +1 -1
  276. package/dist/diagnostics/diagnostic.d.ts +68 -0
  277. package/dist/diagnostics/diagnostic.js +186 -6
  278. package/dist/diagnostics/diagnostic.js.map +1 -1
  279. package/dist/diagnostics/dynamic-tier.js +3 -1
  280. package/dist/diagnostics/dynamic-tier.js.map +1 -1
  281. package/dist/diagnostics/envelope.d.ts +18 -0
  282. package/dist/diagnostics/envelope.js.map +1 -1
  283. package/dist/executable/executable-cache.d.ts +48 -0
  284. package/dist/executable/executable-cache.js +38 -0
  285. package/dist/executable/executable-cache.js.map +1 -1
  286. package/dist/executable/executable-cache.test.js +127 -1
  287. package/dist/executable/executable-cache.test.js.map +1 -1
  288. package/dist/executable/prepare.d.ts +13 -3
  289. package/dist/executable/prepare.js +438 -234
  290. package/dist/executable/prepare.js.map +1 -1
  291. package/dist/frontend/analysis.js +200 -18
  292. package/dist/frontend/analysis.js.map +1 -1
  293. package/dist/frontend/builtin-modules.d.ts +4 -0
  294. package/dist/frontend/builtin-modules.js +10 -0
  295. package/dist/frontend/builtin-modules.js.map +1 -1
  296. package/dist/frontend/early-errors.d.ts +24 -0
  297. package/dist/frontend/early-errors.js +836 -0
  298. package/dist/frontend/early-errors.js.map +1 -0
  299. package/dist/frontend/early-errors.test.d.ts +1 -0
  300. package/dist/frontend/early-errors.test.js +207 -0
  301. package/dist/frontend/early-errors.test.js.map +1 -0
  302. package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
  303. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  304. package/dist/frontend/input-tracker.d.ts +47 -0
  305. package/dist/frontend/input-tracker.js +173 -36
  306. package/dist/frontend/input-tracker.js.map +1 -1
  307. package/dist/frontend/input-tracker.test.js +86 -2
  308. package/dist/frontend/input-tracker.test.js.map +1 -1
  309. package/dist/frontend/js-inference.d.ts +2 -0
  310. package/dist/frontend/js-inference.js +18 -0
  311. package/dist/frontend/js-inference.js.map +1 -0
  312. package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
  313. package/dist/frontend/jsx-opinion-sites.test.js +86 -0
  314. package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
  315. package/dist/frontend/lib-exports.d.ts +23 -4
  316. package/dist/frontend/lib-exports.js +98 -26
  317. package/dist/frontend/lib-exports.js.map +1 -1
  318. package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
  319. package/dist/frontend/lowering/binding-analysis.js +86 -4
  320. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  321. package/dist/frontend/lowering/buffers.d.ts +8 -0
  322. package/dist/frontend/lowering/buffers.js +43 -0
  323. package/dist/frontend/lowering/buffers.js.map +1 -0
  324. package/dist/frontend/lowering/builtin-calls.js +13 -0
  325. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  326. package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
  327. package/dist/frontend/lowering/builtin-namespaces.js +41 -3
  328. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  329. package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
  330. package/dist/frontend/lowering/builtin-statics.js +407 -0
  331. package/dist/frontend/lowering/builtin-statics.js.map +1 -0
  332. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  333. package/dist/frontend/lowering/builtins/arguments.js +12 -0
  334. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  335. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
  336. package/dist/frontend/lowering/builtins/atomics.js +87 -1
  337. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  338. package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
  339. package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
  340. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  341. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
  342. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
  343. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  344. package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
  345. package/dist/frontend/lowering/builtins/child-process.js +565 -28
  346. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  347. package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
  348. package/dist/frontend/lowering/builtins/compression.js +41 -21
  349. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  350. package/dist/frontend/lowering/builtins/constants.js +7 -2
  351. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  352. package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
  353. package/dist/frontend/lowering/builtins/dates.js +23 -1
  354. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  355. package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
  356. package/dist/frontend/lowering/builtins/environment.js +213 -2
  357. package/dist/frontend/lowering/builtins/environment.js.map +1 -1
  358. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
  359. package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
  360. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  361. package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
  362. package/dist/frontend/lowering/builtins/filesystem.js +185 -16
  363. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  364. package/dist/frontend/lowering/builtins/json.js +4 -0
  365. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  366. package/dist/frontend/lowering/builtins/module-calls.js +42 -3
  367. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  368. package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
  369. package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
  370. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
  371. package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
  372. package/dist/frontend/lowering/builtins/numbers.js +10 -2
  373. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  374. package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
  375. package/dist/frontend/lowering/builtins/operating-system.js +101 -20
  376. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  377. package/dist/frontend/lowering/builtins/process.d.ts +18 -2
  378. package/dist/frontend/lowering/builtins/process.js +386 -25
  379. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  380. package/dist/frontend/lowering/builtins/promises.js +169 -8
  381. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  382. package/dist/frontend/lowering/builtins/properties.js +6 -2
  383. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  384. package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
  385. package/dist/frontend/lowering/builtins/querystring.js +202 -18
  386. package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
  387. package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
  388. package/dist/frontend/lowering/builtins/readline.js +200 -38
  389. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  390. package/dist/frontend/lowering/builtins/reflection.js +60 -1
  391. package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
  392. package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
  393. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  394. package/dist/frontend/lowering/builtins/url.js +55 -13
  395. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  396. package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
  397. package/dist/frontend/lowering/builtins/v8.js +7 -5
  398. package/dist/frontend/lowering/builtins/v8.js.map +1 -1
  399. package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
  400. package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
  401. package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
  402. package/dist/frontend/lowering/builtins/webassembly.js +2 -0
  403. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  404. package/dist/frontend/lowering/call-arguments.d.ts +10 -0
  405. package/dist/frontend/lowering/call-arguments.js +37 -2
  406. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  407. package/dist/frontend/lowering/call-signatures.d.ts +10 -0
  408. package/dist/frontend/lowering/call-signatures.js +180 -0
  409. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  410. package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
  411. package/dist/frontend/lowering/cjs-exports-object.js +1 -1
  412. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  413. package/dist/frontend/lowering/cjs-inline-require.js +5 -0
  414. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  415. package/dist/frontend/lowering/class-construction.d.ts +14 -2
  416. package/dist/frontend/lowering/class-construction.js +99 -5
  417. package/dist/frontend/lowering/class-construction.js.map +1 -1
  418. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
  419. package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
  420. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  421. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
  422. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  423. package/dist/frontend/lowering/class-protocols.js +59 -10
  424. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  425. package/dist/frontend/lowering/class-prototypes.js +20 -15
  426. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  427. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  428. package/dist/frontend/lowering/class-runtime-statics.js +35 -1
  429. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  430. package/dist/frontend/lowering/class-unions.js +21 -4
  431. package/dist/frontend/lowering/class-unions.js.map +1 -1
  432. package/dist/frontend/lowering/class-views.d.ts +13 -0
  433. package/dist/frontend/lowering/class-views.js +51 -0
  434. package/dist/frontend/lowering/class-views.js.map +1 -0
  435. package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
  436. package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
  437. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  438. package/dist/frontend/lowering/coercions/state.d.ts +15 -0
  439. package/dist/frontend/lowering/coercions/state.js +24 -0
  440. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  441. package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
  442. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  443. package/dist/frontend/lowering/coercions/structural.js +39 -2
  444. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  445. package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
  446. package/dist/frontend/lowering/coercions/unions.js +54 -10
  447. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  448. package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
  449. package/dist/frontend/lowering/constructor-returns.js +284 -58
  450. package/dist/frontend/lowering/constructor-returns.js.map +1 -1
  451. package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
  452. package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
  453. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  454. package/dist/frontend/lowering/containers/array-construction.js +37 -8
  455. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  456. package/dist/frontend/lowering/containers/array-from-async.js +139 -3
  457. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
  458. package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
  459. package/dist/frontend/lowering/containers/array-iteration.js +24 -7
  460. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
  461. package/dist/frontend/lowering/containers/array-methods.js +30 -11
  462. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  463. package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
  464. package/dist/frontend/lowering/containers/bytes.js +450 -86
  465. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  466. package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
  467. package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
  468. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  469. package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
  470. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  471. package/dist/frontend/lowering/containers/collection-methods.js +52 -17
  472. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  473. package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
  474. package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
  475. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
  476. package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
  477. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  478. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
  479. package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
  480. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  481. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
  482. package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
  483. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  484. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  485. package/dist/frontend/lowering/crypto-tables.js +5 -5
  486. package/dist/frontend/lowering/dispatch-sites.js +3 -0
  487. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  488. package/dist/frontend/lowering/divergences.d.ts +40 -0
  489. package/dist/frontend/lowering/divergences.js +239 -20
  490. package/dist/frontend/lowering/divergences.js.map +1 -1
  491. package/dist/frontend/lowering/effect-free.d.ts +12 -0
  492. package/dist/frontend/lowering/effect-free.js +44 -0
  493. package/dist/frontend/lowering/effect-free.js.map +1 -0
  494. package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
  495. package/dist/frontend/lowering/expressions/array-literals.js +88 -10
  496. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  497. package/dist/frontend/lowering/expressions/binary.js +216 -14
  498. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  499. package/dist/frontend/lowering/expressions/element-access.js +272 -11
  500. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  501. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
  502. package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
  503. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  504. package/dist/frontend/lowering/expressions/identifiers.js +173 -4
  505. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  506. package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
  507. package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
  508. package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
  509. package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
  510. package/dist/frontend/lowering/expressions/narrowing.js +195 -18
  511. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  512. package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
  513. package/dist/frontend/lowering/expressions/object-literals.js +951 -240
  514. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  515. package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
  516. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  517. package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
  518. package/dist/frontend/lowering/expressions/property-access.js +1141 -87
  519. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  520. package/dist/frontend/lowering/expressions/relational.js +262 -4
  521. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  522. package/dist/frontend/lowering/expressions/typeof.js +25 -0
  523. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  524. package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
  525. package/dist/frontend/lowering/expressions/union-fields.js +103 -13
  526. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  527. package/dist/frontend/lowering/expressions/updates.js +156 -22
  528. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  529. package/dist/frontend/lowering/frozen-records.d.ts +6 -0
  530. package/dist/frontend/lowering/frozen-records.js +10 -4
  531. package/dist/frontend/lowering/frozen-records.js.map +1 -1
  532. package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
  533. package/dist/frontend/lowering/frozen-records.test.js +44 -0
  534. package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
  535. package/dist/frontend/lowering/function-names.d.ts +9 -0
  536. package/dist/frontend/lowering/function-names.js +95 -0
  537. package/dist/frontend/lowering/function-names.js.map +1 -0
  538. package/dist/frontend/lowering/function-returns.js +42 -13
  539. package/dist/frontend/lowering/function-returns.js.map +1 -1
  540. package/dist/frontend/lowering/general-streams.js +5 -0
  541. package/dist/frontend/lowering/general-streams.js.map +1 -1
  542. package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
  543. package/dist/frontend/lowering/generator-delegation.js +301 -118
  544. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  545. package/dist/frontend/lowering/generic-functions.d.ts +75 -0
  546. package/dist/frontend/lowering/generic-functions.js +790 -18
  547. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  548. package/dist/frontend/lowering/global-function-values.d.ts +25 -0
  549. package/dist/frontend/lowering/global-function-values.js +193 -0
  550. package/dist/frontend/lowering/global-function-values.js.map +1 -0
  551. package/dist/frontend/lowering/global-values.d.ts +15 -4
  552. package/dist/frontend/lowering/global-values.js +67 -9
  553. package/dist/frontend/lowering/global-values.js.map +1 -1
  554. package/dist/frontend/lowering/handle-properties.js +34 -1
  555. package/dist/frontend/lowering/handle-properties.js.map +1 -1
  556. package/dist/frontend/lowering/host-global-values.d.ts +31 -0
  557. package/dist/frontend/lowering/host-global-values.js +121 -0
  558. package/dist/frontend/lowering/host-global-values.js.map +1 -0
  559. package/dist/frontend/lowering/host-globals.d.ts +74 -0
  560. package/dist/frontend/lowering/host-globals.js +344 -0
  561. package/dist/frontend/lowering/host-globals.js.map +1 -0
  562. package/dist/frontend/lowering/http2-constants.js +1 -1
  563. package/dist/frontend/lowering/iterator-adapters.js +46 -17
  564. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  565. package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
  566. package/dist/frontend/lowering/iterator-prototype.js +160 -0
  567. package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
  568. package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
  569. package/dist/frontend/lowering/key-order-witness.js +571 -9
  570. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  571. package/dist/frontend/lowering/key-order-witness.test.js +1 -0
  572. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  573. package/dist/frontend/lowering/lib-boundary.js +25 -3
  574. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  575. package/dist/frontend/lowering/lower-assert.js +140 -16
  576. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  577. package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
  578. package/dist/frontend/lowering/lower-async-iteration.js +15 -0
  579. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  580. package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
  581. package/dist/frontend/lowering/lower-builtin-values.js +342 -58
  582. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  583. package/dist/frontend/lowering/lower-calls.d.ts +47 -1
  584. package/dist/frontend/lowering/lower-calls.js +1354 -273
  585. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  586. package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
  587. package/dist/frontend/lowering/lower-calls.test.js +121 -0
  588. package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
  589. package/dist/frontend/lowering/lower-classes.d.ts +36 -5
  590. package/dist/frontend/lowering/lower-classes.js +630 -89
  591. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  592. package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
  593. package/dist/frontend/lowering/lower-event-emitter.js +610 -98
  594. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  595. package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
  596. package/dist/frontend/lowering/lower-exprs.js +96 -20
  597. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  598. package/dist/frontend/lowering/lower-functions.js +27 -6
  599. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  600. package/dist/frontend/lowering/lower-generators.js +57 -10
  601. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  602. package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
  603. package/dist/frontend/lowering/lower-global-value.js +14 -5
  604. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  605. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  606. package/dist/frontend/lowering/lower-inspect.js +713 -92
  607. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  608. package/dist/frontend/lowering/lower-modules.js +135 -27
  609. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  610. package/dist/frontend/lowering/lower-namespaces.js +18 -0
  611. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  612. package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
  613. package/dist/frontend/lowering/lower-node-island.js +472 -67
  614. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  615. package/dist/frontend/lowering/lower-server.js +463 -96
  616. package/dist/frontend/lowering/lower-server.js.map +1 -1
  617. package/dist/frontend/lowering/lower-shared-modules.js +13 -1
  618. package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
  619. package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
  620. package/dist/frontend/lowering/lower-stdlib.js +77 -18
  621. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  622. package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
  623. package/dist/frontend/lowering/lower-stmts.js +831 -136
  624. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  625. package/dist/frontend/lowering/lower-stream.js +126 -8
  626. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  627. package/dist/frontend/lowering/lower-timers.js +243 -48
  628. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  629. package/dist/frontend/lowering/lower-url.js +6 -3
  630. package/dist/frontend/lowering/lower-url.js.map +1 -1
  631. package/dist/frontend/lowering/lowerer.d.ts +363 -21
  632. package/dist/frontend/lowering/lowerer.js +1224 -129
  633. package/dist/frontend/lowering/lowerer.js.map +1 -1
  634. package/dist/frontend/lowering/lowerer.test.js +19 -1
  635. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  636. package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
  637. package/dist/frontend/lowering/lowering-facts.js +323 -0
  638. package/dist/frontend/lowering/lowering-facts.js.map +1 -0
  639. package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
  640. package/dist/frontend/lowering/lowering-facts.test.js +100 -0
  641. package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
  642. package/dist/frontend/lowering/module-namespace-elements.js +15 -0
  643. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  644. package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
  645. package/dist/frontend/lowering/nan-coded-reads.js +112 -9
  646. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
  647. package/dist/frontend/lowering/new-target.js +2 -2
  648. package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
  649. package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
  650. package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
  651. package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
  652. package/dist/frontend/lowering/optional-arguments.js +26 -2
  653. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  654. package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
  655. package/dist/frontend/lowering/partial-assertions.js +189 -0
  656. package/dist/frontend/lowering/partial-assertions.js.map +1 -0
  657. package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
  658. package/dist/frontend/lowering/primitive-throws.js +241 -0
  659. package/dist/frontend/lowering/primitive-throws.js.map +1 -0
  660. package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
  661. package/dist/frontend/lowering/primitive-wrappers.js +221 -0
  662. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
  663. package/dist/frontend/lowering/private-statics.d.ts +46 -0
  664. package/dist/frontend/lowering/private-statics.js +322 -0
  665. package/dist/frontend/lowering/private-statics.js.map +1 -0
  666. package/dist/frontend/lowering/record-inherited.d.ts +17 -1
  667. package/dist/frontend/lowering/record-inherited.js +16 -2
  668. package/dist/frontend/lowering/record-inherited.js.map +1 -1
  669. package/dist/frontend/lowering/record-links.d.ts +73 -0
  670. package/dist/frontend/lowering/record-links.js +797 -0
  671. package/dist/frontend/lowering/record-links.js.map +1 -0
  672. package/dist/frontend/lowering/record-sources.d.ts +12 -1
  673. package/dist/frontend/lowering/record-sources.js +60 -0
  674. package/dist/frontend/lowering/record-sources.js.map +1 -1
  675. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
  676. package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
  677. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
  678. package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
  679. package/dist/frontend/lowering/runtime-optional-report.js +300 -0
  680. package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
  681. package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
  682. package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
  683. package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
  684. package/dist/frontend/lowering/static-typeof.d.ts +3 -1
  685. package/dist/frontend/lowering/static-typeof.js +6 -1
  686. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  687. package/dist/frontend/lowering/strict-equality.d.ts +4 -0
  688. package/dist/frontend/lowering/strict-equality.js +14 -0
  689. package/dist/frontend/lowering/strict-equality.js.map +1 -1
  690. package/dist/frontend/lowering/strict-mode.d.ts +1 -5
  691. package/dist/frontend/lowering/strict-mode.js +4 -30
  692. package/dist/frontend/lowering/strict-mode.js.map +1 -1
  693. package/dist/frontend/lowering/structural-instances.d.ts +7 -0
  694. package/dist/frontend/lowering/structural-instances.js +23 -0
  695. package/dist/frontend/lowering/structural-instances.js.map +1 -1
  696. package/dist/frontend/lowering/surfaces.d.ts +42 -1
  697. package/dist/frontend/lowering/surfaces.js +212 -71
  698. package/dist/frontend/lowering/surfaces.js.map +1 -1
  699. package/dist/frontend/lowering/union-retag.d.ts +13 -1
  700. package/dist/frontend/lowering/union-retag.js +55 -1
  701. package/dist/frontend/lowering/union-retag.js.map +1 -1
  702. package/dist/frontend/lowering/union-retag.test.js +51 -0
  703. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  704. package/dist/frontend/lowering/unit-journal.d.ts +136 -17
  705. package/dist/frontend/lowering/unit-journal.js +324 -53
  706. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  707. package/dist/frontend/lowering/unit-journal.test.js +126 -3
  708. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  709. package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
  710. package/dist/frontend/lowering/unit-reuse.js +1008 -0
  711. package/dist/frontend/lowering/unit-reuse.js.map +1 -0
  712. package/dist/frontend/lowering/width-lift.d.ts +12 -0
  713. package/dist/frontend/lowering/zlib-constants.js +3 -2
  714. package/dist/frontend/lowering/zlib-constants.js.map +1 -1
  715. package/dist/frontend/npm-file-import.test.d.ts +1 -0
  716. package/dist/frontend/npm-file-import.test.js +76 -0
  717. package/dist/frontend/npm-file-import.test.js.map +1 -0
  718. package/dist/frontend/npm-static.js +95 -11
  719. package/dist/frontend/npm-static.js.map +1 -1
  720. package/dist/frontend/npm-static.test.js +95 -2
  721. package/dist/frontend/npm-static.test.js.map +1 -1
  722. package/dist/frontend/npm.d.ts +9 -0
  723. package/dist/frontend/npm.js +82 -0
  724. package/dist/frontend/npm.js.map +1 -1
  725. package/dist/frontend/pipeline-native.js +2 -1
  726. package/dist/frontend/pipeline-native.js.map +1 -1
  727. package/dist/frontend/pipeline.d.ts +9 -4
  728. package/dist/frontend/pipeline.js +162 -38
  729. package/dist/frontend/pipeline.js.map +1 -1
  730. package/dist/frontend/pipeline.test.js +68 -11
  731. package/dist/frontend/pipeline.test.js.map +1 -1
  732. package/dist/frontend/program-node.d.ts +3 -0
  733. package/dist/frontend/program-node.js +13 -6
  734. package/dist/frontend/program-node.js.map +1 -1
  735. package/dist/frontend/program.d.ts +71 -2
  736. package/dist/frontend/program.js +836 -411
  737. package/dist/frontend/program.js.map +1 -1
  738. package/dist/frontend/program.test.js +37 -1
  739. package/dist/frontend/program.test.js.map +1 -1
  740. package/dist/frontend/provenance-core.js +4 -0
  741. package/dist/frontend/provenance-core.js.map +1 -1
  742. package/dist/frontend/services-node.d.ts +7 -0
  743. package/dist/frontend/services-node.js +32 -1
  744. package/dist/frontend/services-node.js.map +1 -1
  745. package/dist/frontend/services-node.test.js +51 -0
  746. package/dist/frontend/services-node.test.js.map +1 -1
  747. package/dist/frontend/services.d.ts +14 -0
  748. package/dist/frontend/services.js +52 -2
  749. package/dist/frontend/services.js.map +1 -1
  750. package/dist/frontend/services.test.js +61 -1
  751. package/dist/frontend/services.test.js.map +1 -1
  752. package/dist/frontend/shape-inference/analyze.d.ts +5 -0
  753. package/dist/frontend/shape-inference/analyze.js +104 -4
  754. package/dist/frontend/shape-inference/analyze.js.map +1 -1
  755. package/dist/frontend/shape-inference/domain.js +0 -1
  756. package/dist/frontend/shape-inference/domain.js.map +1 -1
  757. package/dist/frontend/shape-inference/index.js +5 -1
  758. package/dist/frontend/shape-inference/index.js.map +1 -1
  759. package/dist/frontend/shape-inference/memo.d.ts +2 -1
  760. package/dist/frontend/shape-inference/memo.js +6 -2
  761. package/dist/frontend/shape-inference/memo.js.map +1 -1
  762. package/dist/frontend/shape-inference/overlay.d.ts +1 -1
  763. package/dist/frontend/shape-inference/overlay.js +184 -4
  764. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  765. package/dist/frontend/shape-inference/static-objects.js +11 -6
  766. package/dist/frontend/shape-inference/static-objects.js.map +1 -1
  767. package/dist/frontend/source-phase-imports.test.d.ts +1 -0
  768. package/dist/frontend/source-phase-imports.test.js +37 -0
  769. package/dist/frontend/source-phase-imports.test.js.map +1 -0
  770. package/dist/frontend/tier-analysis.d.ts +9 -0
  771. package/dist/frontend/tier-analysis.js +1 -0
  772. package/dist/frontend/tier-analysis.js.map +1 -1
  773. package/dist/frontend/ts7/ast-node.d.ts +6 -1
  774. package/dist/frontend/ts7/ast-node.js +12 -0
  775. package/dist/frontend/ts7/ast-node.js.map +1 -1
  776. package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
  777. package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
  778. package/dist/frontend/ts7/ast-wire.js +3 -5
  779. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  780. package/dist/frontend/ts7/checker-backend.d.ts +13 -0
  781. package/dist/frontend/ts7/checker-backend.js +84 -2
  782. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  783. package/dist/frontend/ts7/checker-backend.test.js +126 -2
  784. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  785. package/dist/frontend/ts7/program-host.d.ts +22 -1
  786. package/dist/frontend/ts7/program-host.js +49 -4
  787. package/dist/frontend/ts7/program-host.js.map +1 -1
  788. package/dist/frontend/ts7/program-host.test.js +83 -0
  789. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  790. package/dist/frontend/ts7/rpc-process.d.ts +16 -1
  791. package/dist/frontend/ts7/rpc-process.js +170 -92
  792. package/dist/frontend/ts7/rpc-process.js.map +1 -1
  793. package/dist/frontend/ts7/rpc-process.test.js +49 -21
  794. package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
  795. package/dist/frontend/tsc-codes.d.ts +57 -3
  796. package/dist/frontend/tsc-codes.js +956 -101
  797. package/dist/frontend/tsc-codes.js.map +1 -1
  798. package/dist/frontend/tsc-codes.test.js +221 -12
  799. package/dist/frontend/tsc-codes.test.js.map +1 -1
  800. package/dist/frontend/type-mapper.d.ts +98 -11
  801. package/dist/frontend/type-mapper.js +770 -182
  802. package/dist/frontend/type-mapper.js.map +1 -1
  803. package/dist/index.d.ts +1 -1
  804. package/dist/index.js +224 -15
  805. package/dist/index.js.map +1 -1
  806. package/dist/index.test.d.ts +1 -0
  807. package/dist/index.test.js +60 -0
  808. package/dist/index.test.js.map +1 -0
  809. package/dist/ir/api.d.ts +1 -1
  810. package/dist/ir/api.js +1 -1
  811. package/dist/ir/api.js.map +1 -1
  812. package/dist/ir/build.d.ts +3 -2
  813. package/dist/ir/build.js +4 -2
  814. package/dist/ir/build.js.map +1 -1
  815. package/dist/ir/builtin-effects.js +96 -0
  816. package/dist/ir/builtin-effects.js.map +1 -1
  817. package/dist/ir/builtin-signatures.d.ts +1 -1
  818. package/dist/ir/builtin-signatures.js +453 -26
  819. package/dist/ir/builtin-signatures.js.map +1 -1
  820. package/dist/ir/callback-specialization.d.ts +3 -2
  821. package/dist/ir/callback-specialization.js +35 -25
  822. package/dist/ir/callback-specialization.js.map +1 -1
  823. package/dist/ir/capture-values.d.ts +8 -4
  824. package/dist/ir/capture-values.js +9 -6
  825. package/dist/ir/capture-values.js.map +1 -1
  826. package/dist/ir/char-unit-locals.d.ts +6 -2
  827. package/dist/ir/char-unit-locals.js +11 -2
  828. package/dist/ir/char-unit-locals.js.map +1 -1
  829. package/dist/ir/class-key-index.d.ts +18 -0
  830. package/dist/ir/class-key-index.js +29 -0
  831. package/dist/ir/class-key-index.js.map +1 -0
  832. package/dist/ir/class-key-index.test.d.ts +1 -0
  833. package/dist/ir/class-key-index.test.js +25 -0
  834. package/dist/ir/class-key-index.test.js.map +1 -0
  835. package/dist/ir/codec.d.ts +82 -0
  836. package/dist/ir/codec.generated.d.ts +13 -0
  837. package/dist/ir/codec.generated.js +5350 -0
  838. package/dist/ir/codec.generated.js.map +1 -0
  839. package/dist/ir/codec.js +325 -0
  840. package/dist/ir/codec.js.map +1 -0
  841. package/dist/ir/codec.test.d.ts +1 -0
  842. package/dist/ir/codec.test.js +225 -0
  843. package/dist/ir/codec.test.js.map +1 -0
  844. package/dist/ir/constant-globals.d.ts +5 -2
  845. package/dist/ir/constant-globals.js +25 -27
  846. package/dist/ir/constant-globals.js.map +1 -1
  847. package/dist/ir/expression-inlining.d.ts +4 -2
  848. package/dist/ir/expression-inlining.js +8 -2
  849. package/dist/ir/expression-inlining.js.map +1 -1
  850. package/dist/ir/field-values.d.ts +5 -2
  851. package/dist/ir/field-values.js +32 -21
  852. package/dist/ir/field-values.js.map +1 -1
  853. package/dist/ir/fields.generated.d.ts +29 -10
  854. package/dist/ir/fields.generated.js +1039 -11
  855. package/dist/ir/fields.generated.js.map +1 -1
  856. package/dist/ir/fields.test.js +46 -2
  857. package/dist/ir/fields.test.js.map +1 -1
  858. package/dist/ir/final-fields.js +1 -1
  859. package/dist/ir/final-fields.js.map +1 -1
  860. package/dist/ir/function-references.d.ts +6 -4
  861. package/dist/ir/function-references.js +11 -4
  862. package/dist/ir/function-references.js.map +1 -1
  863. package/dist/ir/function-references.test.js +14 -0
  864. package/dist/ir/function-references.test.js.map +1 -1
  865. package/dist/ir/init-only-globals.d.ts +4 -2
  866. package/dist/ir/init-only-globals.js +17 -18
  867. package/dist/ir/init-only-globals.js.map +1 -1
  868. package/dist/ir/inline-array-sources.js +4 -1
  869. package/dist/ir/inline-array-sources.js.map +1 -1
  870. package/dist/ir/inline-array-views.d.ts +13 -0
  871. package/dist/ir/inline-array-views.js +945 -0
  872. package/dist/ir/inline-array-views.js.map +1 -0
  873. package/dist/ir/inline-arrays.d.ts +7 -0
  874. package/dist/ir/inline-arrays.js +190 -55
  875. package/dist/ir/inline-arrays.js.map +1 -1
  876. package/dist/ir/inline-arrays.test.js +140 -2
  877. package/dist/ir/inline-arrays.test.js.map +1 -1
  878. package/dist/ir/int32-slots.js +7 -0
  879. package/dist/ir/int32-slots.js.map +1 -1
  880. package/dist/ir/integer-ranges.js +16 -6
  881. package/dist/ir/integer-ranges.js.map +1 -1
  882. package/dist/ir/ir.d.ts +130 -44
  883. package/dist/ir/ir.js +7 -0
  884. package/dist/ir/ir.js.map +1 -1
  885. package/dist/ir/js-groups.d.ts +51 -0
  886. package/dist/ir/js-groups.js +394 -0
  887. package/dist/ir/js-groups.js.map +1 -0
  888. package/dist/ir/js-groups.test.d.ts +1 -0
  889. package/dist/ir/js-groups.test.js +555 -0
  890. package/dist/ir/js-groups.test.js.map +1 -0
  891. package/dist/ir/js-ic.d.ts +10 -9
  892. package/dist/ir/js-ic.js +58 -25
  893. package/dist/ir/js-ic.js.map +1 -1
  894. package/dist/ir/js-ic.test.js +37 -3
  895. package/dist/ir/js-ic.test.js.map +1 -1
  896. package/dist/ir/jsval.js +374 -63
  897. package/dist/ir/jsval.js.map +1 -1
  898. package/dist/ir/jsval.test.js +96 -2
  899. package/dist/ir/jsval.test.js.map +1 -1
  900. package/dist/ir/loop-entry-ranges.js +112 -9
  901. package/dist/ir/loop-entry-ranges.js.map +1 -1
  902. package/dist/ir/loop-entry-ranges.test.js +40 -0
  903. package/dist/ir/loop-entry-ranges.test.js.map +1 -1
  904. package/dist/ir/node-index.d.ts +23 -6
  905. package/dist/ir/node-index.js +126 -49
  906. package/dist/ir/node-index.js.map +1 -1
  907. package/dist/ir/numeric-call-specialization.d.ts +4 -2
  908. package/dist/ir/numeric-call-specialization.js +40 -26
  909. package/dist/ir/numeric-call-specialization.js.map +1 -1
  910. package/dist/ir/paired-while-loops.d.ts +4 -2
  911. package/dist/ir/paired-while-loops.js +8 -2
  912. package/dist/ir/paired-while-loops.js.map +1 -1
  913. package/dist/ir/parameter-versions.d.ts +13 -3
  914. package/dist/ir/parameter-versions.js +63 -40
  915. package/dist/ir/parameter-versions.js.map +1 -1
  916. package/dist/ir/property-bags.d.ts +4 -2
  917. package/dist/ir/property-bags.js +22 -17
  918. package/dist/ir/property-bags.js.map +1 -1
  919. package/dist/ir/receiver-readers.js +58 -2
  920. package/dist/ir/receiver-readers.js.map +1 -1
  921. package/dist/ir/row-pairs.d.ts +4 -2
  922. package/dist/ir/row-pairs.js +12 -11
  923. package/dist/ir/row-pairs.js.map +1 -1
  924. package/dist/ir/runtime-features.d.ts +139 -5
  925. package/dist/ir/runtime-features.js +397 -19
  926. package/dist/ir/runtime-features.js.map +1 -1
  927. package/dist/ir/runtime-features.test.js +135 -1
  928. package/dist/ir/runtime-features.test.js.map +1 -1
  929. package/dist/ir/runtime-jam-loops.d.ts +35 -0
  930. package/dist/ir/runtime-jam-loops.js +604 -0
  931. package/dist/ir/runtime-jam-loops.js.map +1 -0
  932. package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
  933. package/dist/ir/runtime-jam-loops.test.js +565 -0
  934. package/dist/ir/runtime-jam-loops.test.js.map +1 -0
  935. package/dist/ir/saturating-loop-jams.d.ts +11 -2
  936. package/dist/ir/saturating-loop-jams.js +56 -16
  937. package/dist/ir/saturating-loop-jams.js.map +1 -1
  938. package/dist/ir/saturating-loop-jams.test.js +39 -1
  939. package/dist/ir/saturating-loop-jams.test.js.map +1 -1
  940. package/dist/ir/scalar-records.d.ts +5 -2
  941. package/dist/ir/scalar-records.js +12 -2
  942. package/dist/ir/scalar-records.js.map +1 -1
  943. package/dist/ir/self-captures.d.ts +4 -2
  944. package/dist/ir/self-captures.js +40 -28
  945. package/dist/ir/self-captures.js.map +1 -1
  946. package/dist/ir/self-captures.test.js +15 -0
  947. package/dist/ir/self-captures.test.js.map +1 -1
  948. package/dist/ir/serialize.d.ts +8 -2
  949. package/dist/ir/serialize.js +92 -24
  950. package/dist/ir/serialize.js.map +1 -1
  951. package/dist/ir/serialize.test.js +26 -0
  952. package/dist/ir/serialize.test.js.map +1 -1
  953. package/dist/ir/tiers.js +1 -0
  954. package/dist/ir/tiers.js.map +1 -1
  955. package/dist/ir/traverse.js +4 -0
  956. package/dist/ir/traverse.js.map +1 -1
  957. package/dist/ir/typed-argument-clones.d.ts +30 -0
  958. package/dist/ir/typed-argument-clones.js +789 -0
  959. package/dist/ir/typed-argument-clones.js.map +1 -0
  960. package/dist/ir/union-arm-loops.d.ts +3 -0
  961. package/dist/ir/union-arm-loops.js +373 -0
  962. package/dist/ir/union-arm-loops.js.map +1 -0
  963. package/dist/ir/union-arm-loops.test.d.ts +1 -0
  964. package/dist/ir/union-arm-loops.test.js +230 -0
  965. package/dist/ir/union-arm-loops.test.js.map +1 -0
  966. package/dist/ir/validate.js +170 -22
  967. package/dist/ir/validate.js.map +1 -1
  968. package/dist/ir/validate.test.js +46 -0
  969. package/dist/ir/validate.test.js.map +1 -1
  970. package/dist/library/compiler-self-identity.d.ts +8 -2
  971. package/dist/library/compiler-self-identity.js +92 -18
  972. package/dist/library/compiler-self-identity.js.map +1 -1
  973. package/dist/library/compiler-self-identity.test.js +150 -3
  974. package/dist/library/compiler-self-identity.test.js.map +1 -1
  975. package/dist/library/int-infer.d.ts +5 -0
  976. package/dist/library/int-infer.js +15 -3
  977. package/dist/library/int-infer.js.map +1 -1
  978. package/dist/library/ir-policy.js +4 -0
  979. package/dist/library/ir-policy.js.map +1 -1
  980. package/dist/library/library-cache.d.ts +4 -0
  981. package/dist/library/library-cache.js +2 -0
  982. package/dist/library/library-cache.js.map +1 -1
  983. package/dist/library/library-cache.test.js +26 -0
  984. package/dist/library/library-cache.test.js.map +1 -1
  985. package/dist/library/prepare.js +99 -31
  986. package/dist/library/prepare.js.map +1 -1
  987. package/dist/native/cache.d.ts +7 -0
  988. package/dist/native/cache.js +49 -0
  989. package/dist/native/cache.js.map +1 -1
  990. package/dist/native/cache.test.js +13 -1
  991. package/dist/native/cache.test.js.map +1 -1
  992. package/dist/native/cli.js +2 -0
  993. package/dist/native/cli.js.map +1 -1
  994. package/dist/native/compiler.js +26 -5
  995. package/dist/native/compiler.js.map +1 -1
  996. package/dist/native/executable-cache-open.test.js +31 -5
  997. package/dist/native/executable-cache-open.test.js.map +1 -1
  998. package/dist/native/executable-cache.d.ts +6 -1
  999. package/dist/native/executable-cache.js +7 -1
  1000. package/dist/native/executable-cache.js.map +1 -1
  1001. package/dist/native/prepare.d.ts +3 -0
  1002. package/dist/native/prepare.js +74 -28
  1003. package/dist/native/prepare.js.map +1 -1
  1004. package/dist/native/prepare.test.js +25 -3
  1005. package/dist/native/prepare.test.js.map +1 -1
  1006. package/dist/native/sanitizer.js +63 -4
  1007. package/dist/native/sanitizer.js.map +1 -1
  1008. package/dist/native/sanitizer.test.js +93 -2
  1009. package/dist/native/sanitizer.test.js.map +1 -1
  1010. package/dist/native/toolchain.js +9 -2
  1011. package/dist/native/toolchain.js.map +1 -1
  1012. package/dist/node-islands/boundary.d.ts +37 -1
  1013. package/dist/node-islands/boundary.js +65 -7
  1014. package/dist/node-islands/boundary.js.map +1 -1
  1015. package/dist/node-islands/boundary.test.d.ts +1 -0
  1016. package/dist/node-islands/boundary.test.js +76 -0
  1017. package/dist/node-islands/boundary.test.js.map +1 -0
  1018. package/dist/node-islands/detect.d.ts +27 -1
  1019. package/dist/node-islands/detect.js +475 -40
  1020. package/dist/node-islands/detect.js.map +1 -1
  1021. package/dist/node-islands/detect.test.js +175 -4
  1022. package/dist/node-islands/detect.test.js.map +1 -1
  1023. package/dist/node-islands/effect-gate.js +30 -20
  1024. package/dist/node-islands/effect-gate.js.map +1 -1
  1025. package/dist/node-islands/effect-gate.test.js +4 -1
  1026. package/dist/node-islands/effect-gate.test.js.map +1 -1
  1027. package/dist/node-islands/graph-islands.d.ts +40 -0
  1028. package/dist/node-islands/graph-islands.js +128 -0
  1029. package/dist/node-islands/graph-islands.js.map +1 -0
  1030. package/dist/node-islands/growth.d.ts +57 -0
  1031. package/dist/node-islands/growth.js +205 -0
  1032. package/dist/node-islands/growth.js.map +1 -0
  1033. package/dist/node-islands/libnode.d.ts +1 -1
  1034. package/dist/node-islands/libnode.js +1 -1
  1035. package/dist/node-islands/libnode.js.map +1 -1
  1036. package/dist/node-islands/modules.d.ts +28 -0
  1037. package/dist/node-islands/modules.js +156 -0
  1038. package/dist/node-islands/modules.js.map +1 -1
  1039. package/dist/node-islands/modules.test.js +105 -1
  1040. package/dist/node-islands/modules.test.js.map +1 -1
  1041. package/dist/node-islands/policy.js +2 -3
  1042. package/dist/node-islands/policy.js.map +1 -1
  1043. package/dist/node-islands/probe-recorder.d.ts +1 -0
  1044. package/dist/node-islands/probe-recorder.js +596 -0
  1045. package/dist/node-islands/probe-recorder.js.map +1 -0
  1046. package/dist/node-islands/probe-recorder.test.d.ts +1 -0
  1047. package/dist/node-islands/probe-recorder.test.js +80 -0
  1048. package/dist/node-islands/probe-recorder.test.js.map +1 -0
  1049. package/dist/node-islands/report.d.ts +12 -0
  1050. package/dist/node-islands/report.js +28 -0
  1051. package/dist/node-islands/report.js.map +1 -1
  1052. package/dist/node-islands/report.test.js +4 -0
  1053. package/dist/node-islands/report.test.js.map +1 -1
  1054. package/dist/node-islands/rules.js +9 -0
  1055. package/dist/node-islands/rules.js.map +1 -1
  1056. package/dist/node-islands/scan.d.ts +16 -1
  1057. package/dist/node-islands/scan.js +110 -9
  1058. package/dist/node-islands/scan.js.map +1 -1
  1059. package/dist/node-islands/snapshot.d.ts +38 -1
  1060. package/dist/node-islands/snapshot.js +165 -161
  1061. package/dist/node-islands/snapshot.js.map +1 -1
  1062. package/dist/node-islands/snapshot.test.js +63 -2
  1063. package/dist/node-islands/snapshot.test.js.map +1 -1
  1064. package/dist/node-islands/summary.js +8 -0
  1065. package/dist/node-islands/summary.js.map +1 -1
  1066. package/dist/node-islands/type-strip.d.ts +11 -0
  1067. package/dist/node-islands/type-strip.js +157 -0
  1068. package/dist/node-islands/type-strip.js.map +1 -0
  1069. package/dist/node-islands/type-strip.test.d.ts +1 -0
  1070. package/dist/node-islands/type-strip.test.js +31 -0
  1071. package/dist/node-islands/type-strip.test.js.map +1 -0
  1072. package/dist/project-config.d.ts +4 -0
  1073. package/dist/project-config.js +19 -0
  1074. package/dist/project-config.js.map +1 -1
  1075. package/dist/project-config.test.js +10 -0
  1076. package/dist/project-config.test.js.map +1 -1
  1077. package/dist/wasm/translate.js +11 -5
  1078. package/dist/wasm/translate.js.map +1 -1
  1079. package/dist/wasm/translate.test.js +35 -0
  1080. package/dist/wasm/translate.test.js.map +1 -1
  1081. package/package.json +20 -20
  1082. package/surface-manifest.json +221 -122
@@ -1,3 +1,4 @@
1
+ import { programCreatesWrappers, routeWrapperConsumers } from "./primitive-wrappers.js";
1
2
  import { markInferredFactChecks, shapeOverlayFileNames } from "../shape-inference/index.js";
2
3
  import { npmStaticPackageOfPath } from "../npm-static.js";
3
4
  import { globalMemberValue } from "./global-values.js";
@@ -5,18 +6,19 @@ import { unionNarrowFailureMessage } from "./union-narrow.js";
5
6
  import { arrayClassFieldsFn, arrayClassSpeciesFn, arrayOfClassInstance, arrayRootOf, lowerWithArraySpecies, } from "./builtins/array-classes.js";
6
7
  import { canonShadowHook, mapCanonical } from "../canon-map.js";
7
8
  import { Normalizer } from "../canon.js";
8
- import { compactDeclOrigins, inPackageFile, recordOrigin, slotOrigin, } from "./decl-origin.js";
9
- import { isDeclBoundaryFile } from "../decl-projection.js";
9
+ import { resolveEntryExportSymbol } from "../lib-exports.js";
10
+ import { compactDeclOrigins, recordOrigin, slotOrigin } from "./decl-origin.js";
10
11
  import { relieveHeapPressure } from "../../heap-pressure.js";
11
- import { checkedTable, countTable, fixedScalar, flagScalar, functionTable, irDataTable, journalDump, journalMode, lowerWaveRecorded, mapTable, setTable, waveStats, writeRecords, } from "./unit-journal.js";
12
+ import { checkedTable, countTable, fixedScalar, flagScalar, functionTable, irDataTable, journalDump, journalMode, HeldTables, lowerWaveRecorded, mapTable, setTable, waveStats, writeRecords, } from "./unit-journal.js";
13
+ import { UnitReuse, unitReuseVerify, verifyStoredUnit } from "./unit-reuse.js";
12
14
  import { moduleNamespaceDynValue, moduleNamespaceObject, moduleNamespaceValue, } from "./module-namespace-elements.js";
13
15
  import { keyedHelperName, moduleTagNumber, portableRelativePath } from "./stable-names.js";
14
16
  import { positionTag, StructuralPositions } from "./structural-positions.js";
15
- import { activeNodeIslands, isForeignType, setActiveNodeIslands, } from "../../node-islands/boundary.js";
17
+ import { activeNodeIslands, setActiveNodeIslands, } from "../../node-islands/boundary.js";
16
18
  import { bindingSymbolOfRead, onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
17
19
  import { needsGeneralNodeStreams, noteUntypedStreamFlow, stdioIntoGeneralStream, } from "./general-streams.js";
18
20
  import { extendAssertedRecordMembers } from "./assertion-members.js";
19
- import { jsDynamicDeclarations } from "./js-dynamic-objects.js";
21
+ import { LoweringFacts } from "./lowering-facts.js";
20
22
  import { isJsSourceFileName } from "../tsc-codes.js";
21
23
  import { builtinClassKind, builtinClassValue, builtinMemberClassKind, } from "./builtins/builtin-class-dyn.js";
22
24
  import { lifetimeRegionType, lowerLifetimeRegionCall, lowerLifetimeRegionNew, } from "./lifetime-regions.js";
@@ -30,11 +32,13 @@ import { checkRequireBindingAccesses, } from "./require-initialization.js";
30
32
  import { identityPreservingWidening } from "./coercions/identity.js";
31
33
  import { scanDivergences } from "./divergences.js";
32
34
  import { applyKeyOrderWitnesses, KeyOrderNotes } from "./key-order-witness.js";
35
+ import { installBuiltinStatics } from "./builtin-statics.js";
36
+ import { functionKeepsRecordSources } from "./record-sources.js";
33
37
  import { exprFunctionReference } from "../../ir/function-references.js";
34
38
  import { everyStmtList, observeRecordLiteralRebuilds } from "../../ir/traverse.js";
35
39
  import { checkedClassAssertion } from "./class-assertions.js";
36
40
  import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
37
- import { isOptionalProcessStreamProperty, isOptionalProcessVersionsRead, } from "./builtins/process.js";
41
+ import { isOptionalProcessStreamProperty, isOptionalProcessVersionsRead, programPatchesStdio, } from "./builtins/process.js";
38
42
  import { isSettledIteratorValueRead } from "./lower-generators.js";
39
43
  import { isRebindableFunctionSymbol } from "./rebindable-functions.js";
40
44
  import { concreteCollectionNarrow } from "./collection-narrowing.js";
@@ -63,10 +67,11 @@ import { widthCoerce, applyWidthLift, unionRecordWidthHelper, unionArrayWidthHel
63
67
  import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
64
68
  import { unionRetagMappable, narrowedRetagHelper, uninhabitedArmRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionRouteHelper, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, widthNarrowHelper, } from "./coercions/unions.js";
65
69
  import { assertedConversion } from "./coercions/asserted.js";
66
- import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
70
+ import { boxBuiltinValuesChecked, lowerUtilTypeValue, checkedNativeCallableValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
67
71
  import { devirtualizeVirtualCalls } from "./devirtualize.js";
68
72
  import { foldRegexSpanReads } from "./regex-span-reads.js";
69
73
  import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
74
+ import { runtimeOptionalNarrowings, } from "./runtime-optional-report.js";
70
75
  import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
71
76
  import { NarrowingStability, widenedReceiver } from "./narrowing-stability.js";
72
77
  import { ArrayElementStates } from "./runtime-optional-elements.js";
@@ -91,6 +96,7 @@ import { sloppyDynamicWrites } from "./frozen-records.js";
91
96
  import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
92
97
  import { applyHandleProperties } from "./handle-properties.js";
93
98
  import { installBufferValue } from "./containers/bytes.js";
99
+ import { installMutableBuffersArm } from "./buffers.js";
94
100
  import { ClassProtocols } from "./class-protocols.js";
95
101
  import { earlyReadVarSymbols } from "./var-hoisting.js";
96
102
  import { recordTextCodecClass } from "../../ir/ir.js";
@@ -101,7 +107,9 @@ import { returnDispatchReceivers } from "./receiver-returns.js";
101
107
  import { analyzeTiers, dynamicStatementCount, } from "../tier-analysis.js";
102
108
  import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
103
109
  import { finalizeClassMethodValues } from "./class-method-values.js";
110
+ import { finalizeRecordLinks } from "./record-links.js";
104
111
  import { finalizePrivateBrands } from "./private-brands.js";
112
+ import { finalizeFunctionNames } from "./function-names.js";
105
113
  import { INSPECT_CUSTOM_MEMBER, tableKeyFieldType } from "./symbol-fields.js";
106
114
  export { newFnCtx } from "./function-context.js";
107
115
  /* AST + checker → IR.
@@ -128,11 +136,11 @@ import { literalValues } from "../literal-values.js";
128
136
  import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
129
137
  import { declarationGroupKey, typeFailureOf } from "./type-failure.js";
130
138
  import { dynamicSlotDiag } from "../../diagnostics/dynamic-slots.js";
131
- import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, stdlibSnapshotValueUseDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
139
+ import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, hostGlobalDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, stdlibSnapshotValueUseDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
132
140
  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";
133
141
  import { provenanceActive } from "../provenance-registry.js";
134
- import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportsAssignedInFunctions, cjsReexportedModules, cjsNamespaceExportNames, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isFallbackDtsPath, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
135
- 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";
142
+ import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportsAssignedInFunctions, cjsReexportedModules, cjsNamespaceExportNames, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, locOf, orderedImportsOf, npmStaticDepSf7, requireSpecOf, isJsWriteTarget7, isStrictCode, resolveImport, workspacePackageOfPath, } from "../program.js";
143
+ import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, erasedOverloadMemberType, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isOverloadedCallableMemberType, isUnitOnlyTsType, isWorkerHandleType, isFetchHandleType, jsOpenObjectType, mapType, computeSymbolProvenance, declaresLegacyUrl, declaresWebAssemblyNamespace, ShapeRegistry, noteScopeSensitiveMapping, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
136
144
  import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
137
145
  import { builtinClassAliasOf, runtimeClassValueOfType, } from "./builtins/class-values.js";
138
146
  import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
@@ -146,7 +154,7 @@ import { mixinCallClassInfoOf, mixinIntersectionInstanceType, } from "./lower-mi
146
154
  import { tryLowerExpression } from "./expressions/try-lower-expression.js";
147
155
  import { funcTypeFromParamShapes, isThisParameter, paramShape, paramShapes, checkDefaultParamBodyType, requireExactArityValue, collectSignature, collectSignatureInner, lambdaSignature, } from "./call-signatures.js";
148
156
  import { dynamicOverloadChoice, guessedOverloadIdentifier } from "./overload-choice.js";
149
- import { implicitAnyParamSymbolsOf, implicitLocalFnNodeOf, implicitMonoFile, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, genericLocalClassBinding, } from "./generic-functions.js";
157
+ import { implicitAnyParamSymbolsOf, implicitLocalFnNodeOf, implicitMonoFile, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, genericLocalClassBinding, checkGenericIdentityPins, } from "./generic-functions.js";
150
158
  import { bindingNeverReassigned } from "./binding-analysis.js";
151
159
  import { isMessageListenerCall } from "./expressions/message-listeners.js";
152
160
  import { bodyReadsArguments } from "../arguments-usage.js";
@@ -169,7 +177,7 @@ import { lowerTimersPromisesSetInterval, lowerTimeoutMethodCall } from "./builti
169
177
  import { lowerFsToUnixTimestampCall, lowerFsLadderCall, lowerStatsMethodCall, } from "./builtins/filesystem.js";
170
178
  import { lowerSpawnSyncCall, lowerSpawnCall, lowerExecFileCall } from "./builtins/child-process.js";
171
179
  import { lowerExecSyncCall } from "./builtins/child-process-sync.js";
172
- import { isProcessEnv, envValueType, lowerProcessEnvGet } from "./builtins/environment.js";
180
+ import { isProcessEnv, envValueType, lowerProcessEnvGet, refuseHeldEnvWrite, } from "./builtins/environment.js";
173
181
  import { lowerJsonMethodCall, lowerJsonProperty } from "./builtins/json.js";
174
182
  import { lowerCryptoComposedCall, lowerCryptoModuleCall } from "./builtins/crypto.js";
175
183
  import { lowerUrlMethodCall, lowerSearchParamsMethodCall } from "./builtins/url.js";
@@ -207,12 +215,16 @@ import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShor
207
215
  import { lowerRecordFieldCall, lowerObjectMethodCall } from "./lower-calls.js";
208
216
  import { fenceCrossBlockNsRef, nsPathPrefix } from "./lower-namespaces.js";
209
217
  import { isSafeToRepeat } from "./expressions/evaluation-safety.js";
218
+ import { partialAssertionFields } from "./partial-assertions.js";
219
+ import { emptyArrayLiteralArm } from "./expressions/array-literals.js";
210
220
  import { lowerTernary } from "./lower-exprs.js";
211
221
  import { maybePromiseReturnStmt, maybePromiseUnionOf, promiseArmedUnionOf, } from "./maybe-promise.js";
212
222
  import { NodeIslandModuleCollector } from "../../node-islands/modules.js";
213
223
  /** Entry function name. '%' cannot appear in a TS identifier, so a user
214
224
  * function can never collide with it (mangling is injective per prefix). */
215
225
  export const ENTRY_NAME = "%main";
226
+ /** Stands for a null binding map in Lowerer.scopedTypeMemos. */
227
+ const NO_BINDINGS = {};
216
228
  /** Localized failure: rounds of the declaration flush retry. */
217
229
  const MAX_DECLARATION_RETRIES = 16;
218
230
  /** The slot kinds the declaration flush retry degrades (stage L2). */
@@ -464,7 +476,16 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
464
476
  const externalTypes = options.externalTypes ?? new Map();
465
477
  const externalTypeSpecifiersByFile = options.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(externalTypes);
466
478
  const tierMode = options.tierMode ?? "auto";
479
+ const runtimeOptionalReport = options.tierReport !== undefined;
480
+ // One island round lowers the same program through several passes:
481
+ // validation, reachable emit, the whole-slot comparison, the stream
482
+ // relowers, historical order and the coverage remainder. They differ only
483
+ // in their mode flags, so every fact they derive from the program alone is
484
+ // computed once here and shared (lowering-facts.ts); per-pass state stays
485
+ // private to the pass.
486
+ const facts = new LoweringFacts(program, moduleOrder, externalTypeSpecifiersByFile);
467
487
  const validation = new Lowerer(program, entry, moduleOrder, {
488
+ facts,
468
489
  frontendServices: options.frontendServices,
469
490
  projectCheckJs: options.projectCheckJs ?? false,
470
491
  targetPlatform,
@@ -478,6 +499,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
478
499
  externalTypes,
479
500
  externalTypeSpecifiersByFile,
480
501
  tierMode,
502
+ runtimeOptionalReport,
481
503
  });
482
504
  const ffiValidation = validateFfiImports(validation);
483
505
  timing("ffi-validate");
@@ -489,10 +511,12 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
489
511
  const reachableEmit = ffiImports.length === 0
490
512
  ? validation
491
513
  : new Lowerer(program, entry, moduleOrder, {
514
+ facts,
492
515
  frontendServices: options.frontendServices,
493
516
  projectCheckJs: options.projectCheckJs ?? false,
494
517
  targetPlatform,
495
518
  startupCrash,
519
+ admittedOpinions: options.admittedOpinions,
496
520
  inlineRequireCycleCalls,
497
521
  dynamicImportRejections: options.dynamicImportRejections,
498
522
  ffiImports,
@@ -502,13 +526,14 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
502
526
  externalTypes,
503
527
  externalTypeSpecifiersByFile,
504
528
  tierMode,
529
+ runtimeOptionalReport,
505
530
  ffiBindingSymbols: ffiValidation.symbolsByName,
506
531
  });
507
532
  for (const d of extraModuleCycleDiags)
508
533
  reachableEmit.pushDiag(d);
509
534
  for (const d of ffiValidation.diagnostics)
510
535
  reachableEmit.pushDiag(d);
511
- const emitted = reachableEmit.emitReachable(options.libRoots);
536
+ const emitted = reachableEmit.emitReachable(options.libRoots, options.unitStore ?? null);
512
537
  let { reachable } = emitted;
513
538
  let result = emitted.result;
514
539
  let resultLowerer = reachableEmit;
@@ -521,10 +546,12 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
521
546
  // keep push-down). A program that compiles never takes this path.
522
547
  if (result.diagnostics.length > 0 && reachableEmit.hasPartialDegradedTypes()) {
523
548
  const whole = new Lowerer(program, entry, moduleOrder, {
549
+ facts,
524
550
  frontendServices: options.frontendServices,
525
551
  projectCheckJs: options.projectCheckJs ?? false,
526
552
  targetPlatform,
527
553
  startupCrash,
554
+ admittedOpinions: options.admittedOpinions,
528
555
  inlineRequireCycleCalls,
529
556
  ffiImports,
530
557
  libraryCallbacks,
@@ -533,6 +560,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
533
560
  externalTypes,
534
561
  externalTypeSpecifiersByFile,
535
562
  tierMode,
563
+ runtimeOptionalReport,
536
564
  ffiBindingSymbols: ffiValidation.symbolsByName,
537
565
  wholeSlotDegradation: true,
538
566
  });
@@ -559,10 +587,12 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
559
587
  let dynNodeStreams = reachableEmit.requiresDynNodeStreams;
560
588
  const streamPass = (dyn) => {
561
589
  const general = new Lowerer(program, entry, moduleOrder, {
590
+ facts,
562
591
  frontendServices: options.frontendServices,
563
592
  projectCheckJs: options.projectCheckJs ?? false,
564
593
  targetPlatform,
565
594
  startupCrash,
595
+ admittedOpinions: options.admittedOpinions,
566
596
  inlineRequireCycleCalls,
567
597
  dynamicImportRejections: options.dynamicImportRejections,
568
598
  ffiImports,
@@ -572,6 +602,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
572
602
  externalTypes,
573
603
  externalTypeSpecifiersByFile,
574
604
  tierMode,
605
+ runtimeOptionalReport,
575
606
  ffiBindingSymbols: ffiValidation.symbolsByName,
576
607
  generalNodeStreams: true,
577
608
  ...(dyn ? { dynNodeStreams: true } : {}),
@@ -604,6 +635,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
604
635
  // without such a settled fence retain checker-backed IR exactly once.
605
636
  if (resultLowerer.requiresHistoricalOrderRelower) {
606
637
  const emit = new Lowerer(program, entry, moduleOrder, {
638
+ facts,
607
639
  frontendServices: options.frontendServices,
608
640
  projectCheckJs: options.projectCheckJs ?? false,
609
641
  ...(generalNodeStreams ? { generalNodeStreams: true } : {}),
@@ -611,6 +643,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
611
643
  reachable,
612
644
  targetPlatform,
613
645
  startupCrash,
646
+ admittedOpinions: options.admittedOpinions,
614
647
  inlineRequireCycleCalls,
615
648
  dynamicImportRejections: options.dynamicImportRejections,
616
649
  ffiImports,
@@ -621,6 +654,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
621
654
  externalTypes,
622
655
  externalTypeSpecifiersByFile,
623
656
  tierMode,
657
+ runtimeOptionalReport,
624
658
  ...(resultLowerer.wholeSlotDegradation ? { wholeSlotDegradation: true } : {}),
625
659
  });
626
660
  for (const d of extraModuleCycleDiags)
@@ -631,6 +665,20 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
631
665
  resultLowerer = emit;
632
666
  timing("historical-order-relower");
633
667
  }
668
+ // LIBRARY mode: the profile's export names resolved to the units that
669
+ // supply them — the entry's own unit for a direct export, the declaring
670
+ // module's tagged unit for a re-exported one. The export-map resolution
671
+ // reads this to land each profile entry on the compiled function without
672
+ // assuming the entry file declared it.
673
+ if (options.libRoots !== undefined && options.libRoots.length > 0) {
674
+ const libExportUnits = new Map();
675
+ for (const name of options.libRoots) {
676
+ const unit = resultLowerer.libExportUnit(name);
677
+ if (unit !== null)
678
+ libExportUnits.set(name, unit);
679
+ }
680
+ result = { ...result, libExportUnits };
681
+ }
634
682
  // Divergence warnings over the program's own modules: computed once,
635
683
  // after lowering, from the same checker (never part of a failure).
636
684
  const divergences = [
@@ -741,6 +789,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
741
789
  if (options.coverage !== true)
742
790
  return result;
743
791
  const remainderPass = (general, dyn = dynNodeStreams) => new Lowerer(program, entry, moduleOrder, {
792
+ facts,
744
793
  frontendServices: options.frontendServices,
745
794
  projectCheckJs: options.projectCheckJs ?? false,
746
795
  ...(general ? { generalNodeStreams: true } : {}),
@@ -750,6 +799,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
750
799
  alreadyFlushed: resultLowerer.flushedSymbols,
751
800
  degradedTypes: resultLowerer.degradedTypes,
752
801
  retriedSymbols: resultLowerer.retriedSymbols,
802
+ admittedOpinions: options.admittedOpinions,
753
803
  inlineRequireCycleCalls,
754
804
  dynamicImportRejections: options.dynamicImportRejections,
755
805
  targetPlatform,
@@ -761,6 +811,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
761
811
  externalTypes,
762
812
  externalTypeSpecifiersByFile,
763
813
  tierMode,
814
+ runtimeOptionalReport,
764
815
  });
765
816
  let remainder = remainderPass(generalNodeStreams);
766
817
  let rem = remainder.run();
@@ -787,6 +838,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
787
838
  reached: [...options.tierReport.preflight, ...result.diagnostics],
788
839
  deferred: result.runtimeFences,
789
840
  unreached: [...rem.diagnostics, ...rem.runtimeFences],
841
+ runtimeOptional: resultLowerer.runtimeOptionalNarrowings,
790
842
  });
791
843
  // A dynamic function's own statements can include ones that failed.
792
844
  const statementsDynamic = Math.min(tiers?.statementsDynamic ?? dynamicStatementCount(program, dynamicFunctions), result.stats.statementsTotal - result.stats.statementsFailed);
@@ -849,7 +901,7 @@ export function staticImportNamespaceType(lowerer, expr) {
849
901
  !source.fileName.endsWith(".cts") &&
850
902
  !isCjsJsFile(source, lowerer.program) &&
851
903
  lowerer.moduleOrder.includes(source)) {
852
- moduleId = `file:${tsgoPath(resolve(source.fileName))}`;
904
+ moduleId = `file:${lowerer.pathOf(source)}`;
853
905
  }
854
906
  }
855
907
  if (moduleId === null)
@@ -1263,7 +1315,24 @@ function builtinMemberValueName(lowerer, receiver, member) {
1263
1315
  return null;
1264
1316
  return builtinModuleFnOf(lowerer, module, member)?.valueName ?? null;
1265
1317
  }
1318
+ /** Whether `node` is a function, arrow or class DEFINITION that carries no
1319
+ * name of its own, so the binding or property it initializes names it
1320
+ * (V8's SetFunctionName). Every other expression evaluates to a value that
1321
+ * already has whatever name it has. */
1322
+ function isAnonymousCallableDefinition(node) {
1323
+ if (ts.isArrowFunction(node))
1324
+ return true;
1325
+ return (ts.isFunctionExpression(node) || ts.isClassExpression(node)) && node.name === undefined;
1326
+ }
1327
+ /** The name V8 gives a function value read from this expression: its own
1328
+ * definition, through parenthesized, rebindable and const bindings and
1329
+ * property reads (`process.cwd`), or the binding an anonymous definition
1330
+ * initializes. Null when the source does not determine it. */
1266
1331
  export function jsFuncNameOf(node, lowerer) {
1332
+ // Typed source cannot read a function's `name` (SC2020), so the names below
1333
+ // are unobservable there; keeping them JavaScript-only leaves every typed
1334
+ // program's output byte-identical.
1335
+ const js = isJsSourceFile(ts.getSourceFileOfNode(node));
1267
1336
  let n = node;
1268
1337
  while (ts.isParenthesizedExpression(n))
1269
1338
  n = n.expression;
@@ -1278,14 +1347,45 @@ export function jsFuncNameOf(node, lowerer) {
1278
1347
  n = declaration;
1279
1348
  break;
1280
1349
  }
1281
- if (!declaration ||
1282
- !ts.isVariableDeclaration(declaration) ||
1283
- !declaration.initializer ||
1284
- (ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const) === 0)
1350
+ // A binding element or a parameter holds the default's value only when the
1351
+ // destructured value or the argument was undefined; otherwise it holds the
1352
+ // source's value. Which one ran is a runtime fact, so a default never
1353
+ // answers for the binding: when it runs, the definition it created was
1354
+ // already named after the binding, and a named definition it references
1355
+ // keeps the name it spells. A default the source overrides must not lend
1356
+ // its name to the supplied value (`const [x = function unused() {}] =
1357
+ // [function supplied() {}]` is "supplied"), so this answers null and the
1358
+ // name read takes the runtime value's own name.
1359
+ // Without a default the spelling is wrong for every value the binding can
1360
+ // hold, but that shape has no pattern-default signature and is a separate
1361
+ // change; it keeps the previous answer here.
1362
+ if (js && declaration && (ts.isBindingElement(declaration) || ts.isParameter(declaration))) {
1363
+ if (!declaration.initializer)
1364
+ break;
1365
+ return null;
1366
+ }
1367
+ if (!declaration || !ts.isVariableDeclaration(declaration) || !declaration.initializer)
1285
1368
  break;
1286
- n = declaration.initializer;
1287
- while (ts.isParenthesizedExpression(n))
1288
- n = n.expression;
1369
+ let value = declaration.initializer;
1370
+ while (ts.isParenthesizedExpression(value))
1371
+ value = value.expression;
1372
+ // Name inference (V8's SetFunctionName) covers an ANONYMOUS function or
1373
+ // class definition and nothing else: the binding names it, so a
1374
+ // rebindable binding keeps the binding's spelling below. Any other
1375
+ // initializer is a value that carries its own name — a named
1376
+ // definition, a builtin function (`var a = String; a.name` is
1377
+ // "String") or another binding (`var a = b` keeps b's name) — and
1378
+ // resolution follows it.
1379
+ if (isAnonymousCallableDefinition(value)) {
1380
+ // The binding this definition initializes named it when it was
1381
+ // created, so answer that binding and not the alias the reference
1382
+ // reached it through: `import b from "./m"` keeps the "root" of
1383
+ // `const root = (text) => text;` in `m`.
1384
+ if (ts.isIdentifier(declaration.name))
1385
+ return declaration.name.text;
1386
+ break;
1387
+ }
1388
+ n = value;
1289
1389
  }
1290
1390
  if (ts.isIdentifier(n))
1291
1391
  return n.text;
@@ -1293,7 +1393,9 @@ export function jsFuncNameOf(node, lowerer) {
1293
1393
  return n.name.text;
1294
1394
  if ((ts.isFunctionExpression(n) || ts.isFunctionDeclaration(n)) && n.name)
1295
1395
  return n.name.text;
1296
- if (ts.isFunctionExpression(n) || ts.isArrowFunction(n)) {
1396
+ if (ts.isClassExpression(n) && n.name)
1397
+ return n.name.text;
1398
+ if (ts.isFunctionExpression(n) || ts.isArrowFunction(n) || ts.isClassExpression(n)) {
1297
1399
  // An anonymous function takes the name of the binding or property it
1298
1400
  // initializes, through parentheses (`const f = (function () {})`).
1299
1401
  let outer = n;
@@ -1309,6 +1411,32 @@ export function jsFuncNameOf(node, lowerer) {
1309
1411
  if (p && ts.isPropertyAssignment(p) && p.initializer === outer && ts.isIdentifier(p.name)) {
1310
1412
  return p.name.text;
1311
1413
  }
1414
+ // A default parameter names it (`function f(a = function () {})`), as
1415
+ // does an object-assignment shorthand (`({ a = function () {} } = o)`)
1416
+ // and a plain identifier assignment (`a = function () {}`). A member
1417
+ // target never names one: only an identifier reference does.
1418
+ if (js && p && ts.isParameter(p) && p.initializer === outer && ts.isIdentifier(p.name)) {
1419
+ return p.name.text;
1420
+ }
1421
+ if (js &&
1422
+ p &&
1423
+ ts.isShorthandPropertyAssignment(p) &&
1424
+ p.objectAssignmentInitializer === outer &&
1425
+ ts.isIdentifier(p.name)) {
1426
+ return p.name.text;
1427
+ }
1428
+ if (js &&
1429
+ p &&
1430
+ ts.isBinaryExpression(p) &&
1431
+ p.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
1432
+ p.right === outer &&
1433
+ ts.isIdentifier(p.left) &&
1434
+ // The native parser folds a parenthesized target into the target itself
1435
+ // (`(a) = f`), leaving the source's `(` as a gap in front of it. A
1436
+ // parenthesized target is not an IdentifierReference and names nothing.
1437
+ p.getStart() === p.left.getStart()) {
1438
+ return p.left.text;
1439
+ }
1312
1440
  }
1313
1441
  return null;
1314
1442
  }
@@ -1365,6 +1493,9 @@ export class Lowerer {
1365
1493
  /** Per file: whether it assigns `exports` and `module.exports`
1366
1494
  * (cjs-exports-object.ts). */
1367
1495
  cjsExportsAssignments = new Map();
1496
+ /** JavaScript checker diagnostics preflight admitted under an opinion row
1497
+ * (LoadResult.admittedOpinions): the sites opinionAt answers for. */
1498
+ admittedOpinions;
1368
1499
  /** Inline require() calls whose module edge closes a require cycle
1369
1500
  * (LoadResult.inlineRequireCycleCalls). */
1370
1501
  inlineRequireCycleCalls;
@@ -1375,6 +1506,11 @@ export class Lowerer {
1375
1506
  * exact binding discipline as globals/functions. */
1376
1507
  staticCallables = new Map();
1377
1508
  genericFnsBySymbol = new Map();
1509
+ /** Temporal-dead-zone flags of module-scope generic ALIASES (`const h =
1510
+ * id`) that code can read before the declaration runs: the alias has no
1511
+ * binding storage of its own, so a read that can come first checks a
1512
+ * flag instead (bindingGenericFnAliasInfoOf). */
1513
+ genericAliasPresence = new Map();
1378
1514
  /** Typed declarations' instances for arguments that keep their own
1379
1515
  * record or array layout (structural-instances.ts). */
1380
1516
  structuralFnInfos = new Map();
@@ -1645,6 +1781,26 @@ export class Lowerer {
1645
1781
  * type parameters are bound to `unknown`, so lambdaSignature admits
1646
1782
  * them. */
1647
1783
  erasingLambdas = new Set();
1784
+ /** Identity comparisons of a generic declaration met while lowering
1785
+ * (directly against the declaration, or through a dynamic value): exact
1786
+ * only while the program holds that declaration as one function object
1787
+ * (checkGenericIdentityPins). */
1788
+ genericIdentityPins = [];
1789
+ /** Identity comparisons whose operands are dynamic values, recorded while
1790
+ * lowering and resolved by checkGenericIdentityPins only when some
1791
+ * generic declaration is held at more than one signature. */
1792
+ dynIdentityComparisons = [];
1793
+ /** The value instance each pinned binding holds (`const f: Fn = ident`),
1794
+ * keyed by the binding's declaration: two pins of one generic
1795
+ * declaration at different signatures are separate compiled closures, so
1796
+ * checkGenericIdentityPins refuses to compare them. */
1797
+ pinnedValueInstances = new Map();
1798
+ /** Function-vs-function identity comparisons recorded while lowering,
1799
+ * with the closure name each operand lowered to when it is a closure
1800
+ * (an inline instantiation expression names its instance directly). */
1801
+ pinnedIdentityComparisons = [];
1802
+ /** The identity comparison check reports once, after all lowering. */
1803
+ genericIdentityCheckDone = false;
1648
1804
  /** Function expressions lowered against a fixed target signature with a
1649
1805
  * tuple-typed `arguments` (typed-arguments.ts). */
1650
1806
  typedArgumentsLambdas = new Set();
@@ -1741,9 +1897,18 @@ export class Lowerer {
1741
1897
  streamPropMutatedSyms = null;
1742
1898
  /** Whether some source reads process.exitCode (processReadsExitCode). */
1743
1899
  readsExitCode = null;
1900
+ /** Whether some source replaces a process output stream's write method
1901
+ * (programPatchesStdio in builtins/process.ts). */
1902
+ patchesStdio = null;
1903
+ /** The write-replacement site programPatchesStdio found: the executable
1904
+ * planner refuses it beside Node islands (SC8006). */
1905
+ stdioPatchSites = [];
1744
1906
  requestInitPropMutatedSyms = null;
1745
1907
  emitterEventTable = null;
1746
1908
  emitterComputedPatterns = [];
1909
+ /** Some site registers a listener under an unrestricted computed name
1910
+ * (lower-event-emitter.ts emitterEvents). */
1911
+ emitterAnyNameListener = false;
1747
1912
  /** The EventTarget engine's handleEvent reader was lifted
1748
1913
  * (lower-event-target.ts noteEventListeners). */
1749
1914
  handleEventReader = false;
@@ -1796,6 +1961,19 @@ export class Lowerer {
1796
1961
  * prepass. This includes explicit annotations: unchecked TS annotations do
1797
1962
  * not prove that an array property read produced a value. */
1798
1963
  runtimeOptionalBindingTypes = new Map();
1964
+ /** The indexed-read analysis's storage decisions: kept for the coverage
1965
+ * report when --explain-dynamic asks, and written to stderr under
1966
+ * SCRIPTC_DEBUG_RUNTIME_OPTIONAL=1. */
1967
+ runtimeOptionalProvenance;
1968
+ /** Coverage (--explain-dynamic): the widened slots whose storage holds
1969
+ * an absence the checker's type does not admit, with the reads that
1970
+ * narrow them below it (runtime-optional-report.ts). Empty unless the
1971
+ * report was asked for. */
1972
+ runtimeOptionalNarrowings = [];
1973
+ /** JavaScript bindings assigned values outside their declared type
1974
+ * (analyzeJsWidenedBindings): checked-dynamic storage, and reads keep the
1975
+ * stored value instead of narrowing it to the checker's type. */
1976
+ jsWidenedBindings = new Set();
1799
1977
  /** A pipeline() function stage's `source` parameter: the IR type of what
1800
1978
  * the pipeline passes it (the previous stage as an async iterable), set
1801
1979
  * while the stage lowers. Parameter typing and `for await` heads read
@@ -2358,6 +2536,9 @@ export class Lowerer {
2358
2536
  /** The collection types that uses prove for untyped JavaScript bindings,
2359
2537
  * by every identifier naming one (js-collection-types.ts). */
2360
2538
  inferredCollectionTypes = undefined;
2539
+ /** Partial record assertions (`partial-assertions.ts`): per target shape,
2540
+ * the required fields some asserted literal leaves unwritten. */
2541
+ partialAssertions = undefined;
2361
2542
  /** overload-choice's answers per call, binding and function. */
2362
2543
  dynamicOverloadAnswers = new Map();
2363
2544
  /** Error parameters of an error-first callback with a known value in
@@ -2402,6 +2583,11 @@ export class Lowerer {
2402
2583
  * Reachability lowers inits before the declarations they discover, so
2403
2584
  * these rebuild after the worklist restores historical shape metadata. */
2404
2585
  shapeOrderHelperFinalizers = [];
2586
+ /** Whether any lowered function converts a checked-dynamic value into a
2587
+ * closed record, the only conversion that can leave a record holding
2588
+ * undeclared source keys (record-sources.ts). Settled once lowering ends,
2589
+ * before the shape helpers finalize their bodies. */
2590
+ recordSourcesPossible = false;
2405
2591
  /** Construction witnesses that choose each shape's enumeration order
2406
2592
  * once lowering settles (key-order-witness.ts). */
2407
2593
  keyOrder = new KeyOrderNotes();
@@ -2508,6 +2694,9 @@ export class Lowerer {
2508
2694
  * interned here so references under one source-world ABI are the SAME
2509
2695
  * zero-capture closure (see primitiveCtorClosure). */
2510
2696
  primitiveCtorFns = new Map();
2697
+ /** Whether a compiled source creates primitive wrapper objects
2698
+ * (programCreatesWrappers), computed on first use. */
2699
+ createsWrappers = undefined;
2511
2700
  /** Builtin-module FUNCTIONS admitted as values by their surface-table
2512
2701
  * entries. The resolved runtime function plus ABI is the identity key,
2513
2702
  * so named imports, namespace reads, CommonJS bindings, and alias chains
@@ -2515,9 +2704,16 @@ export class Lowerer {
2515
2704
  builtinCallableValueFns = new Map();
2516
2705
  /** Each builtin function-value adapter's Node name, for boxed values. */
2517
2706
  builtinCallableValueNames = new Map();
2707
+ /** Adapters whose name holds on the main thread only
2708
+ * (BuiltinModuleFn.valueNameMainThreadOnly): a Worker boxes them
2709
+ * unnamed, as Node's unwrapped function is. */
2710
+ builtinCallableValueMainThreadNames = new Set();
2518
2711
  /** Builtin function values whose `length` differs from their adapter's
2519
2712
  * parameter count (BuiltinModuleFn.valueLength), by adapter name. */
2520
2713
  builtinCallableValueLengths = new Map();
2714
+ /** Typed builtin adapters with a checked twin (checkedBuiltinValue): the
2715
+ * builtin, its display name and the location the twin is lowered at. */
2716
+ builtinCheckedValues = new Map();
2521
2717
  /** Optional-chain lowering state. While a chain body lowers, the guarded
2522
2718
  * receiver NODE reads as a chainRecv (typed by the narrowed arm) instead
2523
2719
  * of re-lowering, its checker type reads non-nullish (typeOf), and the
@@ -2530,6 +2726,9 @@ export class Lowerer {
2530
2726
  neverValued = new Set();
2531
2727
  chainNarrowedType = new Map();
2532
2728
  chainHandled = new Set();
2729
+ /** One arm's narrowed value for a spread source while a distributed
2730
+ * union spread lowers that arm (lowerDistributedUnionSpread). */
2731
+ spreadArmOverrides = new Map();
2533
2732
  /** for-of-over-matchAll bindings whose `.index` reads the companion-index
2534
2733
  * array: binding SYMBOL → the hidden number[] of match start indices plus
2535
2734
  * the hidden cursor holding THIS iteration's position (registered while
@@ -2631,6 +2830,12 @@ export class Lowerer {
2631
2830
  globalsByDeclNode = new Map();
2632
2831
  globalsList = [];
2633
2832
  npmInitActions = new Map();
2833
+ /** Per-file %init statements of static island imports and re-exports,
2834
+ * by the import or export statement that loads the island module: the
2835
+ * importer's %init header runs them in that statement's place among its
2836
+ * dependencies' %init calls, so the island module evaluates in source
2837
+ * order with the native dependencies around it. */
2838
+ islandImportActions = new Map();
2634
2839
  /** Per-file %init PRELUDE statements for JSON imports: bakeable DATA
2635
2840
  * assignments with no observable evaluation order of their own —
2636
2841
  * prepended by lowerFileInit so the bindings are live before any
@@ -2707,6 +2912,9 @@ export class Lowerer {
2707
2912
  nodeIslandLoads = [];
2708
2913
  /** Island handle bindings by symbol (lower-node-island.ts). */
2709
2914
  islandHandleBindings = new Map();
2915
+ /** Names a native module re-exports from an island package, by the
2916
+ * symbol an alias chain reaches (lower-node-island.ts). */
2917
+ islandReexports = new Map();
2710
2918
  /** `instanceof` expressions the island lowering already handles. */
2711
2919
  islandInstanceofHandled = new Set();
2712
2920
  /** NI-6: the modules shared with Node islands (lower-shared-modules.ts),
@@ -2728,6 +2936,28 @@ export class Lowerer {
2728
2936
  threadSlotFamilies = new Map();
2729
2937
  /** Classes used as ThreadSlots keys: their hierarchies carry a slot word. */
2730
2938
  threadSlotKeys = new Set();
2939
+ /** The narrowing conversions that link copies to their sources, by
2940
+ * `${from}:${to}` (record-links.ts). */
2941
+ recordLinks = new Map();
2942
+ /** Where each of recordLinks' pairs was first converted, by compose
2943
+ * helper name. */
2944
+ recordLinkLocs = new Map();
2945
+ /** The conversion each %rec.string and %rec.primitive helper's calls
2946
+ * replace, by helper name (record-links.ts recordStringCall). */
2947
+ recordStringFallbacks = new Map();
2948
+ /** The conversion helpers that build copies of recordLinks' pairs. */
2949
+ recordLinkSites = [];
2950
+ /** Object.prototype methods other than toString called by name on
2951
+ * record types (finalizeRecordLinks checks them against link sources). */
2952
+ recordMethodCalls = [];
2953
+ /** Completions of "custom" linked helpers (record-links.ts), which
2954
+ * finalizeRecordLinks runs once the links are known. */
2955
+ linkedHelperFinalizers = [];
2956
+ /** Helpers over record types that finalizeRecordLinks completes. */
2957
+ linkedHelpers = [];
2958
+ /** The JavaScript names of object literals' methods, by lifted function
2959
+ * (function-names.ts). */
2960
+ objectMethodNames = new Map();
2731
2961
  forkTargetIdByPath = new Map();
2732
2962
  /** Namespace ModuleBlocks this program lowers, filled by splitFiles:
2733
2963
  * "flattened" — an instantiated namespace whose body joined the file's
@@ -2791,12 +3021,63 @@ export class Lowerer {
2791
3021
  unions = new UnionRegistry();
2792
3022
  /** Context-free successful type mappings. See TypeMapperCtx.typeMemo. */
2793
3023
  typeMemo = new Map();
2794
- ambient = ambientDtsPath();
2795
- overridesAmbient = overridesDtsPath();
3024
+ /** Successful mappings that read no generic-instantiation scope state
3025
+ * (TypeMapperCtx.typeMemoShared): the same answer in every binding scope
3026
+ * and at the top level. A generic instance's unscoped types land here, so
3027
+ * the next instance — and the top level — answers them without mapping
3028
+ * again. */
3029
+ sharedTypeMemo = new Map();
3030
+ /** Successful mappings per generic binding context (TypeMapperCtx.typeMemoFor):
3031
+ * by the installed typeParamBindings map, then the typeParamTsBindings map
3032
+ * (NO_BINDINGS stands for null). Binding maps are filled before they are
3033
+ * installed and never change while installed, so their identity is the
3034
+ * context. The lowerer owns the memos: they live as long as it does. */
3035
+ scopedTypeMemos = new Map();
3036
+ /** The program facts this Lowerer shares with the other passes of its
3037
+ * island round (lowering-facts.ts). Every field that is a fact lives
3038
+ * there, so a pass that re-derives it cannot disagree with its siblings.
3039
+ * A Lowerer built without LowererMode.facts gets a private copy (tests,
3040
+ * one-off lowerings). */
3041
+ facts;
3042
+ /** SCRIPTC_LOWERING_FACTS_VERIFY: the shared provenance memo's hit check,
3043
+ * public so contexts built from this Lowerer (webassembly.ts's hand-made
3044
+ * ctx, property-access.ts passing the Lowerer itself) verify too. */
3045
+ verifySymbolProvenance;
2796
3046
  /** The one mapType context: registries + hooks, assembled in the
2797
3047
  * constructor (typeParamResolver reads the CURRENT instantiation bindings
2798
3048
  * through `this`, so the same ctx serves generic bodies too). */
2799
3049
  typeCtx;
3050
+ /** The context lastContextMemo answered for. Every mapType call asks for the
3051
+ * current binding context, and a lowering pass stays in one context for
3052
+ * thousands of calls, so the pair of identity checks below is the whole
3053
+ * cost on that path: the two-level lookup only runs when the context
3054
+ * actually changes. */
3055
+ lastMemoOuter = null;
3056
+ lastMemoInner = null;
3057
+ lastMemo = null;
3058
+ /** The memo for the current binding context (scopedTypeMemos). */
3059
+ currentTypeMemo() {
3060
+ if (this.typeParamBindings === null && this.typeParamTsBindings === null)
3061
+ return this.typeMemo;
3062
+ const outer = this.typeParamBindings ?? NO_BINDINGS;
3063
+ const inner = this.typeParamTsBindings ?? NO_BINDINGS;
3064
+ if (outer === this.lastMemoOuter && inner === this.lastMemoInner)
3065
+ return this.lastMemo;
3066
+ let byTs = this.scopedTypeMemos.get(outer);
3067
+ if (byTs === undefined) {
3068
+ byTs = new Map();
3069
+ this.scopedTypeMemos.set(outer, byTs);
3070
+ }
3071
+ let memo = byTs.get(inner);
3072
+ if (memo === undefined) {
3073
+ memo = new Map();
3074
+ byTs.set(inner, memo);
3075
+ }
3076
+ this.lastMemoOuter = outer;
3077
+ this.lastMemoInner = inner;
3078
+ this.lastMemo = memo;
3079
+ return memo;
3080
+ }
2800
3081
  stats = {
2801
3082
  statementsTotal: 0,
2802
3083
  statementsFailed: 0,
@@ -2819,6 +3100,11 @@ export class Lowerer {
2819
3100
  /** Whether the program freezes, seals or prevents extensions of untyped
2820
3101
  * values other than fresh literals (noteUntypedIntegrity). */
2821
3102
  untypedIntegrity = false;
3103
+ /** A JavaScript source constructs an ArrayBuffer with a maxByteLength,
3104
+ * or reads a member that resizes, grows or detaches a buffer
3105
+ * (buffers.ts, t262-dc §2.4). Sets IrModule.bytesHeadersMutable and arms
3106
+ * the scr_js_buffers views registry in %main. */
3107
+ buffersMutable = false;
2822
3108
  liftedFns = [];
2823
3109
  /** `for … of` and `for await` loops over untyped iterables, by their
2824
3110
  * generator-kind local (generator-dynamic-dispatch.ts steps the program's
@@ -2837,6 +3123,9 @@ export class Lowerer {
2837
3123
  /** web-streams-dyn.ts's answer: whether a JavaScript source names a web
2838
3124
  * stream class; undefined until asked. */
2839
3125
  namesWebStreamClass = undefined;
3126
+ /** web-streams-dyn.ts's answer: whether a TypeScript source uses a web
3127
+ * stream operation the native streams lack; undefined until asked. */
3128
+ typedWebStreams = undefined;
2840
3129
  /** The first lifted function of each name (liftedFnNamed), for the
2841
3130
  * liftedFns indexed so far. liftedFns only grows. */
2842
3131
  liftedFnsByName = new Map();
@@ -2919,6 +3208,10 @@ export class Lowerer {
2919
3208
  * function called above the declaration statement reads that, never a
2920
3209
  * NULL slot. Filled by collectGlobals. */
2921
3210
  varGlobalEntryInits = new Map();
3211
+ /** Initializer-less JavaScript lets holding a runtime handle or undefined
3212
+ * that a closure captures (inferredEvolvingLetType). Reads inside a nested
3213
+ * function lower as the checked-dynamic value. */
3214
+ closureDynLets = new Set();
2922
3215
  /** Import-cycle bindings with an initialization flag, by global id, and
2923
3216
  * the top-level statements declaring them (cycle-initialization.ts). */
2924
3217
  cycleInitFlags = new Map();
@@ -3165,7 +3458,9 @@ export class Lowerer {
3165
3458
  mapTable("primitiveCtorFns", this.primitiveCtorFns),
3166
3459
  mapTable("builtinCallableValueFns", this.builtinCallableValueFns),
3167
3460
  mapTable("builtinCallableValueNames", this.builtinCallableValueNames),
3461
+ setTable("builtinCallableValueMainThreadNames", this.builtinCallableValueMainThreadNames),
3168
3462
  countTable("builtinCallableValueLengths", this.builtinCallableValueLengths),
3463
+ irDataTable("builtinCheckedValues", this.builtinCheckedValues),
3169
3464
  mapTable("regionRunHelpers", this.regionRunHelpers),
3170
3465
  mapTable("internTableHelpers", this.internTableHelpers),
3171
3466
  functionTable("liftedFns", this.liftedFns, (fn) => this.liftedFnNamed(fn) !== undefined, () => {
@@ -3201,6 +3496,7 @@ export class Lowerer {
3201
3496
  checkedTable("genericFnsBySymbol", () => this.genericFnsBySymbol.size),
3202
3497
  checkedTable("objLitGenericFns", () => this.objLitGenericFns.size),
3203
3498
  checkedTable("bindingGenericFns", () => this.bindingGenericFns.size),
3499
+ checkedTable("genericAliasPresence", () => this.genericAliasPresence.size),
3204
3500
  checkedTable("bindingIdentifiers", () => this.bindingIdentifiers.size),
3205
3501
  checkedTable("ownToStringTargets", () => this.ownToStringTargets.size),
3206
3502
  checkedTable("neverReassignedCache", () => this.neverReassignedCache.size),
@@ -3212,6 +3508,13 @@ export class Lowerer {
3212
3508
  checkedTable("genericFunctionDemandOwner", () => this.genericFunctionDemandOwner.size),
3213
3509
  checkedTable("genericClassDemandOwner", () => this.genericClassDemandOwner.size),
3214
3510
  checkedTable("erasingLambdas", () => this.erasingLambdas.size),
3511
+ checkedTable("genericIdentityPins", () => this.genericIdentityPins.length),
3512
+ checkedTable("dynIdentityComparisons", () => this.dynIdentityComparisons.length),
3513
+ // Pinned binding instances and function-vs-function identity
3514
+ // comparisons feed the same end-of-lowering check; a unit that records
3515
+ // one lowers again rather than replaying a record without it.
3516
+ checkedTable("pinnedValueInstances", () => this.pinnedValueInstances.size),
3517
+ checkedTable("pinnedIdentityComparisons", () => this.pinnedIdentityComparisons.length),
3215
3518
  checkedTable("typedArgumentsLambdas", () => this.typedArgumentsLambdas.size),
3216
3519
  checkedTable("tupleAliasSymbols", () => this.tupleAliasSymbols.size),
3217
3520
  checkedTable("nullishFuncResults", () => this.nullishFuncResults.size),
@@ -3287,6 +3590,7 @@ export class Lowerer {
3287
3590
  checkedTable("globalsByDeclNode", () => this.globalsByDeclNode.size),
3288
3591
  checkedTable("globalsList", () => this.globalsList.length),
3289
3592
  checkedTable("npmInitActions", () => this.npmInitActions.size),
3593
+ checkedTable("islandImportActions", () => this.islandImportActions.size),
3290
3594
  checkedTable("jsonInitActions", () => this.jsonInitActions.size),
3291
3595
  checkedTable("jsonRequireModules", () => this.jsonRequireModules.size),
3292
3596
  checkedTable("jsonRequireCalls", () => this.jsonRequireCalls.size),
@@ -3306,6 +3610,14 @@ export class Lowerer {
3306
3610
  checkedTable("threadSlotNames", () => this.threadSlotNames.size),
3307
3611
  checkedTable("threadSlotFamilies", () => this.threadSlotFamilies.size),
3308
3612
  checkedTable("threadSlotKeys", () => this.threadSlotKeys.size),
3613
+ checkedTable("recordLinks", () => this.recordLinks.size),
3614
+ checkedTable("recordLinkLocs", () => this.recordLinkLocs.size),
3615
+ checkedTable("recordLinkSites", () => this.recordLinkSites.length),
3616
+ checkedTable("recordStringFallbacks", () => this.recordStringFallbacks.size),
3617
+ checkedTable("linkedHelpers", () => this.linkedHelpers.length),
3618
+ checkedTable("linkedHelperFinalizers", () => this.linkedHelperFinalizers.length),
3619
+ checkedTable("recordMethodCalls", () => this.recordMethodCalls.length),
3620
+ checkedTable("objectMethodNames", () => this.objectMethodNames.size),
3309
3621
  checkedTable("forkTargetIdByPath", () => this.forkTargetIdByPath.size),
3310
3622
  checkedTable("nsBlocks", () => this.nsBlocks.size),
3311
3623
  checkedTable("initNameOf", () => this.initNameOf.size),
@@ -3320,6 +3632,7 @@ export class Lowerer {
3320
3632
  checkedTable("preparedClassFactories", () => this.preparedClassFactories.size),
3321
3633
  checkedTable("preparingClassFactories", () => this.preparingClassFactories.size),
3322
3634
  checkedTable("varGlobalEntryInits", () => this.varGlobalEntryInits.size),
3635
+ checkedTable("closureDynLets", () => this.closureDynLets.size),
3323
3636
  checkedTable("cycleInitFlags", () => this.cycleInitFlags.size),
3324
3637
  checkedTable("classInitFlags", () => this.classInitFlags.size),
3325
3638
  checkedTable("cycleInitDeclarations", () => this.cycleInitDeclarations.size),
@@ -3400,10 +3713,9 @@ export class Lowerer {
3400
3713
  // settings
3401
3714
  "frontendServices",
3402
3715
  "nodeIslands",
3403
- "ambient",
3404
- "overridesAmbient",
3405
3716
  "remainder",
3406
3717
  "tierMode",
3718
+ "runtimeOptionalReport",
3407
3719
  "generalNodeStreams",
3408
3720
  "dynNodeStreams",
3409
3721
  "targetPlatform",
@@ -3414,10 +3726,12 @@ export class Lowerer {
3414
3726
  "priorRetriedSymbols",
3415
3727
  "wholeSlotDegradation",
3416
3728
  "inferredCollectionTypes",
3729
+ "partialAssertions",
3417
3730
  "foreignElementKeys",
3418
3731
  // caches made when first needed
3419
3732
  "nanCodedReads",
3420
3733
  "mentionsProcessVersions",
3734
+ "createsWrappers",
3421
3735
  "stringIndexBoundsCache",
3422
3736
  "functionLocalSubclasses",
3423
3737
  "socketEncodingReachable",
@@ -3425,8 +3739,32 @@ export class Lowerer {
3425
3739
  "unixListenReachable",
3426
3740
  "streamPropMutatedSyms",
3427
3741
  "readsExitCode",
3742
+ "patchesStdio",
3743
+ "stdioPatchSites",
3428
3744
  "requestInitPropMutatedSyms",
3429
- "classProtocols",
3745
+ // Program facts the round's passes share (lowering-facts.ts): file
3746
+ // paths, stdlib/external/package classification, a symbol's declared
3747
+ // provenance, the island-handle answers, the admitted-opinion index,
3748
+ // the JavaScript dynamic-declaration set and the class protocol index.
3749
+ // They are pure functions of (program, island set, external surface),
3750
+ // so no pass's mode can change them, and each is verified against a
3751
+ // fresh computation under SCRIPTC_LOWERING_FACTS_VERIFY.
3752
+ "facts",
3753
+ // SCRIPTC_LOWERING_FACTS_VERIFY only: this pass's own class protocol
3754
+ // index and provenance hit check, the comparisons the shared answers
3755
+ // are checked against.
3756
+ "ownClassProtocols",
3757
+ "verifySymbolProvenance",
3758
+ // The whole-program prepass analyzeJsWidenedBindings computes this set
3759
+ // before lowering begins: a pure function of the program's modules.
3760
+ "jsWidenedBindings",
3761
+ // Preflight's admitted opinions are a program fact computed before any
3762
+ // unit lowers.
3763
+ "admittedOpinions",
3764
+ // Coverage's --explain-dynamic report: the indexed-read analysis's
3765
+ // storage decisions and the narrowed reads they explain.
3766
+ "runtimeOptionalProvenance",
3767
+ "runtimeOptionalNarrowings",
3430
3768
  "cjsSplitRequireBindings",
3431
3769
  "cjsWholeExportSymbols",
3432
3770
  "cjsLiveMemberExports",
@@ -3437,24 +3775,33 @@ export class Lowerer {
3437
3775
  "sloppyThisGlobalReads",
3438
3776
  "globalLookupNames",
3439
3777
  "namesWebStreamClass",
3778
+ "typedWebStreams",
3440
3779
  "timeValueDateDecisions",
3441
3780
  "timeValueDateWrites",
3442
3781
  "dynamicOverloadAnswers",
3443
3782
  "argumentCountSlots",
3444
3783
  "coercions.widenedReturnTypes",
3445
- "packageFileMemo",
3784
+ // LIBRARY mode: the unit each root export name seeds is a pure function
3785
+ // of the entry's export table and the signatures collected before any
3786
+ // body lowers, so a pass that asks again computes the same answer.
3787
+ "libExportUnits",
3446
3788
  // NI-5: whether a symbol names an island handle binding depends only on
3447
3789
  // its declaration, so the answer is a memo keyed by symbol.
3448
3790
  "islandHandleBindings",
3791
+ // The island names native modules re-export: a pure function of the
3792
+ // program's modules, collected before lowering begins.
3793
+ "islandReexports",
3449
3794
  // The modules shared with the islands (NI-6): a pure function of the
3450
3795
  // program's modules, computed once, and the TDZ flags its plan gives a
3451
3796
  // statement.
3452
3797
  "sharedModules",
3453
3798
  "sharedInitFlags",
3799
+ // Settled from every lowered function once lowering ends, before the
3800
+ // shape helpers finalize (record-sources.ts).
3801
+ "recordSourcesPossible",
3454
3802
  "slotOriginMemo",
3455
3803
  "recordOriginMemo",
3456
3804
  "boundaryCastOrder",
3457
- "declBoundaryMemo",
3458
3805
  "structuredCloneReadCounts",
3459
3806
  // state of the unit being lowered
3460
3807
  "assertedValues",
@@ -3508,8 +3855,14 @@ export class Lowerer {
3508
3855
  "neverValued",
3509
3856
  "chainNarrowedType",
3510
3857
  "chainHandled",
3858
+ "spreadArmOverrides",
3511
3859
  "splitIdentifierUses",
3512
3860
  "typeMemo",
3861
+ "sharedTypeMemo",
3862
+ "scopedTypeMemos",
3863
+ "lastMemoOuter",
3864
+ "lastMemoInner",
3865
+ "lastMemo",
3513
3866
  "fnStack",
3514
3867
  "positions.nodesByKey",
3515
3868
  "positions.paths",
@@ -3538,14 +3891,19 @@ export class Lowerer {
3538
3891
  flag("cjsModuleGraphEnabled", () => this.cjsModuleGraphEnabled, () => (this.cjsModuleGraphEnabled = true)),
3539
3892
  flag("globalThisComputedWrite", () => this.globalThisComputedWrite, () => (this.globalThisComputedWrite = true)),
3540
3893
  flag("untypedIntegrity", () => this.untypedIntegrity, () => (this.untypedIntegrity = true)),
3894
+ flag("buffersMutable", () => this.buffersMutable, () => (this.buffersMutable = true)),
3541
3895
  flag("partialDegradedTypesMapped", () => this.partialDegradedTypesMapped, () => (this.partialDegradedTypesMapped = true)),
3542
3896
  fixed("errorAccessorReflection", () => this.errorAccessorReflection),
3543
3897
  fixed("subclassLinks", () => this.subclassLinks),
3544
3898
  fixed("errorPathCopies", () => this.errorPathCopies),
3899
+ // A latch of the end-of-lowering audit (checkGenericIdentityPins): a
3900
+ // unit never touches it.
3901
+ fixed("genericIdentityCheckDone", () => this.genericIdentityCheckDone),
3545
3902
  fixed("errorMethodDispatchRevision", () => this.errorMethodDispatchRevision),
3546
3903
  fixed("errorPropertyDispatchRevision", () => this.errorPropertyDispatchRevision),
3547
3904
  fixed("childAdditions", () => this.childAdditions),
3548
3905
  fixed("emitterEventTable", () => this.emitterEventTable),
3906
+ fixed("emitterAnyNameListener", () => this.emitterAnyNameListener),
3549
3907
  fixed("globalThisWrittenNames", () => this.globalThisWrittenNames),
3550
3908
  fixed("importRetryModules", () => this.importRetryModules),
3551
3909
  fixed("localSubclassIndex", () => this.localSubclassIndex),
@@ -3591,6 +3949,8 @@ export class Lowerer {
3591
3949
  * refuse and fence exactly as before. Stage S6 demotes the units of
3592
3950
  * committed refusals in "auto" and keeps them refusals in "static-only". */
3593
3951
  tierMode;
3952
+ /** LowererMode.runtimeOptionalReport. */
3953
+ runtimeOptionalReport;
3594
3954
  generalNodeStreams;
3595
3955
  dynNodeStreams;
3596
3956
  /** Functions finishModule placed in the dynamic tier (ir/tiers.ts). */
@@ -3768,7 +4128,6 @@ export class Lowerer {
3768
4128
  * (decl-origin.ts), by IrModule.declOrigins index. */
3769
4129
  declOrigins = [];
3770
4130
  declOriginIds = new Map();
3771
- packageFileMemo = new Map();
3772
4131
  slotOriginMemo = new Map();
3773
4132
  /** The value whose slot coercion is being lowered, while that value is
3774
4133
  * in a package file: union extractions built for it carry the slot's
@@ -3824,18 +4183,10 @@ export class Lowerer {
3824
4183
  return origin;
3825
4184
  }
3826
4185
  inPackageFileOf(node) {
3827
- const sf = ts.getSourceFileOfNode(node);
3828
- let inside = this.packageFileMemo.get(sf);
3829
- if (inside === undefined) {
3830
- inside = inPackageFile(node);
3831
- this.packageFileMemo.set(sf, inside);
3832
- }
3833
- return inside;
4186
+ return this.facts.inPackageFile(node);
3834
4187
  }
3835
- declBoundaryMemo = null;
3836
4188
  get declBoundary() {
3837
- this.declBoundaryMemo ??= this.program.getSourceFileNames().some(isDeclBoundaryFile);
3838
- return this.declBoundaryMemo;
4189
+ return this.facts.declBoundary;
3839
4190
  }
3840
4191
  /** Tracked classes' bag initializers over a typed `this`
3841
4192
  * (class-dynamic-dispatch.ts recordBagInitializers). */
@@ -3861,6 +4212,7 @@ export class Lowerer {
3861
4212
  this.ffiImports = mode.ffiImports ?? [];
3862
4213
  this.forkTargets = mode.forkTargets ?? [];
3863
4214
  this.frontendServices = mode.frontendServices;
4215
+ this.admittedOpinions = mode.admittedOpinions ?? [];
3864
4216
  this.inlineRequireCycleCalls = mode.inlineRequireCycleCalls ?? new Set();
3865
4217
  this.dynamicImportRejections = mode.dynamicImportRejections ?? new Map();
3866
4218
  this.libraryCallbacks = mode.libraryCallbacks ?? false;
@@ -3870,6 +4222,10 @@ export class Lowerer {
3870
4222
  this.startupCrash = mode.startupCrash ?? null;
3871
4223
  this.targetPlatform = mode.targetPlatform ?? process.platform;
3872
4224
  this.tierMode = mode.tierMode ?? "auto";
4225
+ this.runtimeOptionalReport = mode.runtimeOptionalReport === true;
4226
+ this.runtimeOptionalProvenance = this.runtimeOptionalReport
4227
+ ? RuntimeOptionalProvenance.forReport()
4228
+ : RuntimeOptionalProvenance.fromEnvironment();
3873
4229
  this.generalNodeStreams = mode.generalNodeStreams ?? false;
3874
4230
  this.dynNodeStreams = this.generalNodeStreams && (mode.dynNodeStreams ?? false);
3875
4231
  this.workerTargets = mode.workerTargets ?? [];
@@ -3882,13 +4238,20 @@ export class Lowerer {
3882
4238
  this.ffiImportsByName = new Map(this.ffiImports.map((entry) => [entry.name, entry]));
3883
4239
  this.externalTypeSpecifiersByFile =
3884
4240
  mode.externalTypeSpecifiersByFile ?? directExternalTypeSpecifiersByFile(this.externalTypes);
4241
+ this.facts =
4242
+ mode.facts ?? new LoweringFacts(program, moduleOrder, this.externalTypeSpecifiersByFile);
4243
+ // A shared fact would be a silent miscompile if it described another
4244
+ // program: the round hands every pass its own program and moduleOrder.
4245
+ if (this.facts.program !== program || this.facts.moduleOrder !== moduleOrder)
4246
+ throw new InternalCompilerError("lowerer bug: LowererMode.facts belongs to a different program or moduleOrder");
4247
+ this.verifySymbolProvenance = this.facts.verify
4248
+ ? (sym, answer) => this.verifySymbolProvenanceAnswer(sym, answer)
4249
+ : undefined;
3885
4250
  this.checker = program.getTypeChecker();
3886
4251
  const islands = this.nodeIslands;
3887
4252
  const shadow = canonShadowHook(this.checker);
3888
4253
  this.typeCtx = {
3889
- ...(islands !== null
3890
- ? { foreignType: (t) => isForeignType(islands, t, this.checker) }
3891
- : {}),
4254
+ ...(islands !== null ? { foreignType: (t) => this.foreignType(t) } : {}),
3892
4255
  checker: this.checker,
3893
4256
  positionOf: (node) => this.positions.of(node),
3894
4257
  shapes: this.shapes,
@@ -3924,7 +4287,7 @@ export class Lowerer {
3924
4287
  genericClassInstance: (decl, ref, mapArgument) => this.genericClassInstanceType(decl, ref, mapArgument),
3925
4288
  runtimeClassValue: (type) => runtimeClassValueOfType(this, type),
3926
4289
  localClassValue: (type) => this.instanceResultClass !== null && this.instanceResultClass.declared === type.id
3927
- ? this.instanceResultClass.value
4290
+ ? (noteScopeSensitiveMapping(), this.instanceResultClass.value)
3928
4291
  : (this.localClassValueTypes.get(type.id) ?? null),
3929
4292
  mixinClassInstance: (decl) => this.mixinTypeContext && this.mixinTypeContext.classNode === decl
3930
4293
  ? { kind: "object", className: this.mixinTypeContext.className }
@@ -3935,6 +4298,11 @@ export class Lowerer {
3935
4298
  const instanceClass = instanceType && this.localClassInstanceTypes.get(instanceType.id);
3936
4299
  if (instanceClass)
3937
4300
  return { kind: "object", className: instanceClass };
4301
+ // The instantiation-stack check below (and classNamer) answers
4302
+ // differently inside a generic instance, so this mapping stays in
4303
+ // its scope.
4304
+ if (this.classInsideFunction(decl))
4305
+ noteScopeSensitiveMapping();
3938
4306
  // Computed heritage can close over parameters of its factory.
3939
4307
  // A speculative checker query outside that factory must not lower
3940
4308
  // the extends expression in the caller's lexical scope.
@@ -3982,18 +4350,28 @@ export class Lowerer {
3982
4350
  mixinIntersectionInstance: (widened) => mixinIntersectionInstanceType(this, widened),
3983
4351
  classImplementedProtocol: (type) => this.classImplementedProtocol(type),
3984
4352
  isStdlibFile: (sf) => this.isStdlibFile(sf),
4353
+ primitiveWrappers: () => (this.createsWrappers ??= programCreatesWrappers(this)),
3985
4354
  isNpmFile: (sf) => this.isNpmFile(sf),
3986
4355
  isExperimentalFile: (sf) => isExperimentalDeclarationFile(sf, this.experimentalFiles),
3987
4356
  // The declaration-typed boundary's generated types (decl-projection.ts)
3988
4357
  // describe data, like an explicitly mapped external type surface.
3989
- isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))) ||
3990
- isDeclBoundaryFile(sf.fileName),
4358
+ isExternalTypeFile: this.isExternalTypeFile,
4359
+ symbolProvenance: this.symbolProvenance,
4360
+ ...(this.verifySymbolProvenance
4361
+ ? { verifySymbolProvenance: this.verifySymbolProvenance }
4362
+ : {}),
3991
4363
  typeMemo: this.typeMemo,
4364
+ // A hook: the ctx is spread in several places, and a copy made inside a
4365
+ // binding scope must follow the lowerer's CURRENT scope, not the one
4366
+ // that was installed at spread time.
4367
+ typeMemoFor: () => this.currentTypeMemo(),
4368
+ typeMemoShared: this.sharedTypeMemo,
3992
4369
  ...(this.generalNodeStreams ? { generalNodeStreams: true } : {}),
3993
4370
  ...(this.dynNodeStreams ? { dynNodeStreams: true } : {}),
3994
- canMemoizeType: () => this.typeParamBindings === null &&
3995
- this.typeParamTsBindings === null &&
3996
- this.mixinTypeContext === null,
4371
+ // Memoization is scoped by the binding maps (typeMemoFor); only a mixin
4372
+ // context opts out, because mixinClassInstance answers by class node and
4373
+ // the bindings do not identify it.
4374
+ canMemoizeType: () => this.mixinTypeContext === null,
3997
4375
  // fileTag is filled just below; the hook is only ever CALLED during
3998
4376
  // lowering, long after the constructor completes.
3999
4377
  isProgramFile: (sf) => this.fileTag.has(sf),
@@ -4028,7 +4406,7 @@ export class Lowerer {
4028
4406
  }
4029
4407
  if (this.moduleOrder.length === 0)
4030
4408
  this.fileTag.set(entry, "");
4031
- const jsDynamic = jsDynamicDeclarations(this.moduleOrder, this.checker);
4409
+ const jsDynamic = this.facts.jsDynamicDeclarations();
4032
4410
  if (jsDynamic.size > 0)
4033
4411
  this.typeCtx.jsDynamicDeclaration = (decl) => jsDynamic.has(decl);
4034
4412
  this.registerBuiltinErrorClasses();
@@ -4036,6 +4414,27 @@ export class Lowerer {
4036
4414
  registerBuiltinStreamClasses(this);
4037
4415
  registerBuiltinEventTargetClasses(this);
4038
4416
  }
4417
+ /** Whether preflight admitted the checker diagnostic `code` at `node`: a
4418
+ * site in `admittedOpinions` (tsc-codes.ts, JS_OPINIONS) whose span the
4419
+ * node contains. A `widen`/`throw`/`island` row's lowering path is reached
4420
+ * only through this query, so a program that admitted no such site keeps
4421
+ * the IR it has today. */
4422
+ opinionAt(node, code) {
4423
+ if (this.admittedOpinions.length === 0)
4424
+ return false;
4425
+ const file = ts.getSourceFileOfNode(node).fileName;
4426
+ const start = ts.tokenStartOfNode(node);
4427
+ const hit = this.admittedOpinionSites();
4428
+ const list = hit.get(`${file}\0${code}`);
4429
+ if (list === undefined)
4430
+ return false;
4431
+ return list.some((site) => start <= site.pos && site.end <= node.end);
4432
+ }
4433
+ /** opinionAt's index: admitted sites by file and code (one index per
4434
+ * admitted-opinions list, shared by the round). */
4435
+ admittedOpinionSites() {
4436
+ return this.facts.opinionIndex(this.admittedOpinions);
4437
+ }
4039
4438
  /** A JavaScript file TypeScript type-checks (`// @ts-check`, or the
4040
4439
  * project's `checkJs`). Its JSDoc types are enforced like TypeScript
4041
4440
  * annotations, so its classes use them as a TypeScript file would. */
@@ -4050,17 +4449,32 @@ export class Lowerer {
4050
4449
  registerBuiltinErrorClasses() {
4051
4450
  return registerBuiltinErrorClasses(this);
4052
4451
  }
4053
- classProtocols = null;
4054
4452
  classImplementedProtocol(type) {
4055
- this.classProtocols ??= new ClassProtocols(this.checker, this.moduleOrder);
4056
- return this.classProtocols.usesCheckedIdentity(type);
4453
+ return this.verifyProtocol("usesCheckedIdentity", type, (protocols) => protocols.usesCheckedIdentity(type));
4057
4454
  }
4058
4455
  /** A record view a Map or Set answers: it keeps protocol identity but
4059
4456
  * calls the collection's own methods, never a stored member. */
4060
4457
  classCollectionView(type) {
4061
- this.classProtocols ??= new ClassProtocols(this.checker, this.moduleOrder);
4062
- return this.classProtocols.collectionView(type);
4063
- }
4458
+ return this.verifyProtocol("collectionView", type, (protocols) => protocols.collectionView(type));
4459
+ }
4460
+ /** The round's shared class protocol index (lowering-facts.ts): a pure
4461
+ * analysis of (checker, moduleOrder). With SCRIPTC_LOWERING_FACTS_VERIFY
4462
+ * this Lowerer builds its own index and every answer is compared. */
4463
+ verifyProtocol(query, type, ask) {
4464
+ const answer = ask(this.facts.classProtocols());
4465
+ if (!this.facts.verify)
4466
+ return answer;
4467
+ if (this.ownClassProtocols === null) {
4468
+ this.ownClassProtocols = new ClassProtocols(this.checker, this.moduleOrder);
4469
+ }
4470
+ const fresh = ask(this.ownClassProtocols);
4471
+ this.facts.noteVerified("classProtocols");
4472
+ if (answer === fresh)
4473
+ return answer;
4474
+ throw new InternalCompilerError(`shared class protocol index answered ${String(answer)} for ${query} where a fresh ` +
4475
+ `index over the same program answered ${String(fresh)}`);
4476
+ }
4477
+ ownClassProtocols = null;
4064
4478
  /** Declared class fields may store a DYN value only when its static type
4065
4479
  * is `unknown` or `object` (also with `null` or `undefined`, or an array
4066
4480
  * of those), names checked protocol identity, is an owned runtime
@@ -4077,15 +4491,40 @@ export class Lowerer {
4077
4491
  this.weakCollectionType(type) ||
4078
4492
  this.stdlibHandleType(type, (part) => isEcdhType(this, part) || isDiffieHellmanType(this, part)));
4079
4493
  }
4080
- /** A stdlib WeakMap or WeakSet, alone or with `null`/`undefined`. */
4494
+ /** A stdlib WeakMap or WeakSet, alone or in a union with `null`/`undefined`
4495
+ * (including the `WeakMap | WeakSet` pair). */
4081
4496
  weakCollectionType(type) {
4497
+ return this.weakCollectionNamesOf(type) !== null;
4498
+ }
4499
+ /** The stdlib collections a type denotes — `WeakMap`, `WeakSet`, or the
4500
+ * two in a union — alone or with `null`/`undefined`, which `nullable`
4501
+ * reports; null for everything else. The predicate behind
4502
+ * weak-collection lowering and the JavaScript value read of one of
4503
+ * their methods, whose receiver may hold either collection. */
4504
+ weakCollectionNamesOf(type) {
4505
+ const names = [];
4082
4506
  const weak = (part) => {
4083
4507
  const symbol = part.getSymbol();
4084
- return (((symbol !== undefined && ts.symbolName(symbol) === "WeakMap") ||
4085
- (symbol !== undefined && ts.symbolName(symbol) === "WeakSet")) &&
4086
- symbol.declarations.some((d) => ts.isInterfaceDeclaration(d) && this.isStdlibFile(ts.getSourceFileOfNode(d))));
4508
+ if (symbol === undefined)
4509
+ return false;
4510
+ const symbolName = ts.symbolName(symbol);
4511
+ if (symbolName !== "WeakMap" && symbolName !== "WeakSet")
4512
+ return false;
4513
+ if (!symbol.declarations.some((d) => ts.isInterfaceDeclaration(d) && this.isStdlibFile(ts.getSourceFileOfNode(d))))
4514
+ return false;
4515
+ if (!names.includes(symbolName))
4516
+ names.push(symbolName);
4517
+ return true;
4518
+ };
4519
+ if (!this.stdlibHandleType(type, weak))
4520
+ return null;
4521
+ return {
4522
+ names,
4523
+ nullable: type.isUnionType() &&
4524
+ ts
4525
+ .constituentTypes(type)
4526
+ .some((part) => (part.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0),
4087
4527
  };
4088
- return this.stdlibHandleType(type, weak);
4089
4528
  }
4090
4529
  /** A type `handle` accepts, alone or with `null`/`undefined`. */
4091
4530
  stdlibHandleType(type, handle) {
@@ -4123,7 +4562,7 @@ export class Lowerer {
4123
4562
  !decl.fileName.endsWith(".cts") &&
4124
4563
  !isCjsJsFile(decl, this.program) &&
4125
4564
  this.moduleOrder.includes(decl)) {
4126
- return `file:${tsgoPath(resolve(decl.fileName))}`;
4565
+ return `file:${this.pathOf(decl)}`;
4127
4566
  }
4128
4567
  if (ts.isModuleDeclaration(decl) && ts.isStringLiteral(decl.name)) {
4129
4568
  const builtin = canonicalBuiltinModule(decl.name.text);
@@ -4269,6 +4708,11 @@ export class Lowerer {
4269
4708
  * program-unique through the file qualifier, and collision-free with
4270
4709
  * user identifiers ('%'). */
4271
4710
  classNamer = (decl) => {
4711
+ // A class declared inside a function takes the instantiated owner's name
4712
+ // (`%<instance>`, below), so its type's answer is per instance — and a
4713
+ // mapping that reads it may not be shared between scopes.
4714
+ if (this.classInsideFunction(decl))
4715
+ noteScopeSensitiveMapping();
4272
4716
  const name = ts.isClassExpression(decl) ||
4273
4717
  (() => {
4274
4718
  for (let parent = decl.parent; parent && !ts.isSourceFile(parent); parent = parent.parent) {
@@ -4288,6 +4732,16 @@ export class Lowerer {
4288
4732
  }
4289
4733
  return name;
4290
4734
  };
4735
+ /** True for a class declaration lexically inside a function: only such a
4736
+ * class can take an instantiated owner's name (classNamer), and only there
4737
+ * can localClassInstance's instantiation-stack check answer. */
4738
+ classInsideFunction(decl) {
4739
+ for (let parent = decl.parent; parent !== undefined && !ts.isSourceFile(parent); parent = parent.parent) {
4740
+ if (ts.isFunctionLike(parent))
4741
+ return true;
4742
+ }
4743
+ return false;
4744
+ }
4291
4745
  /** Follows import aliases to the original declaration's symbol. Every
4292
4746
  * value reference resolves through here, so it doubles as the flush
4293
4747
  * point for deferred collection diagnostics: resolving a reference to a
@@ -5400,8 +5854,71 @@ export class Lowerer {
5400
5854
  }
5401
5855
  }
5402
5856
  }
5857
+ /** A JavaScript `let`/`var` binding assigned a value its declared type
5858
+ * does not admit (`let t = parseInt(s); if (isNaN(t)) t = undefined`):
5859
+ * TypeScript types the binding from its initializer and reports the
5860
+ * assignment (TS2322), which JavaScript files relax, so the binding takes
5861
+ * checked-dynamic storage and holds whatever the program stores. JSDoc
5862
+ * type annotations keep their declared storage.
5863
+ *
5864
+ * A set accessor's unannotated parameter joins them: a JavaScript setter's
5865
+ * parameter is whatever the caller passes, and `paramShape` gives the slot
5866
+ * checked-dynamic storage. The checker types it from the twin getter's
5867
+ * return when one exists (`set value(next) { this.stored = next; }` beside
5868
+ * `get value() { return this.stored; }` types `next` as the getter's type),
5869
+ * and otherwise reports TS7032; reading the parameter at the inferred type
5870
+ * would check the caller's value back into it and throw where Node stores
5871
+ * it as is. A JSDoc `@param` type keeps its declared storage, exactly like
5872
+ * a variable's `@type`. */
5873
+ analyzeJsWidenedBindings(parts) {
5874
+ for (const { sf } of parts) {
5875
+ if (!isJsSourceFileName(sf.fileName) || sf.isDeclarationFile)
5876
+ continue;
5877
+ ts.walkPreorder(sf, (node) => {
5878
+ if (ts.isParameter(node) &&
5879
+ ts.isSetAccessorDeclaration(node.parent) &&
5880
+ !node.type &&
5881
+ ts.isIdentifier(node.name) &&
5882
+ !hasJsSetterParamAnnotation(node)) {
5883
+ const setterParam = this.resolveValueSymbol(node.name);
5884
+ if (setterParam)
5885
+ this.jsWidenedBindings.add(setterParam);
5886
+ return undefined;
5887
+ }
5888
+ if (!ts.isBinaryExpression(node) ||
5889
+ node.operatorToken.kind !== ts.SyntaxKind.EqualsToken ||
5890
+ !ts.isIdentifier(node.left))
5891
+ return undefined;
5892
+ const symbol = this.resolveValueSymbol(node.left);
5893
+ if (!symbol || this.runtimeOptionalBindingTypes.has(symbol))
5894
+ return undefined;
5895
+ const decl = symbol.valueDeclaration;
5896
+ if (decl === undefined ||
5897
+ !ts.isVariableDeclaration(decl) ||
5898
+ !ts.isIdentifier(decl.name) ||
5899
+ !isJsSourceFileName(ts.getSourceFileOfNode(decl).fileName) ||
5900
+ hasJsTypeAnnotation(decl) ||
5901
+ decl.parent === undefined ||
5902
+ !ts.isVariableDeclarationList(decl.parent) ||
5903
+ (decl.parent.flags & ts.NodeFlags.Const) !== 0)
5904
+ return undefined;
5905
+ const declared = this.checker.getTypeOfSymbol(symbol);
5906
+ if (declared.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
5907
+ return undefined;
5908
+ const assigned = this.checker.getTypeAtLocation(node.right);
5909
+ if (this.checker.isTypeAssignableTo(assigned, declared))
5910
+ return undefined;
5911
+ this.runtimeOptionalBindingTypes.set(symbol, DYN);
5912
+ this.jsWidenedBindings.add(symbol);
5913
+ const global = this.globalsBySymbol.get(symbol);
5914
+ if (global)
5915
+ global.type = DYN;
5916
+ return undefined;
5917
+ });
5918
+ }
5919
+ }
5403
5920
  analyzeRuntimeOptionalArrayReads(parts) {
5404
- const provenance = RuntimeOptionalProvenance.fromEnvironment();
5921
+ const provenance = this.runtimeOptionalProvenance;
5405
5922
  // The site whose value the current promotion follows (debug only).
5406
5923
  let provenanceSite;
5407
5924
  const optionalSymbols = new Set();
@@ -5714,19 +6231,31 @@ export class Lowerer {
5714
6231
  };
5715
6232
  /** `r.name` where the name resolves to the receiver's index signature. */
5716
6233
  const isRecordIndexPropertyRead = (e) => {
5717
- // A name that resolves to a declared member is not an index read, and
5718
- // only a receiver with an index signature maps to an indexed record.
5719
- if (symbolOf(e.name))
5720
- return false;
5721
- const receiverType = this.typeOf(e.expression);
5722
- if (this.checker.getIndexInfosOfType(receiverType).length === 0)
6234
+ // A name that resolves to a declared member is a member read, and only
6235
+ // a receiver with an index signature maps to an indexed record. The
6236
+ // name's own symbol separates the two spellings: a mapped
6237
+ // `Record<string, V>` answers no declaration at all, while a named
6238
+ // object type answers the index signature's symbol, whose declaration
6239
+ // is that signature. Reading the receiver's type instead would ask the
6240
+ // checker about a node inside a body lowered only for coverage, which
6241
+ // the batch prefetch covers and an extra individual query does not.
6242
+ const nameSymbol = symbolOf(e.name);
6243
+ const answersIndexSignature = nameSymbol === null ||
6244
+ (nameSymbol.declarations ?? []).some((decl) => ts.isIndexSignatureDeclaration(decl));
6245
+ if (!answersIndexSignature)
5723
6246
  return false;
5724
- const receiver = this.mapTypeOf(receiverType);
6247
+ const receiver = this.mapTypeOf(this.typeOf(e.expression));
5725
6248
  if (receiver?.kind !== "record")
5726
6249
  return false;
5727
6250
  const shape = this.shapes.get(receiver.shapeId);
5728
6251
  if (!shape || shape.tuple || !shape.indexValue || shape.indexValue.kind === "dyn")
5729
6252
  return false;
6253
+ // A slot whose value type already admits undefined tells the checker
6254
+ // itself that a key can be missing (`{ [name: string]: string |
6255
+ // undefined }` in the http-header shape), so the read hides nothing.
6256
+ if (shape.indexValue.kind === "union" &&
6257
+ this.armTag(shape.indexValue.unionId, UNDEFINED_T) >= 0)
6258
+ return false;
5730
6259
  if (shape.fields.some((field) => field.name === e.name.text))
5731
6260
  return false;
5732
6261
  const read = this.mapTypeOf(this.typeOf(e));
@@ -8288,6 +8817,11 @@ export class Lowerer {
8288
8817
  }
8289
8818
  }
8290
8819
  provenance?.flush();
8820
+ // Coverage (--explain-dynamic): the slots the analysis widened past the
8821
+ // checker's type, with the reads that narrow them back and the
8822
+ // decisions that widened them. Report-only; lowering does not read it.
8823
+ if (this.runtimeOptionalReport)
8824
+ this.runtimeOptionalNarrowings = runtimeOptionalNarrowings(this, sourceFiles);
8291
8825
  }
8292
8826
  run() {
8293
8827
  const parts = this.splitFiles();
@@ -8309,6 +8843,7 @@ export class Lowerer {
8309
8843
  this.analyzeRuntimeOptionalArrayReads(parts);
8310
8844
  this.analyzeDateJsonResults(parts);
8311
8845
  this.analyzeGuardedRecordReadGlobals(parts);
8846
+ this.analyzeJsWidenedBindings(parts);
8312
8847
  });
8313
8848
  // Decorated classes analyze AFTER the whole collection pass: a
8314
8849
  // decorator's return type may name a subclass declared below the
@@ -8466,9 +9001,12 @@ export class Lowerer {
8466
9001
  // array-HOF loop functions, which ride the same list), and the
8467
9002
  // implicit-any instances lowered eagerly at their first call sites.
8468
9003
  this.settleSharedHelperLocations([...functions, ...this.liftedFns, ...this.implicitFns]);
8469
- functions.push(...this.liftedFns);
8470
- functions.push(...this.implicitFns);
8471
- functions.push(...runtimeClassConstructs(this, functions));
9004
+ for (const fn of this.liftedFns)
9005
+ functions.push(fn);
9006
+ for (const fn of this.implicitFns)
9007
+ functions.push(fn);
9008
+ for (const fn of runtimeClassConstructs(this, functions))
9009
+ functions.push(fn);
8472
9010
  if (this.remainder) {
8473
9011
  // Deferred collection diagnostics nothing flushed — declarations no
8474
9012
  // reference ever made relevant. They belong to the unreached group
@@ -8479,6 +9017,9 @@ export class Lowerer {
8479
9017
  for (const d of [...diags])
8480
9018
  this.pushDiag(d);
8481
9019
  }
9020
+ // Coverage visits more bodies; more value instances can only add
9021
+ // refusals to the identity comparison check.
9022
+ checkGenericIdentityPins(this);
8482
9023
  return {
8483
9024
  module: null,
8484
9025
  diagnostics: this.diags,
@@ -8491,12 +9032,25 @@ export class Lowerer {
8491
9032
  return this.finishModule(functions);
8492
9033
  }
8493
9034
  /** Final retention, pruning, and module assembly shared by ordinary emit
8494
- * and the retained reachability worklist. */
8495
- finishModule(functions) {
9035
+ * and the retained reachability worklist. `library` is true for a native
9036
+ * library's emit, whose runtime has no builtin-statics unit. */
9037
+ finishModule(functions, library = false) {
9038
+ // Every instance of every generic value is known now (the
9039
+ // monomorphization worklists drained): an identity comparison against
9040
+ // one is exact only if the declaration is held at a single signature.
9041
+ checkGenericIdentityPins(this);
9042
+ finalizeRecordLinks(this, functions);
9043
+ // The statics lookup installs before value boxing, so the function
9044
+ // values it adds to the entry module are boxed with the rest.
9045
+ if (!library)
9046
+ installBuiltinStatics(this, functions);
9047
+ boxBuiltinValuesChecked(this, functions);
9048
+ finalizeFunctionNames(this, functions);
8496
9049
  if (this.diags.length === 0)
8497
9050
  fuseArrayPipelines(this, functions);
8498
9051
  finalizeClassMethodValues(this, functions);
8499
9052
  finalizePrivateBrands(this, functions);
9053
+ routeWrapperConsumers(this, functions);
8500
9054
  trackClassFieldCreation(this, functions);
8501
9055
  boxClassInstancesExactly(this, functions);
8502
9056
  addUntypedIntegrityWords(this);
@@ -8504,6 +9058,9 @@ export class Lowerer {
8504
9058
  guardFrozenWrites(this, functions);
8505
9059
  applyHandleProperties(this, functions);
8506
9060
  installBufferValue(functions);
9061
+ // A mutable-buffers program arms the views registry before any buffer
9062
+ // exists, so every buffer in it is detachable from the start.
9063
+ const buffersMutable = this.buffersMutable && installMutableBuffersArm(functions);
8507
9064
  installFetchBodyWebStreams(this, functions);
8508
9065
  returnDispatchReceivers(this, functions);
8509
9066
  // Globals typed by a class that never REGISTERED (a JS class whose
@@ -8626,10 +9183,12 @@ export class Lowerer {
8626
9183
  ...(this.threadSlotKeys.size > 0
8627
9184
  ? { threadSlotKeys: [...this.threadSlotKeys].sort() }
8628
9185
  : {}),
9186
+ ...(this.recordLinks.size > 0 ? { recordLinks: [...this.recordLinks.values()] } : {}),
8629
9187
  ...(this.freezableArrays.size > 0
8630
9188
  ? { freezableArrays: [...this.freezableArrays].sort() }
8631
9189
  : {}),
8632
9190
  ...(this.untypedIntegrity ? { untypedIntegrity: true } : {}),
9191
+ ...(buffersMutable ? { bytesHeadersMutable: true } : {}),
8633
9192
  ...(sloppyDynWrites.length > 0 ? { sloppyDynWrites } : {}),
8634
9193
  ...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
8635
9194
  ...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
@@ -8653,11 +9212,19 @@ export class Lowerer {
8653
9212
  // becomes its js twin), so coverage's dynamic statements are unchanged.
8654
9213
  if (module && this.dynamicFunctions.length > 0)
8655
9214
  promoteJsvals(module);
9215
+ // A program that replaces a process output stream's write method beside
9216
+ // Node islands is refused by the executable planner (SC8006): an
9217
+ // island's process.stdout is its own object. Only island builds pay for
9218
+ // the whole-program scan.
9219
+ const stdioPatches = this.nodeIslands !== null && programPatchesStdio(this)
9220
+ ? [...this.stdioPatchSites]
9221
+ : undefined;
8656
9222
  return {
8657
9223
  module,
8658
9224
  diagnostics: this.diags,
8659
9225
  runtimeFences: this.runtimeFences,
8660
9226
  stats: this.stats,
9227
+ ...(stdioPatches !== undefined && stdioPatches.length > 0 ? { stdioPatches } : {}),
8661
9228
  ...(this.dynamicFunctions.length > 0 ? { dynamicFunctions: this.dynamicFunctions } : {}),
8662
9229
  ...(this.statsByFile.size > 0 ? { statsByFile: this.statsByFile } : {}),
8663
9230
  ...(this.provenanceElided.length > 0 ? { provenanceElided: this.provenanceElided } : {}),
@@ -8760,11 +9327,14 @@ export class Lowerer {
8760
9327
  reportBlockedBody(decl) {
8761
9328
  const diags = blockedBodyDiagnostics(this, decl);
8762
9329
  const symbol = declSymbolOf(this, decl);
8763
- if (symbol && this.alreadyFlushed.has(symbol))
8764
- this.reachedBlockedBodyDiagnostics.push(...diags);
8765
- else
9330
+ if (symbol && this.alreadyFlushed.has(symbol)) {
9331
+ for (const d of diags)
9332
+ this.reachedBlockedBodyDiagnostics.push(d);
9333
+ }
9334
+ else {
8766
9335
  for (const d of diags)
8767
9336
  this.pushDiag(d);
9337
+ }
8768
9338
  }
8769
9339
  /** Whether run() counts a signature-blocked declaration in
8770
9340
  * stats.functionsSkipped: whole-program passes and the coverage
@@ -8774,6 +9344,42 @@ export class Lowerer {
8774
9344
  return this.reachable === null || this.remainder;
8775
9345
  }
8776
9346
  /* ── reachability ─────────────────────────────────────────────────── */
9347
+ /** LIBRARY mode: the unit the root name `name` seeds, resolved through
9348
+ * the entry module's export table. A direct `export function f` and every
9349
+ * facade that names it (`export { f }`, `export { f as g }`,
9350
+ * `export { f } from "./m"`, `export * from "./m"`) reach the same
9351
+ * declaration, and the unit is whatever the declaration's own module
9352
+ * qualified it as — the entry's bare name or another module's `%mN.` tag.
9353
+ * Memoized: the four emit passes and the result's export map read one
9354
+ * answer. Null when the name is not an export of a compiled function
9355
+ * (SC4002/SC4004/SC4007 report it). */
9356
+ libExportUnit(name) {
9357
+ const memo = this.libExportUnits;
9358
+ if (memo.has(name))
9359
+ return memo.get(name);
9360
+ const symbol = resolveEntryExportSymbol(this.checker, this.entry, name);
9361
+ let unit = null;
9362
+ if (symbol !== null) {
9363
+ unit = this.fnSigsBySymbol.get(symbol)?.name ?? null;
9364
+ if (unit === null) {
9365
+ // The export table's symbol can be a copy of the declaration's; the
9366
+ // declaration's own symbol is the one signatures are keyed by.
9367
+ for (const declaration of symbol.declarations) {
9368
+ if (!ts.isFunctionDeclaration(declaration))
9369
+ continue;
9370
+ const declared = declSymbolOf(this, declaration);
9371
+ unit = declared === undefined ? null : (this.fnSigsBySymbol.get(declared)?.name ?? null);
9372
+ if (unit !== null)
9373
+ break;
9374
+ }
9375
+ }
9376
+ }
9377
+ memo.set(name, unit);
9378
+ return unit;
9379
+ }
9380
+ /** One answer per root name: a pass builds its own Lowerer, and the
9381
+ * signatures this reads are collected before any body is lowered. */
9382
+ libExportUnits = new Map();
8777
9383
  /** Reachable emit: computes the set of body names the program's entry
8778
9384
  * reaches and retains each body IR as it lowers. Seeds are the per-file
8779
9385
  * init bodies (top-level statements always run); edges fire from
@@ -8787,7 +9393,7 @@ export class Lowerer {
8787
9393
  * demand-driven) and lifted lambdas lower inline with their enclosing
8788
9394
  * body; both fire edges through the same hooks and are not units
8789
9395
  * themselves. */
8790
- emitReachable(extraRoots) {
9396
+ emitReachable(extraRoots, unitStore = null) {
8791
9397
  // Frontend passes below rewrite function bodies through the IR mapper
8792
9398
  // (caught-value and class dispatch); key-order notes follow the record
8793
9399
  // literals they rebuild until the witness pass has read them.
@@ -8817,23 +9423,47 @@ export class Lowerer {
8817
9423
  collectionEdges.add(name);
8818
9424
  };
8819
9425
  this.prefetchProgramSymbols(parts);
8820
- this.collectProgram(parts);
8821
- this.speculativeTypeQueries(() => {
8822
- extendAssertedRecordMembers(this, parts.map((fp) => fp.sf));
8823
- this.analyzeRuntimeOptionalArrayReads(parts);
8824
- this.analyzeDateJsonResults(parts);
8825
- this.analyzeGuardedRecordReadGlobals(parts);
8826
- });
8827
- // Decorated classes analyze post-collection here too: the %init seeds
8828
- // lower the decoration calls, whose edges (decorator bodies, construct
8829
- // thunks) reachable emit must see.
8830
- for (const info of this.classes.values())
8831
- analyzeClassDecoration(this, info);
8832
- this.prepareModuleInits(parts);
8833
- prepareCjsModuleGraph(this, parts);
9426
+ // Collection poisons the pass the way statement lowering does: a Node
9427
+ // island module the build cannot ship pushes its diagnostic (SC8006)
9428
+ // and aborts (nodeIslandModules.addLoaded, lower-node-island.ts). The
9429
+ // diagnostic is the report, and emission must not run on a program
9430
+ // collected halfway, so the pass ends here with it. A poison nothing
9431
+ // reported is still a bug and stays a crash.
9432
+ try {
9433
+ this.collectProgram(parts);
9434
+ this.speculativeTypeQueries(() => {
9435
+ extendAssertedRecordMembers(this, parts.map((fp) => fp.sf));
9436
+ this.analyzeRuntimeOptionalArrayReads(parts);
9437
+ this.analyzeDateJsonResults(parts);
9438
+ this.analyzeGuardedRecordReadGlobals(parts);
9439
+ this.analyzeJsWidenedBindings(parts);
9440
+ });
9441
+ // Decorated classes analyze post-collection here too: the %init seeds
9442
+ // lower the decoration calls, whose edges (decorator bodies, construct
9443
+ // thunks) reachable emit must see.
9444
+ for (const info of this.classes.values())
9445
+ analyzeClassDecoration(this, info);
9446
+ this.prepareModuleInits(parts);
9447
+ prepareCjsModuleGraph(this, parts);
9448
+ }
9449
+ catch (e) {
9450
+ if (!(e instanceof PoisonError) || this.diags.length === 0)
9451
+ throw e;
9452
+ return {
9453
+ reachable: collectionEdges,
9454
+ result: {
9455
+ module: null,
9456
+ diagnostics: this.diags,
9457
+ runtimeFences: this.runtimeFences,
9458
+ stats: this.stats,
9459
+ },
9460
+ };
9461
+ }
8834
9462
  // Every lowerable body, by emitted-function name. The names double as
8835
9463
  // retained-function keys and are deterministic by construction
8836
9464
  // (qualified declaration names).
9465
+ // `source` is the declaration whose text a unit lowers and `owners` the
9466
+ // declarations around it (unit-reuse.ts).
8837
9467
  const units = new Map();
8838
9468
  // Roots are collected with plain pushes: spread arguments into a rest
8839
9469
  // parameter pass the nodes as dynamic values.
@@ -8884,6 +9514,7 @@ export class Lowerer {
8884
9514
  order: unitOrder++,
8885
9515
  roots: functionRoots(decl),
8886
9516
  lower: () => this.lowerFunction(decl),
9517
+ source: decl,
8887
9518
  });
8888
9519
  }
8889
9520
  }
@@ -8906,6 +9537,7 @@ export class Lowerer {
8906
9537
  order: unitOrder++,
8907
9538
  roots: classCtorRoots(info),
8908
9539
  lower: () => info.localClass && !info.localClass.ready ? null : this.lowerClassCtor(info),
9540
+ source: info.decl ?? undefined,
8909
9541
  });
8910
9542
  // The descriptor helpers of a class that extends Array, reached
8911
9543
  // from its constructor.
@@ -8914,11 +9546,13 @@ export class Lowerer {
8914
9546
  order: unitOrder++,
8915
9547
  roots: [],
8916
9548
  lower: () => arrayClassFieldsFn(this, info),
9549
+ source: info.decl ?? undefined,
8917
9550
  });
8918
9551
  units.set(`%${cName}.species`, {
8919
9552
  order: unitOrder++,
8920
9553
  roots: [],
8921
9554
  lower: () => arrayClassSpeciesFn(this, info),
9555
+ source: info.decl ?? undefined,
8922
9556
  });
8923
9557
  }
8924
9558
  for (const { mName, member } of this.classMethodMembers(info)) {
@@ -8928,6 +9562,8 @@ export class Lowerer {
8928
9562
  lower: () => info.localClass && !info.localClass.ready
8929
9563
  ? null
8930
9564
  : this.lowerClassMethodMember(info, member),
9565
+ source: member,
9566
+ owners: info.decl ? [info.decl] : [],
8931
9567
  });
8932
9568
  }
8933
9569
  for (const prop of info.throwingSetters) {
@@ -8935,6 +9571,7 @@ export class Lowerer {
8935
9571
  order: unitOrder++,
8936
9572
  roots: [],
8937
9573
  lower: () => this.throwingSetterFn(info, prop),
9574
+ source: info.decl ?? undefined,
8938
9575
  });
8939
9576
  }
8940
9577
  }
@@ -8944,6 +9581,8 @@ export class Lowerer {
8944
9581
  order: unitOrder++,
8945
9582
  roots: functionRoots(entry.member),
8946
9583
  lower: () => lowerStaticMethod(this, info, name),
9584
+ source: entry.member,
9585
+ owners: info.decl ? [info.decl] : [],
8947
9586
  });
8948
9587
  }
8949
9588
  }
@@ -9218,11 +9857,16 @@ export class Lowerer {
9218
9857
  });
9219
9858
  // LIBRARY mode's extra reachability roots (LowerOptions.libRoots): the
9220
9859
  // profile-mapped exports are called from outside the graph, so they
9221
- // seed the worklist beside the init bodies. Unknown names are inert
9222
- // (the export-map resolution reports them as SC4002 later).
9860
+ // seed the worklist beside the init bodies. Each name resolves through
9861
+ // the entry module's export table to the unit that supplies it, so a
9862
+ // re-exported function seeds its own module's unit. Unknown names are
9863
+ // inert (the export-map resolution reports them as SC4002 later).
9223
9864
  const rootEdge = this.onEdge;
9224
- for (const root of extraRoots ?? [])
9225
- rootEdge?.(root);
9865
+ for (const root of extraRoots ?? []) {
9866
+ const unit = this.libExportUnit(root);
9867
+ if (unit !== null)
9868
+ rootEdge?.(unit);
9869
+ }
9226
9870
  const shuffle = lowerShuffle();
9227
9871
  const lowerUnitBody = (name) => {
9228
9872
  const unit = units.get(name);
@@ -9230,17 +9874,77 @@ export class Lowerer {
9230
9874
  const owner = demandOwner(priority);
9231
9875
  return this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => this.withClosureRoot(name, unit.lower)));
9232
9876
  };
9233
- const recorded = journalMode() === "serial" ? waveStats() : null;
9234
- const host = recorded === null ? null : this.waveHost(loweredUnits, lowerUnitBody);
9877
+ // With a unit store, every unit is recorded as in the serial mode, and
9878
+ // a unit applies the record an earlier build stored for it where that
9879
+ // record still holds (unit-reuse.ts).
9880
+ const reuse = unitStore === null
9881
+ ? null
9882
+ : UnitReuse.open(unitStore, this.program, parts.map((fp) => fp.sf), {
9883
+ facts: (declaration) => this.declarationFacts(declaration),
9884
+ exportsOf: (specifier) => {
9885
+ const symbol = this.checker.getSymbolAtLocation(specifier);
9886
+ if (!symbol)
9887
+ return null;
9888
+ return this.checker
9889
+ .getExportsOfModule(symbol)
9890
+ .map((exported) => ts.symbolName(exported))
9891
+ .sort()
9892
+ .join("\n");
9893
+ },
9894
+ isLocal: (identifier, container) => {
9895
+ const declarations = this.checker.getSymbolAtLocation(identifier)?.declarations;
9896
+ if (declarations === undefined || declarations.length === 0)
9897
+ return false;
9898
+ const sf = ts.getSourceFileOfNode(container);
9899
+ return declarations.every((declaration) => ts.getSourceFileOfNode(declaration) === sf &&
9900
+ declaration.pos >= container.pos &&
9901
+ declaration.end <= container.end);
9902
+ },
9903
+ });
9904
+ const recorded = journalMode() === "serial" || (reuse !== null && reuse.records) ? waveStats() : null;
9905
+ const host = recorded === null
9906
+ ? null
9907
+ : this.waveHost(loweredUnits, lowerUnitBody, (name) => {
9908
+ const priority = metadataPriority.get(name);
9909
+ return { owner: demandOwner(priority), priority };
9910
+ });
9235
9911
  const dump = recorded === null ? null : journalDump();
9912
+ const fileOfUnit = (name) => {
9913
+ const source = units.get(name)?.source;
9914
+ return source === undefined ? null : ts.getSourceFileOfNode(source).fileName;
9915
+ };
9916
+ const waveReuse = reuse === null || !reuse.records
9917
+ ? null
9918
+ : {
9919
+ verify: unitReuseVerify(),
9920
+ stored: (name) => {
9921
+ // A unit without a declared rank takes the next expression
9922
+ // rank when it lowers, which applying a record would not
9923
+ // advance.
9924
+ const unit = units.get(name);
9925
+ const file = fileOfUnit(name);
9926
+ if (unit === undefined || file === null || !metadataPriority.has(name))
9927
+ return null;
9928
+ return reuse.candidate(name, file, unit.source ?? null, unit.owners ?? []);
9929
+ },
9930
+ check: (name, stored, pending, unit) => verifyStoredUnit(name, stored, pending, unit.record, unit.reasons),
9931
+ note: (name, record, applied, files) => {
9932
+ const file = fileOfUnit(name);
9933
+ if (file !== null)
9934
+ reuse.note(name, file, record, applied, files);
9935
+ },
9936
+ };
9236
9937
  const recordLines = [];
9237
9938
  const drainUnits = () => {
9939
+ // The waves of one drain have only checker prefetches between them, so
9940
+ // they share the content their units start from (HeldTables).
9941
+ const held = host !== null && recorded !== null ? new HeldTables(host.tables, recorded) : null;
9238
9942
  while (queue.length > 0) {
9239
9943
  const wave = queue.splice(0);
9240
9944
  shuffle?.(wave);
9241
9945
  this.checker.prefetchRoots(wave.flatMap((name) => units.get(name).roots));
9242
9946
  if (host !== null && recorded !== null) {
9243
- lowerWaveRecorded(host, wave, recorded, dump === null ? null : recordLines);
9947
+ lowerWaveRecorded(host, wave, recorded, dump === null ? null : recordLines, waveReuse, held);
9244
9948
  continue;
9245
9949
  }
9246
9950
  for (const name of wave) {
@@ -9260,6 +9964,7 @@ export class Lowerer {
9260
9964
  }
9261
9965
  }
9262
9966
  }
9967
+ held?.check();
9263
9968
  };
9264
9969
  drainUnits();
9265
9970
  this.restoreGenericInstanceOrder();
@@ -9301,6 +10006,11 @@ export class Lowerer {
9301
10006
  classDispatch.finalize(this);
9302
10007
  if (dump !== null)
9303
10008
  writeRecords(dump, recordLines);
10009
+ if (reuse !== null) {
10010
+ reuse.finish();
10011
+ if (process.env["SCRIPTC_TIMING"] === "1")
10012
+ process.stderr.write(`scriptc lowering ${JSON.stringify({ phase: "unit-reuse", ...reuse.stats })}\n`);
10013
+ }
9304
10014
  if (recorded !== null && process.env["SCRIPTC_TIMING"] === "1")
9305
10015
  process.stderr.write(`scriptc lowering ${JSON.stringify({ phase: "unit-records", ...recorded })}\n`);
9306
10016
  const orderedUnits = unitsInOrder();
@@ -9308,13 +10018,30 @@ export class Lowerer {
9308
10018
  this.shapes.settleDeclaredOrderPriorities();
9309
10019
  for (const finalize of this.shapeOrderMetadataFinalizers)
9310
10020
  finalize();
9311
- applyKeyOrderWitnesses(this, [
10021
+ const keyOrderFunctions = [
9312
10022
  ...orderedUnits,
9313
10023
  ...initFunctions,
9314
10024
  ...instanceFunctions,
9315
10025
  ...this.liftedFns,
9316
10026
  ...this.implicitFns,
9317
- ]);
10027
+ ];
10028
+ // A program whose functions never convert a checked-dynamic value into a
10029
+ // closed record cannot keep a source view anywhere, so the captures that
10030
+ // consult one keep their static copy (record-sources.ts). Decided before
10031
+ // the key-order pass, which reads the fact (a same-shape copy of a kept
10032
+ // record keeps its keys; the `"k" in r` sites answer through the view).
10033
+ const sourceScan = { memo: new Map(), visiting: new Set() };
10034
+ for (const fn of keyOrderFunctions) {
10035
+ if (!functionKeepsRecordSources(this, fn, sourceScan))
10036
+ continue;
10037
+ this.recordSourcesPossible = true;
10038
+ break;
10039
+ }
10040
+ applyKeyOrderWitnesses(this, keyOrderFunctions);
10041
+ // A kept width spread builds a record that holds undeclared keys, so the
10042
+ // captures that consult a kept source must be active for it too.
10043
+ if (this.keyOrder.keptWidthSpreads > 0)
10044
+ this.recordSourcesPossible = true;
9318
10045
  observeRecordLiteralRebuilds(null);
9319
10046
  for (const finalize of this.shapeOrderHelperFinalizers)
9320
10047
  finalize();
@@ -9335,7 +10062,8 @@ export class Lowerer {
9335
10062
  ...byName(this.liftedFns),
9336
10063
  ...byName(this.implicitFns),
9337
10064
  ];
9338
- functions.push(...runtimeClassConstructs(this, functions));
10065
+ for (const fn of runtimeClassConstructs(this, functions))
10066
+ functions.push(fn);
9339
10067
  if (this.regexGroupResults)
9340
10068
  for (const fn of functions)
9341
10069
  foldRegexSpanReads(this, fn);
@@ -9348,11 +10076,52 @@ export class Lowerer {
9348
10076
  files: parts.map((fp) => fp.sf),
9349
10077
  });
9350
10078
  this.reachableForArtifacts = reachable;
9351
- return { reachable, result: this.finishModule(functions) };
10079
+ return { reachable, result: this.finishModule(functions, extraRoots !== undefined) };
10080
+ }
10081
+ /** What the steps before the worklist settled for a top-level
10082
+ * declaration, as text without source positions (unit-reuse.ts): a
10083
+ * function's signature, a class's layout and the signatures of its
10084
+ * methods and statics, and the globals of a variable statement. */
10085
+ declarationFacts(declaration) {
10086
+ const positionFree = (key, value) => key === "loc" || key === "scope" ? undefined : value;
10087
+ if (ts.isFunctionDeclaration(declaration)) {
10088
+ const symbol = declSymbolOf(this, declaration);
10089
+ const sig = symbol ? this.fnSigsBySymbol.get(symbol) : undefined;
10090
+ return sig === undefined ? "" : JSON.stringify(sig, positionFree);
10091
+ }
10092
+ if (ts.isClassDeclaration(declaration)) {
10093
+ const info = this.classes.get(this.classNamer(declaration));
10094
+ if (info === undefined)
10095
+ return "";
10096
+ const staticMethods = [];
10097
+ if (info.staticMethods)
10098
+ for (const [name, method] of info.staticMethods)
10099
+ staticMethods.push({ name, params: method.params, ret: method.ret });
10100
+ return JSON.stringify({
10101
+ def: info.def,
10102
+ fields: [...info.fields],
10103
+ methods: [...info.methods],
10104
+ statics: info.staticFields.map((field) => ({
10105
+ name: field.name,
10106
+ type: field.type,
10107
+ runtimeOptional: field.runtimeOptional ?? false,
10108
+ globalId: field.globalId,
10109
+ readonly: field.readonly,
10110
+ })),
10111
+ staticMethods,
10112
+ }, positionFree);
10113
+ }
10114
+ if (ts.isVariableStatement(declaration)) {
10115
+ const globals = [];
10116
+ for (const decl of declaration.declarationList.declarations.nodes)
10117
+ globals.push(this.globalsByDeclNode.get(decl) ?? null);
10118
+ return JSON.stringify(globals, positionFree);
10119
+ }
10120
+ return "";
9352
10121
  }
9353
10122
  /** The lowerer's side of a recorded wave (unit-journal.ts).
9354
10123
  * `lowerUnitBody` lowers a unit as reachable emit does. */
9355
- waveHost(loweredUnits, lowerUnitBody) {
10124
+ waveHost(loweredUnits, lowerUnitBody, ownerOf) {
9356
10125
  const scalars = this.journalScalars();
9357
10126
  const flags = new Map(scalars.map((scalar) => [scalar.name, scalar]));
9358
10127
  let instances = new Map();
@@ -9384,6 +10153,35 @@ export class Lowerer {
9384
10153
  return undefined;
9385
10154
  }
9386
10155
  };
10156
+ // Makes a recorded call again (resolves has answered true for it).
10157
+ const replay = (event) => {
10158
+ switch (event.kind) {
10159
+ case "edge":
10160
+ this.noteEdge(event.name);
10161
+ break;
10162
+ case "superConstructorEdge":
10163
+ this.noteSuperConstructorEdge(event.name);
10164
+ break;
10165
+ case "virtualEdge":
10166
+ this.noteVirtualEdge(classNamed(event.name), event.detail);
10167
+ break;
10168
+ case "functionDemand":
10169
+ this.noteGenericInstanceDemand(instanceNamed(event.name));
10170
+ break;
10171
+ case "classDemand":
10172
+ this.noteGenericClassInstanceDemand(classNamed(event.name));
10173
+ break;
10174
+ case "statement":
10175
+ this.countStatement(statementNode(event), event.detail ?? undefined);
10176
+ break;
10177
+ case "failedStatement":
10178
+ this.countStatementFailed(statementNode(event), event.detail ?? undefined);
10179
+ break;
10180
+ case "flag":
10181
+ flags.get(event.name).set();
10182
+ break;
10183
+ }
10184
+ };
9387
10185
  return {
9388
10186
  tables: this.journalTables(),
9389
10187
  scalars,
@@ -9428,6 +10226,15 @@ export class Lowerer {
9428
10226
  return true;
9429
10227
  }
9430
10228
  },
10229
+ keep: (name, fn, events) => {
10230
+ if (fn)
10231
+ loweredUnits.set(name, fn);
10232
+ const { owner, priority } = ownerOf(name);
10233
+ this.withGenericDemandOwner(owner, () => this.shapes.withDeclaredOrderPriority(priority, () => {
10234
+ for (const event of events)
10235
+ replay(event);
10236
+ }));
10237
+ },
9431
10238
  };
9432
10239
  }
9433
10240
  /** Reachability hook (see emitReachable): fires when lowering resolves a
@@ -9512,10 +10319,12 @@ export class Lowerer {
9512
10319
  }
9513
10320
  const captured = this.diags.splice(diagsBefore);
9514
10321
  if (captured.some((d) => d.code === "SC9001")) {
9515
- this.diags.push(...captured);
10322
+ for (const d of captured)
10323
+ this.diags.push(d);
9516
10324
  return null;
9517
10325
  }
9518
- this.runtimeFences.push(...captured);
10326
+ for (const d of captured)
10327
+ this.runtimeFences.push(d);
9519
10328
  const fence = this.runtimeFenceStmt(captured[0], node, target.fallback, target.bareMessage);
9520
10329
  const loc = locOf(node);
9521
10330
  if (target.kind === "statement")
@@ -9785,7 +10594,8 @@ export class Lowerer {
9785
10594
  .slice(diagsBefore)
9786
10595
  .filter((d) => d.rejects !== undefined || this.loweredOnceDiags.has(d));
9787
10596
  this.diags.length = diagsBefore;
9788
- this.diags.push(...kept);
10597
+ for (const d of kept)
10598
+ this.diags.push(d);
9789
10599
  }
9790
10600
  /** A unit that still fails after its retries commits its first
9791
10601
  * attempt's own diagnostics (`first`, taken before the first
@@ -9796,7 +10606,11 @@ export class Lowerer {
9796
10606
  const carried = (d) => d.rejects !== undefined || this.loweredOnceDiags.has(d);
9797
10607
  const kept = this.diags.slice(diagsBefore).filter(carried);
9798
10608
  this.diags.length = diagsBefore;
9799
- this.diags.push(...first.filter((d) => !carried(d)), ...kept);
10609
+ for (const d of first)
10610
+ if (!carried(d))
10611
+ this.diags.push(d);
10612
+ for (const d of kept)
10613
+ this.diags.push(d);
9800
10614
  }
9801
10615
  /** Lowers one unit whose body-level poison skips it (a generic
9802
10616
  * instance), with localized failure's commit point: a degradable type
@@ -10025,7 +10839,14 @@ export class Lowerer {
10025
10839
  }
10026
10840
  this.typeFail(node, type, "index-signature", indexSignatureTypeDiag(this.checker.typeToString(type), locOf(node)));
10027
10841
  }
10028
- // Attribute an unsupported package type to its package.
10842
+ // Attribute an unsupported package type to its package. A PACKAGE DATA
10843
+ // SHAPE (an interface or type alias declared only by a package the
10844
+ // module graph never loads) never reaches this: it describes data the
10845
+ // program itself builds, so mapTypeEntry already widened it to the
10846
+ // checked-dynamic value exactly as it does for the same shape declared
10847
+ // locally. What arrives here is a package's VALUE shape — a class or a
10848
+ // merged value declaration, which only that package's implementation
10849
+ // could produce.
10029
10850
  {
10030
10851
  const pkg = this.npmPackageOf(widened);
10031
10852
  if (pkg) {
@@ -10083,9 +10904,11 @@ export class Lowerer {
10083
10904
  // story, naming the type — and for the families with a WHY, the same
10084
10905
  // pointed reason the identifier/constructor chokepoints teach.
10085
10906
  if (stdlibNominal) {
10086
- const intlHint = "Intl formatter values have no representation — the COMPOSED en-US forms lower: " +
10087
- 'new Intl.NumberFormat("en-US").format(x) and x.toLocaleString("en-US") with default options; ' +
10088
- "the rest is ICU locale data the binary does not carry";
10907
+ const intlHint = "Intl formatter values have no representation — the COMPOSED forms lower: " +
10908
+ 'new Intl.NumberFormat("en-US").format(x), x.toLocaleString("en-US") and ' +
10909
+ "x.toLocaleString() with default options, d.toLocaleString(), d.toLocaleTimeString(), " +
10910
+ "and Intl.Segmenter with grapheme or word granularity; the formatter objects " +
10911
+ "themselves (locale negotiation, resolvedOptions, options bags) remain unsupported";
10089
10912
  const typeHints = {
10090
10913
  ArrayBuffer: "fixed ArrayBuffer storage and typed-array views are supported; resizable and detached storage are not modeled",
10091
10914
  SharedArrayBuffer: "fixed SharedArrayBuffer storage is supported; growable shared storage is not modeled",
@@ -10124,6 +10947,13 @@ export class Lowerer {
10124
10947
  this.pushDiag(diag);
10125
10948
  throw new PoisonError();
10126
10949
  }
10950
+ /** A read of a Node 24 global the native runtime does not implement
10951
+ * (host-globals.ts): refusing is the honest answer, and the reason id
10952
+ * lets a Node island run the module instead. */
10953
+ hostGlobalFence(name, node) {
10954
+ this.pushDiag(hostGlobalDiag(name, locOf(node)));
10955
+ throw new PoisonError();
10956
+ }
10127
10957
  /** The declaration-side refusal of a stdlib-global snapshot read as a
10128
10958
  * VALUE (stdlibGlobalAliasDecl): report once, at the declaration's name,
10129
10959
  * naming the type the program asked the compiler to hold when it has a
@@ -10474,7 +11304,12 @@ export class Lowerer {
10474
11304
  * (`T`, `T[]`, `{ v: T }`, `(x: T) => T` all resolve). Inert outside
10475
11305
  * generic instantiation. */
10476
11306
  typeParamResolver = (t) => {
10477
- if (!this.typeParamBindings || !(t.flags & ts.TypeFlags.TypeParameter))
11307
+ if (!(t.flags & ts.TypeFlags.TypeParameter))
11308
+ return null;
11309
+ // The answer is the current bindings' (an unbound parameter maps by the
11310
+ // symbolic rules), so the mapping may not leave its scope.
11311
+ noteScopeSensitiveMapping();
11312
+ if (!this.typeParamBindings)
10478
11313
  return null;
10479
11314
  const sym = t.getSymbol();
10480
11315
  return (sym && this.typeParamBindings.get(sym)) ?? null;
@@ -10486,7 +11321,10 @@ export class Lowerer {
10486
11321
  * over literal arguments). Inert outside generic function and class
10487
11322
  * instantiation. */
10488
11323
  typeParamTsResolver = (t) => {
10489
- if (!this.typeParamTsBindings || !(t.flags & ts.TypeFlags.TypeParameter))
11324
+ if (!(t.flags & ts.TypeFlags.TypeParameter))
11325
+ return null;
11326
+ noteScopeSensitiveMapping();
11327
+ if (!this.typeParamTsBindings)
10490
11328
  return null;
10491
11329
  const sym = t.getSymbol();
10492
11330
  return (sym && this.typeParamTsBindings.get(sym)) ?? null;
@@ -10496,7 +11334,13 @@ export class Lowerer {
10496
11334
  * (boundAliasInstances), or null when its signature never instantiated
10497
11335
  * that reference. Inert outside generic function instantiation. */
10498
11336
  boundAliasTsResolver = (t) => {
10499
- if (!this.typeParamTsBindings || t.getAliasTypeArguments().length === 0)
11337
+ const aliasArguments = t.getAliasTypeArguments().length;
11338
+ if (aliasArguments === 0)
11339
+ return null;
11340
+ // boundAliasInstances is keyed by the installed ts bindings, so this
11341
+ // answer belongs to the instantiation that asks.
11342
+ noteScopeSensitiveMapping();
11343
+ if (!this.typeParamTsBindings)
10500
11344
  return null;
10501
11345
  const tsBindings = this.typeParamTsBindings;
10502
11346
  return (this.boundAliasInstances.get(t)?.find((entry) => entry.tsBindings === tsBindings)?.instance ??
@@ -10570,8 +11414,26 @@ export class Lowerer {
10570
11414
  return dyn;
10571
11415
  this.badType(node, t);
10572
11416
  }
11417
+ // A JavaScript binding whose inferred type holds a union of functions
11418
+ // and arrays (a test table of `[fn, cases]` rows, or one row
11419
+ // destructured): the checked-dynamic kind dynFallbackType gives the
11420
+ // unmappable spellings of such tables, so the rows keep their functions'
11421
+ // names and the destructured items their values.
11422
+ if (isJsSourceFile(ts.getSourceFileOfNode(node)) && this.mixesFunctionsWithArrays(mapped))
11423
+ return DYN;
10573
11424
  return jsOpenObjectType(node, mapped, this.shapes, this.unions);
10574
11425
  }
11426
+ /** Whether `type`, or an array element type inside it, is a union with
11427
+ * both a function arm and an array arm. */
11428
+ mixesFunctionsWithArrays(type) {
11429
+ if (type.kind === "array")
11430
+ return this.mixesFunctionsWithArrays(type.elem);
11431
+ if (type.kind !== "union")
11432
+ return false;
11433
+ const arms = this.unions.get(type.unionId)?.arms ?? [];
11434
+ return ((arms.some((arm) => arm.kind === "func") && arms.some((arm) => arm.kind === "array")) ||
11435
+ arms.some((arm) => arm.kind === "array" && this.mixesFunctionsWithArrays(arm)));
11436
+ }
10575
11437
  /** Exact-shape enforcement (SC2002). Records are monomorphic structs, so
10576
11438
  * everywhere a value flows into a typed slot (call arg, initializer,
10577
11439
  * assignment, field, return) the shapes must MATCH — or width-coerce:
@@ -10929,6 +11791,28 @@ export class Lowerer {
10929
11791
  if (boxed)
10930
11792
  return boxed;
10931
11793
  }
11794
+ // A node:path family is its module object (pathModuleValue), the
11795
+ // bare module the target platform's family.
11796
+ if (expr.type.kind === "moduleNs" &&
11797
+ (expr.type.moduleId === "builtin:path" ||
11798
+ expr.type.moduleId === "builtin:path/posix" ||
11799
+ expr.type.moduleId === "builtin:path/win32")) {
11800
+ const family = expr.type.moduleId !== "builtin:path"
11801
+ ? expr.type.moduleId.slice("builtin:".length)
11802
+ : builtinModuleConstOf(this, "path", "sep") === "\\"
11803
+ ? "path/win32"
11804
+ : "path/posix";
11805
+ const value = pathModuleValue(this, family, expr.loc);
11806
+ if (expr.kind === "moduleNsRef")
11807
+ return value;
11808
+ return {
11809
+ kind: "seqExpr",
11810
+ stmts: [{ kind: "exprStmt", expr, loc: expr.loc }],
11811
+ result: value,
11812
+ type: DYN,
11813
+ loc: expr.loc,
11814
+ };
11815
+ }
10932
11816
  if (expr.type.kind === "moduleNs" &&
10933
11817
  expr.type.moduleId === "builtin:events" &&
10934
11818
  isJsSourceFileName(expr.loc.file)) {
@@ -10967,7 +11851,7 @@ export class Lowerer {
10967
11851
  (this.unions.get(expr.type.unionId)?.arms.some(liveReference) ?? false));
10968
11852
  return {
10969
11853
  kind: "dynFrom",
10970
- value: expr,
11854
+ value: this.checkedBuiltinValue(expr),
10971
11855
  type: DYN,
10972
11856
  loc: expr.loc,
10973
11857
  ...(liveRef ? { liveRef: true } : {}),
@@ -11249,6 +12133,14 @@ export class Lowerer {
11249
12133
  if (helper) {
11250
12134
  return { kind: "call", callee: helper, args: [expr], type: expected, loc: expr.loc };
11251
12135
  }
12136
+ // Inside a type assertion's operand the program claimed the value's
12137
+ // shape: an arm the asserted target excludes traps (divergence 38's
12138
+ // lying-assertion stance) instead of refusing the whole conversion.
12139
+ if (this.coercions.assertedOperand > 0) {
12140
+ const checked = this.widthLiftPlan(expr.type, expected);
12141
+ if (checked?.how === "checkedRetag")
12142
+ return this.applyWidthLift(checked, expr, expected, expr.loc);
12143
+ }
11252
12144
  return assertedConversion(this, expr, expected) ?? expr;
11253
12145
  }
11254
12146
  if (expr.type.kind === "void") {
@@ -11501,8 +12393,8 @@ export class Lowerer {
11501
12393
  recordUnionRouteHelper(source, toId, loc) {
11502
12394
  return recordUnionRouteHelper(this, source, toId, loc);
11503
12395
  }
11504
- unionRetagHelper(fromId, toId, loc, trappable) {
11505
- return unionRetagHelper(this, fromId, toId, loc, trappable);
12396
+ unionRetagHelper(fromId, toId, loc, trappable, classRoutes) {
12397
+ return unionRetagHelper(this, fromId, toId, loc, trappable, classRoutes);
11506
12398
  }
11507
12399
  narrowedArmHelper(fromId, target, loc, message) {
11508
12400
  return narrowedArmHelper(this, fromId, target, loc, message);
@@ -12040,6 +12932,11 @@ export class Lowerer {
12040
12932
  elements.every((element) => element !== null && this.widthLiftPlan(element.type, candidate.elem) !== null));
12041
12933
  }
12042
12934
  }
12935
+ // An EMPTY literal carries no element to select an arm by: it
12936
+ // builds as the union's first array arm (the emptyArrayLiteralArm
12937
+ // rule the contextual union and the `?? []` default share).
12938
+ if (!arm)
12939
+ arm = emptyArrayLiteralArm(x, arms) ?? undefined;
12043
12940
  if (arm) {
12044
12941
  const built = this.lowerArrayLiteral(x, arm);
12045
12942
  return this.coerceInto(node, built, expected);
@@ -12137,6 +13034,12 @@ export class Lowerer {
12137
13034
  return true;
12138
13035
  if (to.inner.kind === "void")
12139
13036
  return from.inner.kind !== "void";
13037
+ // A module namespace widens into a checked-dynamic payload: both settle
13038
+ // the module's namespace object (coerceToExpected routes the value
13039
+ // through moduleNamespacePromiseDynValue). The joint payload of several
13040
+ // namespace-valued promise arms is exactly this dyn (mergePromiseArms).
13041
+ if (from.inner.kind === "moduleNs" && to.inner.kind === "dyn")
13042
+ return true;
12140
13043
  return (this.dynConvertible(from) &&
12141
13044
  canDynCheckTo(to, (id) => this.shapes.get(id), (id) => this.unions.get(id)));
12142
13045
  }
@@ -12178,8 +13081,81 @@ export class Lowerer {
12178
13081
  return this.lowerExprExpecting(node, expected);
12179
13082
  if (this.returnsFreshCollection(node) && expected.kind !== "void")
12180
13083
  return this.lowerExprExpecting(node, expected);
13084
+ // A fresh object literal into a record result: the same
13085
+ // destination-directed construction. An unannotated method inside a
13086
+ // contextually typed literal is checked against the CONTEXTUAL
13087
+ // signature's result while its own return type stays the literal's
13088
+ // inferred (narrower) record — `ToolDefinition<Schema, Details>`
13089
+ // methods returning `{ content, details }`. Building at the
13090
+ // contextual type would then coerce that wider record into the
13091
+ // declared result and refuse; the result slot is the layout.
13092
+ if (this.returnsFreshRecord(node, expected))
13093
+ return this.lowerExprExpecting(node, expected);
12181
13094
  return this.asyncReturnValueOf(node, this.lowerExpr(node), expected);
12182
13095
  }
13096
+ /** A fresh object literal returned into a RECORD result whose ordinary
13097
+ * construction cannot reach that result: not a thenable, so it is built
13098
+ * at the result type like a synchronous return. An unannotated method
13099
+ * inside a contextually typed literal is checked against the CONTEXTUAL
13100
+ * signature's result while its own return type stays the literal's
13101
+ * inferred (narrower) record — `ToolDefinition<Schema, Details>` methods
13102
+ * returning `{ content, details }`. Building at the contextual type
13103
+ * would then coerce that wider record into the declared result and
13104
+ * refuse; the result slot is the layout. A literal that declares `then`
13105
+ * is awaited instead, and a literal whose contextual build does convert
13106
+ * keeps the ordinary lowering, so no convertible value changes. */
13107
+ returnsFreshRecord(node, expected) {
13108
+ if (expected.kind !== "record")
13109
+ return false;
13110
+ let e = node;
13111
+ while (ts.isParenthesizedExpression(e))
13112
+ e = e.expression;
13113
+ // A conditional of fresh object literals (`return valid ? { entries, … }
13114
+ // : { entries: [], … }`) is the same fresh construction per arm: the
13115
+ // checker's join can carry an EMPTY arm's uninhabited element
13116
+ // representation, which the populated arm then cannot lift into. Build
13117
+ // both arms at the declared result, exactly as a synchronous return
13118
+ // does. Neither arm can be a thenable (an object literal that declares
13119
+ // `then` is awaited instead), so no promise adoption is bypassed. A
13120
+ // conditional whose join every arm already lifts into takes the same
13121
+ // path for the same layout: each arm is constructed at the result
13122
+ // instead of the join being constructed and width-copied into it (the
13123
+ // zero-cost gate lists the programs whose code that changes).
13124
+ if (ts.isConditionalExpression(e))
13125
+ return this.isFreshRecordLiteral(e.whenTrue) && this.isFreshRecordLiteral(e.whenFalse);
13126
+ return this.freshRecordLiteralInto(e, expected);
13127
+ }
13128
+ /** A parenthesized fresh object literal that does not declare `then`. */
13129
+ isFreshRecordLiteral(node) {
13130
+ let e = node;
13131
+ while (ts.isParenthesizedExpression(e))
13132
+ e = e.expression;
13133
+ return (ts.isObjectLiteralExpression(e) &&
13134
+ this.checker.getPropertyOfType(this.typeOf(e), "then") === undefined);
13135
+ }
13136
+ /** One arm of a returned conditional: a fresh object literal whose
13137
+ * ordinary construction cannot reach the declared result (see
13138
+ * returnsFreshRecord). */
13139
+ freshRecordLiteralInto(node, expected) {
13140
+ let e = node;
13141
+ while (ts.isParenthesizedExpression(e))
13142
+ e = e.expression;
13143
+ if (!ts.isObjectLiteralExpression(e))
13144
+ return false;
13145
+ if (this.checker.getPropertyOfType(this.typeOf(e), "then") !== undefined)
13146
+ return false;
13147
+ // The record the ordinary path builds: the literal's context, with an
13148
+ // async return's `T | PromiseLike<T>` stripped to the awaited record
13149
+ // (object-literals.ts does the same before mapping).
13150
+ let context = this.checker.getContextualType(e) ?? this.typeOf(e);
13151
+ if (context.isUnionType() &&
13152
+ ts.constituentTypes(context).some((t) => ts.symbolNameOf(t.getSymbol()) === "PromiseLike"))
13153
+ context = this.checker.getAwaitedType(context) ?? context;
13154
+ const built = this.mapTypeOf(context);
13155
+ if (!built || built.kind !== "record")
13156
+ return false;
13157
+ return this.widthLiftPlan(built, expected) === null;
13158
+ }
12183
13159
  /** An array literal or a `new Map(...)`, `new Set(...)` or `new
12184
13160
  * Array(...)` of the builtins: a fresh collection, never a thenable, so
12185
13161
  * an async return takes the declared result type as its construction
@@ -12207,6 +13183,20 @@ export class Lowerer {
12207
13183
  isJsSourceFile(ts.getSourceFileOfNode(node)) &&
12208
13184
  ts.isObjectLiteralExpression(literal));
12209
13185
  }
13186
+ /** Whether `node`'s TS type is a `Promise<never>` (the throw-only async
13187
+ * function's declared result): the promise can never settle, so the value
13188
+ * it would resolve to is unreachable. The IR keeps `Promise<never>` as a
13189
+ * promise with a void payload, exactly like `Promise<void>`, so the TS
13190
+ * payload type is what separates the two. */
13191
+ promisePayloadIsNever(node) {
13192
+ const t = this.typeOf(node);
13193
+ if ((t.flags & ts.TypeFlags.Object) === 0)
13194
+ return false;
13195
+ if ((t.objectFlags & ts.ObjectFlags.Reference) === 0)
13196
+ return false;
13197
+ const args = this.checker.getTypeArguments(t);
13198
+ return args.length === 1 && (args[0].flags & ts.TypeFlags.Never) !== 0;
13199
+ }
12210
13200
  /** The value of `return <e>` (already lowered untyped) in an async or
12211
13201
  * void context: a promise flattens through the returned-promise await,
12212
13202
  * everything else converts into the declared result. */
@@ -12215,6 +13205,13 @@ export class Lowerer {
12215
13205
  return null;
12216
13206
  if (this.ctx.isAsync && e.type.kind === "promise" && expected.kind !== "promise") {
12217
13207
  const awaited = this.returnedPromiseAwait(e);
13208
+ // A `Promise<never>` never settles, so the awaited value is
13209
+ // unreachable: it fills any result shape instead of failing the
13210
+ // void-to-record conversion.
13211
+ if (expected.kind !== "void" &&
13212
+ e.type.inner.kind === "void" &&
13213
+ this.promisePayloadIsNever(node))
13214
+ return this.divergentValue(awaited, expected);
12218
13215
  return this.coerceInto(node, awaited, expected);
12219
13216
  }
12220
13217
  return this.coerceInto(node, e, expected);
@@ -12324,7 +13321,8 @@ export class Lowerer {
12324
13321
  }
12325
13322
  if (this.adoptsReturnedPromise() &&
12326
13323
  !this.returnsLiteralIntoDyn(node, expected) &&
12327
- !this.returnsFreshCollection(node)) {
13324
+ !this.returnsFreshCollection(node) &&
13325
+ !this.returnsFreshRecord(node, expected)) {
12328
13326
  // The async return lowers its operand untyped first (a promise
12329
13327
  // adopts before its payload converts); a maybe-promise union needs
12330
13328
  // the statement form, which branches between adoption and fulfillment.
@@ -12436,6 +13434,10 @@ export class Lowerer {
12436
13434
  * undefined-armed union fields, which can be absent, and `true` for
12437
13435
  * every other declared field. */
12438
13436
  recordFieldPresent(obj, shapeId, field, loc) {
13437
+ // A partial record view (partial-assertions.ts) can lack a field its
13438
+ // asserted literal never wrote, whatever the field's required type.
13439
+ if (partialAssertionFields(this, shapeId).has(field))
13440
+ return { kind: "recordHas", obj, shapeId, field, type: BOOL, loc };
12439
13441
  const f = this.shapes.get(shapeId)?.fields.find((x) => x.name === field);
12440
13442
  if (f && f.type.kind === "union" && this.armTag(f.type.unionId, UNDEFINED_T) >= 0) {
12441
13443
  return { kind: "recordHas", obj, shapeId, field, type: BOOL, loc };
@@ -13139,7 +14141,7 @@ export class Lowerer {
13139
14141
  * call runs for its effects (it throws or exits), and the expression ends
13140
14142
  * in an unreachable trap instead of producing a value. The result reads an
13141
14143
  * uninitialized hidden local that control never reaches. */
13142
- divergentValue(call, expected) {
14144
+ divergentValue(call, expected, message = "unreachable: a 'never' call returned — please report this") {
13143
14145
  const loc = call.loc;
13144
14146
  const slot = this.declareHiddenLocal("%never", expected);
13145
14147
  slot.mutable = true;
@@ -13151,7 +14153,7 @@ export class Lowerer {
13151
14153
  {
13152
14154
  kind: "runtimeFence",
13153
14155
  code: "SC9002",
13154
- message: "unreachable: a 'never' call returned — please report this",
14156
+ message,
13155
14157
  loc,
13156
14158
  },
13157
14159
  ],
@@ -13739,6 +14741,14 @@ export class Lowerer {
13739
14741
  this.rejectUnresolvedSymbol(this.resolveValueSymbol(ident), ident.text, ident, fallback);
13740
14742
  }
13741
14743
  rejectUnresolvedSymbol(symbol, name, node, fallback) {
14744
+ // A `.js` WRITE to a name nothing declares. Sloppy mode resolves it by
14745
+ // creating a property on the global object — process-wide state a native
14746
+ // binary has no object for, so those programs run in a Node island
14747
+ // (plan D-5). Until the write is routed there it is refused by name
14748
+ // rather than by the generic no-lowering text.
14749
+ if (symbol === null && isJsWriteTarget7(node) && isJsSourceFile(ts.getSourceFileOfNode(node))) {
14750
+ this.unsupported("SC1091", node, `writing the undeclared name '${name}' in a JavaScript source`, undefined, isStrictCode(node) ? undefined : "implicit-global-write");
14751
+ }
13742
14752
  if (this.isBlockedBinding(symbol)) {
13743
14753
  this.pushDiag(blockedBindingUseDiag(name, locOf(node)));
13744
14754
  throw new PoisonError();
@@ -13929,11 +14939,58 @@ export class Lowerer {
13929
14939
  * members by name + this provenance, and everything else those files
13930
14940
  * declare hits the SC2020-family fence). The file half of every
13931
14941
  * supported-surface provenance check. */
13932
- isStdlibFile = (sf) => sf.fileName === this.ambient ||
13933
- sf.fileName === this.overridesAmbient ||
13934
- isFallbackDtsPath(sf.fileName) ||
13935
- this.program.isSourceFileDefaultLibrary(sf) ||
13936
- (sf.isDeclarationFile && isNodeTypesPath(sf.fileName));
14942
+ isStdlibFile = (sf) => this.facts.isStdlibFile(sf);
14943
+ /** provenanceOf's answers (type-mapper.ts's SymbolProvenance), keyed by
14944
+ * symbol. A symbol's declarations are fixed for one loaded program, and
14945
+ * the mapper asks on every object type it maps, so the round shares one
14946
+ * map (lowering-facts.ts). */
14947
+ get symbolProvenance() {
14948
+ return this.facts.symbolProvenance;
14949
+ }
14950
+ /** SCRIPTC_LOWERING_FACTS_VERIFY: the shared provenance memo answered, so
14951
+ * recompute it and fail on a disagreement (lowering-facts.ts). */
14952
+ verifySymbolProvenanceAnswer(sym, answer) {
14953
+ const fresh = computeSymbolProvenance(sym, this.isStdlibFile);
14954
+ // The two lazily filled answers (`??=` on a hit) are declaration-only
14955
+ // too, so recompute the ones an answer carries. The pass that filled one
14956
+ // stored the value it computed, and this comparison catches a later pass
14957
+ // that would have filled a different one.
14958
+ const freshWebAssembly = answer.webAssembly === undefined
14959
+ ? undefined
14960
+ : declaresWebAssemblyNamespace(sym.declarations, this.isStdlibFile);
14961
+ const freshLegacyUrl = answer.legacyUrl === undefined
14962
+ ? undefined
14963
+ : declaresLegacyUrl(sym.declarations, { isStdlibFile: this.isStdlibFile });
14964
+ const same = fresh.stdlibInterface === answer.stdlibInterface &&
14965
+ fresh.stdlibClass === answer.stdlibClass &&
14966
+ fresh.libInterface === answer.libInterface &&
14967
+ freshWebAssembly === answer.webAssembly &&
14968
+ freshLegacyUrl === answer.legacyUrl;
14969
+ this.facts.noteVerified("symbolProvenance");
14970
+ if (same)
14971
+ return;
14972
+ if (freshWebAssembly !== undefined)
14973
+ fresh.webAssembly = freshWebAssembly;
14974
+ if (freshLegacyUrl !== undefined)
14975
+ fresh.legacyUrl = freshLegacyUrl;
14976
+ throw new InternalCompilerError(`shared symbol provenance for ${ts.symbolName(sym)} does not match a fresh ` +
14977
+ `computation: shared ${JSON.stringify(answer)}, recomputed ${JSON.stringify(fresh)}`);
14978
+ }
14979
+ /** Whether the file holds declarations of an explicitly mapped external
14980
+ * type surface (coverage's --external-types) or of the declaration-typed
14981
+ * boundary's generated types. Both are fixed for the program, and the
14982
+ * mapper asks per type (lowering-facts.ts keeps the answer). */
14983
+ isExternalTypeFile = (sf) => this.facts.isExternalTypeFile(sf, this.externalTypeSpecifiersByFile);
14984
+ /** tsgoPath(resolve(sf.fileName)): the path spelling the module tables
14985
+ * key by. A source file's path cannot change while the program lowers. */
14986
+ pathOf = (sf) => this.facts.pathOf(sf);
14987
+ /** Whether values of `type` are island handles (boundary.ts's
14988
+ * isForeignType; the answers and their invalidation live in
14989
+ * lowering-facts.ts). The type mapper asks this on every mapType call,
14990
+ * memo hits included. */
14991
+ foreignType(type) {
14992
+ return this.facts.foreignType(type, this.nodeIslands, this.checker);
14993
+ }
13937
14994
  nodeTypesOnlySymbol(sym) {
13938
14995
  return nodeTypesOnlySymbol(this, sym);
13939
14996
  }
@@ -14355,6 +15412,7 @@ export class Lowerer {
14355
15412
  : null;
14356
15413
  }
14357
15414
  fieldSetStmt(target, value, loc, blame) {
15415
+ refuseHeldEnvWrite(this, blame);
14358
15416
  return markSloppyRecordWrites(this, fieldSetStmt(this, target, value, loc, blame), blame);
14359
15417
  }
14360
15418
  lowerFieldCompound(access, op, rhsNode, loc) {
@@ -14851,6 +15909,8 @@ export class Lowerer {
14851
15909
  const valueParams = fn.valueParams;
14852
15910
  if (!valueParams)
14853
15911
  return null;
15912
+ if (fn.checked?.only)
15913
+ return checkedNativeCallableValue(this, fn, display, loc);
14854
15914
  const shapes = valueParams.map((param) => {
14855
15915
  if (param.mode === "rest")
14856
15916
  return { mode: "rest", type: arrayOf(param.type) };
@@ -14871,6 +15931,8 @@ export class Lowerer {
14871
15931
  fnName = keyedHelperName(this, `%builtin.value.${fn.valueFn ?? fn.fn}`, key);
14872
15932
  this.builtinCallableValueFns.set(key, fnName);
14873
15933
  this.builtinCallableValueNames.set(fnName, fn.valueName ?? display.slice(display.lastIndexOf(".") + 1));
15934
+ if (fn.valueNameMainThreadOnly)
15935
+ this.builtinCallableValueMainThreadNames.add(fnName);
14874
15936
  if (fn.valueLength !== undefined)
14875
15937
  this.builtinCallableValueLengths.set(fnName, fn.valueLength);
14876
15938
  const params = funcType.params.map((type, index) => ({
@@ -14951,19 +16013,42 @@ export class Lowerer {
14951
16013
  loc,
14952
16014
  });
14953
16015
  }
16016
+ if (valueParams.some((param) => param.name !== undefined)) {
16017
+ // Every materialization writes this entry at ITS location, so a second
16018
+ // one overwrites the first in place. A table only grows by addition, so
16019
+ // that change is no part of this unit's function: name it (unit-journal.ts
16020
+ // UnitEvents.touch), and the change is counted here instead of being
16021
+ // found by HeldTables.check as an unnamed write.
16022
+ if (this.builtinCheckedValues.has(fnName))
16023
+ this.unitEvents?.touch(fnName);
16024
+ this.builtinCheckedValues.set(fnName, { fn, display, loc });
16025
+ }
14954
16026
  return { kind: "closure", fnName, captures: [], type: funcType, loc };
14955
16027
  }
16028
+ /** A builtin function value about to become untyped: its checked twin
16029
+ * when the builtin names its parameters (checkedNativeCallableValue), so
16030
+ * untyped callers meet Node's argument validation. Typed slots keep the
16031
+ * typed adapter. */
16032
+ checkedBuiltinValue(expr) {
16033
+ const checked = expr.kind === "closure" ? this.builtinCheckedValues.get(expr.fnName) : undefined;
16034
+ return checked
16035
+ ? checkedNativeCallableValue(this, checked.fn, checked.display, checked.loc)
16036
+ : expr;
16037
+ }
14956
16038
  /** The name and length a builtin function's adapter boxes under: the ones
14957
- * Node's function carries (`[Function: randomUUID]`). Empty for any other
14958
- * value. */
16039
+ * Node's function carries (`[Function: randomUUID]`), with the main-thread
16040
+ * qualifier of a name a Worker does not carry (`process.cwd`). Empty for
16041
+ * any other value. */
14959
16042
  builtinFunctionIdentity(expr) {
14960
16043
  if (expr.kind !== "closure")
14961
16044
  return {};
14962
16045
  const name = this.builtinCallableValueNames.get(expr.fnName);
14963
16046
  const length = this.builtinCallableValueLengths.get(expr.fnName);
16047
+ const mainThreadOnly = this.builtinCallableValueMainThreadNames.has(expr.fnName);
14964
16048
  return {
14965
16049
  ...(name !== undefined ? { fnName: name } : {}),
14966
16050
  ...(length !== undefined ? { fnLength: length } : {}),
16051
+ ...(mainThreadOnly ? { fnNameMainThreadOnly: true } : {}),
14967
16052
  };
14968
16053
  }
14969
16054
  isBuiltinCallableValue(expr) {
@@ -15378,6 +16463,16 @@ function droppedMembers(lowerer, from, to, seen) {
15378
16463
  }
15379
16464
  return out;
15380
16465
  }
16466
+ /** A JSDoc `@param` type on a set accessor's parameter is an annotation like
16467
+ * a variable's `@type` (hasJsTypeAnnotation, lower-stmts.ts): the setter
16468
+ * keeps its declared storage. Setters take exactly one parameter, so any
16469
+ * `@param` before it belongs to it. */
16470
+ function hasJsSetterParamAnnotation(param) {
16471
+ const accessor = param.parent;
16472
+ if (!accessor)
16473
+ return false;
16474
+ return /@param\b/.test(ts.getSourceFileOfNode(accessor).text.slice(accessor.pos, ts.tokenStartOfNode(param)));
16475
+ }
15381
16476
  /** fs.realpathSync and its .native as function values (fs.realpath stores
15382
16477
  * `var origRealpathSync = fs.realpathSync`): path and options pass through
15383
16478
  * unchecked to the runtime, which applies Node's argument handling. */