@scriptc/compiler 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (492) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +832 -55
  2. package/dist/backend/cycle-analysis.js +6 -1
  3. package/dist/backend/cycle-analysis.js.map +1 -1
  4. package/dist/backend/executable-features.js +1 -0
  5. package/dist/backend/executable-features.js.map +1 -1
  6. package/dist/backend/literals.d.ts +7 -0
  7. package/dist/backend/literals.js +32 -0
  8. package/dist/backend/literals.js.map +1 -1
  9. package/dist/backend/literals.test.js +17 -1
  10. package/dist/backend/literals.test.js.map +1 -1
  11. package/dist/backend/llvm/alloc.d.ts +15 -4
  12. package/dist/backend/llvm/alloc.js +63 -25
  13. package/dist/backend/llvm/alloc.js.map +1 -1
  14. package/dist/backend/llvm/alloc.test.js +62 -2
  15. package/dist/backend/llvm/alloc.test.js.map +1 -1
  16. package/dist/backend/llvm/appended-array-literals.d.ts +2 -0
  17. package/dist/backend/llvm/appended-array-literals.js +109 -0
  18. package/dist/backend/llvm/appended-array-literals.js.map +1 -0
  19. package/dist/backend/llvm/appended-array-literals.test.d.ts +1 -0
  20. package/dist/backend/llvm/appended-array-literals.test.js +90 -0
  21. package/dist/backend/llvm/appended-array-literals.test.js.map +1 -0
  22. package/dist/backend/llvm/array-search.d.ts +8 -0
  23. package/dist/backend/llvm/array-search.js +52 -0
  24. package/dist/backend/llvm/array-search.js.map +1 -0
  25. package/dist/backend/llvm/array-search.test.d.ts +1 -0
  26. package/dist/backend/llvm/array-search.test.js +72 -0
  27. package/dist/backend/llvm/array-search.test.js.map +1 -0
  28. package/dist/backend/llvm/call-lifetimes.d.ts +11 -1
  29. package/dist/backend/llvm/call-lifetimes.js +74 -4
  30. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  31. package/dist/backend/llvm/call-lifetimes.test.js +54 -0
  32. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  33. package/dist/backend/llvm/classes.js +97 -38
  34. package/dist/backend/llvm/classes.js.map +1 -1
  35. package/dist/backend/llvm/classes.test.js +2 -2
  36. package/dist/backend/llvm/common.d.ts +1 -1
  37. package/dist/backend/llvm/common.js +1 -1
  38. package/dist/backend/llvm/dense-array-access.d.ts +5 -0
  39. package/dist/backend/llvm/dense-array-access.js +18 -13
  40. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  41. package/dist/backend/llvm/dense-array-access.test.js +15 -2
  42. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  43. package/dist/backend/llvm/dyn.d.ts +6 -0
  44. package/dist/backend/llvm/dyn.js +84 -11
  45. package/dist/backend/llvm/dyn.js.map +1 -1
  46. package/dist/backend/llvm/emitter.d.ts +108 -16
  47. package/dist/backend/llvm/emitter.js +598 -108
  48. package/dist/backend/llvm/emitter.js.map +1 -1
  49. package/dist/backend/llvm/emitter.test.js +26 -3
  50. package/dist/backend/llvm/emitter.test.js.map +1 -1
  51. package/dist/backend/llvm/expr-async.js +174 -7
  52. package/dist/backend/llvm/expr-async.js.map +1 -1
  53. package/dist/backend/llvm/expr-bytes.js +11 -0
  54. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  55. package/dist/backend/llvm/expr-callbacks.d.ts +8 -0
  56. package/dist/backend/llvm/expr-callbacks.js +96 -2
  57. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  58. package/dist/backend/llvm/expr-calls.d.ts +12 -1
  59. package/dist/backend/llvm/expr-calls.js +133 -54
  60. package/dist/backend/llvm/expr-calls.js.map +1 -1
  61. package/dist/backend/llvm/expr-containers.d.ts +7 -0
  62. package/dist/backend/llvm/expr-containers.js +80 -22
  63. package/dist/backend/llvm/expr-containers.js.map +1 -1
  64. package/dist/backend/llvm/expr-context.d.ts +2 -0
  65. package/dist/backend/llvm/expr-control.d.ts +8 -0
  66. package/dist/backend/llvm/expr-control.js +103 -69
  67. package/dist/backend/llvm/expr-control.js.map +1 -1
  68. package/dist/backend/llvm/expr-dynamic.js +21 -10
  69. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  70. package/dist/backend/llvm/expr-primitives.d.ts +7 -0
  71. package/dist/backend/llvm/expr-primitives.js +53 -51
  72. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  73. package/dist/backend/llvm/expr-records.js +19 -5
  74. package/dist/backend/llvm/expr-records.js.map +1 -1
  75. package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
  76. package/dist/backend/llvm/expr-stream-bridges.js +111 -39
  77. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  78. package/dist/backend/llvm/expr-stream-bridges.test.js +49 -1
  79. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  80. package/dist/backend/llvm/expr-stream-callbacks.d.ts +13 -2
  81. package/dist/backend/llvm/expr-stream-callbacks.js +80 -5
  82. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  83. package/dist/backend/llvm/inline-unions.d.ts +48 -0
  84. package/dist/backend/llvm/inline-unions.js +134 -0
  85. package/dist/backend/llvm/inline-unions.js.map +1 -0
  86. package/dist/backend/llvm/inline-unions.test.d.ts +1 -0
  87. package/dist/backend/llvm/inline-unions.test.js +124 -0
  88. package/dist/backend/llvm/inline-unions.test.js.map +1 -0
  89. package/dist/backend/llvm/int32-abi.d.ts +18 -2
  90. package/dist/backend/llvm/int32-abi.js +23 -2
  91. package/dist/backend/llvm/int32-abi.js.map +1 -1
  92. package/dist/backend/llvm/int32-abi.test.js +75 -1
  93. package/dist/backend/llvm/int32-abi.test.js.map +1 -1
  94. package/dist/backend/llvm/integer-remainder.d.ts +28 -5
  95. package/dist/backend/llvm/integer-remainder.js +80 -9
  96. package/dist/backend/llvm/integer-remainder.js.map +1 -1
  97. package/dist/backend/llvm/lib-dispatch.js +170 -28
  98. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  99. package/dist/backend/llvm/lib-filesystem.js +181 -5
  100. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  101. package/dist/backend/llvm/lib-network.js +9 -6
  102. package/dist/backend/llvm/lib-network.js.map +1 -1
  103. package/dist/backend/llvm/lib-process.js +2 -2
  104. package/dist/backend/llvm/lib-process.js.map +1 -1
  105. package/dist/backend/llvm/lib-shared.js +208 -9
  106. package/dist/backend/llvm/lib-shared.js.map +1 -1
  107. package/dist/backend/llvm/lib-stream.js +97 -0
  108. package/dist/backend/llvm/lib-stream.js.map +1 -1
  109. package/dist/backend/llvm/local-array-reads.js +12 -6
  110. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  111. package/dist/backend/llvm/local-array-reads.test.js +6 -3
  112. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  113. package/dist/backend/llvm/local-union-storage.d.ts +26 -2
  114. package/dist/backend/llvm/local-union-storage.js +132 -12
  115. package/dist/backend/llvm/local-union-storage.js.map +1 -1
  116. package/dist/backend/llvm/local-union-storage.test.js +107 -1
  117. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  118. package/dist/backend/llvm/loop-array-borrows.d.ts +8 -2
  119. package/dist/backend/llvm/loop-array-borrows.js +93 -13
  120. package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
  121. package/dist/backend/llvm/map-number-lookup.d.ts +20 -0
  122. package/dist/backend/llvm/map-number-lookup.js +66 -0
  123. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  124. package/dist/backend/llvm/map-number-lookup.test.d.ts +1 -0
  125. package/dist/backend/llvm/map-number-lookup.test.js +102 -0
  126. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -0
  127. package/dist/backend/llvm/map-read-lifetimes.js +1 -0
  128. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  129. package/dist/backend/llvm/publish.d.ts +4 -0
  130. package/dist/backend/llvm/publish.js +3 -1
  131. package/dist/backend/llvm/publish.js.map +1 -1
  132. package/dist/backend/llvm/record-results.d.ts +29 -0
  133. package/dist/backend/llvm/record-results.js +260 -0
  134. package/dist/backend/llvm/record-results.js.map +1 -0
  135. package/dist/backend/llvm/reference-effects.js +15 -0
  136. package/dist/backend/llvm/reference-effects.js.map +1 -1
  137. package/dist/backend/llvm/reference-writes.js +29 -9
  138. package/dist/backend/llvm/reference-writes.js.map +1 -1
  139. package/dist/backend/llvm/regions.d.ts +68 -0
  140. package/dist/backend/llvm/regions.js +314 -0
  141. package/dist/backend/llvm/regions.js.map +1 -0
  142. package/dist/backend/llvm/regions.test.d.ts +1 -0
  143. package/dist/backend/llvm/regions.test.js +173 -0
  144. package/dist/backend/llvm/regions.test.js.map +1 -0
  145. package/dist/backend/llvm/serialized-ir-emission.test.js +2 -0
  146. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  147. package/dist/backend/llvm/shapes.d.ts +86 -13
  148. package/dist/backend/llvm/shapes.js +208 -54
  149. package/dist/backend/llvm/shapes.js.map +1 -1
  150. package/dist/backend/llvm/shapes.test.js +68 -9
  151. package/dist/backend/llvm/shapes.test.js.map +1 -1
  152. package/dist/backend/llvm/split-loops.js +1 -1
  153. package/dist/backend/llvm/split-loops.js.map +1 -1
  154. package/dist/backend/llvm/stack-objects.d.ts +29 -0
  155. package/dist/backend/llvm/stack-objects.js +142 -0
  156. package/dist/backend/llvm/stack-objects.js.map +1 -0
  157. package/dist/backend/llvm/stack-objects.test.d.ts +1 -0
  158. package/dist/backend/llvm/stack-objects.test.js +255 -0
  159. package/dist/backend/llvm/stack-objects.test.js.map +1 -0
  160. package/dist/backend/llvm/string-reads.d.ts +4 -1
  161. package/dist/backend/llvm/string-reads.js +89 -9
  162. package/dist/backend/llvm/string-reads.js.map +1 -1
  163. package/dist/backend/llvm/switch-dispatch.js +5 -4
  164. package/dist/backend/llvm/switch-dispatch.js.map +1 -1
  165. package/dist/backend/llvm/walkers.d.ts +13 -0
  166. package/dist/backend/llvm/walkers.js +108 -10
  167. package/dist/backend/llvm/walkers.js.map +1 -1
  168. package/dist/backend/may-throw.js +10 -4
  169. package/dist/backend/may-throw.js.map +1 -1
  170. package/dist/backend/native/contracts.d.ts +7 -2
  171. package/dist/backend/native/executable.js +28 -2
  172. package/dist/backend/native/executable.js.map +1 -1
  173. package/dist/backend/native/library.js +1 -1
  174. package/dist/backend/native/library.js.map +1 -1
  175. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  176. package/dist/backend/native/runtime-inputs.js +3 -0
  177. package/dist/backend/native/runtime-inputs.js.map +1 -1
  178. package/dist/backend/native-link-info-core.d.ts +1 -0
  179. package/dist/backend/native-link-info-core.js.map +1 -1
  180. package/dist/backend/native-toolchain.test.js +1 -1
  181. package/dist/backend/native-toolchain.test.js.map +1 -1
  182. package/dist/backend/runtime-abi.d.ts +2 -2
  183. package/dist/backend/runtime-abi.js +2 -2
  184. package/dist/backend/runtime-pack-core.d.ts +1 -0
  185. package/dist/backend/runtime-pack-core.js +1 -0
  186. package/dist/backend/runtime-pack-core.js.map +1 -1
  187. package/dist/backend/runtime-pack-targets.test.js +1 -1
  188. package/dist/backend/runtime-pack.test.js +1 -1
  189. package/dist/backend/target-diagnostics.js +17 -0
  190. package/dist/backend/target-diagnostics.js.map +1 -1
  191. package/dist/backend/target-diagnostics.test.js +16 -0
  192. package/dist/backend/target-diagnostics.test.js.map +1 -1
  193. package/dist/compat/fetch-profile.js +4 -4
  194. package/dist/compat/fetch-profile.js.map +1 -1
  195. package/dist/contracts/check.js +2 -0
  196. package/dist/contracts/check.js.map +1 -1
  197. package/dist/coverage/report.js +1 -1
  198. package/dist/coverage/report.js.map +1 -1
  199. package/dist/diagnostics/diagnostic.d.ts +6 -5
  200. package/dist/diagnostics/diagnostic.js +7 -6
  201. package/dist/diagnostics/diagnostic.js.map +1 -1
  202. package/dist/executable/executable-cache.d.ts +1 -0
  203. package/dist/executable/executable-cache.js.map +1 -1
  204. package/dist/frontend/builtin-modules.d.ts +1 -1
  205. package/dist/frontend/builtin-modules.js +1 -0
  206. package/dist/frontend/builtin-modules.js.map +1 -1
  207. package/dist/frontend/comptime-node.js +2 -2
  208. package/dist/frontend/comptime-node.js.map +1 -1
  209. package/dist/frontend/experimental-import.d.ts +12 -0
  210. package/dist/frontend/experimental-import.js +63 -0
  211. package/dist/frontend/experimental-import.js.map +1 -0
  212. package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
  213. package/dist/frontend/lowering/binding-analysis.js +1 -1
  214. package/dist/frontend/lowering/builtin-calls.d.ts +6 -1
  215. package/dist/frontend/lowering/builtin-calls.js +36 -0
  216. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  217. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  218. package/dist/frontend/lowering/builtins/arguments.js +8 -4
  219. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  220. package/dist/frontend/lowering/builtins/blob.d.ts +20 -0
  221. package/dist/frontend/lowering/builtins/blob.js +167 -0
  222. package/dist/frontend/lowering/builtins/blob.js.map +1 -0
  223. package/dist/frontend/lowering/builtins/child-process-async.d.ts +2 -2
  224. package/dist/frontend/lowering/builtins/child-process-async.js +2 -2
  225. package/dist/frontend/lowering/builtins/child-process-methods.js +1 -1
  226. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  227. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -1
  228. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  229. package/dist/frontend/lowering/builtins/compression.js +3 -2
  230. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  231. package/dist/frontend/lowering/builtins/console.d.ts +16 -6
  232. package/dist/frontend/lowering/builtins/console.js +33 -9
  233. package/dist/frontend/lowering/builtins/console.js.map +1 -1
  234. package/dist/frontend/lowering/builtins/crypto.js +415 -120
  235. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  236. package/dist/frontend/lowering/builtins/errors.js +20 -0
  237. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  238. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +10 -0
  239. package/dist/frontend/lowering/builtins/filesystem-calls.js +89 -1
  240. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  241. package/dist/frontend/lowering/builtins/filesystem.d.ts +16 -7
  242. package/dist/frontend/lowering/builtins/filesystem.js +97 -15
  243. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  244. package/dist/frontend/lowering/builtins/fs-glob.d.ts +23 -0
  245. package/dist/frontend/lowering/builtins/fs-glob.js +224 -0
  246. package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -0
  247. package/dist/frontend/lowering/builtins/json.d.ts +2 -2
  248. package/dist/frontend/lowering/builtins/json.js +13 -4
  249. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  250. package/dist/frontend/lowering/builtins/key-object.d.ts +13 -0
  251. package/dist/frontend/lowering/builtins/key-object.js +56 -0
  252. package/dist/frontend/lowering/builtins/key-object.js.map +1 -0
  253. package/dist/frontend/lowering/builtins/module-calls.js +60 -12
  254. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  255. package/dist/frontend/lowering/builtins/numbers.d.ts +1 -0
  256. package/dist/frontend/lowering/builtins/numbers.js +17 -0
  257. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  258. package/dist/frontend/lowering/builtins/operating-system.d.ts +18 -0
  259. package/dist/frontend/lowering/builtins/operating-system.js +361 -1
  260. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  261. package/dist/frontend/lowering/builtins/performance.d.ts +25 -3
  262. package/dist/frontend/lowering/builtins/performance.js +340 -5
  263. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  264. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  265. package/dist/frontend/lowering/builtins/process.js +122 -17
  266. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  267. package/dist/frontend/lowering/builtins/promises.js +109 -2
  268. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  269. package/dist/frontend/lowering/builtins/properties.d.ts +0 -7
  270. package/dist/frontend/lowering/builtins/properties.js +39 -11
  271. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  272. package/dist/frontend/lowering/builtins/readline.d.ts +23 -8
  273. package/dist/frontend/lowering/builtins/readline.js +266 -90
  274. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  275. package/dist/frontend/lowering/builtins/text-codecs.d.ts +3 -4
  276. package/dist/frontend/lowering/builtins/text-codecs.js +3 -4
  277. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  278. package/dist/frontend/lowering/builtins/url.d.ts +8 -0
  279. package/dist/frontend/lowering/builtins/url.js +36 -0
  280. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  281. package/dist/frontend/lowering/call-arguments.js +1 -1
  282. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  283. package/dist/frontend/lowering/call-signatures.js +20 -2
  284. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  285. package/dist/frontend/lowering/checked-promise-all.d.ts +10 -3
  286. package/dist/frontend/lowering/checked-promise-all.js +52 -6
  287. package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
  288. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +8 -3
  289. package/dist/frontend/lowering/class-dynamic-dispatch.js +159 -32
  290. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  291. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
  292. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  293. package/dist/frontend/lowering/class-protocol-dispatch.d.ts +45 -0
  294. package/dist/frontend/lowering/class-protocol-dispatch.js +516 -0
  295. package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -0
  296. package/dist/frontend/lowering/coercions/structural-plans.js +2 -1
  297. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  298. package/dist/frontend/lowering/coercions/structural.js +3 -3
  299. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  300. package/dist/frontend/lowering/collation-repertoire.js +6 -5
  301. package/dist/frontend/lowering/collation-repertoire.js.map +1 -1
  302. package/dist/frontend/lowering/containers/array-callbacks.js +33 -6
  303. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  304. package/dist/frontend/lowering/containers/array-construction.js +8 -4
  305. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  306. package/dist/frontend/lowering/containers/array-methods.d.ts +0 -7
  307. package/dist/frontend/lowering/containers/array-methods.js +43 -2
  308. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  309. package/dist/frontend/lowering/containers/array-pipelines.js +1 -1
  310. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  311. package/dist/frontend/lowering/containers/bytes.js +38 -26
  312. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  313. package/dist/frontend/lowering/containers/for-of.d.ts +1 -1
  314. package/dist/frontend/lowering/containers/for-of.js +5 -1
  315. package/dist/frontend/lowering/containers/for-of.js.map +1 -1
  316. package/dist/frontend/lowering/containers/indexed-objects.js +1 -1
  317. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  318. package/dist/frontend/lowering/containers/string-and-regexp.js +91 -0
  319. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  320. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  321. package/dist/frontend/lowering/crypto-tables.js +77 -12
  322. package/dist/frontend/lowering/crypto-tables.js.map +1 -1
  323. package/dist/frontend/lowering/cycle-initialization.d.ts +18 -2
  324. package/dist/frontend/lowering/cycle-initialization.js +166 -12
  325. package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
  326. package/dist/frontend/lowering/deferred-module-initializers.js +7 -2
  327. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  328. package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
  329. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  330. package/dist/frontend/lowering/expressions/nullish-assignment.js +10 -0
  331. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  332. package/dist/frontend/lowering/expressions/object-literals.js +21 -68
  333. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  334. package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
  335. package/dist/frontend/lowering/generator-delegation.js +231 -10
  336. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  337. package/dist/frontend/lowering/generic-functions.d.ts +2 -2
  338. package/dist/frontend/lowering/generic-functions.js +2 -2
  339. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  340. package/dist/frontend/lowering/http2-constants.js +1 -1
  341. package/dist/frontend/lowering/lifetime-regions.d.ts +11 -0
  342. package/dist/frontend/lowering/lifetime-regions.js +216 -0
  343. package/dist/frontend/lowering/lifetime-regions.js.map +1 -0
  344. package/dist/frontend/lowering/lower-array-sort.d.ts +40 -3
  345. package/dist/frontend/lowering/lower-array-sort.js +661 -194
  346. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  347. package/dist/frontend/lowering/lower-array-sort.test.js +103 -4
  348. package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
  349. package/dist/frontend/lowering/lower-assert.js +2 -2
  350. package/dist/frontend/lowering/lower-async-iteration.d.ts +6 -3
  351. package/dist/frontend/lowering/lower-async-iteration.js +248 -2
  352. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  353. package/dist/frontend/lowering/lower-calls.js +173 -111
  354. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  355. package/dist/frontend/lowering/lower-classes.d.ts +12 -5
  356. package/dist/frontend/lowering/lower-classes.js +156 -11
  357. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  358. package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
  359. package/dist/frontend/lowering/lower-comptime.js +4 -4
  360. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  361. package/dist/frontend/lowering/lower-console.d.ts +13 -0
  362. package/dist/frontend/lowering/lower-console.js +460 -4
  363. package/dist/frontend/lowering/lower-console.js.map +1 -1
  364. package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -0
  365. package/dist/frontend/lowering/lower-event-emitter.js +124 -38
  366. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  367. package/dist/frontend/lowering/lower-event-target.d.ts +63 -0
  368. package/dist/frontend/lowering/lower-event-target.js +362 -0
  369. package/dist/frontend/lowering/lower-event-target.js.map +1 -0
  370. package/dist/frontend/lowering/lower-expando.js +2 -2
  371. package/dist/frontend/lowering/lower-exprs.js +247 -42
  372. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  373. package/dist/frontend/lowering/lower-generators.d.ts +15 -7
  374. package/dist/frontend/lowering/lower-generators.js +183 -99
  375. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  376. package/dist/frontend/lowering/lower-inspect.d.ts +8 -1
  377. package/dist/frontend/lowering/lower-inspect.js +247 -28
  378. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  379. package/dist/frontend/lowering/lower-mixins.js +1 -1
  380. package/dist/frontend/lowering/lower-modules.d.ts +1 -1
  381. package/dist/frontend/lowering/lower-modules.js +27 -17
  382. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  383. package/dist/frontend/lowering/lower-namespaces.d.ts +2 -2
  384. package/dist/frontend/lowering/lower-namespaces.js +2 -2
  385. package/dist/frontend/lowering/lower-server.js +39 -14
  386. package/dist/frontend/lowering/lower-server.js.map +1 -1
  387. package/dist/frontend/lowering/lower-stdlib.d.ts +11 -1
  388. package/dist/frontend/lowering/lower-stdlib.js +45 -4
  389. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  390. package/dist/frontend/lowering/lower-stmts.d.ts +2 -2
  391. package/dist/frontend/lowering/lower-stmts.js +112 -23
  392. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  393. package/dist/frontend/lowering/lower-stream.js +234 -22
  394. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  395. package/dist/frontend/lowering/lower-timers.js +1 -1
  396. package/dist/frontend/lowering/lowerer.d.ts +45 -6
  397. package/dist/frontend/lowering/lowerer.js +360 -48
  398. package/dist/frontend/lowering/lowerer.js.map +1 -1
  399. package/dist/frontend/lowering/native-ffi.js +2 -2
  400. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  401. package/dist/frontend/lowering/regex-span-reads.d.ts +12 -0
  402. package/dist/frontend/lowering/regex-span-reads.js +164 -0
  403. package/dist/frontend/lowering/regex-span-reads.js.map +1 -0
  404. package/dist/frontend/lowering/runtime-optional-records.d.ts +115 -0
  405. package/dist/frontend/lowering/runtime-optional-records.js +715 -0
  406. package/dist/frontend/lowering/runtime-optional-records.js.map +1 -0
  407. package/dist/frontend/lowering/runtime-optional-records.test.d.ts +1 -0
  408. package/dist/frontend/lowering/runtime-optional-records.test.js +175 -0
  409. package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -0
  410. package/dist/frontend/lowering/surfaces.d.ts +7 -3
  411. package/dist/frontend/lowering/surfaces.js +385 -32
  412. package/dist/frontend/lowering/surfaces.js.map +1 -1
  413. package/dist/frontend/lowering/var-hoisting.d.ts +3 -0
  414. package/dist/frontend/lowering/var-hoisting.js +261 -0
  415. package/dist/frontend/lowering/var-hoisting.js.map +1 -0
  416. package/dist/frontend/module-syntax.d.ts +1 -1
  417. package/dist/frontend/module-syntax.js +1 -1
  418. package/dist/frontend/npm-static-prune.js +1 -1
  419. package/dist/frontend/npm-static-prune.js.map +1 -1
  420. package/dist/frontend/npm-static-rewrite-syntax.js +4 -3
  421. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  422. package/dist/frontend/pipeline.js +6 -4
  423. package/dist/frontend/pipeline.js.map +1 -1
  424. package/dist/frontend/program.d.ts +6 -5
  425. package/dist/frontend/program.js +42 -22
  426. package/dist/frontend/program.js.map +1 -1
  427. package/dist/frontend/program.test.js +13 -0
  428. package/dist/frontend/program.test.js.map +1 -1
  429. package/dist/frontend/resolve.js +1 -1
  430. package/dist/frontend/ts7/adapter.js +1 -1
  431. package/dist/frontend/ts7/ast-bytes.d.ts +1 -1
  432. package/dist/frontend/ts7/ast-bytes.js +1 -1
  433. package/dist/frontend/ts7/semantic-json.d.ts +1 -1
  434. package/dist/frontend/ts7/semantic-json.js +1 -1
  435. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  436. package/dist/frontend/ts7/world-check.js +1 -1
  437. package/dist/frontend/tsc-codes.js +2 -2
  438. package/dist/frontend/tsc-codes.js.map +1 -1
  439. package/dist/frontend/type-mapper.d.ts +28 -1
  440. package/dist/frontend/type-mapper.js +288 -30
  441. package/dist/frontend/type-mapper.js.map +1 -1
  442. package/dist/index.js +6 -4
  443. package/dist/index.js.map +1 -1
  444. package/dist/ir/analysis.d.ts +12 -6
  445. package/dist/ir/analysis.js +26 -10
  446. package/dist/ir/analysis.js.map +1 -1
  447. package/dist/ir/analysis.test.js +15 -3
  448. package/dist/ir/analysis.test.js.map +1 -1
  449. package/dist/ir/builtin-effects.js +108 -2
  450. package/dist/ir/builtin-effects.js.map +1 -1
  451. package/dist/ir/builtin-signatures.d.ts +1 -1
  452. package/dist/ir/builtin-signatures.js +436 -53
  453. package/dist/ir/builtin-signatures.js.map +1 -1
  454. package/dist/ir/function-references.test.js +1 -0
  455. package/dist/ir/function-references.test.js.map +1 -1
  456. package/dist/ir/int32-slots.js +2 -0
  457. package/dist/ir/int32-slots.js.map +1 -1
  458. package/dist/ir/intrinsic-signatures.js +2 -0
  459. package/dist/ir/intrinsic-signatures.js.map +1 -1
  460. package/dist/ir/ir.d.ts +129 -36
  461. package/dist/ir/ir.js +42 -1
  462. package/dist/ir/ir.js.map +1 -1
  463. package/dist/ir/runtime-features.d.ts +1 -0
  464. package/dist/ir/runtime-features.js +116 -5
  465. package/dist/ir/runtime-features.js.map +1 -1
  466. package/dist/ir/scalar-records.js +1 -2
  467. package/dist/ir/scalar-records.js.map +1 -1
  468. package/dist/ir/serialize.js +1 -1
  469. package/dist/ir/serialize.js.map +1 -1
  470. package/dist/ir/traverse.js +1 -0
  471. package/dist/ir/traverse.js.map +1 -1
  472. package/dist/ir/validate.js +250 -34
  473. package/dist/ir/validate.js.map +1 -1
  474. package/dist/ir/validate.test.js +125 -0
  475. package/dist/ir/validate.test.js.map +1 -1
  476. package/dist/library/fence-eval.d.ts +1 -1
  477. package/dist/library/fence-eval.js +5 -4
  478. package/dist/library/fence-eval.js.map +1 -1
  479. package/dist/library/ir-policy.js +11 -4
  480. package/dist/library/ir-policy.js.map +1 -1
  481. package/dist/library/library-profile.js +13 -13
  482. package/dist/library/library-profile.js.map +1 -1
  483. package/dist/library/prepare.js +1 -1
  484. package/dist/library/prepare.js.map +1 -1
  485. package/dist/library/sidecar.js +3 -3
  486. package/dist/library/sidecar.js.map +1 -1
  487. package/dist/native/prepare.js +3 -2
  488. package/dist/native/prepare.js.map +1 -1
  489. package/dist/native/sanitizer.test.js +1 -0
  490. package/dist/native/sanitizer.test.js.map +1 -1
  491. package/package.json +20 -20
  492. package/surface-manifest.json +537 -142
