@scriptc/compiler 0.4.7 → 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 (776) 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 +23 -5
  4. package/ambient/node-fallback/fs.d.ts +3 -2
  5. package/ambient/node-fallback/http.d.ts +23 -17
  6. package/ambient/node-fallback/https.d.ts +5 -2
  7. package/ambient/node-fallback/net.d.ts +6 -0
  8. package/ambient/node-fallback/os.d.ts +11 -1
  9. package/ambient/node-fallback/path-posix.d.ts +6 -0
  10. package/ambient/node-fallback/path-win32.d.ts +5 -0
  11. package/ambient/node-fallback/path.d.ts +2 -0
  12. package/ambient/node-fallback/zlib.d.ts +31 -2
  13. package/ambient/scriptc-node-fallback.d.ts +37 -7
  14. package/ambient/scriptc.d.ts +7 -2
  15. package/dist/backend/executable-features.js +11 -3
  16. package/dist/backend/executable-features.js.map +1 -1
  17. package/dist/backend/library-pack.d.ts +6 -0
  18. package/dist/backend/library-pack.js +17 -6
  19. package/dist/backend/library-pack.js.map +1 -1
  20. package/dist/backend/library-pack.test.d.ts +1 -0
  21. package/dist/backend/library-pack.test.js +28 -0
  22. package/dist/backend/library-pack.test.js.map +1 -0
  23. package/dist/backend/linker.d.ts +9 -2
  24. package/dist/backend/linker.js +190 -32
  25. package/dist/backend/linker.js.map +1 -1
  26. package/dist/backend/lld.d.ts +8 -4
  27. package/dist/backend/lld.js +19 -13
  28. package/dist/backend/lld.js.map +1 -1
  29. package/dist/backend/lld.test.js +3 -1
  30. package/dist/backend/lld.test.js.map +1 -1
  31. package/dist/backend/llvm/alloc.d.ts +15 -2
  32. package/dist/backend/llvm/alloc.js +172 -36
  33. package/dist/backend/llvm/alloc.js.map +1 -1
  34. package/dist/backend/llvm/alloc.test.js +69 -1
  35. package/dist/backend/llvm/alloc.test.js.map +1 -1
  36. package/dist/backend/llvm/arenas.d.ts +17 -4
  37. package/dist/backend/llvm/arenas.js +105 -10
  38. package/dist/backend/llvm/arenas.js.map +1 -1
  39. package/dist/backend/llvm/arenas.test.js +229 -0
  40. package/dist/backend/llvm/arenas.test.js.map +1 -1
  41. package/dist/backend/llvm/bytes-alias.js +10 -1
  42. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  43. package/dist/backend/llvm/bytes-headers.js +6 -0
  44. package/dist/backend/llvm/bytes-headers.js.map +1 -1
  45. package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
  46. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  47. package/dist/backend/llvm/call-lifetimes.js +10 -0
  48. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  49. package/dist/backend/llvm/classes.d.ts +16 -9
  50. package/dist/backend/llvm/classes.js +142 -37
  51. package/dist/backend/llvm/classes.js.map +1 -1
  52. package/dist/backend/llvm/classes.test.js +42 -0
  53. package/dist/backend/llvm/classes.test.js.map +1 -1
  54. package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
  55. package/dist/backend/llvm/cpu-dispatch.js +31 -7
  56. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  57. package/dist/backend/llvm/dyn.d.ts +12 -3
  58. package/dist/backend/llvm/dyn.js +31 -7
  59. package/dist/backend/llvm/dyn.js.map +1 -1
  60. package/dist/backend/llvm/emit-function.js +67 -4
  61. package/dist/backend/llvm/emit-function.js.map +1 -1
  62. package/dist/backend/llvm/emit-module.js +90 -39
  63. package/dist/backend/llvm/emit-module.js.map +1 -1
  64. package/dist/backend/llvm/emit-module.test.d.ts +1 -0
  65. package/dist/backend/llvm/emit-module.test.js +52 -0
  66. package/dist/backend/llvm/emit-module.test.js.map +1 -0
  67. package/dist/backend/llvm/emit-statements.js +99 -15
  68. package/dist/backend/llvm/emit-statements.js.map +1 -1
  69. package/dist/backend/llvm/emitter.d.ts +113 -8
  70. package/dist/backend/llvm/emitter.js +438 -67
  71. package/dist/backend/llvm/emitter.js.map +1 -1
  72. package/dist/backend/llvm/emitter.test.js +31 -3
  73. package/dist/backend/llvm/emitter.test.js.map +1 -1
  74. package/dist/backend/llvm/expr-async.js +19 -1
  75. package/dist/backend/llvm/expr-async.js.map +1 -1
  76. package/dist/backend/llvm/expr-bytes.js +16 -1
  77. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  78. package/dist/backend/llvm/expr-calls.js +18 -2
  79. package/dist/backend/llvm/expr-calls.js.map +1 -1
  80. package/dist/backend/llvm/expr-dynamic.js +31 -10
  81. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  82. package/dist/backend/llvm/expr-primitives.js +31 -3
  83. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  84. package/dist/backend/llvm/expr-records.d.ts +1 -1
  85. package/dist/backend/llvm/expr-records.js +124 -56
  86. package/dist/backend/llvm/expr-records.js.map +1 -1
  87. package/dist/backend/llvm/expr-stream-bridges.js +17 -0
  88. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  89. package/dist/backend/llvm/js-groups.d.ts +21 -0
  90. package/dist/backend/llvm/js-groups.js +277 -0
  91. package/dist/backend/llvm/js-groups.js.map +1 -0
  92. package/dist/backend/llvm/js-ic.d.ts +19 -1
  93. package/dist/backend/llvm/js-ic.js +96 -23
  94. package/dist/backend/llvm/js-ic.js.map +1 -1
  95. package/dist/backend/llvm/lib-dispatch.js +132 -1
  96. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  97. package/dist/backend/llvm/lib-network.js +33 -6
  98. package/dist/backend/llvm/lib-network.js.map +1 -1
  99. package/dist/backend/llvm/lib-process.js +44 -3
  100. package/dist/backend/llvm/lib-process.js.map +1 -1
  101. package/dist/backend/llvm/lib-shared.js +69 -2
  102. package/dist/backend/llvm/lib-shared.js.map +1 -1
  103. package/dist/backend/llvm/local-union-storage.test.js +32 -0
  104. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  105. package/dist/backend/llvm/loop-state.js +7 -2
  106. package/dist/backend/llvm/loop-state.js.map +1 -1
  107. package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
  108. package/dist/backend/llvm/map-entry-fusion.js +3 -3
  109. package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
  110. package/dist/backend/llvm/map-number-lookup.test.js +6 -6
  111. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  112. package/dist/backend/llvm/nullable-unions.js +7 -6
  113. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  114. package/dist/backend/llvm/nullable-unions.test.js +4 -1
  115. package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
  116. package/dist/backend/llvm/receivers.js +3 -0
  117. package/dist/backend/llvm/receivers.js.map +1 -1
  118. package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
  119. package/dist/backend/llvm/record-entry-fusion.js +217 -0
  120. package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
  121. package/dist/backend/llvm/record-results.d.ts +5 -2
  122. package/dist/backend/llvm/record-results.js +13 -12
  123. package/dist/backend/llvm/record-results.js.map +1 -1
  124. package/dist/backend/llvm/record-views.js +12 -6
  125. package/dist/backend/llvm/record-views.js.map +1 -1
  126. package/dist/backend/llvm/reference-effects.js +1 -0
  127. package/dist/backend/llvm/reference-effects.js.map +1 -1
  128. package/dist/backend/llvm/reference-writes.js +3 -0
  129. package/dist/backend/llvm/reference-writes.js.map +1 -1
  130. package/dist/backend/llvm/region-ir.js +1 -0
  131. package/dist/backend/llvm/region-ir.js.map +1 -1
  132. package/dist/backend/llvm/region-sites.d.ts +18 -0
  133. package/dist/backend/llvm/region-sites.js +79 -1
  134. package/dist/backend/llvm/region-sites.js.map +1 -1
  135. package/dist/backend/llvm/runtime-registries.test.js +53 -6
  136. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  137. package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
  138. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  139. package/dist/backend/llvm/shapes.d.ts +33 -3
  140. package/dist/backend/llvm/shapes.js +183 -13
  141. package/dist/backend/llvm/shapes.js.map +1 -1
  142. package/dist/backend/llvm/stack-objects.d.ts +1 -2
  143. package/dist/backend/llvm/stack-objects.js +8 -5
  144. package/dist/backend/llvm/stack-objects.js.map +1 -1
  145. package/dist/backend/llvm/walkers.d.ts +12 -0
  146. package/dist/backend/llvm/walkers.js +46 -2
  147. package/dist/backend/llvm/walkers.js.map +1 -1
  148. package/dist/backend/may-throw.js +12 -2
  149. package/dist/backend/may-throw.js.map +1 -1
  150. package/dist/backend/may-throw.test.js +13 -0
  151. package/dist/backend/may-throw.test.js.map +1 -1
  152. package/dist/backend/native/contracts.d.ts +48 -8
  153. package/dist/backend/native/executable.js +55 -13
  154. package/dist/backend/native/executable.js.map +1 -1
  155. package/dist/backend/native/helper-identity-record.d.ts +11 -0
  156. package/dist/backend/native/helper-identity-record.js +76 -0
  157. package/dist/backend/native/helper-identity-record.js.map +1 -0
  158. package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
  159. package/dist/backend/native/helper-identity-record.test.js +101 -0
  160. package/dist/backend/native/helper-identity-record.test.js.map +1 -0
  161. package/dist/backend/native/library.js +9 -1
  162. package/dist/backend/native/library.js.map +1 -1
  163. package/dist/backend/native/runtime-inputs.js +4 -1
  164. package/dist/backend/native/runtime-inputs.js.map +1 -1
  165. package/dist/backend/native/vendor.d.ts +1 -1
  166. package/dist/backend/native/vendor.js +1 -1
  167. package/dist/backend/native/vendor.js.map +1 -1
  168. package/dist/backend/native-codegen-core.d.ts +13 -10
  169. package/dist/backend/native-codegen-core.js +26 -13
  170. package/dist/backend/native-codegen-core.js.map +1 -1
  171. package/dist/backend/native-codegen.js +27 -8
  172. package/dist/backend/native-codegen.js.map +1 -1
  173. package/dist/backend/native-codegen.test.js +110 -14
  174. package/dist/backend/native-codegen.test.js.map +1 -1
  175. package/dist/backend/native-link-info-core.d.ts +37 -8
  176. package/dist/backend/native-link-info-core.js.map +1 -1
  177. package/dist/backend/runtime-pack-core.d.ts +17 -2
  178. package/dist/backend/runtime-pack-core.js +18 -3
  179. package/dist/backend/runtime-pack-core.js.map +1 -1
  180. package/dist/backend/runtime-pack-targets.test.js +1 -1
  181. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  182. package/dist/backend/runtime-pack.test.js +211 -2
  183. package/dist/backend/runtime-pack.test.js.map +1 -1
  184. package/dist/backend/tree-classes.d.ts +42 -0
  185. package/dist/backend/tree-classes.js +723 -0
  186. package/dist/backend/tree-classes.js.map +1 -0
  187. package/dist/backend/tree-classes.test.d.ts +1 -0
  188. package/dist/backend/tree-classes.test.js +338 -0
  189. package/dist/backend/tree-classes.test.js.map +1 -0
  190. package/dist/backend/vendor-archives.d.ts +5 -1
  191. package/dist/backend/vendor-archives.js +51 -7
  192. package/dist/backend/vendor-archives.js.map +1 -1
  193. package/dist/backend/vendor-inputs.d.ts +25 -4
  194. package/dist/backend/vendor-inputs.js +68 -4
  195. package/dist/backend/vendor-inputs.js.map +1 -1
  196. package/dist/backend/vendor-inputs.test.js +35 -1
  197. package/dist/backend/vendor-inputs.test.js.map +1 -1
  198. package/dist/backend/warm-cache.js +1 -1
  199. package/dist/backend/warm-cache.js.map +1 -1
  200. package/dist/compat/fetch-profile.js +2 -2
  201. package/dist/coverage/report.js +47 -0
  202. package/dist/coverage/report.js.map +1 -1
  203. package/dist/coverage/surface-manifest.js +1 -1
  204. package/dist/diagnostics/codes.d.ts +8 -0
  205. package/dist/diagnostics/codes.js +8 -0
  206. package/dist/diagnostics/codes.js.map +1 -1
  207. package/dist/diagnostics/diagnostic.d.ts +27 -9
  208. package/dist/diagnostics/diagnostic.js +60 -19
  209. package/dist/diagnostics/diagnostic.js.map +1 -1
  210. package/dist/diagnostics/envelope.d.ts +18 -0
  211. package/dist/diagnostics/envelope.js.map +1 -1
  212. package/dist/executable/executable-cache.d.ts +21 -2
  213. package/dist/executable/executable-cache.js +21 -1
  214. package/dist/executable/executable-cache.js.map +1 -1
  215. package/dist/executable/executable-cache.test.js +123 -1
  216. package/dist/executable/executable-cache.test.js.map +1 -1
  217. package/dist/executable/prepare.js +199 -248
  218. package/dist/executable/prepare.js.map +1 -1
  219. package/dist/frontend/analysis.js +200 -18
  220. package/dist/frontend/analysis.js.map +1 -1
  221. package/dist/frontend/builtin-modules.d.ts +4 -0
  222. package/dist/frontend/builtin-modules.js +10 -0
  223. package/dist/frontend/builtin-modules.js.map +1 -1
  224. package/dist/frontend/early-errors.d.ts +12 -2
  225. package/dist/frontend/early-errors.js +535 -4
  226. package/dist/frontend/early-errors.js.map +1 -1
  227. package/dist/frontend/early-errors.test.js +165 -0
  228. package/dist/frontend/early-errors.test.js.map +1 -1
  229. package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
  230. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  231. package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
  232. package/dist/frontend/jsx-opinion-sites.test.js +86 -0
  233. package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
  234. package/dist/frontend/lib-exports.d.ts +23 -4
  235. package/dist/frontend/lib-exports.js +98 -26
  236. package/dist/frontend/lib-exports.js.map +1 -1
  237. package/dist/frontend/lowering/binding-analysis.js +21 -3
  238. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  239. package/dist/frontend/lowering/buffers.d.ts +8 -0
  240. package/dist/frontend/lowering/buffers.js +43 -0
  241. package/dist/frontend/lowering/buffers.js.map +1 -0
  242. package/dist/frontend/lowering/builtin-calls.js +4 -0
  243. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  244. package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
  245. package/dist/frontend/lowering/builtin-namespaces.js +24 -3
  246. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  247. package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
  248. package/dist/frontend/lowering/builtin-statics.js +407 -0
  249. package/dist/frontend/lowering/builtin-statics.js.map +1 -0
  250. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  251. package/dist/frontend/lowering/builtins/arguments.js +12 -0
  252. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  253. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
  254. package/dist/frontend/lowering/builtins/atomics.js +87 -1
  255. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  256. package/dist/frontend/lowering/builtins/child-process-methods.js +2 -2
  257. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  258. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
  259. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
  260. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  261. package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
  262. package/dist/frontend/lowering/builtins/child-process.js +560 -27
  263. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  264. package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
  265. package/dist/frontend/lowering/builtins/compression.js +41 -21
  266. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  267. package/dist/frontend/lowering/builtins/constants.js +7 -2
  268. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  269. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
  270. package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
  271. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  272. package/dist/frontend/lowering/builtins/json.js +4 -0
  273. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  274. package/dist/frontend/lowering/builtins/module-calls.js +3 -1
  275. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  276. package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
  277. package/dist/frontend/lowering/builtins/numbers.js +10 -2
  278. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  279. package/dist/frontend/lowering/builtins/operating-system.d.ts +6 -3
  280. package/dist/frontend/lowering/builtins/operating-system.js +96 -16
  281. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  282. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  283. package/dist/frontend/lowering/builtins/process.js +103 -8
  284. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  285. package/dist/frontend/lowering/builtins/promises.js +169 -8
  286. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  287. package/dist/frontend/lowering/builtins/properties.js +6 -2
  288. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  289. package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
  290. package/dist/frontend/lowering/builtins/readline.js +180 -36
  291. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  292. package/dist/frontend/lowering/builtins/url.js +35 -12
  293. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  294. package/dist/frontend/lowering/builtins/webassembly.js +2 -0
  295. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  296. package/dist/frontend/lowering/call-arguments.d.ts +10 -0
  297. package/dist/frontend/lowering/call-arguments.js +37 -2
  298. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  299. package/dist/frontend/lowering/call-signatures.d.ts +10 -0
  300. package/dist/frontend/lowering/call-signatures.js +103 -0
  301. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  302. package/dist/frontend/lowering/class-construction.d.ts +14 -2
  303. package/dist/frontend/lowering/class-construction.js +99 -5
  304. package/dist/frontend/lowering/class-construction.js.map +1 -1
  305. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +9 -0
  306. package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
  307. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  308. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
  309. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  310. package/dist/frontend/lowering/class-prototypes.js +20 -15
  311. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  312. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  313. package/dist/frontend/lowering/class-runtime-statics.js +20 -1
  314. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  315. package/dist/frontend/lowering/class-unions.js +21 -4
  316. package/dist/frontend/lowering/class-unions.js.map +1 -1
  317. package/dist/frontend/lowering/coercions/function-adapters.js +9 -0
  318. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  319. package/dist/frontend/lowering/coercions/state.d.ts +8 -0
  320. package/dist/frontend/lowering/coercions/state.js +17 -0
  321. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  322. package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
  323. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  324. package/dist/frontend/lowering/coercions/structural.js +10 -1
  325. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  326. package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
  327. package/dist/frontend/lowering/coercions/unions.js +54 -10
  328. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  329. package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
  330. package/dist/frontend/lowering/constructor-returns.js +284 -58
  331. package/dist/frontend/lowering/constructor-returns.js.map +1 -1
  332. package/dist/frontend/lowering/containers/array-callbacks.js +156 -62
  333. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  334. package/dist/frontend/lowering/containers/array-construction.js +21 -3
  335. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  336. package/dist/frontend/lowering/containers/array-from-async.js +139 -3
  337. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
  338. package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
  339. package/dist/frontend/lowering/containers/array-iteration.js +24 -7
  340. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
  341. package/dist/frontend/lowering/containers/array-methods.js +14 -11
  342. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  343. package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
  344. package/dist/frontend/lowering/containers/bytes.js +446 -86
  345. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  346. package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
  347. package/dist/frontend/lowering/containers/callback-arguments.js +21 -12
  348. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  349. package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
  350. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  351. package/dist/frontend/lowering/containers/collection-methods.js +52 -17
  352. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  353. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
  354. package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
  355. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  356. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
  357. package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
  358. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  359. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  360. package/dist/frontend/lowering/crypto-tables.js +5 -5
  361. package/dist/frontend/lowering/dispatch-sites.js +3 -0
  362. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  363. package/dist/frontend/lowering/divergences.d.ts +40 -0
  364. package/dist/frontend/lowering/divergences.js +239 -20
  365. package/dist/frontend/lowering/divergences.js.map +1 -1
  366. package/dist/frontend/lowering/effect-free.d.ts +12 -0
  367. package/dist/frontend/lowering/effect-free.js +44 -0
  368. package/dist/frontend/lowering/effect-free.js.map +1 -0
  369. package/dist/frontend/lowering/expressions/array-literals.d.ts +10 -0
  370. package/dist/frontend/lowering/expressions/array-literals.js +62 -0
  371. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  372. package/dist/frontend/lowering/expressions/binary.js +115 -5
  373. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  374. package/dist/frontend/lowering/expressions/element-access.js +151 -7
  375. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  376. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
  377. package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
  378. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  379. package/dist/frontend/lowering/expressions/identifiers.js +31 -2
  380. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  381. package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
  382. package/dist/frontend/lowering/expressions/narrowing.js +175 -22
  383. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  384. package/dist/frontend/lowering/expressions/object-literals.js +173 -11
  385. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  386. package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
  387. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  388. package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
  389. package/dist/frontend/lowering/expressions/property-access.js +379 -109
  390. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  391. package/dist/frontend/lowering/expressions/relational.js +237 -7
  392. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  393. package/dist/frontend/lowering/expressions/typeof.js +8 -0
  394. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  395. package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
  396. package/dist/frontend/lowering/expressions/union-fields.js +103 -13
  397. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  398. package/dist/frontend/lowering/expressions/updates.js +74 -55
  399. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  400. package/dist/frontend/lowering/function-returns.js +37 -10
  401. package/dist/frontend/lowering/function-returns.js.map +1 -1
  402. package/dist/frontend/lowering/general-streams.js +5 -0
  403. package/dist/frontend/lowering/general-streams.js.map +1 -1
  404. package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
  405. package/dist/frontend/lowering/generator-delegation.js +301 -118
  406. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  407. package/dist/frontend/lowering/generic-functions.d.ts +27 -1
  408. package/dist/frontend/lowering/generic-functions.js +432 -18
  409. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  410. package/dist/frontend/lowering/global-function-values.d.ts +25 -0
  411. package/dist/frontend/lowering/global-function-values.js +193 -0
  412. package/dist/frontend/lowering/global-function-values.js.map +1 -0
  413. package/dist/frontend/lowering/global-values.d.ts +6 -4
  414. package/dist/frontend/lowering/global-values.js +24 -10
  415. package/dist/frontend/lowering/global-values.js.map +1 -1
  416. package/dist/frontend/lowering/host-global-values.d.ts +31 -0
  417. package/dist/frontend/lowering/host-global-values.js +121 -0
  418. package/dist/frontend/lowering/host-global-values.js.map +1 -0
  419. package/dist/frontend/lowering/host-globals.d.ts +74 -0
  420. package/dist/frontend/lowering/host-globals.js +344 -0
  421. package/dist/frontend/lowering/host-globals.js.map +1 -0
  422. package/dist/frontend/lowering/http2-constants.js +1 -1
  423. package/dist/frontend/lowering/iterator-adapters.js +46 -17
  424. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  425. package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
  426. package/dist/frontend/lowering/iterator-prototype.js +160 -0
  427. package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
  428. package/dist/frontend/lowering/key-order-witness.js +43 -22
  429. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  430. package/dist/frontend/lowering/key-order-witness.test.js +1 -0
  431. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  432. package/dist/frontend/lowering/lib-boundary.js +11 -3
  433. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  434. package/dist/frontend/lowering/lower-assert.js +30 -15
  435. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  436. package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
  437. package/dist/frontend/lowering/lower-async-iteration.js +15 -0
  438. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  439. package/dist/frontend/lowering/lower-builtin-values.js +11 -1
  440. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  441. package/dist/frontend/lowering/lower-calls.d.ts +25 -0
  442. package/dist/frontend/lowering/lower-calls.js +929 -227
  443. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  444. package/dist/frontend/lowering/lower-calls.test.js +59 -16
  445. package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
  446. package/dist/frontend/lowering/lower-classes.d.ts +20 -0
  447. package/dist/frontend/lowering/lower-classes.js +468 -44
  448. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  449. package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
  450. package/dist/frontend/lowering/lower-event-emitter.js +253 -83
  451. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  452. package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
  453. package/dist/frontend/lowering/lower-exprs.js +71 -20
  454. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  455. package/dist/frontend/lowering/lower-functions.js +25 -6
  456. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  457. package/dist/frontend/lowering/lower-generators.js +57 -10
  458. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  459. package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
  460. package/dist/frontend/lowering/lower-global-value.js +14 -5
  461. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  462. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  463. package/dist/frontend/lowering/lower-inspect.js +638 -64
  464. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  465. package/dist/frontend/lowering/lower-modules.js +48 -2
  466. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  467. package/dist/frontend/lowering/lower-namespaces.js +18 -0
  468. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  469. package/dist/frontend/lowering/lower-node-island.js +16 -6
  470. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  471. package/dist/frontend/lowering/lower-server.js +303 -87
  472. package/dist/frontend/lowering/lower-server.js.map +1 -1
  473. package/dist/frontend/lowering/lower-stdlib.js +45 -0
  474. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  475. package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
  476. package/dist/frontend/lowering/lower-stmts.js +270 -52
  477. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  478. package/dist/frontend/lowering/lower-timers.js +110 -27
  479. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  480. package/dist/frontend/lowering/lower-url.js +6 -3
  481. package/dist/frontend/lowering/lower-url.js.map +1 -1
  482. package/dist/frontend/lowering/lowerer.d.ts +227 -21
  483. package/dist/frontend/lowering/lowerer.js +651 -92
  484. package/dist/frontend/lowering/lowerer.js.map +1 -1
  485. package/dist/frontend/lowering/lowerer.test.js +18 -0
  486. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  487. package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
  488. package/dist/frontend/lowering/lowering-facts.js +323 -0
  489. package/dist/frontend/lowering/lowering-facts.js.map +1 -0
  490. package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
  491. package/dist/frontend/lowering/lowering-facts.test.js +100 -0
  492. package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
  493. package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
  494. package/dist/frontend/lowering/nan-coded-reads.js +112 -9
  495. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
  496. package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
  497. package/dist/frontend/lowering/optional-arguments.js +26 -2
  498. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  499. package/dist/frontend/lowering/partial-assertions.d.ts +0 -3
  500. package/dist/frontend/lowering/partial-assertions.js +9 -15
  501. package/dist/frontend/lowering/partial-assertions.js.map +1 -1
  502. package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
  503. package/dist/frontend/lowering/primitive-throws.js +241 -0
  504. package/dist/frontend/lowering/primitive-throws.js.map +1 -0
  505. package/dist/frontend/lowering/primitive-wrappers.js +1 -0
  506. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
  507. package/dist/frontend/lowering/record-inherited.d.ts +17 -1
  508. package/dist/frontend/lowering/record-inherited.js +16 -2
  509. package/dist/frontend/lowering/record-inherited.js.map +1 -1
  510. package/dist/frontend/lowering/record-links.d.ts +73 -0
  511. package/dist/frontend/lowering/record-links.js +797 -0
  512. package/dist/frontend/lowering/record-links.js.map +1 -0
  513. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
  514. package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
  515. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
  516. package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
  517. package/dist/frontend/lowering/runtime-optional-report.js +300 -0
  518. package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
  519. package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
  520. package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
  521. package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
  522. package/dist/frontend/lowering/static-typeof.d.ts +3 -1
  523. package/dist/frontend/lowering/static-typeof.js +6 -1
  524. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  525. package/dist/frontend/lowering/strict-mode.d.ts +1 -5
  526. package/dist/frontend/lowering/strict-mode.js +4 -30
  527. package/dist/frontend/lowering/strict-mode.js.map +1 -1
  528. package/dist/frontend/lowering/structural-instances.d.ts +7 -0
  529. package/dist/frontend/lowering/structural-instances.js +23 -0
  530. package/dist/frontend/lowering/structural-instances.js.map +1 -1
  531. package/dist/frontend/lowering/surfaces.d.ts +15 -1
  532. package/dist/frontend/lowering/surfaces.js +78 -10
  533. package/dist/frontend/lowering/surfaces.js.map +1 -1
  534. package/dist/frontend/lowering/union-retag.d.ts +13 -1
  535. package/dist/frontend/lowering/union-retag.js +55 -1
  536. package/dist/frontend/lowering/union-retag.js.map +1 -1
  537. package/dist/frontend/lowering/union-retag.test.js +51 -0
  538. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  539. package/dist/frontend/lowering/unit-journal.d.ts +8 -0
  540. package/dist/frontend/lowering/unit-journal.js +14 -0
  541. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  542. package/dist/frontend/lowering/unit-journal.test.js +36 -1
  543. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  544. package/dist/frontend/lowering/zlib-constants.js +3 -2
  545. package/dist/frontend/lowering/zlib-constants.js.map +1 -1
  546. package/dist/frontend/npm-static.js +78 -9
  547. package/dist/frontend/npm-static.js.map +1 -1
  548. package/dist/frontend/npm-static.test.js +95 -2
  549. package/dist/frontend/npm-static.test.js.map +1 -1
  550. package/dist/frontend/pipeline.d.ts +5 -4
  551. package/dist/frontend/pipeline.js +94 -31
  552. package/dist/frontend/pipeline.js.map +1 -1
  553. package/dist/frontend/pipeline.test.js +68 -11
  554. package/dist/frontend/pipeline.test.js.map +1 -1
  555. package/dist/frontend/program.d.ts +62 -2
  556. package/dist/frontend/program.js +695 -422
  557. package/dist/frontend/program.js.map +1 -1
  558. package/dist/frontend/program.test.js +37 -1
  559. package/dist/frontend/program.test.js.map +1 -1
  560. package/dist/frontend/services-node.d.ts +7 -0
  561. package/dist/frontend/services-node.js +32 -1
  562. package/dist/frontend/services-node.js.map +1 -1
  563. package/dist/frontend/services-node.test.js +51 -0
  564. package/dist/frontend/services-node.test.js.map +1 -1
  565. package/dist/frontend/shape-inference/overlay.js +68 -2
  566. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  567. package/dist/frontend/tier-analysis.d.ts +9 -0
  568. package/dist/frontend/tier-analysis.js +1 -0
  569. package/dist/frontend/tier-analysis.js.map +1 -1
  570. package/dist/frontend/tsc-codes.d.ts +57 -3
  571. package/dist/frontend/tsc-codes.js +935 -150
  572. package/dist/frontend/tsc-codes.js.map +1 -1
  573. package/dist/frontend/tsc-codes.test.js +221 -12
  574. package/dist/frontend/tsc-codes.test.js.map +1 -1
  575. package/dist/frontend/type-mapper.d.ts +91 -9
  576. package/dist/frontend/type-mapper.js +622 -181
  577. package/dist/frontend/type-mapper.js.map +1 -1
  578. package/dist/index.d.ts +1 -1
  579. package/dist/index.js +80 -15
  580. package/dist/index.js.map +1 -1
  581. package/dist/index.test.d.ts +1 -0
  582. package/dist/index.test.js +60 -0
  583. package/dist/index.test.js.map +1 -0
  584. package/dist/ir/builtin-effects.js +43 -0
  585. package/dist/ir/builtin-effects.js.map +1 -1
  586. package/dist/ir/builtin-signatures.d.ts +1 -1
  587. package/dist/ir/builtin-signatures.js +242 -16
  588. package/dist/ir/builtin-signatures.js.map +1 -1
  589. package/dist/ir/callback-specialization.d.ts +3 -2
  590. package/dist/ir/callback-specialization.js +35 -25
  591. package/dist/ir/callback-specialization.js.map +1 -1
  592. package/dist/ir/capture-values.d.ts +8 -4
  593. package/dist/ir/capture-values.js +9 -6
  594. package/dist/ir/capture-values.js.map +1 -1
  595. package/dist/ir/char-unit-locals.d.ts +6 -2
  596. package/dist/ir/char-unit-locals.js +11 -2
  597. package/dist/ir/char-unit-locals.js.map +1 -1
  598. package/dist/ir/class-key-index.d.ts +18 -0
  599. package/dist/ir/class-key-index.js +29 -0
  600. package/dist/ir/class-key-index.js.map +1 -0
  601. package/dist/ir/class-key-index.test.d.ts +1 -0
  602. package/dist/ir/class-key-index.test.js +25 -0
  603. package/dist/ir/class-key-index.test.js.map +1 -0
  604. package/dist/ir/codec.generated.d.ts +1 -1
  605. package/dist/ir/codec.generated.js +724 -648
  606. package/dist/ir/codec.generated.js.map +1 -1
  607. package/dist/ir/constant-globals.d.ts +5 -2
  608. package/dist/ir/constant-globals.js +25 -27
  609. package/dist/ir/constant-globals.js.map +1 -1
  610. package/dist/ir/expression-inlining.d.ts +4 -2
  611. package/dist/ir/expression-inlining.js +8 -2
  612. package/dist/ir/expression-inlining.js.map +1 -1
  613. package/dist/ir/field-values.d.ts +5 -2
  614. package/dist/ir/field-values.js +32 -21
  615. package/dist/ir/field-values.js.map +1 -1
  616. package/dist/ir/fields.generated.d.ts +11 -2
  617. package/dist/ir/fields.generated.js +8 -0
  618. package/dist/ir/fields.generated.js.map +1 -1
  619. package/dist/ir/final-fields.js +1 -1
  620. package/dist/ir/final-fields.js.map +1 -1
  621. package/dist/ir/function-references.d.ts +5 -4
  622. package/dist/ir/function-references.js +7 -4
  623. package/dist/ir/function-references.js.map +1 -1
  624. package/dist/ir/function-references.test.js +7 -0
  625. package/dist/ir/function-references.test.js.map +1 -1
  626. package/dist/ir/init-only-globals.d.ts +4 -2
  627. package/dist/ir/init-only-globals.js +17 -18
  628. package/dist/ir/init-only-globals.js.map +1 -1
  629. package/dist/ir/inline-array-views.js +1 -0
  630. package/dist/ir/inline-array-views.js.map +1 -1
  631. package/dist/ir/int32-slots.js +7 -0
  632. package/dist/ir/int32-slots.js.map +1 -1
  633. package/dist/ir/ir.d.ts +59 -4
  634. package/dist/ir/ir.js +7 -0
  635. package/dist/ir/ir.js.map +1 -1
  636. package/dist/ir/js-groups.d.ts +51 -0
  637. package/dist/ir/js-groups.js +394 -0
  638. package/dist/ir/js-groups.js.map +1 -0
  639. package/dist/ir/js-groups.test.d.ts +1 -0
  640. package/dist/ir/js-groups.test.js +555 -0
  641. package/dist/ir/js-groups.test.js.map +1 -0
  642. package/dist/ir/js-ic.js +30 -5
  643. package/dist/ir/js-ic.js.map +1 -1
  644. package/dist/ir/js-ic.test.js +27 -1
  645. package/dist/ir/js-ic.test.js.map +1 -1
  646. package/dist/ir/node-index.d.ts +23 -6
  647. package/dist/ir/node-index.js +126 -49
  648. package/dist/ir/node-index.js.map +1 -1
  649. package/dist/ir/numeric-call-specialization.d.ts +4 -2
  650. package/dist/ir/numeric-call-specialization.js +40 -26
  651. package/dist/ir/numeric-call-specialization.js.map +1 -1
  652. package/dist/ir/paired-while-loops.d.ts +4 -2
  653. package/dist/ir/paired-while-loops.js +8 -2
  654. package/dist/ir/paired-while-loops.js.map +1 -1
  655. package/dist/ir/parameter-versions.d.ts +13 -4
  656. package/dist/ir/parameter-versions.js +63 -42
  657. package/dist/ir/parameter-versions.js.map +1 -1
  658. package/dist/ir/property-bags.d.ts +4 -2
  659. package/dist/ir/property-bags.js +22 -17
  660. package/dist/ir/property-bags.js.map +1 -1
  661. package/dist/ir/row-pairs.d.ts +4 -2
  662. package/dist/ir/row-pairs.js +12 -11
  663. package/dist/ir/row-pairs.js.map +1 -1
  664. package/dist/ir/runtime-features.d.ts +87 -12
  665. package/dist/ir/runtime-features.js +263 -160
  666. package/dist/ir/runtime-features.js.map +1 -1
  667. package/dist/ir/runtime-features.test.js +109 -139
  668. package/dist/ir/runtime-features.test.js.map +1 -1
  669. package/dist/ir/runtime-jam-loops.d.ts +35 -0
  670. package/dist/ir/runtime-jam-loops.js +604 -0
  671. package/dist/ir/runtime-jam-loops.js.map +1 -0
  672. package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
  673. package/dist/ir/runtime-jam-loops.test.js +565 -0
  674. package/dist/ir/runtime-jam-loops.test.js.map +1 -0
  675. package/dist/ir/saturating-loop-jams.d.ts +4 -2
  676. package/dist/ir/saturating-loop-jams.js +11 -10
  677. package/dist/ir/saturating-loop-jams.js.map +1 -1
  678. package/dist/ir/scalar-records.d.ts +5 -2
  679. package/dist/ir/scalar-records.js +12 -2
  680. package/dist/ir/scalar-records.js.map +1 -1
  681. package/dist/ir/self-captures.d.ts +4 -2
  682. package/dist/ir/self-captures.js +32 -27
  683. package/dist/ir/self-captures.js.map +1 -1
  684. package/dist/ir/serialize.d.ts +6 -1
  685. package/dist/ir/serialize.js +87 -23
  686. package/dist/ir/serialize.js.map +1 -1
  687. package/dist/ir/serialize.test.js +26 -0
  688. package/dist/ir/serialize.test.js.map +1 -1
  689. package/dist/ir/tiers.js +1 -0
  690. package/dist/ir/tiers.js.map +1 -1
  691. package/dist/ir/traverse.js +4 -0
  692. package/dist/ir/traverse.js.map +1 -1
  693. package/dist/ir/typed-argument-clones.d.ts +30 -0
  694. package/dist/ir/typed-argument-clones.js +789 -0
  695. package/dist/ir/typed-argument-clones.js.map +1 -0
  696. package/dist/ir/union-arm-loops.d.ts +3 -0
  697. package/dist/ir/union-arm-loops.js +373 -0
  698. package/dist/ir/union-arm-loops.js.map +1 -0
  699. package/dist/ir/union-arm-loops.test.d.ts +1 -0
  700. package/dist/ir/union-arm-loops.test.js +230 -0
  701. package/dist/ir/union-arm-loops.test.js.map +1 -0
  702. package/dist/ir/validate.js +88 -18
  703. package/dist/ir/validate.js.map +1 -1
  704. package/dist/library/compiler-self-identity.d.ts +8 -2
  705. package/dist/library/compiler-self-identity.js +92 -18
  706. package/dist/library/compiler-self-identity.js.map +1 -1
  707. package/dist/library/compiler-self-identity.test.js +150 -3
  708. package/dist/library/compiler-self-identity.test.js.map +1 -1
  709. package/dist/library/int-infer.d.ts +5 -0
  710. package/dist/library/int-infer.js +15 -3
  711. package/dist/library/int-infer.js.map +1 -1
  712. package/dist/library/ir-policy.js +1 -0
  713. package/dist/library/ir-policy.js.map +1 -1
  714. package/dist/library/library-cache.d.ts +4 -0
  715. package/dist/library/library-cache.js +2 -0
  716. package/dist/library/library-cache.js.map +1 -1
  717. package/dist/library/library-cache.test.js +26 -0
  718. package/dist/library/library-cache.test.js.map +1 -1
  719. package/dist/library/prepare.js +99 -31
  720. package/dist/library/prepare.js.map +1 -1
  721. package/dist/native/cache.d.ts +7 -0
  722. package/dist/native/cache.js +47 -0
  723. package/dist/native/cache.js.map +1 -1
  724. package/dist/native/cache.test.js +13 -1
  725. package/dist/native/cache.test.js.map +1 -1
  726. package/dist/native/cli.js +1 -1
  727. package/dist/native/cli.js.map +1 -1
  728. package/dist/native/compiler.js +18 -3
  729. package/dist/native/compiler.js.map +1 -1
  730. package/dist/native/executable-cache-open.test.js +31 -5
  731. package/dist/native/executable-cache-open.test.js.map +1 -1
  732. package/dist/native/executable-cache.d.ts +6 -1
  733. package/dist/native/executable-cache.js +7 -1
  734. package/dist/native/executable-cache.js.map +1 -1
  735. package/dist/native/prepare.d.ts +3 -0
  736. package/dist/native/prepare.js +43 -26
  737. package/dist/native/prepare.js.map +1 -1
  738. package/dist/native/prepare.test.js +25 -3
  739. package/dist/native/prepare.test.js.map +1 -1
  740. package/dist/native/sanitizer.js +10 -1
  741. package/dist/native/sanitizer.js.map +1 -1
  742. package/dist/native/sanitizer.test.js +7 -2
  743. package/dist/native/sanitizer.test.js.map +1 -1
  744. package/dist/node-islands/boundary.d.ts +12 -0
  745. package/dist/node-islands/boundary.js +38 -6
  746. package/dist/node-islands/boundary.js.map +1 -1
  747. package/dist/node-islands/boundary.test.d.ts +1 -0
  748. package/dist/node-islands/boundary.test.js +76 -0
  749. package/dist/node-islands/boundary.test.js.map +1 -0
  750. package/dist/node-islands/detect.d.ts +9 -0
  751. package/dist/node-islands/detect.js +110 -0
  752. package/dist/node-islands/detect.js.map +1 -1
  753. package/dist/node-islands/detect.test.js +24 -0
  754. package/dist/node-islands/detect.test.js.map +1 -1
  755. package/dist/node-islands/graph-islands.d.ts +40 -0
  756. package/dist/node-islands/graph-islands.js +128 -0
  757. package/dist/node-islands/graph-islands.js.map +1 -0
  758. package/dist/node-islands/growth.d.ts +57 -0
  759. package/dist/node-islands/growth.js +205 -0
  760. package/dist/node-islands/growth.js.map +1 -0
  761. package/dist/node-islands/report.d.ts +12 -0
  762. package/dist/node-islands/report.js +28 -0
  763. package/dist/node-islands/report.js.map +1 -1
  764. package/dist/node-islands/report.test.js +2 -0
  765. package/dist/node-islands/report.test.js.map +1 -1
  766. package/dist/node-islands/rules.js +5 -0
  767. package/dist/node-islands/rules.js.map +1 -1
  768. package/dist/node-islands/scan.d.ts +11 -2
  769. package/dist/node-islands/scan.js +61 -9
  770. package/dist/node-islands/scan.js.map +1 -1
  771. package/dist/wasm/translate.js +11 -5
  772. package/dist/wasm/translate.js.map +1 -1
  773. package/dist/wasm/translate.test.js +35 -0
  774. package/dist/wasm/translate.test.js.map +1 -1
  775. package/package.json +20 -20
  776. package/surface-manifest.json +184 -117