@@ -1,11 +1,16 @@
1
+ import { lifetimeRegionType, lowerLifetimeRegionCall, lowerLifetimeRegionNew, } from "./lifetime-regions.js";
2
+ import { isExperimentalDeclarationFile } from "../experimental-import.js";
1
3
  import { checkCycleBindingAccesses, refuseUncheckedCycleReads, } from "./cycle-initialization.js";
2
4
  import { identityPreservingWidening } from "./coercions/identity.js";
3
5
  import { scanDivergences } from "./divergences.js";
4
6
  import { checkedClassAssertion } from "./class-assertions.js";
5
7
  import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
6
8
  import { isOptionalProcessStreamProperty } from "./builtins/process.js";
9
+ import { isSettledIteratorValueRead } from "./lower-generators.js";
7
10
  import { concreteCollectionNarrow } from "./collection-narrowing.js";
8
11
  import { lowerWorkerMetadata } from "./builtins/workers.js";
12
+ import { fenceStaticBlobMember, lowerBlobNew, lowerStaticBlobCall } from "./builtins/blob.js";
13
+ import { lowerKeyObjectCall } from "./builtins/key-object.js";
9
14
  import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
10
15
  import { iteratorSlotAdapter } from "./iterator-adapters.js";
11
16
  import { lowerBuiltinCall } from "./builtin-calls.js";
@@ -16,12 +21,14 @@ import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceA
16
21
  import { unionRetagMappable, narrowedRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
17
22
  import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
18
23
  import { devirtualizeVirtualCalls } from "./devirtualize.js";
24
+ import { foldRegexSpanReads } from "./regex-span-reads.js";
19
25
  import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
20
26
  import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
21
27
  import { NarrowingStability } from "./narrowing-stability.js";
22
28
  import { ArrayElementStates } from "./runtime-optional-elements.js";
23
29
  import { indexReadInBounds } from "./runtime-optional-bounds.js";
24
30
  import { ArrayOwnership } from "./runtime-optional-ownership.js";
31
+ import { RecordFlowClasses } from "./runtime-optional-records.js";
25
32
  import { StringIndexBounds } from "./string-index-bounds.js";
26
33
  import { NanCodedReads } from "./nan-coded-reads.js";
27
34
  import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
@@ -31,8 +38,11 @@ import { UnregisteredClassTypes } from "./unregistered-class-types.js";
31
38
  import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, } from "./function-context.js";
32
39
  import { InternalCompilerError } from "../../errors.js";
33
40
  import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
41
+ import {} from "./class-protocol-dispatch.js";
34
42
  import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
35
43
  import { ClassProtocols } from "./class-protocols.js";