@@ -1,5 +1,5 @@
1
1
  import { lowerStaticPrivateAssignment } from "./private-statics.js";
2
- import { keepsInitializerLayout, notePreservedLayout } from "./structural-instances.js";
2
+ import { keepsCheckedDynamicValue, keepsInitializerLayout, notePreservedLayout, } from "./structural-instances.js";
3
3
  import { partialFieldRead } from "./partial-assertions.js";
4
4
  import { jsGlobalValueByName } from "./global-values.js";
5
5
  import { lowerTupleAliasDecl, stripTypeWrappers } from "./typed-arguments.js";
@@ -7,14 +7,15 @@ import { islandHandleBinding, lowerIslandExpr, isIslandRequireSpec, lowerIslandR
7
7
  import { isIslandSubclassDecl } from "../../node-islands/boundary.js";
8
8
  import { allBytesArms, indexedUnionArms, lowerIndexedUnionMember, lowerIndexedUnionNumberRead, lowerIndexedUnionRead, } from "./indexed-unions.js";
9
9
  import { declaredMemberOf, fenceDatePrototypeWrite, isPromisePrototypeRead, lowerUnionKeyedRead, } from "./expressions/property-access.js";
10
- import { hostedStorageView, hostsAll } from "./expressions/hosted-narrowing.js";
10
+ import { hostedStorageView, hostsAll, recordViewHosted } from "./expressions/hosted-narrowing.js";
11
+ import { assertionViewCopy, bindingIdentityUse, bindingWrite } from "./divergences.js";
11
12
  import { requestGeneralStreamSurface } from "./general-streams.js";
12
13
  import { lowerForAwaitDynStream, nodeStreamInterfaceSide } from "./dyn-streams.js";
13
14
  import { lowerForAwaitValueStream } from "./builtins/hash-stream.js";
14
15
  import { lowerChildPropertyWrite } from "./handle-properties.js";
15
16
  import { matchAllRowsReadByElements, storedMatchAllRowsReadByElements, } from "./containers/match-row-uses.js";
16
17
  import { dynUndefinedExpr, nodeThrowExpr, numLit, strLit, varRef } from "../../ir/build.js";
17
- import { runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
18
+ import { literalFieldKeys, runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
18
19
  import { declaresHoistedBinding, staticCondition } from "./static-typeof.js";
19
20
  import { lowerCollectionSpread } from "./containers/collection-methods.js";
20
21
  import { lowerEventObjectPropertyWrite } from "./lower-event-target.js";
@@ -39,17 +40,18 @@ import { requireInitFlagStmt } from "./require-initialization.js";
39
40
  import { isJsonRequireDecl } from "./json-require.js";
40
41
  import { isTimeValueDateDeclaration } from "./date-values.js";
41
42
  import { bindingSource } from "../binding-source.js";
42
- import { lowerConstructorReturn } from "./constructor-returns.js";
43
+ import { clearPendingPrimitiveReturn, lowerConstructorReturn } from "./constructor-returns.js";
43
44
  import { statementGroupKey } from "./type-failure.js";
44
45
  import { cjsExportValueByName, cjsNamespaceDestructureOf, cjsTableMethodEntry, inlineProgramRequireOf, requireNestedPatternsOf, splitRequireAssignmentOf, splitRequireBindingOf, splitRequireBindingOfIdent, splitRequireEarlyReadOf, wholeExportSymbolOfModule, } from "./cjs-inline-require.js";
45
46
  import { cjsExportMemberWriteGlobalOf, isCjsExportsIdentifier, isCjsModuleExports, isFreshExportsReset, } from "./cjs-exports-object.js";
46
47
  import { isDeadTscHelperDecl, tscInteropBindingOfDecl } from "./cjs-tsc-interop.js";
47
48
  import { arrayValueRead, arrayValueStore, arrayValueType, unionArrayValueRead, lowerSafeIndexRead, } from "./array-values.js";
48
49
  import { lowerForAwaitGenerator, lowerForOfGenerator, lowerYieldStarStatement, } from "./lower-generators.js";
49
- import { classAsyncGeneratorIterator, lowerForAwaitBuiltin } from "./lower-async-iteration.js";
50
+ import { classAsyncGeneratorIterator, isNodeReadableIteratorSource, isWebReadableIteratorSource, lowerForAwaitBuiltin, } from "./lower-async-iteration.js";
50
51
  import { BOOL, BYTES_U8, CAUGHT, DATE_T, DYN_HANDLE_KINDS, DYN, F64, SEARCH_PARAMS_T, STRING, UNDEFINED_T, VOID, arrayOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
51
52
  import { PoisonError, boundIdentifiersOf, dynFallbackType, neverTaintedJsType, staticImportNamespaceType, } from "./lowerer.js";
52
53
  import { enforceLibBoundary, lowerSurplusCalls } from "./lib-boundary.js";
54
+ import { isBuiltinIdentityToken, isPrimitiveValueType, lowerPrimitiveBaseDelete, } from "./primitive-throws.js";
53
55
  import { cjsExportAssignmentOf, cjsExportChainOf, cjsVoidInitPreambleReals, cjsExportDiscardReason, cjsExportTargetLiteral, isCjsJsFile, isEsModuleStamp, isJsSourceFile, locOf, requireEarlyReference, requireSpecOf, } from "../program.js";
54
56
  import { isStrictCode } from "./strict-mode.js";
55
57
  import { markSloppyRecordWrites } from "./frozen-records.js";
@@ -62,7 +64,7 @@ import { lowerForOfArrayIter, lowerForOfMap, lowerForOfSearchParams, lowerForOfS
62
64
  import { lowerForOfHelperChain } from "./containers/iterator-helpers.js";
63
65
  import { objectIterOverIndexShape } from "./containers/indexed-objects.js";
64
66
  import { strCharsCall } from "./containers/array-construction.js";
65
- import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, genericBindingPresenceStore, genericBindingStoredValue, implicitLocalFnInfoOf, implicitLocalFnNodeOf, implicitMethodCallInfersReturn, genericLocalClassBinding, } from "./generic-functions.js";
67
+ import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, genericAliasPresenceStore, genericBindingPresenceStore, genericBindingStoredValue, implicitLocalFnInfoOf, implicitLocalFnNodeOf, implicitMethodCallInfersReturn, genericLocalClassBinding, } from "./generic-functions.js";
66
68
  import { bindingNeverReassigned, deadUnmappableBinding, fileWritesBinding, nullishExprUnitOf, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
67
69
  import { hasExplicitJsDocReturn } from "./function-returns.js";
68
70
  import { recordKeysArrayCall } from "./lower-calls.js";
@@ -1726,6 +1728,39 @@ export function lowerStmt(lowerer, stmt) {
1726
1728
  // observed empty returns even when JSDoc omits undefined. Any remaining
1727
1729
  // incompatible boundary keeps the ordinary per-statement refusal.
1728
1730
  let value = null;
1731
+ // A derived constructor that can record a pending TypeError on a
1732
+ // primitive return drops it when a return of its own completes: a
1733
+ // `finally` block's `return;`, `return undefined` or `return this`
1734
+ // replaces the earlier completion instead of leaving it pending. The
1735
+ // drop follows the operand, which may throw — an operand that throws
1736
+ // never completes the return, so a `finally` that catches it and then
1737
+ // finishes resumes the earlier primitive return (and its TypeError).
1738
+ const withClearedPending = (ret) => {
1739
+ const clear = clearPendingPrimitiveReturn(lowerer, stmt);
1740
+ if (clear.length === 0)
1741
+ return ret;
1742
+ const loc = locOf(stmt);
1743
+ const body = ret.kind === "block" ? ret.body : [ret];
1744
+ const last = body.at(-1);
1745
+ if (last?.kind !== "return")
1746
+ return { kind: "block", body: [...clear, ret], loc };
1747
+ const before = body.slice(0, -1);
1748
+ if (last.value === null)
1749
+ return { kind: "block", body: [...before, ...clear, last], loc };
1750
+ // A constructor returns void, so a valued operand only evaluates for
1751
+ // effect — ahead of the drop, since a `return this.fail()` inside a
1752
+ // `finally` that catches the throw never completes.
1753
+ return {
1754
+ kind: "block",
1755
+ body: [
1756
+ ...before,
1757
+ { kind: "exprStmt", expr: last.value, loc },
1758
+ ...clear,
1759
+ { kind: "return", value: null, loc },
1760
+ ],
1761
+ loc,
1762
+ };
1763
+ };
1729
1764
  if (stmt.expression) {
1730
1765
  // A constructor's returned object replaces the constructed `this`.
1731
1766
  if (lowerer.currentClass?.ctor) {
@@ -1733,7 +1768,7 @@ export function lowerStmt(lowerer, stmt) {
1733
1768
  if (constructorReturn !== null)
1734
1769
  return constructorReturn;
1735
1770
  }
1736
- return lowerer.lowerReturnStmt(stmt.expression, locOf(stmt));
1771
+ return withClearedPending(lowerer.lowerReturnStmt(stmt.expression, locOf(stmt)));
1737
1772
  }
1738
1773
  else if (lowerer.ctx.returnType.kind === "union") {
1739
1774
  value = lowerer.wrappedUndefined(lowerer.ctx.returnType, locOf(stmt));
@@ -1749,8 +1784,8 @@ export function lowerStmt(lowerer, stmt) {
1749
1784
  }
1750
1785
  // An async generator's bare return has no operand to await.
1751
1786
  if (lowerer.ctx.isAsync === true && lowerer.ctx.generator)
1752
- return { kind: "return", value, awaited: true, loc: locOf(stmt) };
1753
- return { kind: "return", value, loc: locOf(stmt) };
1787
+ return withClearedPending({ kind: "return", value, awaited: true, loc: locOf(stmt) });
1788
+ return withClearedPending({ kind: "return", value, loc: locOf(stmt) });
1754
1789
  }
1755
1790
  if (ts.isBreakStatement(stmt) || ts.isContinueStatement(stmt)) {
1756
1791
  const kw = ts.isBreakStatement(stmt) ? "break" : "continue";
@@ -5003,17 +5038,20 @@ function evolvingArrayHolderType(lowerer, decl) {
5003
5038
  return null;
5004
5039
  return evolvingArrayHold(lowerer, decl.initializer) === null ? null : DYN;
5005
5040
  }
5006
- /** A single static type for an initializer-less JavaScript `let` whose
5007
- * later plain writes all agree. An evolving JS local reads as `undefined`
5008
- * until control flow proves a write, so a scalar slot is sound only when
5009
- * every ordinary use already has that concrete flow type. A write's call
5010
- * counts when its signature is declared in the standard library, whose
5011
- * return types are declared rather than inferred from JavaScript. A
5012
- * closure capture can observe the local before an outer assignment, and
5013
- * the checker leaves captured evolving lets broad: a captured runtime
5014
- * handle (`let child; if (...) child = spawn(...)`) takes the handle or
5015
- * `undefined`, which nested functions read as a checked-dynamic value
5016
- * (closureDynLets), and other captured bindings stay checked-dynamic. */
5041
+ /** A single static type for an initializer-less `let` without an
5042
+ * annotation whose later plain writes all agree. An evolving local reads as
5043
+ * `undefined` until control flow proves a write, so a scalar slot is sound
5044
+ * only when every ordinary use already has that concrete flow type (or an
5045
+ * arm of it). A write of `null` or `undefined` joins the written type as an
5046
+ * optional arm (`let stat; try { stat = lstatSync(".") } catch { stat = null }`
5047
+ * holds `Stats | null`). A write's call counts when its signature is
5048
+ * declared in the standard library, whose return types are declared rather
5049
+ * than inferred from JavaScript. A closure capture can observe the local
5050
+ * before an outer assignment, and the checker leaves captured evolving lets
5051
+ * broad: a captured runtime handle (`let child; if (...) child = spawn(...)`)
5052
+ * takes the handle or `undefined`, which nested functions read as a
5053
+ * checked-dynamic value (closureDynLets), and other captured bindings stay
5054
+ * checked-dynamic. */
5017
5055
  export function inferredEvolvingLetType(lowerer, decl) {
5018
5056
  if (!ts.isIdentifier(decl.name))
5019
5057
  return null;
@@ -5068,7 +5106,10 @@ export function inferredEvolvingLetType(lowerer, decl) {
5068
5106
  }
5069
5107
  return "skip";
5070
5108
  }
5071
- if (ts.isBinaryExpression(node)) {
5109
+ // A compound assignment (`x += 1`) reads and rewrites the binding
5110
+ // through an operator this scan does not model; a comparison
5111
+ // (`x === null`) only reads it, and the read check below covers that.
5112
+ if (ts.isBinaryExpression(node) && ts.isAssignmentOperator(node.operatorToken.kind)) {
5072
5113
  let left = node.left;
5073
5114
  while (ts.isParenthesizedExpression(left))
5074
5115
  left = left.expression;
@@ -5091,7 +5132,7 @@ export function inferredEvolvingLetType(lowerer, decl) {
5091
5132
  return "stop";
5092
5133
  }
5093
5134
  const mapped = lowerer.mapTypeOf(lowerer.typeOf(node.right));
5094
- if (!mapped || mapped.kind === "dyn" || mapped.kind === "void" || isUnitType(mapped)) {
5135
+ if (!mapped || mapped.kind === "dyn" || mapped.kind === "void") {
5095
5136
  invalid = true;
5096
5137
  return "stop";
5097
5138
  }
@@ -5114,20 +5155,49 @@ export function inferredEvolvingLetType(lowerer, decl) {
5114
5155
  return undefined;
5115
5156
  };
5116
5157
  ts.walkPreorder(scope, visit);
5117
- const first = writes[0];
5118
- if (invalid || first === undefined || !writes.every((write) => typeEquals(write, first)))
5158
+ // A write of an already-unioned value contributes its arms, so a call
5159
+ // declared `Stats | null` reads the same as separate value and unit
5160
+ // writes.
5161
+ const armsOf = (t) => t.kind === "union" ? (lowerer.unions.get(t.unionId)?.arms ?? [t]) : [t];
5162
+ const valueArms = [];
5163
+ const unitArms = [];
5164
+ for (const write of writes) {
5165
+ for (const arm of armsOf(write)) {
5166
+ const seen = isUnitType(arm) ? unitArms : valueArms;
5167
+ if (!seen.some((other) => typeEquals(other, arm)))
5168
+ seen.push(arm);
5169
+ }
5170
+ }
5171
+ const value = valueArms[0];
5172
+ if (invalid || value === undefined || valueArms.length > 1)
5119
5173
  return null;
5174
+ const arms = [value];
5175
+ if (unitArms.length > 0) {
5176
+ // An evolving local reads as `undefined` before control flow proves a
5177
+ // write, so the optional storage carries that arm as well.
5178
+ arms.push(UNDEFINED_T);
5179
+ for (const unit of unitArms) {
5180
+ if (unit.kind !== "undefinedT")
5181
+ arms.push(unit);
5182
+ }
5183
+ }
5184
+ const storage = arms.length === 1 ? value : { kind: "union", unionId: lowerer.unions.intern(arms) };
5185
+ // A narrowed read sees an arm, or a sub-union of arms, of the storage.
5120
5186
  if (!reads.every((read) => {
5121
5187
  const mapped = lowerer.mapTypeOf(lowerer.typeOf(read));
5122
- return mapped !== null && typeEquals(mapped, first);
5188
+ return (mapped !== null && armsOf(mapped).every((arm) => arms.some((own) => typeEquals(own, arm))));
5123
5189
  }))
5124
5190
  return null;
5125
5191
  if (!captured)
5126
- return first;
5127
- if (!DYN_HANDLE_KINDS.has(first.kind))
5192
+ return storage;
5193
+ if (!DYN_HANDLE_KINDS.has(value.kind))
5128
5194
  return null;
5129
5195
  lowerer.closureDynLets.add(symbol);
5130
- return { kind: "union", unionId: lowerer.unions.intern([first, UNDEFINED_T]) };
5196
+ // A nested function can read the binding before the outer assignment:
5197
+ // the optional arm is what the checked-dynamic read of the closure sees.
5198
+ return storage.kind === "union"
5199
+ ? storage
5200
+ : { kind: "union", unionId: lowerer.unions.intern([value, UNDEFINED_T]) };
5131
5201
  }
5132
5202
  /** Whether a call's resolved signature is declared in the standard library
5133
5203
  * (`spawn(...)`), so its declared return type is the value's type. Calls of
@@ -5313,11 +5383,11 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5313
5383
  }
5314
5384
  // `const h = id` — an ALIAS of a generic function: the alias's symbol
5315
5385
  // registers the target's info (calls and pinned values resolve like
5316
- // the target's own name), the binding has no runtime value, and the
5317
- // statement emits nothing (collectGlobals skipped module-scope
5318
- // globals by the same test; block-scoped aliases register here).
5386
+ // the target's own name) and the binding has no runtime value, so the
5387
+ // statement emits nothing but the flag of a module-scope alias whose
5388
+ // reads can run before it (genericAliasPresenceStore).
5319
5389
  if (bindingGenericFnAliasInfoOf(lowerer, decl))
5320
- return null;
5390
+ return genericAliasPresenceStore(lowerer, decl);
5321
5391
  // `const stored = overloadedDeclaration`: no runtime slot is needed;
5322
5392
  // calls project onto the declaration's implementation ABI and value
5323
5393
  // reads reuse its interned closure identity.
@@ -5439,6 +5509,12 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5439
5509
  raw.type.kind === "dyn" &&
5440
5510
  (g.type.kind === "record" ||
5441
5511
  g.type.kind === "object" ||
5512
+ // `const p = Promise.all.call(C, xs)` in JavaScript: the call runs
5513
+ // the specification's algorithm with `C`'s capability and returns
5514
+ // whatever `C` constructed, a foreign instance the checker still
5515
+ // calls `Promise<T>`. The binding holds that value as dyn; a
5516
+ // native-promise check would reject it (t262-db B3).
5517
+ (g.type.kind === "promise" && isJsPromiseStaticCall(raw)) ||
5442
5518
  (ts.isIdentifier(decl.name) &&
5443
5519
  jsBindingKeepsCheckedObject(lowerer, decl.name, g.type) &&
5444
5520
  (existingValueForm(decl.initializer) || jsHoldsDynObject(lowerer, decl.initializer)))))
@@ -5452,6 +5528,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5452
5528
  g.type = raw.type;
5453
5529
  notePreservedLayout(lowerer, decl);
5454
5530
  }
5531
+ // The same for a module const initialized by an assertion: the value's
5532
+ // storage already answers the asserted view (narrowing.ts), so the
5533
+ // module holds that layout and writes through it reach the object.
5534
+ if (!isVarDeclared(decl) &&
5535
+ (ts.getCombinedNodeFlags(decl) & ts.NodeFlags.Const) !== 0 &&
5536
+ assertionKeepsStorageLayout(lowerer, decl, raw.type, g.type)) {
5537
+ g.type = raw.type;
5538
+ notePreservedLayout(lowerer, decl);
5539
+ }
5540
+ if (!isVarDeclared(decl) &&
5541
+ keepsCheckedDynamicValue(lowerer, decl.initializer, raw.type, g.type))
5542
+ g.type = raw.type;
5455
5543
  const arithmetic = raw.type.kind === "union" ? lowerer.unions.get(raw.type.unionId)?.arms : undefined;
5456
5544
  if (arithmetic?.length === 2 &&
5457
5545
  arithmetic.every((a) => a.kind === "f64" || a.kind === "string" || a.kind === "bool") &&
@@ -5464,6 +5552,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5464
5552
  lowerer.runtimeOptionalArithmeticGlobals.add(g);
5465
5553
  }
5466
5554
  const init = lowerer.coerceInto(decl.initializer, raw, g.type);
5555
+ refuseAssertionViewWrite(lowerer, decl);
5467
5556
  return {
5468
5557
  kind: "assign",
5469
5558
  localId: g.id,
@@ -5505,12 +5594,13 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5505
5594
  // `let x: number;` — declared, uninitialized. tsc guarantees no read
5506
5595
  // before assignment (TS2454) and rejects uninitialized const (TS1155).
5507
5596
  // Unannotated `let x;` is an evolving `any` — the checked-dynamic
5508
- // binding fallback (irTypeOf → dynFallbackType).
5597
+ // binding fallback (irTypeOf → dynFallbackType) unless its writes agree
5598
+ // on a type.
5509
5599
  // Undefined-armed unions (`let x: string | undefined;`) are readable
5510
5600
  // immediately (the type covers the unassigned state), so they
5511
5601
  // initialize to the interned undefined arm like an omitted optional.
5512
5602
  let type = lowerer.irTypeOf(decl.name);
5513
- if (type.kind === "dyn" && isLet && isJsSourceFile(ts.getSourceFileOfNode(decl))) {
5603
+ if (type.kind === "dyn" && isLet && decl.type === undefined) {
5514
5604
  type = inferredEvolvingLetType(lowerer, decl) ?? type;
5515
5605
  }
5516
5606
  // `var v: void;` / `let x: undefined;` — a unit-only binding rides
@@ -5621,6 +5711,12 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5621
5711
  type = init.type;
5622
5712
  notePreservedLayout(lowerer, decl);
5623
5713
  }
5714
+ // An index-signature binding whose assertion of an existing value lowered
5715
+ // to that value (narrowing.ts keeps it instead of answering a copy whose
5716
+ // keys live in a map of its own) keeps the value too: converting it here
5717
+ // would take every write through the binding with it.
5718
+ if (keepsCheckedDynamicValue(lowerer, decl.initializer, init.type, type))
5719
+ type = init.type;
5624
5720
  // A JavaScript binding assigned values outside its declared type
5625
5721
  // (analyzeJsWidenedBindings in lowerer.ts) holds them as checked-dynamic.
5626
5722
  {
@@ -5678,9 +5774,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5678
5774
  const keepsAssertedObject = init.type.kind === "dyn" &&
5679
5775
  !decl.type &&
5680
5776
  keptIdentityAssertion(lowerer, decl.initializer) !== undefined;
5777
+ // `const p = Promise.all.call(C, xs)` in JavaScript: the checked-dynamic
5778
+ // promise-static call returns whatever `C` constructed — a foreign
5779
+ // instance, not the `Promise<T>` the checker infers from the signature —
5780
+ // so the binding holds it as dyn (t262-db B3).
5781
+ const keepsPromiseStaticValue = isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
5782
+ !decl.type &&
5783
+ !hasJsTypeAnnotation(decl) &&
5784
+ isJsPromiseStaticCall(init);
5681
5785
  if (expandsObject ||
5682
5786
  preservesObjectIdentity ||
5683
5787
  keepsAssertedObject ||
5788
+ keepsPromiseStaticValue ||
5684
5789
  (isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
5685
5790
  !decl.type &&
5686
5791
  isNativeBuiltinValueInitializer(lowerer, decl.initializer))) {
@@ -5977,13 +6082,9 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5977
6082
  // the stored type hosts (`const view: Route & { order: number } = ...`)
5978
6083
  // keeps it too: coercing into the annotated layout would copy the
5979
6084
  // value and read members the writes have not created yet.
5980
- if (!isLet &&
5981
- decl.initializer &&
5982
- isAssertionInitializer(decl.initializer) &&
5983
- (settledType.kind === "union" || settledType.kind === "record") &&
5984
- (init.type.kind === "union" || init.type.kind === "record") &&
5985
- hostsAll(lowerer, init.type, settledType)) {
6085
+ if (!isLet && assertionKeepsStorageLayout(lowerer, decl, init.type, settledType)) {
5986
6086
  settledType = init.type;
6087
+ notePreservedLayout(lowerer, decl);
5987
6088
  }
5988
6089
  // An exact class behind a generic interface keeps its native
5989
6090
  // representation so generic calls can specialize against its body.
@@ -6012,6 +6113,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
6012
6113
  // Slot coercion: `const r: A | B = bValue;` wraps implicitly; width
6013
6114
  // subtyping (`const p: {a: number} = wider;`) is rejected, not coerced.
6014
6115
  init = lowerer.coerceInto(decl.initializer, init, settledType);
6116
+ refuseAssertionViewWrite(lowerer, decl);
6015
6117
  const local = lowerer.declareLocal(decl.name, decl.name.text, settledType, isLet);
6016
6118
  if (runtimeStringArithmetic && init.type.kind === "union") {
6017
6119
  lowerer.runtimeOptionalArithmeticLocals.add(lowerer.runtimeOptionalRootOf(local));
@@ -6061,6 +6163,17 @@ function inferredOptionalRecordType(lowerer, decl, declared, actual) {
6061
6163
  return declared;
6062
6164
  return actual;
6063
6165
  }
6166
+ /** Whether a lowered initializer is the checked-dynamic `Promise.<static>.call(C, …)`
6167
+ * call (lower-calls.ts, JavaScript sources only). Its result is whatever `C`
6168
+ * constructed, so a binding the checker typed `Promise<T>` holds it as dyn. */
6169
+ function isJsPromiseStaticCall(value) {
6170
+ // Surplus arguments evaluate as statements before the call, so the
6171
+ // initializer is a sequence expression whose result is the call.
6172
+ let result = value;
6173
+ while (result.kind === "seqExpr")
6174
+ result = result.result;
6175
+ return result.kind === "libCall" && result.fn === "promise.genericStatic";
6176
+ }
6064
6177
  function lowerVariableInitializer(lowerer, node, expected) {
6065
6178
  let value = node;
6066
6179
  while (ts.isParenthesizedExpression(value) ||
@@ -6802,13 +6915,35 @@ function declaresCheckedDynField(lowerer, type, name) {
6802
6915
  const arms = lowerer.unions.get(type.unionId)?.arms ?? [];
6803
6916
  return arms.length > 0 && arms.every((arm) => declaresCheckedDynField(lowerer, arm, name));
6804
6917
  }
6918
+ /** The constant property key of a `delete` target: the name of a dot
6919
+ * access, or the one key of a bracket access spelled as a literal or
6920
+ * proved by a literal-typed binding (`const key = "a"`). A key of several
6921
+ * literals folds to nothing — deleting it would need per-key dispatch, so
6922
+ * the record branch refuses and names the keys. Consistent with keyed
6923
+ * record reads/writes (literalFieldKeys), the key expression is not
6924
+ * evaluated: only a literal or an identifier folds, and an identifier
6925
+ * read is pure. */
6926
+ function constantDeleteKey(lowerer, target) {
6927
+ if (ts.isPropertyAccessExpression(target))
6928
+ return target.name.text;
6929
+ if (!ts.isElementAccessExpression(target))
6930
+ return null;
6931
+ const keyNode = target.argumentExpression;
6932
+ if (ts.isStringLiteralLike(keyNode))
6933
+ return keyNode.text;
6934
+ if (!ts.isIdentifier(keyNode))
6935
+ return null;
6936
+ const keys = literalFieldKeys(lowerer, keyNode);
6937
+ return keys?.length === 1 ? keys[0] : null;
6938
+ }
6805
6939
  /** Statement-position `delete`: process.env keys → process.envUnset
6806
6940
  * (unsetenv), pure `Record<string, T>` keys → recordKeyDelete (the
6807
6941
  * overflow Map delete), declared OPTIONAL fields → the field's ABSENT
6808
6942
  * state (the slot reads undefined and no longer counts as an own
6809
6943
  * property). Everything else
6810
- * fences with the honest reason — a required field is a struct slot no
6811
- * runtime can remove, and an optional `unknown`/`any` field maps to the
6944
+ * fences with the honest reason — a required record field is a struct slot
6945
+ * with no ABSENT state, a class field is part of the instance's fixed
6946
+ * layout, and an optional `unknown`/`any` field maps to the
6812
6947
  * checked-dynamic slot, which has no ABSENT state yet. */
6813
6948
  function lowerDeleteStatement(lowerer, expr) {
6814
6949
  const loc = locOf(expr);
@@ -6879,6 +7014,18 @@ function lowerDeleteStatement(lowerer, expr) {
6879
7014
  return unionDelete;
6880
7015
  }
6881
7016
  let obj = lowerer.lowerExpr(target.expression);
7017
+ // A PRIMITIVE receiver: `delete` runs ToObject on the base AFTER the key,
7018
+ // and the base's type decides the answer — null and undefined throw
7019
+ // Node's TypeError, `?.` on a nullish base short-circuits to `true`
7020
+ // without evaluating the key, and every other primitive deletes from its
7021
+ // ToObject wrapper (a String's indexes and `length` refuse the delete).
7022
+ if (isPrimitiveValueType(obj.type) && !isBuiltinIdentityToken(lowerer, target.expression, obj)) {
7023
+ return {
7024
+ kind: "exprStmt",
7025
+ expr: lowerPrimitiveBaseDelete(lowerer, expr, target, obj, VOID),
7026
+ loc,
7027
+ };
7028
+ }
6882
7029
  // `delete this.stack` in an Error subclass that declares a `stack`
6883
7030
  // accessor (quickjs-wasi's JSException): V8 gives each error an own
6884
7031
  // `stack` that shadows the accessor, and the delete removes it so reads
@@ -6954,13 +7101,12 @@ function lowerDeleteStatement(lowerer, expr) {
6954
7101
  loc,
6955
7102
  };
6956
7103
  }
6957
- // The constant property key of the target (dot access or a literal
6958
- // bracket), when there is one.
6959
- const constantKey = ts.isPropertyAccessExpression(target)
6960
- ? target.name.text
6961
- : ts.isStringLiteral(target.argumentExpression)
6962
- ? target.argumentExpression.text
6963
- : null;
7104
+ // The constant property key of the target: dot access, a literal
7105
+ // bracket, or an element access whose key is a literal-typed binding
7106
+ // (`const key = "a"; delete r[key]`) — the same stance a keyed record
7107
+ // read/write takes (literalFieldKeys): identifier evaluation is pure, so
7108
+ // skipping it matches JavaScript.
7109
+ const constantKey = constantDeleteKey(lowerer, target);
6964
7110
  // An OPTIONAL `unknown`/`any` field rides the checked-dynamic slot,
6965
7111
  // which has no ABSENT state yet (an omitted such field already reads as
6966
7112
  // present), so it cannot delete. Name that reason instead of calling
@@ -7002,12 +7148,29 @@ function lowerDeleteStatement(lowerer, expr) {
7002
7148
  if (optionalCheckedDynDelete) {
7003
7149
  lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
7004
7150
  }
7005
- lowerer.unsupported("SC1090", expr, "'delete' of required record fields (a monomorphic shape cannot remove its slot — only optional fields delete, becoming the undefined arm)");
7151
+ // A key of SEVERAL literals names no single slot: say that instead of
7152
+ // blaming a field the caller never named.
7153
+ const keyNames = constantKey === null && ts.isElementAccessExpression(target)
7154
+ ? literalFieldKeys(lowerer, target.argumentExpression)
7155
+ : null;
7156
+ if (keyNames !== null && keyNames.length > 1) {
7157
+ lowerer.unsupported("SC1090", expr, `'delete' through keys of ${keyNames.length} literals (${keyNames.map((k) => `'${k}'`).join(", ")}; delete one constant key at a time, or switch over the key)`);
7158
+ }
7159
+ lowerer.unsupported("SC1090", expr, "'delete' of required record fields (the shape's slot cannot be removed — only an optional field (`f?: T`) has an absent state, which Object.keys, 'in', and JSON.stringify follow; make the field optional if the program must remove it)");
7006
7160
  }
7007
7161
  if (optionalCheckedDynDelete) {
7008
7162
  lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
7009
7163
  }
7010
- lowerer.unsupported("SC1090", expr, `'delete' on '${lowerer.fmt(obj.type)}' receivers (process.env keys and pure Record<string, T> keys delete)`);
7164
+ // A class field lives in the instance's fixed layout: there is no
7165
+ // per-field presence state for a delete to write, so Object.keys,
7166
+ // `in`, and JSON.stringify would keep reporting the field where Node
7167
+ // drops it. Name that reason instead of the generic receiver fence.
7168
+ if (obj.type.kind === "object" &&
7169
+ constantKey !== null &&
7170
+ lowerer.classes.get(obj.type.className)?.fields.has(constantKey)) {
7171
+ lowerer.unsupported("SC1090", expr, "'delete' of class fields (an instance's fields are its fixed layout — there is no per-field presence state, so Object.keys, 'in', and JSON.stringify would still report a deleted field; only optional record fields (`f?: T`) and Record<string, T> keys delete)");
7172
+ }
7173
+ lowerer.unsupported("SC1090", expr, `'delete' on '${lowerer.fmt(obj.type)}' receivers (process.env keys, pure Record<string, T> keys, and optional record fields delete)`);
7011
7174
  }
7012
7175
  /** True when the `var`/`let` binding `nameNode` names cannot change after
7013
7176
  * the top-level CommonJS export statement `exportNode` that exports it by
@@ -9667,7 +9830,12 @@ export function lowerForOf(lowerer, stmt) {
9667
9830
  }
9668
9831
  const awaitArray = !!stmt.awaitModifier && lowerer.mapTypeOf(lowerer.typeOf(stmt.expression))?.kind === "array";
9669
9832
  if (stmt.awaitModifier && !awaitArray) {
9670
- {
9833
+ // A web ReadableStream's and a Node readable's iterator views both type
9834
+ // as AsyncIterableIterator, which lowers like the async protocols — but
9835
+ // the loop consumes each view through its own lowering
9836
+ // (lowerForAwaitBuiltin below).
9837
+ if (!isWebReadableIteratorSource(lowerer, stmt.expression) &&
9838
+ !isNodeReadableIteratorSource(lowerer, stmt.expression)) {
9671
9839
  const genT = lowerer.stageSourceType(stmt.expression) ??
9672
9840
  lowerer.mapTypeOf(lowerer.typeOf(stmt.expression));
9673
9841
  if (genT?.kind === "generator" && genT.async) {
@@ -12322,4 +12490,54 @@ function isAssertionInitializer(node) {
12322
12490
  e = e.expression;
12323
12491
  return ts.isAsExpression(e) || ts.isTypeAssertion(e);
12324
12492
  }
12493
+ /** `const view = route as Route & { order: number }`: the asserted type
12494
+ * refines the record arms the value is stored in (hosted-narrowing.ts), and
12495
+ * a projection (`{ text: string }` over `TextBlock`) only names members the
12496
+ * stored record already holds. Either way Node erases the assertion and
12497
+ * keeps the object, so the binding keeps the value's layout and its writes
12498
+ * reach that object instead of a copy. */
12499
+ function assertionKeepsStorageLayout(lowerer, decl, init, settled) {
12500
+ if (decl.initializer === undefined || !isAssertionInitializer(decl.initializer))
12501
+ return false;
12502
+ if (settled.kind !== "union" && settled.kind !== "record")
12503
+ return false;
12504
+ if (init.kind !== "union" && init.kind !== "record")
12505
+ return false;
12506
+ if (hostsAll(lowerer, init, settled))
12507
+ return true;
12508
+ // A projection (`{ text: string }` over `TextBlock`) keeps the stored
12509
+ // record only when the binding's identity is observable through it
12510
+ // (a write, an identity comparison). A read-only view is equal either
12511
+ // way, keeps the copy narrowing.ts made, and stays reported.
12512
+ if (!bindingIdentityUse(decl, lowerer.checker))
12513
+ return false;
12514
+ return (init.kind === "record" &&
12515
+ settled.kind === "record" &&
12516
+ recordViewHosted(lowerer, init.shapeId, settled.shapeId));
12517
+ }
12518
+ /** `const v = x as { a: number; extra?: string }; v.extra = "x"`: the
12519
+ * assertion's view names a member the value's own layout does not, so the
12520
+ * binding receives a COPY of `x` and the write lands on that copy — Node
12521
+ * erases the assertion and adds the property to `x` itself, so the write
12522
+ * must reach a caller-visible object. Reads of a copy are equal either
12523
+ * way, and so is a nested write through a member the copy shares (the same
12524
+ * child object in both), so only a write to the copy's own field is
12525
+ * refused, by name. Where the layouts agree the binding keeps the value's
12526
+ * storage instead (assertionKeepsStorageLayout), narrowing.ts and
12527
+ * lowerVarDecl record that in layoutKeptNodes, and nothing here fires.
12528
+ * Runs for file-scope and local bindings alike, after the declaration has
12529
+ * been lowered (so the keep is known). */
12530
+ function refuseAssertionViewWrite(lowerer, decl) {
12531
+ if (decl.initializer === undefined || !isAssertionInitializer(decl.initializer))
12532
+ return;
12533
+ if (lowerer.layoutKeptNodes.has(decl.initializer))
12534
+ return;
12535
+ const copy = assertionViewCopy(lowerer, decl.initializer);
12536
+ if (copy === null)
12537
+ return;
12538
+ const write = bindingWrite(lowerer, decl);
12539
+ if (write === null)
12540
+ return;
12541
+ lowerer.unsupported("SC1090", decl, `writing '${write.text}' through '${decl.name.getText()}', a copy of the '${copy.source}' value the assertion views as '${copy.target}' (the write would land on the copy; write through the original binding, or declare the member on the value's type)`);
12542
+ }
12325
12543
  //# sourceMappingURL=lower-stmts.js.map