44
+ import { earlyReadVarSymbols } from "./var-hoisting.js";
45
+ import { recordTextCodecClass } from "../../ir/ir.js";
36
46
  import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
37
47
  import { finalizeClassMethodValues } from "./class-method-values.js";
38
48
  export { newFnCtx } from "./function-context.js";
@@ -60,10 +70,11 @@ import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, c
60
70
  import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
61
71
  import { provenanceActive } from "../provenance-registry.js";
62
72
  import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
63
- import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
73
+ import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
64
74
  import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
65
75
  import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
66
76
  import { prepareCjsModuleGraph } from "./lower-node-module.js";
77
+ import { registerBuiltinEventTargetClasses } from "./lower-event-target.js";
67
78
  import { registerBuiltinErrorClasses, registerBuiltinEmitterClass, registerBuiltinStreamClasses, builtinErrorInfoOf, builtinEmitterInfoOf, builtinStreamInfoOf, analyzeClassDecoration, classIteratorDrainCall, classIteratorNextCall, classIteratorOf, classIteratorOpenCall, classIteratorRestDrainCall, classMemberNameOf, classValueRef, collectClassShape, exactClassOfReceiver, collectClassShapeInner, ctorAbiEquals, findMethodOn, findStaticOn, genericClassInstanceType, isSubclassOf, inHierarchy, overrideBelow, staticShadowBelow, upcastTo, lowerClassMembers, lowerClassCtor, lowerClassExpression, lowerClassExpressionInfo, lowerClassMethodMember, lowerClassValueProperty, lowerStaticMethod, throwingSetterFn, fieldInitStmts, lowerStaticFieldInits, lowerStaticFieldRead, lowerDerivedCtorBody, superCallStmt, lowerSuperMethodCall, superThisRef, lowerSuperAccessorRead, lowerSuperAccessorWrite, inheritsBuiltinErrorCtor, inheritsBuiltinEmitterCtor, errorConstructorArgs, lowerNew, accessorCall, } from "./lower-classes.js";
68
79
  import { mixinCallClassInfoOf, mixinIntersectionInstanceType, } from "./lower-mixins.js";
69
80
  import { tryLowerExpression } from "./expressions/try-lower-expression.js";
@@ -104,14 +115,14 @@ import { lowerReadlineMethodCall } from "./builtins/readline.js";
104
115
  import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
105
116
  import { lowerErrorCodeProperty } from "./builtins/errors.js";
106
117
  import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
107
- import { isConsoleLog, consoleCallMember } from "./builtins/console.js";
118
+ import { consoleCallMember, consoleMethodMember, isConsoleLog, } from "./builtins/console.js";
108
119
  import { lowerConsoleNew } from "./lower-console.js";
109
120
  import { lowerNumberStaticCall, lowerNumberStaticProperty } from "./builtins/numbers.js";
110
121
  import { lowerDateCall } from "./builtins/dates.js";
111
122
  import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
112
123
  import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
113
124
  import { lowerPromiseStaticCall } from "./builtins/promises.js";
114
- import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
125
+ import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
115
126
  import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
116
127
  import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
117
128
  import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
@@ -495,8 +506,8 @@ export function neverTaintedJsType(lowerer, node, t) {
495
506
  * per-statement runtime fence would have thrown (message + "[code at
496
507
  * file:line]"), rendered eagerly so the runtime can throw it verbatim
497
508
  * (scr_throw_lowering_fence). The diagnostic joins the runtime-fence
498
- * ledger exactly like a deferred statement fence — nothing silently
499
- * drops off the coverage report. */
509
+ * ledger exactly like a deferred statement fence, so every fence appears
510
+ * on the coverage report. */
500
511
  export function ladderFenceExpr(lowerer, surface, node, hint) {
501
512
  const loc = locOf(node);
502
513
  const d = noLoweringDiag(surface, loc, hint);
@@ -1101,6 +1112,9 @@ export class Lowerer {
1101
1112
  requestInitPropMutatedSyms = null;
1102
1113
  emitterEventTable = null;
1103
1114
  emitterComputedPatterns = [];
1115
+ /** The EventTarget engine's handleEvent reader was lifted
1116
+ * (lower-event-target.ts noteEventListeners). */
1117
+ handleEventReader = false;
1104
1118
  /** Locals widened beyond the checker's type because an inferred indexed
1105
1119
  * read can be absent at runtime. Bare reads preserve that union until a
1106
1120
  * surrounding JavaScript guard/default consumes it. */
@@ -1116,6 +1130,9 @@ export class Lowerer {
1116
1130
  /** All storage slots widened for runtime absence, including slots whose
1117
1131
  * current control-flow branch has temporarily narrowed the value. */
1118
1132
  runtimeOptionalStorageLocals = new Set();
1133
+ /** `var` bindings code can read before their first store
1134
+ * (var-hoisting.ts): their storage holds undefined until then. */
1135
+ earlyReadVars = new Set();
1119
1136
  /** Globals whose checker-bare type was widened because an indexed read can
1120
1137
  * carry undefined at runtime. Identifier reads keep the union tag so
1121
1138
  * typeof and later boundaries observe the real value. */
@@ -1129,6 +1146,9 @@ export class Lowerer {
1129
1146
  * prepass. This includes explicit annotations: unchecked TS annotations do
1130
1147
  * not prove that an array property read produced a value. */
1131
1148
  runtimeOptionalBindingTypes = new Map();
1149
+ /** Set when a match result lowers to execGroups/matchGroups, the inputs
1150
+ * of regex span folding. */
1151
+ regexGroupResults = false;
1132
1152
  /** Bindings that receive an unchecked indexed read (or a value derived
1133
1153
  * from one) through an initializer or assignment. The checker narrows a
1134
1154
  * declared optional binding to that read's bare type, so presence tests
@@ -1147,6 +1167,10 @@ export class Lowerer {
1147
1167
  /** Record fields promoted to an undefined-armed union by an indexed-read
1148
1168
  * value. The key is the concrete emitted shape and field name. */
1149
1169
  runtimeOptionalFields = new Set();
1170
+ /** Record bindings whose flow class reaches storage outside the class:
1171
+ * they keep the declared layout, so an initializer from unchecked reads
1172
+ * converts once instead of the binding adopting the widened variant. */
1173
+ runtimeOptionalRecordsKeptDeclared = new Set();
1150
1174
  /** Callback pattern parameters carry an optional source without making
1151
1175
  * every name destructured from a present source optional. */
1152
1176
  runtimeOptionalPatternTypes = new Map();
@@ -1162,6 +1186,9 @@ export class Lowerer {
1162
1186
  /** for-of loops over arrays that can hold neither holes nor undefined:
1163
1187
  * each pass reads the element payload directly. */
1164
1188
  presentElementLoops = new Set();
1189
+ /** The fs/promises glob() call lowerForOf is lowering as a for await
1190
+ * head; other glob() calls have no lowering. */
1191
+ fspGlobHead = null;
1165
1192
  /** Capture entries and their origin share one mutable box. Normalize each
1166
1193
  * entry to the origin so writes and flow proofs stay synchronized. */
1167
1194
  runtimeOptionalRoots = new Map();
@@ -1439,6 +1466,10 @@ export class Lowerer {
1439
1466
  return type;
1440
1467
  }
1441
1468
  const shapeId = this.shapes.intern(shape.fields.map((f) => ({ name: f.name, type: f.name === field ? fieldType : f.type })), shape.tuple === true, shape.indexValue, shape.declaredOrder);
1469
+ // The widened shape keeps the fields this one already widened.
1470
+ for (const f of shape.fields)
1471
+ if (this.isRuntimeOptionalField(type.shapeId, f.name))
1472
+ this.runtimeOptionalFields.add(this.runtimeOptionalFieldKey(shapeId, f.name));
1442
1473
  this.runtimeOptionalFields.add(this.runtimeOptionalFieldKey(shapeId, field));
1443
1474
  return { kind: "record", shapeId };
1444
1475
  }
@@ -1522,8 +1553,9 @@ export class Lowerer {
1522
1553
  * runtime closure pointer: a coercion adapter allocates a different
1523
1554
  * closure at the registration and release sites, so lowerFfiCall must
1524
1555
  * refuse these forms at compile time (SC5003). Any new closure-minting
1525
- * adapter helper MUST add its name here, or the identity guard silently
1526
- * reopens and the mismatch surfaces as a runtime release trap instead. */
1556
+ * adapter helper MUST add its name here, or the identity guard reopens
1557
+ * without a diagnostic and the mismatch surfaces as a runtime release
1558
+ * trap instead. */
1527
1559
  freshClosureAdapters = new Set();
1528
1560
  /** Symbols bound by `const process = globalThis.process` (and the other
1529
1561
  * stdlib-global snapshot spellings): pure alias plumbing — receiver
@@ -1599,6 +1631,11 @@ export class Lowerer {
1599
1631
  /** Named method slots observed before class collection need a callable
1600
1632
  * ABI and shared prototype descriptors instead of call-site specialization. */
1601
1633
  prototypeMethodAccesses = new Map();
1634
+ /** Typed calls through class-backed protocols, by signature; class
1635
+ * dynamic dispatch adds their native arms (class-protocol-dispatch.ts). */
1636
+ protocolDispatches = new Map();
1637
+ /** Bindings no other function assigns (class-protocol-dispatch.ts). */
1638
+ protocolOwnedBindings = new Map();
1602
1639
  /** Field names whose complete source census stores only lexical arrows. */
1603
1640
  receiverFreeCallbackFields = new Set();
1604
1641
  /** Inferred JS methods participating in an override chain keep a vtable
@@ -1655,6 +1692,12 @@ export class Lowerer {
1655
1692
  workerTargets;
1656
1693
  workerTargetIdByPath = new Map();
1657
1694
  usesWorkers = false;
1695
+ /** The program constructs a LifetimeRegion (lifetime-regions.ts). */
1696
+ usesLifetimeRegions = false;
1697
+ /** Per-directory answers of experimental-import.ts's declaration-file test. */
1698
+ experimentalFiles = new Map();
1699
+ /** Interned LifetimeRegion.run helpers, by callback type key. */
1700
+ regionRunHelpers = new Map();
1658
1701
  forkTargetIdByPath = new Map();
1659
1702
  /** Namespace ModuleBlocks this program lowers, filled by splitFiles:
1660
1703
  * "flattened" — an instantiated namespace whose body joined the file's
@@ -1761,6 +1804,9 @@ export class Lowerer {
1761
1804
  /** Import-cycle bindings with an initialization flag, by global id, and
1762
1805
  * the top-level statements declaring them (cycle-initialization.ts). */
1763
1806
  cycleInitFlags = new Map();
1807
+ /** Initialization flags of classes reachable before their statement ran,
1808
+ * by class name (cycle-initialization.ts). */
1809
+ classInitFlags = new Map();
1764
1810
  cycleInitDeclarations = new Map();
1765
1811
  get ctx() {
1766
1812
  const top = this.fnStack[this.fnStack.length - 1];
@@ -1784,6 +1830,9 @@ export class Lowerer {
1784
1830
  /** Set while a subclass constructor's super() call notes its base
1785
1831
  * constructor edge: that edge does not instantiate the base exactly. */
1786
1832
  superConstructorEdge = false;
1833
+ /** Set when the async generator `return` being lowered awaited its
1834
+ * promise operand (returnedPromiseAwait). */
1835
+ returnAwaitedPromise = false;
1787
1836
  virtualEdges = new Map();
1788
1837
  classCanBeConstructed(info) {
1789
1838
  return (this.constructedClasses === null ||
@@ -1963,6 +2012,9 @@ export class Lowerer {
1963
2012
  // fileTag is filled just below; the hook is only ever CALLED during
1964
2013
  // lowering, long after the constructor completes.
1965
2014
  isProgramFile: (sf) => this.fileTag.has(sf),
2015
+ lifetimeRegionClass: (decl) => isExperimentalDeclarationFile(decl.getSourceFile(), this.experimentalFiles)
2016
+ ? lifetimeRegionType(this)
2017
+ : null,
1966
2018
  moduleNamespaceId: (type) => this.moduleNamespaceIdOfType(type),
1967
2019
  };
1968
2020
  // Modules reachable only through literal import() joined
@@ -1977,6 +2029,7 @@ export class Lowerer {
1977
2029
  this.registerBuiltinErrorClasses();
1978
2030
  registerBuiltinEmitterClass(this);
1979
2031
  registerBuiltinStreamClasses(this);
2032
+ registerBuiltinEventTargetClasses(this);
1980
2033
  }
1981
2034
  registerBuiltinErrorClasses() {
1982
2035
  return registerBuiltinErrorClasses(this);
@@ -3009,8 +3062,70 @@ export class Lowerer {
3009
3062
  familyBySymbol.set(symbol, family);
3010
3063
  }
3011
3064
  }
3065
+ // Static methods never share a dispatch slot: each is its own family.
3066
+ if (info.staticMethods) {
3067
+ for (const sig of info.staticMethods.values()) {
3068
+ const name = sig.member.name;
3069
+ if (!(ts.isIdentifier(name) || ts.isStringLiteral(name)))
3070
+ continue;
3071
+ const symbol = symbolOf(name);
3072
+ if (symbol && !signatureBySymbol.has(symbol))
3073
+ signatureBySymbol.set(symbol, { params: sig.params, returnType: sig.ret, method: sig });
3074
+ }
3075
+ }
3012
3076
  }
3013
3077
  const mappedOrNull = (node) => panicSafe(() => this.mapTypeOf(this.typeOf(node)), null);
3078
+ const admitsUndefined = (type) => typeEquals(addUndefined(type), type);
3079
+ const plainRecordShape = (type) => {
3080
+ if (type?.kind !== "record")
3081
+ return null;
3082
+ const shape = this.shapes.get(type.shapeId);
3083
+ return shape && !shape.tuple && !shape.indexValue && shape.fields.length > 0
3084
+ ? type.shapeId
3085
+ : null;
3086
+ };
3087
+ // Parameters and results read the signatures collected above; bindings
3088
+ // ask the checker, so the scan builds no layout of its own.
3089
+ const parameterType = (node) => {
3090
+ const parameter = node.parent;
3091
+ if (!parameter || !ts.isParameter(parameter))
3092
+ return null;
3093
+ const fn = parameter.parent;
3094
+ const symbol = (ts.isFunctionDeclaration(fn) || ts.isMethodDeclaration(fn)) && fn.name
3095
+ ? symbolOf(fn.name)
3096
+ : null;
3097
+ const index = fn.parameters.indexOf(parameter);
3098
+ return (symbol && signatureBySymbol.get(symbol)?.params[index]?.type) ?? null;
3099
+ };
3100
+ const returnTypeOf = (fn) => {
3101
+ const symbol = fn.name ? symbolOf(fn.name) : null;
3102
+ return (symbol && signatureBySymbol.get(symbol)?.returnType) ?? null;
3103
+ };
3104
+ const recordFlows = new RecordFlowClasses(sourceFiles, {
3105
+ symbolOf,
3106
+ declarationOf: (symbol) => this.checker.valueDeclarationOf(symbol),
3107
+ mayBeRecord: (node) => {
3108
+ if (node.parent && ts.isParameter(node.parent))
3109
+ return plainRecordShape(parameterType(node)) !== null;
3110
+ const t = panicSafe(() => this.typeOf(node), null);
3111
+ return (t !== null &&
3112
+ (t.flags & ts.TypeFlags.Object) !== 0 &&
3113
+ !this.checker.isArrayType(t) &&
3114
+ this.checker.getCallSignatures(t).length === 0 &&
3115
+ this.checker.getConstructSignatures(t).length === 0);
3116
+ },
3117
+ prefetchTypes: (nodes) => this.checker.prefetchCollectionTypes(nodes),
3118
+ mayReturnRecord: (fn) => plainRecordShape(returnTypeOf(fn)) !== null,
3119
+ familyOf: (method) => familyBySymbol.get(method),
3120
+ recordShape: (node) => plainRecordShape(node.parent && ts.isParameter(node.parent) ? parameterType(node) : mappedOrNull(node)),
3121
+ returnShape: (fn) => plainRecordShape(returnTypeOf(fn)),
3122
+ isGlobal: (node, name) => this.isStdlibGlobal(node, name),
3123
+ });
3124
+ /** Optional fields of the records a visible function returns. */
3125
+ const returnFields = new Map();
3126
+ /** Record parameters that receive a value with optional fields, by the
3127
+ * parameter's own symbol. */
3128
+ const recordParameterSlots = new Map();
3014
3129
  const nanCoded = new NanCodedReads({
3015
3130
  symbolOf,
3016
3131
  declarationOf: (symbol) => this.checker.valueDeclarationOf(symbol),
@@ -3228,6 +3343,10 @@ export class Lowerer {
3228
3343
  return true;
3229
3344
  if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
3230
3345
  return true;
3346
+ if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
3347
+ return true;
3348
+ if (ts.isPropertyAccessExpression(e) && isOsConstantsSymbol(symbolOf(e.expression), this))
3349
+ return true;
3231
3350
  if (ts.isCallExpression(e) && this.runtimeOptionalReduceTypes.has(e))
3232
3351
  return true;
3233
3352
  if (ts.isCallExpression(e) &&
@@ -3285,10 +3404,8 @@ export class Lowerer {
3285
3404
  if (op === ts.SyntaxKind.AmpersandAmpersandToken)
3286
3405
  return mayBeOptional(e.left) || mayBeOptional(e.right);
3287
3406
  }
3288
- if (ts.isPropertyAccessExpression(e) && ts.isIdentifier(e.expression)) {
3289
- const symbol = symbolOf(e.expression);
3290
- const fields = symbol === null ? undefined : optionalFields.get(symbol);
3291
- return fields?.has(fieldName(e)) ?? false;
3407
+ if (ts.isPropertyAccessExpression(e)) {
3408
+ return fieldsOfValue(e.expression)?.has(fieldName(e)) ?? false;
3292
3409
  }
3293
3410
  return false;
3294
3411
  };
@@ -3397,10 +3514,40 @@ export class Lowerer {
3397
3514
  // a spread or a parameter receives the source's optional fields.
3398
3515
  const fieldsOfValue = (node) => {
3399
3516
  const e = peel(node);
3400
- if (!ts.isIdentifier(e))
3401
- return undefined;
3402
- const symbol = symbolOf(e);
3403
- return symbol === null ? undefined : optionalFields.get(symbol);
3517
+ if (ts.isIdentifier(e)) {
3518
+ const symbol = symbolOf(e);
3519
+ // A binding whose class reaches other storage keeps the declared
3520
+ // layout, so its fields read as present.
3521
+ return symbol === null || recordFlows.opened(symbol)
3522
+ ? undefined
3523
+ : optionalFields.get(symbol);
3524
+ }
3525
+ // A fresh literal carries the fields its values can leave undefined.
3526
+ if (ts.isObjectLiteralExpression(e)) {
3527
+ const out = spreadFieldsOf(e);
3528
+ for (const prop of e.properties) {
3529
+ if (!ts.isPropertyAssignment(prop) && !ts.isShorthandPropertyAssignment(prop))
3530
+ continue;
3531
+ const name = prop.name;
3532
+ if (!(ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)))
3533
+ continue;
3534
+ const value = ts.isPropertyAssignment(prop) ? prop.initializer : name;
3535
+ if (mayBeOptional(value))
3536
+ out.add(name.text);
3537
+ }
3538
+ return out.size > 0 ? out : undefined;
3539
+ }
3540
+ if (ts.isCallExpression(e) &&
3541
+ (ts.isIdentifier(e.expression) || ts.isPropertyAccessExpression(e.expression))) {
3542
+ const symbol = symbolOf(ts.isIdentifier(e.expression) ? e.expression : e.expression.name);
3543
+ return symbol === null ? undefined : returnFields.get(symbol);
3544
+ }
3545
+ if (ts.isConditionalExpression(e)) {
3546
+ const a = fieldsOfValue(e.whenTrue);
3547
+ const b = fieldsOfValue(e.whenFalse);
3548
+ return a && b ? new Set([...a, ...b]) : (a ?? b);
3549
+ }
3550
+ return undefined;
3404
3551
  };
3405
3552
  const noteFieldsFrom = (symbol, source) => {
3406
3553
  const fields = fieldsOfValue(source);
@@ -3520,6 +3667,19 @@ export class Lowerer {
3520
3667
  found = true;
3521
3668
  return found;
3522
3669
  };
3670
+ /** A return of a var that code can read before its first store. */
3671
+ const returnsEarlyVar = (fn) => {
3672
+ const early = (e) => {
3673
+ const read = peel(e);
3674
+ if (!ts.isIdentifier(read))
3675
+ return false;
3676
+ const symbol = symbolOf(read);
3677
+ return symbol !== null && this.earlyReadVars.has(symbol);
3678
+ };
3679
+ if (fn.body && !ts.isBlock(fn.body))
3680
+ return early(fn.body);
3681
+ return returnsOf(fn).some(early);
3682
+ };
3523
3683
  const jsLambdas = [];
3524
3684
  // TypeScript lambdas keep the checker's inferred return type, which
3525
3685
  // spells a missing read as its bare element type and `read ?? "text"`
@@ -4415,23 +4575,21 @@ export class Lowerer {
4415
4575
  const bound = symbolOf(parameter.name);
4416
4576
  if (!bound)
4417
4577
  continue;
4418
- let promoted = parameterShape.type;
4578
+ const declared = this.shapes.get(parameterShape.type.shapeId);
4579
+ // The parameter's layout settles with its flow class once
4580
+ // the fixed point ends. A literal or call argument only adds
4581
+ // fields the declaration calls present.
4582
+ const fresh = !ts.isIdentifier(peel(arg));
4419
4583
  for (const field of fields) {
4420
- const source = promoted.kind === "record"
4421
- ? this.shapes.get(promoted.shapeId)?.fields.find((f) => f.name === field)
4422
- : undefined;
4423
- if (source) {
4424
- promoted = this.runtimeOptionalRecordField(promoted, field, addUndefined(source.type));
4425
- }
4426
- if (noteFieldSymbol(bound, field))
4584
+ const slot = declared?.fields.find((f) => f.name === field);
4585
+ if (!slot || (fresh && admitsUndefined(slot.type)))
4586
+ continue;
4587
+ if (noteFieldSymbol(bound, field)) {
4588
+ provenance?.note("record-parameter", parameter, arg);
4427
4589
  changed = true;
4590
+ }
4428
4591
  }
4429
- if (!typeEquals(promoted, parameterShape.type)) {
4430
- parameterShape.type = promoted;
4431
- this.runtimeOptionalBindingTypes.set(bound, promoted);
4432
- provenance?.note("record-parameter", parameter, arg);
4433
- changed = true;
4434
- }
4592
+ recordParameterSlots.set(bound, { target, index: i });
4435
4593
  }
4436
4594
  }
4437
4595
  if (ts.isSpreadElement(arg) || !shape)
@@ -4515,7 +4673,27 @@ export class Lowerer {
4515
4673
  };
4516
4674
  const scanReturns = (symbol, decl) => {
4517
4675
  let changed = false;
4676
+ const recordReturn = recordFlows.returnClass(symbol) !== null;
4677
+ const returned = signatureBySymbol.get(symbol)?.returnType;
4678
+ const returnedShape = returned?.kind === "record" ? this.shapes.get(returned.shapeId) : null;
4518
4679
  for (const expression of returnsOf(decl)) {
4680
+ const fields = recordReturn ? fieldsOfValue(expression) : undefined;
4681
+ if (fields) {
4682
+ for (const field of fields) {
4683
+ // A result field that already admits undefined keeps the
4684
+ // checker's narrowing.
4685
+ const slot = returnedShape?.fields.find((f) => f.name === field);
4686
+ if (slot && admitsUndefined(slot.type))
4687
+ continue;
4688
+ const set = returnFields.get(symbol) ?? new Set();
4689
+ if (set.has(field))
4690
+ continue;
4691
+ set.add(field);
4692
+ returnFields.set(symbol, set);
4693
+ provenance?.note("record-return", decl.name ?? decl, expression);
4694
+ changed = true;
4695
+ }
4696
+ }
4519
4697
  if (mayBeOptional(expression) && !optionalReturns.has(symbol)) {
4520
4698
  optionalReturns.add(symbol);
4521
4699
  provenance?.note("return", decl.name ?? decl, expression);
@@ -4529,6 +4707,19 @@ export class Lowerer {
4529
4707
  }
4530
4708
  return changed;
4531
4709
  };
4710
+ // A `var` that code can read before its first store holds undefined
4711
+ // there, whatever its declared type.
4712
+ for (const symbol of earlyReadVarSymbols(this, sourceFiles)) {
4713
+ // Text codec bindings keep their own presence-checked storage.
4714
+ const declaration = this.checker.valueDeclarationOf(symbol);
4715
+ const mapped = declaration && ts.isVariableDeclaration(declaration)
4716
+ ? mappedOrNull(declaration.name)
4717
+ : null;
4718
+ if (mapped?.kind === "record" && recordTextCodecClass(this.shapes.get(mapped.shapeId)))
4719
+ continue;
4720
+ optionalSymbols.add(symbol);
4721
+ this.earlyReadVars.add(symbol);
4722
+ }
4532
4723
  let changed = true;
4533
4724
  while (changed) {
4534
4725
  changed = false;
@@ -4546,8 +4737,10 @@ export class Lowerer {
4546
4737
  if (scanReturns(symbol, decl))
4547
4738
  changed = true;
4548
4739
  for (const fn of tsLambdas) {
4549
- // An annotated return is the author's contract, as for parameters.
4550
- if (fn.type)
4740
+ // An annotated return is the author's contract, as for parameters,
4741
+ // except that a var read before its first store is undefined
4742
+ // whatever the annotation says.
4743
+ if (fn.type && !returnsEarlyVar(fn))
4551
4744
  continue;
4552
4745
  const mapped = this.mapTypeOf(this.typeOf(fn));
4553
4746
  if (mapped?.kind !== "func")
@@ -4679,6 +4872,72 @@ export class Lowerer {
4679
4872
  this.runtimeOptionalGlobals.add(global);
4680
4873
  }
4681
4874
  }
4875
+ // Record layouts settle per flow class: a closed class widens every
4876
+ // member to the union of its members' optional fields, and a class that
4877
+ // reaches other storage keeps the declared layout for every member.
4878
+ const classFields = new Map();
4879
+ const addClassFields = (id, fields) => {
4880
+ if (id === null)
4881
+ return;
4882
+ const set = classFields.get(id) ?? new Set();
4883
+ for (const field of fields)
4884
+ set.add(field);
4885
+ classFields.set(id, set);
4886
+ };
4887
+ for (const [symbol, fields] of optionalFields)
4888
+ addClassFields(recordFlows.bindingClass(symbol), fields);
4889
+ for (const [symbol, fields] of returnFields)
4890
+ addClassFields(recordFlows.returnClass(symbol), fields);
4891
+ const settledFields = (id, own) => id === null
4892
+ ? own
4893
+ : classFields.has(id) && recordFlows.closed(id)
4894
+ ? classFields.get(id)
4895
+ : undefined;
4896
+ const widenRecordFields = (type, fields) => {
4897
+ let promoted = type;
4898
+ for (const field of fields) {
4899
+ const source = promoted.kind === "record"
4900
+ ? this.shapes.get(promoted.shapeId)?.fields.find((f) => f.name === field)
4901
+ : undefined;
4902
+ if (source)
4903
+ promoted = this.runtimeOptionalRecordField(promoted, field, addUndefined(source.type));
4904
+ }
4905
+ return promoted;
4906
+ };
4907
+ for (const [symbol, id] of recordFlows.bindings())
4908
+ if (classFields.has(id) && !recordFlows.closed(id))
4909
+ this.runtimeOptionalRecordsKeptDeclared.add(symbol);
4910
+ // Every tracked parameter settles with its class, including one that
4911
+ // only receives plain records. An untracked one (a function used as a
4912
+ // value, a method another member name or view can reach) widens to the
4913
+ // fields its own arguments carry.
4914
+ for (const { symbol, fn, index } of recordFlows.parameters())
4915
+ recordParameterSlots.set(symbol, { target: fn, index });
4916
+ for (const [bound, { target, index }] of recordParameterSlots) {
4917
+ const shape = signatureBySymbol.get(target)?.params[index];
4918
+ if (!shape || shape.type.kind !== "record")
4919
+ continue;
4920
+ const fields = settledFields(recordFlows.bindingClass(bound), optionalFields.get(bound));
4921
+ if (!fields)
4922
+ continue;
4923
+ const promoted = widenRecordFields(shape.type, fields);
4924
+ if (typeEquals(promoted, shape.type))
4925
+ continue;
4926
+ shape.type = promoted;
4927
+ this.runtimeOptionalBindingTypes.set(bound, promoted);
4928
+ }
4929
+ for (const [symbol, sig] of signatureBySymbol) {
4930
+ const id = recordFlows.returnClass(symbol);
4931
+ const fields = id === null ? undefined : settledFields(id, undefined);
4932
+ if (fields && sig.returnType.kind === "record") {
4933
+ const next = widenRecordFields(sig.returnType, fields);
4934
+ sig.returnType = next;
4935
+ if (sig.top)
4936
+ sig.top.returnType = next;
4937
+ if (sig.method)
4938
+ sig.method.ret = next;
4939
+ }
4940
+ }
4682
4941
  for (const [symbol, sig] of signatureBySymbol) {
4683
4942
  const params = optionalParams.get(symbol);
4684
4943
  if (params) {
@@ -4762,7 +5021,7 @@ export class Lowerer {
4762
5021
  global.type = promoted;
4763
5022
  }
4764
5023
  }
4765
- const fields = optionalFields.get(symbol);
5024
+ const fields = settledFields(recordFlows.bindingClass(symbol), optionalFields.get(symbol));
4766
5025
  if (!dynamicObjectEntryRows.has(symbol) && !optionalSymbols.has(symbol) && !fields)
4767
5026
  return;
4768
5027
  const current = this.mapTypeOf(this.typeOf(node.name));
@@ -4781,16 +5040,8 @@ export class Lowerer {
4781
5040
  };
4782
5041
  }
4783
5042
  }
4784
- if (fields && promoted.kind === "record") {
4785
- for (const field of fields) {
4786
- const source = promoted.kind === "record"
4787
- ? this.shapes.get(promoted.shapeId)?.fields.find((f) => f.name === field)
4788
- : undefined;
4789
- if (!source)
4790
- continue;
4791
- promoted = this.runtimeOptionalRecordField(promoted, field, addUndefined(source.type));
4792
- }
4793
- }
5043
+ if (fields && promoted.kind === "record")
5044
+ promoted = widenRecordFields(promoted, fields);
4794
5045
  if (!typeEquals(promoted, current)) {
4795
5046
  this.runtimeOptionalBindingTypes.set(symbol, promoted);
4796
5047
  const global = ts.isIdentifier(node.name)
@@ -5107,6 +5358,7 @@ export class Lowerer {
5107
5358
  globals: this.globalsList,
5108
5359
  entry: ENTRY_NAME,
5109
5360
  ...(this.usesWorkers ? { workers: true } : {}),
5361
+ ...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
5110
5362
  ...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
5111
5363
  ...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
5112
5364
  };
@@ -5291,6 +5543,8 @@ export class Lowerer {
5291
5543
  for (const info of this.classes.values()) {
5292
5544
  if (info.builtinError)
5293
5545
  continue; // runtime-provided; nothing lowers
5546
+ if (info.lifetimeRegion)
5547
+ continue; // synthesized with the class
5294
5548
  // Generic-class INSTANTIATIONS (and mixin instantiations) are
5295
5549
  // demand-driven, not units: their members lower unconditionally in
5296
5550
  // the instance drain below — the generic-fn instance rule.
@@ -5606,6 +5860,9 @@ export class Lowerer {
5606
5860
  ...this.liftedFns,
5607
5861
  ...this.implicitFns,
5608
5862
  ];
5863
+ if (this.regexGroupResults)
5864
+ for (const fn of functions)
5865
+ foldRegexSpanReads(this, fn);
5609
5866
  // The worklist can leave a virtual site with a single implementation.
5610
5867
  // Devirtualize after construction/override reachability has settled.
5611
5868
  devirtualizeVirtualCalls(this, functions, {
@@ -5727,7 +5984,7 @@ export class Lowerer {
5727
5984
  : diag;
5728
5985
  const pending = this.pendingFlushes.get(diag);
5729
5986
  // Deferred collection: the wrapper decides whether these ever report
5730
- // (a reference flushes them; unreferenced declarations stay silent in
5987
+ // (a reference flushes them; unreferenced declarations report nothing in
5731
5988
  // builds and report under coverage's unreached group).
5732
5989
  if (this.diagSink) {
5733
5990
  if (pending && d !== diag)
@@ -5941,7 +6198,7 @@ export class Lowerer {
5941
6198
  return stdlibMemberFence(this, access);
5942
6199
  }
5943
6200
  fenceStaticResponseMember(access, use) {
5944
- return fenceStaticResponseMember(this, access, use);
6201
+ return fenceStaticResponseMember(this, access, use) ?? fenceStaticBlobMember(this, access, use);
5945
6202
  }
5946
6203
  fenceUnsupportedFetchConstructorMember(access) {
5947
6204
  return fenceUnsupportedFetchConstructorMember(this, access);
@@ -6698,6 +6955,21 @@ export class Lowerer {
6698
6955
  return this.checkedNarrowCall(helper, expr, expected, expr.loc);
6699
6956
  }
6700
6957
  }
6958
+ // A record arm beside unit arms flowing into another layout of that
6959
+ // record (`R | undefined` into the runtime-optional variant of R): the
6960
+ // same checked extraction of the record arm, then the record's width
6961
+ // lift into the destination layout.
6962
+ if (expr.type.kind === "union" && expected.kind === "record") {
6963
+ const arms = this.unions.get(expr.type.unionId)?.arms ?? [];
6964
+ const records = arms.filter((arm) => !isUnitType(arm));
6965
+ const arm = records.length === 1 && records[0].kind === "record" ? records[0] : null;
6966
+ const lift = arm ? this.widthLiftPlan(arm, expected) : null;
6967
+ const helper = arm && lift ? this.narrowedArmHelper(expr.type.unionId, arm, expr.loc) : null;
6968
+ if (arm && lift && helper) {
6969
+ const narrowed = this.checkedNarrowCall(helper, expr, arm, expr.loc);
6970
+ return this.applyWidthLift(lift, narrowed, expected, expr.loc);
6971
+ }
6972
+ }
6701
6973
  if (!typeEquals(expr.type, expected)) {
6702
6974
  const w = this.widthCoerce(expr, expected);
6703
6975
  if (w)
@@ -7296,6 +7568,8 @@ export class Lowerer {
7296
7568
  builtinOption("RequestInit") ||
7297
7569
  builtinOption("ErrorOptions") ||
7298
7570
  builtinOption("SpawnOptions") ||
7571
+ builtinOption("UrlObject") ||
7572
+ builtinOption("URLFormatOptions") ||
7299
7573
  !this.mapTypeOf(this.typeOf(x))) {
7300
7574
  return lowerDynObjectLiteral(this, x);
7301
7575
  }
@@ -7496,8 +7770,10 @@ export class Lowerer {
7496
7770
  returnedPromiseAwait(e) {
7497
7771
  if (e.type.kind !== "promise")
7498
7772
  throw new InternalCompilerError("returned-promise await of a non-promise");
7499
- if (!this.adoptsReturnedPromise())
7773
+ if (!this.adoptsReturnedPromise()) {
7774
+ this.returnAwaitedPromise = true;
7500
7775
  return { kind: "awaitExpr", value: e, type: e.type.inner, loc: e.loc };
7776
+ }
7501
7777
  return { kind: "awaitExpr", value: e, type: e.type.inner, adopt: true, loc: e.loc };
7502
7778
  }
7503
7779
  /** `return <expr>` lowered as a STATEMENT against the declared return.
@@ -7507,6 +7783,26 @@ export class Lowerer {
7507
7783
  * caller never sees a value, so the return goes out bare. Async
7508
7784
  * void-inner returns still resolve a returned promise first. */
7509
7785
  lowerReturnStmt(node, loc) {
7786
+ if (!(this.ctx.isAsync === true && this.ctx.generator))
7787
+ return this.lowerReturnOf(node, loc);
7788
+ // An async generator's `return x` awaits x; for a promise that await
7789
+ // is the returned-promise await, and the return needs no other turn.
7790
+ const saved = this.returnAwaitedPromise;
7791
+ this.returnAwaitedPromise = false;
7792
+ const s = this.lowerReturnOf(node, loc);
7793
+ const awaited = this.returnAwaitedPromise;
7794
+ this.returnAwaitedPromise = saved;
7795
+ if (!awaited)
7796
+ return s;
7797
+ if (s.kind === "return")
7798
+ return { ...s, awaited: true };
7799
+ if (s.kind === "block" && s.body.at(-1)?.kind === "return") {
7800
+ const last = s.body.at(-1);
7801
+ return { ...s, body: [...s.body.slice(0, -1), { ...last, awaited: true }] };
7802
+ }
7803
+ return s;
7804
+ }
7805
+ lowerReturnOf(node, loc) {
7510
7806
  const expected = this.ctx.returnType;
7511
7807
  if (expected.kind === "void") {
7512
7808
  let e = this.lowerExpr(node);
@@ -8597,7 +8893,7 @@ export class Lowerer {
8597
8893
  * lowered — set by lowerLabeled around lowering the labeled construct,
8598
8894
  * consumed exactly once by the construct's own lowering (takeLabels).
8599
8895
  * A lowering that never consumes them signals lowerLabeled to fence:
8600
- * silently dropping a label would compile `break lbl` wrong. */
8896
+ * dropping a label without a diagnostic would compile `break lbl` wrong. */
8601
8897
  pendingLabels = null;
8602
8898
  takeLabels() {
8603
8899
  const labels = this.pendingLabels;
@@ -8804,6 +9100,9 @@ export class Lowerer {
8804
9100
  lowerElementWrite(expr) {
8805
9101
  return lowerElementWrite(this, expr);
8806
9102
  }
9103
+ lowerLiveWebValue(node) {
9104
+ return lowerLiveWebValue(this, node);
9105
+ }
8807
9106
  ensureString(e, node) {
8808
9107
  return ensureString(this, e, node);
8809
9108
  }
@@ -8945,7 +9244,8 @@ export class Lowerer {
8945
9244
  // dispatch. The general identifier-call paths have no lowering for a
8946
9245
  // promise-returning ambient global, and `import` is a keyword callee no
8947
9246
  // identifier path matches.
8948
- return (lowerFfiCall(this, expr) ??
9247
+ return (lowerLifetimeRegionCall(this, expr) ??
9248
+ lowerFfiCall(this, expr) ??
8949
9249
  lowerFetchCall(this, expr) ??
8950
9250
  lowerStaticFetchCompanionCall(this, expr) ??
8951
9251
  lowerStaticAbortControllerCall(this, expr) ??
@@ -8954,6 +9254,8 @@ export class Lowerer {
8954
9254
  lowerStaticReadableStreamControllerCall(this, expr) ??
8955
9255
  lowerStaticReadableStreamReaderCall(this, expr) ??
8956
9256
  lowerStaticResponseCall(this, expr) ??
9257
+ lowerStaticBlobCall(this, expr) ??
9258
+ lowerKeyObjectCall(this, expr) ??
8957
9259
  lowerFetchElementMethodCall(this, expr) ??
8958
9260
  lowerDynamicImportCall(this, expr) ??
8959
9261
  lowerCall(this, expr));
@@ -9080,9 +9382,12 @@ export class Lowerer {
9080
9382
  return inheritsBuiltinEmitterCtor(this, info);
9081
9383
  }
9082
9384
  lowerNew(expr) {
9083
- const builtin = lowerAbortControllerNew(this, expr) ??
9385
+ const builtin = lowerLifetimeRegionNew(this, expr) ??
9386
+ lowerAbortControllerNew(this, expr) ??
9387
+ lowerEventTargetNew(this, expr) ??
9084
9388
  lowerFetchWebNew(this, expr) ??
9085
9389
  lowerResponseNew(this, expr) ??
9390
+ lowerBlobNew(this, expr) ??
9086
9391
  lowerStaticReadableStreamNew(this, expr) ??
9087
9392
  lowerConsoleNew(this, expr);
9088
9393
  return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
@@ -9135,6 +9440,9 @@ export class Lowerer {
9135
9440
  consoleCallMember(call) {
9136
9441
  return consoleCallMember(this, call);
9137
9442
  }
9443
+ consoleMethodMember(call) {
9444
+ return consoleMethodMember(this, call);
9445
+ }
9138
9446
  /* ── standard library (process + node:fs) ─────────────────────────── */
9139
9447
  builtinImportOf(ident) {
9140
9448
  return builtinImportOf(this, ident);
@@ -9361,6 +9669,10 @@ export class Lowerer {
9361
9669
  if (bi.module === "http" && bi.member === "STATUS_CODES") {
9362
9670
  return { kind: "libCall", fn: "http.statusCodes", args: [], type: DYN, loc };
9363
9671
  }
9672
+ // os.constants: the runtime's null-prototype constants object.
9673
+ if (bi.module === "os" && bi.member === "constants") {
9674
+ return { kind: "libCall", fn: "os.constants", args: [], type: DYN, loc };
9675
+ }
9364
9676
  // tls.rootCertificates through the namespace: the same runtime-valued
9365
9677
  // constant the named-import read lowers to.
9366
9678
  {