@scriptc/compiler 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1082) hide show
  1. package/ambient/node-fallback/child_process.d.ts +71 -22
  2. package/ambient/node-fallback/crypto.d.ts +15 -7
  3. package/ambient/node-fallback/events.d.ts +29 -6
  4. package/ambient/node-fallback/fs-promises.d.ts +1 -1
  5. package/ambient/node-fallback/fs.d.ts +57 -12
  6. package/ambient/node-fallback/http.d.ts +26 -18
  7. package/ambient/node-fallback/https.d.ts +5 -2
  8. package/ambient/node-fallback/net.d.ts +25 -0
  9. package/ambient/node-fallback/os.d.ts +11 -1
  10. package/ambient/node-fallback/path-posix.d.ts +6 -0
  11. package/ambient/node-fallback/path-win32.d.ts +5 -0
  12. package/ambient/node-fallback/path.d.ts +2 -0
  13. package/ambient/node-fallback/querystring.d.ts +3 -3
  14. package/ambient/node-fallback/zlib.d.ts +31 -2
  15. package/ambient/scriptc-node-fallback.d.ts +95 -20
  16. package/ambient/scriptc.d.ts +7 -2
  17. package/dist/backend/executable-features.js +22 -1
  18. package/dist/backend/executable-features.js.map +1 -1
  19. package/dist/backend/immutability.d.ts +12 -1
  20. package/dist/backend/immutability.js +50 -4
  21. package/dist/backend/immutability.js.map +1 -1
  22. package/dist/backend/immutability.test.js +95 -1
  23. package/dist/backend/immutability.test.js.map +1 -1
  24. package/dist/backend/library-pack.d.ts +6 -0
  25. package/dist/backend/library-pack.js +18 -5
  26. package/dist/backend/library-pack.js.map +1 -1
  27. package/dist/backend/library-pack.test.d.ts +1 -0
  28. package/dist/backend/library-pack.test.js +28 -0
  29. package/dist/backend/library-pack.test.js.map +1 -0
  30. package/dist/backend/linker.d.ts +20 -2
  31. package/dist/backend/linker.js +221 -35
  32. package/dist/backend/linker.js.map +1 -1
  33. package/dist/backend/lld.d.ts +15 -6
  34. package/dist/backend/lld.js +24 -16
  35. package/dist/backend/lld.js.map +1 -1
  36. package/dist/backend/lld.test.js +13 -5
  37. package/dist/backend/lld.test.js.map +1 -1
  38. package/dist/backend/llvm/alloc.d.ts +15 -2
  39. package/dist/backend/llvm/alloc.js +172 -36
  40. package/dist/backend/llvm/alloc.js.map +1 -1
  41. package/dist/backend/llvm/alloc.test.js +69 -1
  42. package/dist/backend/llvm/alloc.test.js.map +1 -1
  43. package/dist/backend/llvm/arenas.d.ts +17 -4
  44. package/dist/backend/llvm/arenas.js +105 -10
  45. package/dist/backend/llvm/arenas.js.map +1 -1
  46. package/dist/backend/llvm/arenas.test.js +229 -0
  47. package/dist/backend/llvm/arenas.test.js.map +1 -1
  48. package/dist/backend/llvm/bytes-alias.js +10 -1
  49. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  50. package/dist/backend/llvm/bytes-headers.js +6 -0
  51. package/dist/backend/llvm/bytes-headers.js.map +1 -1
  52. package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
  53. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  54. package/dist/backend/llvm/call-lifetimes.js +10 -0
  55. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  56. package/dist/backend/llvm/classes.d.ts +16 -9
  57. package/dist/backend/llvm/classes.js +142 -37
  58. package/dist/backend/llvm/classes.js.map +1 -1
  59. package/dist/backend/llvm/classes.test.js +42 -0
  60. package/dist/backend/llvm/classes.test.js.map +1 -1
  61. package/dist/backend/llvm/constant-callbacks.test.js +50 -1
  62. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  63. package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
  64. package/dist/backend/llvm/cpu-dispatch.js +34 -9
  65. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  66. package/dist/backend/llvm/dyn.d.ts +64 -3
  67. package/dist/backend/llvm/dyn.js +251 -15
  68. package/dist/backend/llvm/dyn.js.map +1 -1
  69. package/dist/backend/llvm/emit-function.js +68 -5
  70. package/dist/backend/llvm/emit-function.js.map +1 -1
  71. package/dist/backend/llvm/emit-module.js +226 -77
  72. package/dist/backend/llvm/emit-module.js.map +1 -1
  73. package/dist/backend/llvm/emit-module.test.d.ts +1 -0
  74. package/dist/backend/llvm/emit-module.test.js +52 -0
  75. package/dist/backend/llvm/emit-module.test.js.map +1 -0
  76. package/dist/backend/llvm/emit-statements.js +138 -34
  77. package/dist/backend/llvm/emit-statements.js.map +1 -1
  78. package/dist/backend/llvm/emitter.d.ts +142 -10
  79. package/dist/backend/llvm/emitter.js +523 -73
  80. package/dist/backend/llvm/emitter.js.map +1 -1
  81. package/dist/backend/llvm/emitter.test.js +31 -3
  82. package/dist/backend/llvm/emitter.test.js.map +1 -1
  83. package/dist/backend/llvm/expr-async.js +19 -1
  84. package/dist/backend/llvm/expr-async.js.map +1 -1
  85. package/dist/backend/llvm/expr-bytes.js +16 -1
  86. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  87. package/dist/backend/llvm/expr-calls.d.ts +4 -1
  88. package/dist/backend/llvm/expr-calls.js +38 -6
  89. package/dist/backend/llvm/expr-calls.js.map +1 -1
  90. package/dist/backend/llvm/expr-dynamic.js +237 -23
  91. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  92. package/dist/backend/llvm/expr-primitives.js +123 -12
  93. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  94. package/dist/backend/llvm/expr-records.d.ts +1 -1
  95. package/dist/backend/llvm/expr-records.js +124 -56
  96. package/dist/backend/llvm/expr-records.js.map +1 -1
  97. package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
  98. package/dist/backend/llvm/expr-stream-bridges.js +59 -2
  99. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  100. package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
  101. package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
  102. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  103. package/dist/backend/llvm/integer-values.d.ts +2 -0
  104. package/dist/backend/llvm/integer-values.js +6 -0
  105. package/dist/backend/llvm/integer-values.js.map +1 -1
  106. package/dist/backend/llvm/js-groups.d.ts +21 -0
  107. package/dist/backend/llvm/js-groups.js +277 -0
  108. package/dist/backend/llvm/js-groups.js.map +1 -0
  109. package/dist/backend/llvm/js-ic.d.ts +57 -1
  110. package/dist/backend/llvm/js-ic.js +389 -22
  111. package/dist/backend/llvm/js-ic.js.map +1 -1
  112. package/dist/backend/llvm/lib-dispatch.js +152 -1
  113. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  114. package/dist/backend/llvm/lib-filesystem.js +116 -11
  115. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  116. package/dist/backend/llvm/lib-network.js +33 -6
  117. package/dist/backend/llvm/lib-network.js.map +1 -1
  118. package/dist/backend/llvm/lib-process.js +180 -27
  119. package/dist/backend/llvm/lib-process.js.map +1 -1
  120. package/dist/backend/llvm/lib-shared.js +139 -2
  121. package/dist/backend/llvm/lib-shared.js.map +1 -1
  122. package/dist/backend/llvm/lib-stream.js +67 -0
  123. package/dist/backend/llvm/lib-stream.js.map +1 -1
  124. package/dist/backend/llvm/local-union-storage.test.js +32 -0
  125. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  126. package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
  127. package/dist/backend/llvm/loop-entry-versions.js +43 -21
  128. package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
  129. package/dist/backend/llvm/loop-state.d.ts +7 -1
  130. package/dist/backend/llvm/loop-state.js +26 -3
  131. package/dist/backend/llvm/loop-state.js.map +1 -1
  132. package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
  133. package/dist/backend/llvm/map-entry-fusion.js +3 -3
  134. package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
  135. package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
  136. package/dist/backend/llvm/map-number-lookup.js +7 -3
  137. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  138. package/dist/backend/llvm/map-number-lookup.test.js +58 -17
  139. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  140. package/dist/backend/llvm/nullable-unions.js +7 -6
  141. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  142. package/dist/backend/llvm/nullable-unions.test.js +4 -1
  143. package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
  144. package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
  145. package/dist/backend/llvm/receiver-brackets.test.js +68 -0
  146. package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
  147. package/dist/backend/llvm/receivers.js +3 -0
  148. package/dist/backend/llvm/receivers.js.map +1 -1
  149. package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
  150. package/dist/backend/llvm/record-entry-fusion.js +217 -0
  151. package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
  152. package/dist/backend/llvm/record-results.d.ts +5 -2
  153. package/dist/backend/llvm/record-results.js +13 -12
  154. package/dist/backend/llvm/record-results.js.map +1 -1
  155. package/dist/backend/llvm/record-views.d.ts +22 -2
  156. package/dist/backend/llvm/record-views.js +147 -12
  157. package/dist/backend/llvm/record-views.js.map +1 -1
  158. package/dist/backend/llvm/record-views.test.js +76 -0
  159. package/dist/backend/llvm/record-views.test.js.map +1 -1
  160. package/dist/backend/llvm/reference-effects.js +1 -0
  161. package/dist/backend/llvm/reference-effects.js.map +1 -1
  162. package/dist/backend/llvm/reference-writes.js +4 -0
  163. package/dist/backend/llvm/reference-writes.js.map +1 -1
  164. package/dist/backend/llvm/region-ir.js +1 -0
  165. package/dist/backend/llvm/region-ir.js.map +1 -1
  166. package/dist/backend/llvm/region-sites.d.ts +18 -0
  167. package/dist/backend/llvm/region-sites.js +79 -1
  168. package/dist/backend/llvm/region-sites.js.map +1 -1
  169. package/dist/backend/llvm/runtime-registries.test.js +53 -6
  170. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  171. package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
  172. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  173. package/dist/backend/llvm/shapes.d.ts +36 -3
  174. package/dist/backend/llvm/shapes.js +201 -16
  175. package/dist/backend/llvm/shapes.js.map +1 -1
  176. package/dist/backend/llvm/shapes.test.js +4 -0
  177. package/dist/backend/llvm/shapes.test.js.map +1 -1
  178. package/dist/backend/llvm/speculative-integers.d.ts +10 -1
  179. package/dist/backend/llvm/speculative-integers.js +59 -8
  180. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  181. package/dist/backend/llvm/stack-objects.d.ts +1 -2
  182. package/dist/backend/llvm/stack-objects.js +8 -5
  183. package/dist/backend/llvm/stack-objects.js.map +1 -1
  184. package/dist/backend/llvm/unwind-abi.d.ts +3 -3
  185. package/dist/backend/llvm/unwind-abi.js +8 -3
  186. package/dist/backend/llvm/unwind-abi.js.map +1 -1
  187. package/dist/backend/llvm/walkers.d.ts +12 -0
  188. package/dist/backend/llvm/walkers.js +47 -3
  189. package/dist/backend/llvm/walkers.js.map +1 -1
  190. package/dist/backend/may-throw.js +12 -2
  191. package/dist/backend/may-throw.js.map +1 -1
  192. package/dist/backend/may-throw.test.js +13 -0
  193. package/dist/backend/may-throw.test.js.map +1 -1
  194. package/dist/backend/native/contracts.d.ts +94 -0
  195. package/dist/backend/native/executable.js +134 -10
  196. package/dist/backend/native/executable.js.map +1 -1
  197. package/dist/backend/native/helper-identity-record.d.ts +11 -0
  198. package/dist/backend/native/helper-identity-record.js +76 -0
  199. package/dist/backend/native/helper-identity-record.js.map +1 -0
  200. package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
  201. package/dist/backend/native/helper-identity-record.test.js +101 -0
  202. package/dist/backend/native/helper-identity-record.test.js.map +1 -0
  203. package/dist/backend/native/library.js +10 -2
  204. package/dist/backend/native/library.js.map +1 -1
  205. package/dist/backend/native/runtime-inputs.js +8 -1
  206. package/dist/backend/native/runtime-inputs.js.map +1 -1
  207. package/dist/backend/native/vendor.d.ts +1 -1
  208. package/dist/backend/native/vendor.js +1 -1
  209. package/dist/backend/native/vendor.js.map +1 -1
  210. package/dist/backend/native-codegen-core.d.ts +13 -10
  211. package/dist/backend/native-codegen-core.js +26 -13
  212. package/dist/backend/native-codegen-core.js.map +1 -1
  213. package/dist/backend/native-codegen.js +30 -8
  214. package/dist/backend/native-codegen.js.map +1 -1
  215. package/dist/backend/native-codegen.test.js +110 -14
  216. package/dist/backend/native-codegen.test.js.map +1 -1
  217. package/dist/backend/native-link-info-core.d.ts +72 -0
  218. package/dist/backend/native-link-info-core.js.map +1 -1
  219. package/dist/backend/native-link-info.js +1 -0
  220. package/dist/backend/native-link-info.js.map +1 -1
  221. package/dist/backend/native-profile.d.ts +4 -1
  222. package/dist/backend/native-profile.js +12 -1
  223. package/dist/backend/native-profile.js.map +1 -1
  224. package/dist/backend/native-profile.test.js +10 -0
  225. package/dist/backend/native-profile.test.js.map +1 -1
  226. package/dist/backend/publication.d.ts +4 -1
  227. package/dist/backend/publication.js +4 -2
  228. package/dist/backend/publication.js.map +1 -1
  229. package/dist/backend/runtime-abi.d.ts +2 -2
  230. package/dist/backend/runtime-abi.js +2 -2
  231. package/dist/backend/runtime-pack-core.d.ts +46 -7
  232. package/dist/backend/runtime-pack-core.js +37 -2
  233. package/dist/backend/runtime-pack-core.js.map +1 -1
  234. package/dist/backend/runtime-pack-native.d.ts +18 -1
  235. package/dist/backend/runtime-pack-native.js +138 -29
  236. package/dist/backend/runtime-pack-native.js.map +1 -1
  237. package/dist/backend/runtime-pack-native.test.js +166 -4
  238. package/dist/backend/runtime-pack-native.test.js.map +1 -1
  239. package/dist/backend/runtime-pack-targets.test.js +3 -1
  240. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  241. package/dist/backend/runtime-pack.d.ts +7 -0
  242. package/dist/backend/runtime-pack.js +25 -3
  243. package/dist/backend/runtime-pack.js.map +1 -1
  244. package/dist/backend/runtime-pack.test.js +213 -12
  245. package/dist/backend/runtime-pack.test.js.map +1 -1
  246. package/dist/backend/tree-classes.d.ts +42 -0
  247. package/dist/backend/tree-classes.js +723 -0
  248. package/dist/backend/tree-classes.js.map +1 -0
  249. package/dist/backend/tree-classes.test.d.ts +1 -0
  250. package/dist/backend/tree-classes.test.js +338 -0
  251. package/dist/backend/tree-classes.test.js.map +1 -0
  252. package/dist/backend/vendor-archives.d.ts +8 -1
  253. package/dist/backend/vendor-archives.js +313 -8
  254. package/dist/backend/vendor-archives.js.map +1 -1
  255. package/dist/backend/vendor-inputs.d.ts +60 -3
  256. package/dist/backend/vendor-inputs.js +109 -3
  257. package/dist/backend/vendor-inputs.js.map +1 -1
  258. package/dist/backend/vendor-inputs.test.js +62 -1
  259. package/dist/backend/vendor-inputs.test.js.map +1 -1
  260. package/dist/backend/warm-cache.js +2 -0
  261. package/dist/backend/warm-cache.js.map +1 -1
  262. package/dist/compat/fetch-profile.d.ts +7 -1
  263. package/dist/compat/fetch-profile.js +25 -12
  264. package/dist/compat/fetch-profile.js.map +1 -1
  265. package/dist/compile-types.d.ts +7 -0
  266. package/dist/contracts/check.d.ts +3 -0
  267. package/dist/contracts/check.js +18 -5
  268. package/dist/contracts/check.js.map +1 -1
  269. package/dist/coverage/report.js +47 -0
  270. package/dist/coverage/report.js.map +1 -1
  271. package/dist/coverage/surface-manifest.js +1 -1
  272. package/dist/coverage/surface-manifest.js.map +1 -1
  273. package/dist/diagnostics/codes.d.ts +14 -0
  274. package/dist/diagnostics/codes.js +14 -0
  275. package/dist/diagnostics/codes.js.map +1 -1
  276. package/dist/diagnostics/diagnostic.d.ts +68 -0
  277. package/dist/diagnostics/diagnostic.js +186 -6
  278. package/dist/diagnostics/diagnostic.js.map +1 -1
  279. package/dist/diagnostics/dynamic-tier.js +3 -1
  280. package/dist/diagnostics/dynamic-tier.js.map +1 -1
  281. package/dist/diagnostics/envelope.d.ts +18 -0
  282. package/dist/diagnostics/envelope.js.map +1 -1
  283. package/dist/executable/executable-cache.d.ts +48 -0
  284. package/dist/executable/executable-cache.js +38 -0
  285. package/dist/executable/executable-cache.js.map +1 -1
  286. package/dist/executable/executable-cache.test.js +127 -1
  287. package/dist/executable/executable-cache.test.js.map +1 -1
  288. package/dist/executable/prepare.d.ts +13 -3
  289. package/dist/executable/prepare.js +438 -234
  290. package/dist/executable/prepare.js.map +1 -1
  291. package/dist/frontend/analysis.js +200 -18
  292. package/dist/frontend/analysis.js.map +1 -1
  293. package/dist/frontend/builtin-modules.d.ts +4 -0
  294. package/dist/frontend/builtin-modules.js +10 -0
  295. package/dist/frontend/builtin-modules.js.map +1 -1
  296. package/dist/frontend/early-errors.d.ts +24 -0
  297. package/dist/frontend/early-errors.js +836 -0
  298. package/dist/frontend/early-errors.js.map +1 -0
  299. package/dist/frontend/early-errors.test.d.ts +1 -0
  300. package/dist/frontend/early-errors.test.js +207 -0
  301. package/dist/frontend/early-errors.test.js.map +1 -0
  302. package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
  303. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  304. package/dist/frontend/input-tracker.d.ts +47 -0
  305. package/dist/frontend/input-tracker.js +173 -36
  306. package/dist/frontend/input-tracker.js.map +1 -1
  307. package/dist/frontend/input-tracker.test.js +86 -2
  308. package/dist/frontend/input-tracker.test.js.map +1 -1
  309. package/dist/frontend/js-inference.d.ts +2 -0
  310. package/dist/frontend/js-inference.js +18 -0
  311. package/dist/frontend/js-inference.js.map +1 -0
  312. package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
  313. package/dist/frontend/jsx-opinion-sites.test.js +86 -0
  314. package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
  315. package/dist/frontend/lib-exports.d.ts +23 -4
  316. package/dist/frontend/lib-exports.js +98 -26
  317. package/dist/frontend/lib-exports.js.map +1 -1
  318. package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
  319. package/dist/frontend/lowering/binding-analysis.js +86 -4
  320. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  321. package/dist/frontend/lowering/buffers.d.ts +8 -0
  322. package/dist/frontend/lowering/buffers.js +43 -0
  323. package/dist/frontend/lowering/buffers.js.map +1 -0
  324. package/dist/frontend/lowering/builtin-calls.js +13 -0
  325. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  326. package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
  327. package/dist/frontend/lowering/builtin-namespaces.js +41 -3
  328. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  329. package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
  330. package/dist/frontend/lowering/builtin-statics.js +407 -0
  331. package/dist/frontend/lowering/builtin-statics.js.map +1 -0
  332. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  333. package/dist/frontend/lowering/builtins/arguments.js +12 -0
  334. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  335. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
  336. package/dist/frontend/lowering/builtins/atomics.js +87 -1
  337. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  338. package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
  339. package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
  340. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  341. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
  342. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
  343. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  344. package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
  345. package/dist/frontend/lowering/builtins/child-process.js +565 -28
  346. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  347. package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
  348. package/dist/frontend/lowering/builtins/compression.js +41 -21
  349. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  350. package/dist/frontend/lowering/builtins/constants.js +7 -2
  351. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  352. package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
  353. package/dist/frontend/lowering/builtins/dates.js +23 -1
  354. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  355. package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
  356. package/dist/frontend/lowering/builtins/environment.js +213 -2
  357. package/dist/frontend/lowering/builtins/environment.js.map +1 -1
  358. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
  359. package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
  360. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  361. package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
  362. package/dist/frontend/lowering/builtins/filesystem.js +185 -16
  363. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  364. package/dist/frontend/lowering/builtins/json.js +4 -0
  365. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  366. package/dist/frontend/lowering/builtins/module-calls.js +42 -3
  367. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  368. package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
  369. package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
  370. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
  371. package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
  372. package/dist/frontend/lowering/builtins/numbers.js +10 -2
  373. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  374. package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
  375. package/dist/frontend/lowering/builtins/operating-system.js +101 -20
  376. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  377. package/dist/frontend/lowering/builtins/process.d.ts +18 -2
  378. package/dist/frontend/lowering/builtins/process.js +386 -25
  379. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  380. package/dist/frontend/lowering/builtins/promises.js +169 -8
  381. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  382. package/dist/frontend/lowering/builtins/properties.js +6 -2
  383. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  384. package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
  385. package/dist/frontend/lowering/builtins/querystring.js +202 -18
  386. package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
  387. package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
  388. package/dist/frontend/lowering/builtins/readline.js +200 -38
  389. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  390. package/dist/frontend/lowering/builtins/reflection.js +60 -1
  391. package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
  392. package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
  393. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  394. package/dist/frontend/lowering/builtins/url.js +55 -13
  395. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  396. package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
  397. package/dist/frontend/lowering/builtins/v8.js +7 -5
  398. package/dist/frontend/lowering/builtins/v8.js.map +1 -1
  399. package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
  400. package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
  401. package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
  402. package/dist/frontend/lowering/builtins/webassembly.js +2 -0
  403. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  404. package/dist/frontend/lowering/call-arguments.d.ts +10 -0
  405. package/dist/frontend/lowering/call-arguments.js +37 -2
  406. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  407. package/dist/frontend/lowering/call-signatures.d.ts +10 -0
  408. package/dist/frontend/lowering/call-signatures.js +180 -0
  409. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  410. package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
  411. package/dist/frontend/lowering/cjs-exports-object.js +1 -1
  412. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  413. package/dist/frontend/lowering/cjs-inline-require.js +5 -0
  414. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  415. package/dist/frontend/lowering/class-construction.d.ts +14 -2
  416. package/dist/frontend/lowering/class-construction.js +99 -5
  417. package/dist/frontend/lowering/class-construction.js.map +1 -1
  418. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
  419. package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
  420. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  421. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
  422. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  423. package/dist/frontend/lowering/class-protocols.js +59 -10
  424. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  425. package/dist/frontend/lowering/class-prototypes.js +20 -15
  426. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  427. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  428. package/dist/frontend/lowering/class-runtime-statics.js +35 -1
  429. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  430. package/dist/frontend/lowering/class-unions.js +21 -4
  431. package/dist/frontend/lowering/class-unions.js.map +1 -1
  432. package/dist/frontend/lowering/class-views.d.ts +13 -0
  433. package/dist/frontend/lowering/class-views.js +51 -0
  434. package/dist/frontend/lowering/class-views.js.map +1 -0
  435. package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
  436. package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
  437. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  438. package/dist/frontend/lowering/coercions/state.d.ts +15 -0
  439. package/dist/frontend/lowering/coercions/state.js +24 -0
  440. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  441. package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
  442. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  443. package/dist/frontend/lowering/coercions/structural.js +39 -2
  444. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  445. package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
  446. package/dist/frontend/lowering/coercions/unions.js +54 -10
  447. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  448. package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
  449. package/dist/frontend/lowering/constructor-returns.js +284 -58
  450. package/dist/frontend/lowering/constructor-returns.js.map +1 -1
  451. package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
  452. package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
  453. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  454. package/dist/frontend/lowering/containers/array-construction.js +37 -8
  455. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  456. package/dist/frontend/lowering/containers/array-from-async.js +139 -3
  457. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
  458. package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
  459. package/dist/frontend/lowering/containers/array-iteration.js +24 -7
  460. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
  461. package/dist/frontend/lowering/containers/array-methods.js +30 -11
  462. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  463. package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
  464. package/dist/frontend/lowering/containers/bytes.js +450 -86
  465. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  466. package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
  467. package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
  468. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  469. package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
  470. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  471. package/dist/frontend/lowering/containers/collection-methods.js +52 -17
  472. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  473. package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
  474. package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
  475. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
  476. package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
  477. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  478. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
  479. package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
  480. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  481. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
  482. package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
  483. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  484. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  485. package/dist/frontend/lowering/crypto-tables.js +5 -5
  486. package/dist/frontend/lowering/dispatch-sites.js +3 -0
  487. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  488. package/dist/frontend/lowering/divergences.d.ts +40 -0
  489. package/dist/frontend/lowering/divergences.js +239 -20
  490. package/dist/frontend/lowering/divergences.js.map +1 -1
  491. package/dist/frontend/lowering/effect-free.d.ts +12 -0
  492. package/dist/frontend/lowering/effect-free.js +44 -0
  493. package/dist/frontend/lowering/effect-free.js.map +1 -0
  494. package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
  495. package/dist/frontend/lowering/expressions/array-literals.js +88 -10
  496. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  497. package/dist/frontend/lowering/expressions/binary.js +216 -14
  498. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  499. package/dist/frontend/lowering/expressions/element-access.js +272 -11
  500. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  501. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
  502. package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
  503. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  504. package/dist/frontend/lowering/expressions/identifiers.js +173 -4
  505. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  506. package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
  507. package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
  508. package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
  509. package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
  510. package/dist/frontend/lowering/expressions/narrowing.js +195 -18
  511. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  512. package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
  513. package/dist/frontend/lowering/expressions/object-literals.js +951 -240
  514. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  515. package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
  516. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  517. package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
  518. package/dist/frontend/lowering/expressions/property-access.js +1141 -87
  519. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  520. package/dist/frontend/lowering/expressions/relational.js +262 -4
  521. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  522. package/dist/frontend/lowering/expressions/typeof.js +25 -0
  523. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  524. package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
  525. package/dist/frontend/lowering/expressions/union-fields.js +103 -13
  526. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  527. package/dist/frontend/lowering/expressions/updates.js +156 -22
  528. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  529. package/dist/frontend/lowering/frozen-records.d.ts +6 -0
  530. package/dist/frontend/lowering/frozen-records.js +10 -4
  531. package/dist/frontend/lowering/frozen-records.js.map +1 -1
  532. package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
  533. package/dist/frontend/lowering/frozen-records.test.js +44 -0
  534. package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
  535. package/dist/frontend/lowering/function-names.d.ts +9 -0
  536. package/dist/frontend/lowering/function-names.js +95 -0
  537. package/dist/frontend/lowering/function-names.js.map +1 -0
  538. package/dist/frontend/lowering/function-returns.js +42 -13
  539. package/dist/frontend/lowering/function-returns.js.map +1 -1
  540. package/dist/frontend/lowering/general-streams.js +5 -0
  541. package/dist/frontend/lowering/general-streams.js.map +1 -1
  542. package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
  543. package/dist/frontend/lowering/generator-delegation.js +301 -118
  544. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  545. package/dist/frontend/lowering/generic-functions.d.ts +75 -0
  546. package/dist/frontend/lowering/generic-functions.js +790 -18
  547. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  548. package/dist/frontend/lowering/global-function-values.d.ts +25 -0
  549. package/dist/frontend/lowering/global-function-values.js +193 -0
  550. package/dist/frontend/lowering/global-function-values.js.map +1 -0
  551. package/dist/frontend/lowering/global-values.d.ts +15 -4
  552. package/dist/frontend/lowering/global-values.js +67 -9
  553. package/dist/frontend/lowering/global-values.js.map +1 -1
  554. package/dist/frontend/lowering/handle-properties.js +34 -1
  555. package/dist/frontend/lowering/handle-properties.js.map +1 -1
  556. package/dist/frontend/lowering/host-global-values.d.ts +31 -0
  557. package/dist/frontend/lowering/host-global-values.js +121 -0
  558. package/dist/frontend/lowering/host-global-values.js.map +1 -0
  559. package/dist/frontend/lowering/host-globals.d.ts +74 -0
  560. package/dist/frontend/lowering/host-globals.js +344 -0
  561. package/dist/frontend/lowering/host-globals.js.map +1 -0
  562. package/dist/frontend/lowering/http2-constants.js +1 -1
  563. package/dist/frontend/lowering/iterator-adapters.js +46 -17
  564. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  565. package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
  566. package/dist/frontend/lowering/iterator-prototype.js +160 -0
  567. package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
  568. package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
  569. package/dist/frontend/lowering/key-order-witness.js +571 -9
  570. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  571. package/dist/frontend/lowering/key-order-witness.test.js +1 -0
  572. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  573. package/dist/frontend/lowering/lib-boundary.js +25 -3
  574. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  575. package/dist/frontend/lowering/lower-assert.js +140 -16
  576. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  577. package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
  578. package/dist/frontend/lowering/lower-async-iteration.js +15 -0
  579. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  580. package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
  581. package/dist/frontend/lowering/lower-builtin-values.js +342 -58
  582. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  583. package/dist/frontend/lowering/lower-calls.d.ts +47 -1
  584. package/dist/frontend/lowering/lower-calls.js +1354 -273
  585. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  586. package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
  587. package/dist/frontend/lowering/lower-calls.test.js +121 -0
  588. package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
  589. package/dist/frontend/lowering/lower-classes.d.ts +36 -5
  590. package/dist/frontend/lowering/lower-classes.js +630 -89
  591. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  592. package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
  593. package/dist/frontend/lowering/lower-event-emitter.js +610 -98
  594. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  595. package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
  596. package/dist/frontend/lowering/lower-exprs.js +96 -20
  597. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  598. package/dist/frontend/lowering/lower-functions.js +27 -6
  599. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  600. package/dist/frontend/lowering/lower-generators.js +57 -10
  601. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  602. package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
  603. package/dist/frontend/lowering/lower-global-value.js +14 -5
  604. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  605. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  606. package/dist/frontend/lowering/lower-inspect.js +713 -92
  607. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  608. package/dist/frontend/lowering/lower-modules.js +135 -27
  609. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  610. package/dist/frontend/lowering/lower-namespaces.js +18 -0
  611. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  612. package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
  613. package/dist/frontend/lowering/lower-node-island.js +472 -67
  614. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  615. package/dist/frontend/lowering/lower-server.js +463 -96
  616. package/dist/frontend/lowering/lower-server.js.map +1 -1
  617. package/dist/frontend/lowering/lower-shared-modules.js +13 -1
  618. package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
  619. package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
  620. package/dist/frontend/lowering/lower-stdlib.js +77 -18
  621. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  622. package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
  623. package/dist/frontend/lowering/lower-stmts.js +831 -136
  624. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  625. package/dist/frontend/lowering/lower-stream.js +126 -8
  626. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  627. package/dist/frontend/lowering/lower-timers.js +243 -48
  628. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  629. package/dist/frontend/lowering/lower-url.js +6 -3
  630. package/dist/frontend/lowering/lower-url.js.map +1 -1
  631. package/dist/frontend/lowering/lowerer.d.ts +363 -21
  632. package/dist/frontend/lowering/lowerer.js +1224 -129
  633. package/dist/frontend/lowering/lowerer.js.map +1 -1
  634. package/dist/frontend/lowering/lowerer.test.js +19 -1
  635. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  636. package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
  637. package/dist/frontend/lowering/lowering-facts.js +323 -0
  638. package/dist/frontend/lowering/lowering-facts.js.map +1 -0
  639. package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
  640. package/dist/frontend/lowering/lowering-facts.test.js +100 -0
  641. package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
  642. package/dist/frontend/lowering/module-namespace-elements.js +15 -0
  643. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  644. package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
  645. package/dist/frontend/lowering/nan-coded-reads.js +112 -9
  646. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
  647. package/dist/frontend/lowering/new-target.js +2 -2
  648. package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
  649. package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
  650. package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
  651. package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
  652. package/dist/frontend/lowering/optional-arguments.js +26 -2
  653. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  654. package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
  655. package/dist/frontend/lowering/partial-assertions.js +189 -0
  656. package/dist/frontend/lowering/partial-assertions.js.map +1 -0
  657. package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
  658. package/dist/frontend/lowering/primitive-throws.js +241 -0
  659. package/dist/frontend/lowering/primitive-throws.js.map +1 -0
  660. package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
  661. package/dist/frontend/lowering/primitive-wrappers.js +221 -0
  662. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
  663. package/dist/frontend/lowering/private-statics.d.ts +46 -0
  664. package/dist/frontend/lowering/private-statics.js +322 -0
  665. package/dist/frontend/lowering/private-statics.js.map +1 -0
  666. package/dist/frontend/lowering/record-inherited.d.ts +17 -1
  667. package/dist/frontend/lowering/record-inherited.js +16 -2
  668. package/dist/frontend/lowering/record-inherited.js.map +1 -1
  669. package/dist/frontend/lowering/record-links.d.ts +73 -0
  670. package/dist/frontend/lowering/record-links.js +797 -0
  671. package/dist/frontend/lowering/record-links.js.map +1 -0
  672. package/dist/frontend/lowering/record-sources.d.ts +12 -1
  673. package/dist/frontend/lowering/record-sources.js +60 -0
  674. package/dist/frontend/lowering/record-sources.js.map +1 -1
  675. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
  676. package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
  677. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
  678. package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
  679. package/dist/frontend/lowering/runtime-optional-report.js +300 -0
  680. package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
  681. package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
  682. package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
  683. package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
  684. package/dist/frontend/lowering/static-typeof.d.ts +3 -1
  685. package/dist/frontend/lowering/static-typeof.js +6 -1
  686. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  687. package/dist/frontend/lowering/strict-equality.d.ts +4 -0
  688. package/dist/frontend/lowering/strict-equality.js +14 -0
  689. package/dist/frontend/lowering/strict-equality.js.map +1 -1
  690. package/dist/frontend/lowering/strict-mode.d.ts +1 -5
  691. package/dist/frontend/lowering/strict-mode.js +4 -30
  692. package/dist/frontend/lowering/strict-mode.js.map +1 -1
  693. package/dist/frontend/lowering/structural-instances.d.ts +7 -0
  694. package/dist/frontend/lowering/structural-instances.js +23 -0
  695. package/dist/frontend/lowering/structural-instances.js.map +1 -1
  696. package/dist/frontend/lowering/surfaces.d.ts +42 -1
  697. package/dist/frontend/lowering/surfaces.js +212 -71
  698. package/dist/frontend/lowering/surfaces.js.map +1 -1
  699. package/dist/frontend/lowering/union-retag.d.ts +13 -1
  700. package/dist/frontend/lowering/union-retag.js +55 -1
  701. package/dist/frontend/lowering/union-retag.js.map +1 -1
  702. package/dist/frontend/lowering/union-retag.test.js +51 -0
  703. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  704. package/dist/frontend/lowering/unit-journal.d.ts +136 -17
  705. package/dist/frontend/lowering/unit-journal.js +324 -53
  706. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  707. package/dist/frontend/lowering/unit-journal.test.js +126 -3
  708. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  709. package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
  710. package/dist/frontend/lowering/unit-reuse.js +1008 -0
  711. package/dist/frontend/lowering/unit-reuse.js.map +1 -0
  712. package/dist/frontend/lowering/width-lift.d.ts +12 -0
  713. package/dist/frontend/lowering/zlib-constants.js +3 -2
  714. package/dist/frontend/lowering/zlib-constants.js.map +1 -1
  715. package/dist/frontend/npm-file-import.test.d.ts +1 -0
  716. package/dist/frontend/npm-file-import.test.js +76 -0
  717. package/dist/frontend/npm-file-import.test.js.map +1 -0
  718. package/dist/frontend/npm-static.js +95 -11
  719. package/dist/frontend/npm-static.js.map +1 -1
  720. package/dist/frontend/npm-static.test.js +95 -2
  721. package/dist/frontend/npm-static.test.js.map +1 -1
  722. package/dist/frontend/npm.d.ts +9 -0
  723. package/dist/frontend/npm.js +82 -0
  724. package/dist/frontend/npm.js.map +1 -1
  725. package/dist/frontend/pipeline-native.js +2 -1
  726. package/dist/frontend/pipeline-native.js.map +1 -1
  727. package/dist/frontend/pipeline.d.ts +9 -4
  728. package/dist/frontend/pipeline.js +162 -38
  729. package/dist/frontend/pipeline.js.map +1 -1
  730. package/dist/frontend/pipeline.test.js +68 -11
  731. package/dist/frontend/pipeline.test.js.map +1 -1
  732. package/dist/frontend/program-node.d.ts +3 -0
  733. package/dist/frontend/program-node.js +13 -6
  734. package/dist/frontend/program-node.js.map +1 -1
  735. package/dist/frontend/program.d.ts +71 -2
  736. package/dist/frontend/program.js +836 -411
  737. package/dist/frontend/program.js.map +1 -1
  738. package/dist/frontend/program.test.js +37 -1
  739. package/dist/frontend/program.test.js.map +1 -1
  740. package/dist/frontend/provenance-core.js +4 -0
  741. package/dist/frontend/provenance-core.js.map +1 -1
  742. package/dist/frontend/services-node.d.ts +7 -0
  743. package/dist/frontend/services-node.js +32 -1
  744. package/dist/frontend/services-node.js.map +1 -1
  745. package/dist/frontend/services-node.test.js +51 -0
  746. package/dist/frontend/services-node.test.js.map +1 -1
  747. package/dist/frontend/services.d.ts +14 -0
  748. package/dist/frontend/services.js +52 -2
  749. package/dist/frontend/services.js.map +1 -1
  750. package/dist/frontend/services.test.js +61 -1
  751. package/dist/frontend/services.test.js.map +1 -1
  752. package/dist/frontend/shape-inference/analyze.d.ts +5 -0
  753. package/dist/frontend/shape-inference/analyze.js +104 -4
  754. package/dist/frontend/shape-inference/analyze.js.map +1 -1
  755. package/dist/frontend/shape-inference/domain.js +0 -1
  756. package/dist/frontend/shape-inference/domain.js.map +1 -1
  757. package/dist/frontend/shape-inference/index.js +5 -1
  758. package/dist/frontend/shape-inference/index.js.map +1 -1
  759. package/dist/frontend/shape-inference/memo.d.ts +2 -1
  760. package/dist/frontend/shape-inference/memo.js +6 -2
  761. package/dist/frontend/shape-inference/memo.js.map +1 -1
  762. package/dist/frontend/shape-inference/overlay.d.ts +1 -1
  763. package/dist/frontend/shape-inference/overlay.js +184 -4
  764. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  765. package/dist/frontend/shape-inference/static-objects.js +11 -6
  766. package/dist/frontend/shape-inference/static-objects.js.map +1 -1
  767. package/dist/frontend/source-phase-imports.test.d.ts +1 -0
  768. package/dist/frontend/source-phase-imports.test.js +37 -0
  769. package/dist/frontend/source-phase-imports.test.js.map +1 -0
  770. package/dist/frontend/tier-analysis.d.ts +9 -0
  771. package/dist/frontend/tier-analysis.js +1 -0
  772. package/dist/frontend/tier-analysis.js.map +1 -1
  773. package/dist/frontend/ts7/ast-node.d.ts +6 -1
  774. package/dist/frontend/ts7/ast-node.js +12 -0
  775. package/dist/frontend/ts7/ast-node.js.map +1 -1
  776. package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
  777. package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
  778. package/dist/frontend/ts7/ast-wire.js +3 -5
  779. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  780. package/dist/frontend/ts7/checker-backend.d.ts +13 -0
  781. package/dist/frontend/ts7/checker-backend.js +84 -2
  782. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  783. package/dist/frontend/ts7/checker-backend.test.js +126 -2
  784. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  785. package/dist/frontend/ts7/program-host.d.ts +22 -1
  786. package/dist/frontend/ts7/program-host.js +49 -4
  787. package/dist/frontend/ts7/program-host.js.map +1 -1
  788. package/dist/frontend/ts7/program-host.test.js +83 -0
  789. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  790. package/dist/frontend/ts7/rpc-process.d.ts +16 -1
  791. package/dist/frontend/ts7/rpc-process.js +170 -92
  792. package/dist/frontend/ts7/rpc-process.js.map +1 -1
  793. package/dist/frontend/ts7/rpc-process.test.js +49 -21
  794. package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
  795. package/dist/frontend/tsc-codes.d.ts +57 -3
  796. package/dist/frontend/tsc-codes.js +956 -101
  797. package/dist/frontend/tsc-codes.js.map +1 -1
  798. package/dist/frontend/tsc-codes.test.js +221 -12
  799. package/dist/frontend/tsc-codes.test.js.map +1 -1
  800. package/dist/frontend/type-mapper.d.ts +98 -11
  801. package/dist/frontend/type-mapper.js +770 -182
  802. package/dist/frontend/type-mapper.js.map +1 -1
  803. package/dist/index.d.ts +1 -1
  804. package/dist/index.js +224 -15
  805. package/dist/index.js.map +1 -1
  806. package/dist/index.test.d.ts +1 -0
  807. package/dist/index.test.js +60 -0
  808. package/dist/index.test.js.map +1 -0
  809. package/dist/ir/api.d.ts +1 -1
  810. package/dist/ir/api.js +1 -1
  811. package/dist/ir/api.js.map +1 -1
  812. package/dist/ir/build.d.ts +3 -2
  813. package/dist/ir/build.js +4 -2
  814. package/dist/ir/build.js.map +1 -1
  815. package/dist/ir/builtin-effects.js +96 -0
  816. package/dist/ir/builtin-effects.js.map +1 -1
  817. package/dist/ir/builtin-signatures.d.ts +1 -1
  818. package/dist/ir/builtin-signatures.js +453 -26
  819. package/dist/ir/builtin-signatures.js.map +1 -1
  820. package/dist/ir/callback-specialization.d.ts +3 -2
  821. package/dist/ir/callback-specialization.js +35 -25
  822. package/dist/ir/callback-specialization.js.map +1 -1
  823. package/dist/ir/capture-values.d.ts +8 -4
  824. package/dist/ir/capture-values.js +9 -6
  825. package/dist/ir/capture-values.js.map +1 -1
  826. package/dist/ir/char-unit-locals.d.ts +6 -2
  827. package/dist/ir/char-unit-locals.js +11 -2
  828. package/dist/ir/char-unit-locals.js.map +1 -1
  829. package/dist/ir/class-key-index.d.ts +18 -0
  830. package/dist/ir/class-key-index.js +29 -0
  831. package/dist/ir/class-key-index.js.map +1 -0
  832. package/dist/ir/class-key-index.test.d.ts +1 -0
  833. package/dist/ir/class-key-index.test.js +25 -0
  834. package/dist/ir/class-key-index.test.js.map +1 -0
  835. package/dist/ir/codec.d.ts +82 -0
  836. package/dist/ir/codec.generated.d.ts +13 -0
  837. package/dist/ir/codec.generated.js +5350 -0
  838. package/dist/ir/codec.generated.js.map +1 -0
  839. package/dist/ir/codec.js +325 -0
  840. package/dist/ir/codec.js.map +1 -0
  841. package/dist/ir/codec.test.d.ts +1 -0
  842. package/dist/ir/codec.test.js +225 -0
  843. package/dist/ir/codec.test.js.map +1 -0
  844. package/dist/ir/constant-globals.d.ts +5 -2
  845. package/dist/ir/constant-globals.js +25 -27
  846. package/dist/ir/constant-globals.js.map +1 -1
  847. package/dist/ir/expression-inlining.d.ts +4 -2
  848. package/dist/ir/expression-inlining.js +8 -2
  849. package/dist/ir/expression-inlining.js.map +1 -1
  850. package/dist/ir/field-values.d.ts +5 -2
  851. package/dist/ir/field-values.js +32 -21
  852. package/dist/ir/field-values.js.map +1 -1
  853. package/dist/ir/fields.generated.d.ts +29 -10
  854. package/dist/ir/fields.generated.js +1039 -11
  855. package/dist/ir/fields.generated.js.map +1 -1
  856. package/dist/ir/fields.test.js +46 -2
  857. package/dist/ir/fields.test.js.map +1 -1
  858. package/dist/ir/final-fields.js +1 -1
  859. package/dist/ir/final-fields.js.map +1 -1
  860. package/dist/ir/function-references.d.ts +6 -4
  861. package/dist/ir/function-references.js +11 -4
  862. package/dist/ir/function-references.js.map +1 -1
  863. package/dist/ir/function-references.test.js +14 -0
  864. package/dist/ir/function-references.test.js.map +1 -1
  865. package/dist/ir/init-only-globals.d.ts +4 -2
  866. package/dist/ir/init-only-globals.js +17 -18
  867. package/dist/ir/init-only-globals.js.map +1 -1
  868. package/dist/ir/inline-array-sources.js +4 -1
  869. package/dist/ir/inline-array-sources.js.map +1 -1
  870. package/dist/ir/inline-array-views.d.ts +13 -0
  871. package/dist/ir/inline-array-views.js +945 -0
  872. package/dist/ir/inline-array-views.js.map +1 -0
  873. package/dist/ir/inline-arrays.d.ts +7 -0
  874. package/dist/ir/inline-arrays.js +190 -55
  875. package/dist/ir/inline-arrays.js.map +1 -1
  876. package/dist/ir/inline-arrays.test.js +140 -2
  877. package/dist/ir/inline-arrays.test.js.map +1 -1
  878. package/dist/ir/int32-slots.js +7 -0
  879. package/dist/ir/int32-slots.js.map +1 -1
  880. package/dist/ir/integer-ranges.js +16 -6
  881. package/dist/ir/integer-ranges.js.map +1 -1
  882. package/dist/ir/ir.d.ts +130 -44
  883. package/dist/ir/ir.js +7 -0
  884. package/dist/ir/ir.js.map +1 -1
  885. package/dist/ir/js-groups.d.ts +51 -0
  886. package/dist/ir/js-groups.js +394 -0
  887. package/dist/ir/js-groups.js.map +1 -0
  888. package/dist/ir/js-groups.test.d.ts +1 -0
  889. package/dist/ir/js-groups.test.js +555 -0
  890. package/dist/ir/js-groups.test.js.map +1 -0
  891. package/dist/ir/js-ic.d.ts +10 -9
  892. package/dist/ir/js-ic.js +58 -25
  893. package/dist/ir/js-ic.js.map +1 -1
  894. package/dist/ir/js-ic.test.js +37 -3
  895. package/dist/ir/js-ic.test.js.map +1 -1
  896. package/dist/ir/jsval.js +374 -63
  897. package/dist/ir/jsval.js.map +1 -1
  898. package/dist/ir/jsval.test.js +96 -2
  899. package/dist/ir/jsval.test.js.map +1 -1
  900. package/dist/ir/loop-entry-ranges.js +112 -9
  901. package/dist/ir/loop-entry-ranges.js.map +1 -1
  902. package/dist/ir/loop-entry-ranges.test.js +40 -0
  903. package/dist/ir/loop-entry-ranges.test.js.map +1 -1
  904. package/dist/ir/node-index.d.ts +23 -6
  905. package/dist/ir/node-index.js +126 -49
  906. package/dist/ir/node-index.js.map +1 -1
  907. package/dist/ir/numeric-call-specialization.d.ts +4 -2
  908. package/dist/ir/numeric-call-specialization.js +40 -26
  909. package/dist/ir/numeric-call-specialization.js.map +1 -1
  910. package/dist/ir/paired-while-loops.d.ts +4 -2
  911. package/dist/ir/paired-while-loops.js +8 -2
  912. package/dist/ir/paired-while-loops.js.map +1 -1
  913. package/dist/ir/parameter-versions.d.ts +13 -3
  914. package/dist/ir/parameter-versions.js +63 -40
  915. package/dist/ir/parameter-versions.js.map +1 -1
  916. package/dist/ir/property-bags.d.ts +4 -2
  917. package/dist/ir/property-bags.js +22 -17
  918. package/dist/ir/property-bags.js.map +1 -1
  919. package/dist/ir/receiver-readers.js +58 -2
  920. package/dist/ir/receiver-readers.js.map +1 -1
  921. package/dist/ir/row-pairs.d.ts +4 -2
  922. package/dist/ir/row-pairs.js +12 -11
  923. package/dist/ir/row-pairs.js.map +1 -1
  924. package/dist/ir/runtime-features.d.ts +139 -5
  925. package/dist/ir/runtime-features.js +397 -19
  926. package/dist/ir/runtime-features.js.map +1 -1
  927. package/dist/ir/runtime-features.test.js +135 -1
  928. package/dist/ir/runtime-features.test.js.map +1 -1
  929. package/dist/ir/runtime-jam-loops.d.ts +35 -0
  930. package/dist/ir/runtime-jam-loops.js +604 -0
  931. package/dist/ir/runtime-jam-loops.js.map +1 -0
  932. package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
  933. package/dist/ir/runtime-jam-loops.test.js +565 -0
  934. package/dist/ir/runtime-jam-loops.test.js.map +1 -0
  935. package/dist/ir/saturating-loop-jams.d.ts +11 -2
  936. package/dist/ir/saturating-loop-jams.js +56 -16
  937. package/dist/ir/saturating-loop-jams.js.map +1 -1
  938. package/dist/ir/saturating-loop-jams.test.js +39 -1
  939. package/dist/ir/saturating-loop-jams.test.js.map +1 -1
  940. package/dist/ir/scalar-records.d.ts +5 -2
  941. package/dist/ir/scalar-records.js +12 -2
  942. package/dist/ir/scalar-records.js.map +1 -1
  943. package/dist/ir/self-captures.d.ts +4 -2
  944. package/dist/ir/self-captures.js +40 -28
  945. package/dist/ir/self-captures.js.map +1 -1
  946. package/dist/ir/self-captures.test.js +15 -0
  947. package/dist/ir/self-captures.test.js.map +1 -1
  948. package/dist/ir/serialize.d.ts +8 -2
  949. package/dist/ir/serialize.js +92 -24
  950. package/dist/ir/serialize.js.map +1 -1
  951. package/dist/ir/serialize.test.js +26 -0
  952. package/dist/ir/serialize.test.js.map +1 -1
  953. package/dist/ir/tiers.js +1 -0
  954. package/dist/ir/tiers.js.map +1 -1
  955. package/dist/ir/traverse.js +4 -0
  956. package/dist/ir/traverse.js.map +1 -1
  957. package/dist/ir/typed-argument-clones.d.ts +30 -0
  958. package/dist/ir/typed-argument-clones.js +789 -0
  959. package/dist/ir/typed-argument-clones.js.map +1 -0
  960. package/dist/ir/union-arm-loops.d.ts +3 -0
  961. package/dist/ir/union-arm-loops.js +373 -0
  962. package/dist/ir/union-arm-loops.js.map +1 -0
  963. package/dist/ir/union-arm-loops.test.d.ts +1 -0
  964. package/dist/ir/union-arm-loops.test.js +230 -0
  965. package/dist/ir/union-arm-loops.test.js.map +1 -0
  966. package/dist/ir/validate.js +170 -22
  967. package/dist/ir/validate.js.map +1 -1
  968. package/dist/ir/validate.test.js +46 -0
  969. package/dist/ir/validate.test.js.map +1 -1
  970. package/dist/library/compiler-self-identity.d.ts +8 -2
  971. package/dist/library/compiler-self-identity.js +92 -18
  972. package/dist/library/compiler-self-identity.js.map +1 -1
  973. package/dist/library/compiler-self-identity.test.js +150 -3
  974. package/dist/library/compiler-self-identity.test.js.map +1 -1
  975. package/dist/library/int-infer.d.ts +5 -0
  976. package/dist/library/int-infer.js +15 -3
  977. package/dist/library/int-infer.js.map +1 -1
  978. package/dist/library/ir-policy.js +4 -0
  979. package/dist/library/ir-policy.js.map +1 -1
  980. package/dist/library/library-cache.d.ts +4 -0
  981. package/dist/library/library-cache.js +2 -0
  982. package/dist/library/library-cache.js.map +1 -1
  983. package/dist/library/library-cache.test.js +26 -0
  984. package/dist/library/library-cache.test.js.map +1 -1
  985. package/dist/library/prepare.js +99 -31
  986. package/dist/library/prepare.js.map +1 -1
  987. package/dist/native/cache.d.ts +7 -0
  988. package/dist/native/cache.js +49 -0
  989. package/dist/native/cache.js.map +1 -1
  990. package/dist/native/cache.test.js +13 -1
  991. package/dist/native/cache.test.js.map +1 -1
  992. package/dist/native/cli.js +2 -0
  993. package/dist/native/cli.js.map +1 -1
  994. package/dist/native/compiler.js +26 -5
  995. package/dist/native/compiler.js.map +1 -1
  996. package/dist/native/executable-cache-open.test.js +31 -5
  997. package/dist/native/executable-cache-open.test.js.map +1 -1
  998. package/dist/native/executable-cache.d.ts +6 -1
  999. package/dist/native/executable-cache.js +7 -1
  1000. package/dist/native/executable-cache.js.map +1 -1
  1001. package/dist/native/prepare.d.ts +3 -0
  1002. package/dist/native/prepare.js +74 -28
  1003. package/dist/native/prepare.js.map +1 -1
  1004. package/dist/native/prepare.test.js +25 -3
  1005. package/dist/native/prepare.test.js.map +1 -1
  1006. package/dist/native/sanitizer.js +63 -4
  1007. package/dist/native/sanitizer.js.map +1 -1
  1008. package/dist/native/sanitizer.test.js +93 -2
  1009. package/dist/native/sanitizer.test.js.map +1 -1
  1010. package/dist/native/toolchain.js +9 -2
  1011. package/dist/native/toolchain.js.map +1 -1
  1012. package/dist/node-islands/boundary.d.ts +37 -1
  1013. package/dist/node-islands/boundary.js +65 -7
  1014. package/dist/node-islands/boundary.js.map +1 -1
  1015. package/dist/node-islands/boundary.test.d.ts +1 -0
  1016. package/dist/node-islands/boundary.test.js +76 -0
  1017. package/dist/node-islands/boundary.test.js.map +1 -0
  1018. package/dist/node-islands/detect.d.ts +27 -1
  1019. package/dist/node-islands/detect.js +475 -40
  1020. package/dist/node-islands/detect.js.map +1 -1
  1021. package/dist/node-islands/detect.test.js +175 -4
  1022. package/dist/node-islands/detect.test.js.map +1 -1
  1023. package/dist/node-islands/effect-gate.js +30 -20
  1024. package/dist/node-islands/effect-gate.js.map +1 -1
  1025. package/dist/node-islands/effect-gate.test.js +4 -1
  1026. package/dist/node-islands/effect-gate.test.js.map +1 -1
  1027. package/dist/node-islands/graph-islands.d.ts +40 -0
  1028. package/dist/node-islands/graph-islands.js +128 -0
  1029. package/dist/node-islands/graph-islands.js.map +1 -0
  1030. package/dist/node-islands/growth.d.ts +57 -0
  1031. package/dist/node-islands/growth.js +205 -0
  1032. package/dist/node-islands/growth.js.map +1 -0
  1033. package/dist/node-islands/libnode.d.ts +1 -1
  1034. package/dist/node-islands/libnode.js +1 -1
  1035. package/dist/node-islands/libnode.js.map +1 -1
  1036. package/dist/node-islands/modules.d.ts +28 -0
  1037. package/dist/node-islands/modules.js +156 -0
  1038. package/dist/node-islands/modules.js.map +1 -1
  1039. package/dist/node-islands/modules.test.js +105 -1
  1040. package/dist/node-islands/modules.test.js.map +1 -1
  1041. package/dist/node-islands/policy.js +2 -3
  1042. package/dist/node-islands/policy.js.map +1 -1
  1043. package/dist/node-islands/probe-recorder.d.ts +1 -0
  1044. package/dist/node-islands/probe-recorder.js +596 -0
  1045. package/dist/node-islands/probe-recorder.js.map +1 -0
  1046. package/dist/node-islands/probe-recorder.test.d.ts +1 -0
  1047. package/dist/node-islands/probe-recorder.test.js +80 -0
  1048. package/dist/node-islands/probe-recorder.test.js.map +1 -0
  1049. package/dist/node-islands/report.d.ts +12 -0
  1050. package/dist/node-islands/report.js +28 -0
  1051. package/dist/node-islands/report.js.map +1 -1
  1052. package/dist/node-islands/report.test.js +4 -0
  1053. package/dist/node-islands/report.test.js.map +1 -1
  1054. package/dist/node-islands/rules.js +9 -0
  1055. package/dist/node-islands/rules.js.map +1 -1
  1056. package/dist/node-islands/scan.d.ts +16 -1
  1057. package/dist/node-islands/scan.js +110 -9
  1058. package/dist/node-islands/scan.js.map +1 -1
  1059. package/dist/node-islands/snapshot.d.ts +38 -1
  1060. package/dist/node-islands/snapshot.js +165 -161
  1061. package/dist/node-islands/snapshot.js.map +1 -1
  1062. package/dist/node-islands/snapshot.test.js +63 -2
  1063. package/dist/node-islands/snapshot.test.js.map +1 -1
  1064. package/dist/node-islands/summary.js +8 -0
  1065. package/dist/node-islands/summary.js.map +1 -1
  1066. package/dist/node-islands/type-strip.d.ts +11 -0
  1067. package/dist/node-islands/type-strip.js +157 -0
  1068. package/dist/node-islands/type-strip.js.map +1 -0
  1069. package/dist/node-islands/type-strip.test.d.ts +1 -0
  1070. package/dist/node-islands/type-strip.test.js +31 -0
  1071. package/dist/node-islands/type-strip.test.js.map +1 -0
  1072. package/dist/project-config.d.ts +4 -0
  1073. package/dist/project-config.js +19 -0
  1074. package/dist/project-config.js.map +1 -1
  1075. package/dist/project-config.test.js +10 -0
  1076. package/dist/project-config.test.js.map +1 -1
  1077. package/dist/wasm/translate.js +11 -5
  1078. package/dist/wasm/translate.js.map +1 -1
  1079. package/dist/wasm/translate.test.js +35 -0
  1080. package/dist/wasm/translate.test.js.map +1 -1
  1081. package/package.json +20 -20
  1082. package/surface-manifest.json +221 -122
@@ -1,23 +1,27 @@
1
- import { keepsInitializerLayout, notePreservedLayout } from "./structural-instances.js";
1
+ import { lowerStaticPrivateAssignment } from "./private-statics.js";
2
+ import { keepsCheckedDynamicValue, keepsInitializerLayout, notePreservedLayout, } from "./structural-instances.js";
3
+ import { partialFieldRead } from "./partial-assertions.js";
2
4
  import { jsGlobalValueByName } from "./global-values.js";
3
5
  import { lowerTupleAliasDecl, stripTypeWrappers } from "./typed-arguments.js";
4
- import { islandHandleBinding, lowerIslandExpr, lowerIslandSubclass } from "./lower-node-island.js";
6
+ import { islandHandleBinding, lowerIslandExpr, isIslandRequireSpec, lowerIslandRequireAtStatement, lowerIslandSubclass, } from "./lower-node-island.js";
5
7
  import { isIslandSubclassDecl } from "../../node-islands/boundary.js";
6
8
  import { allBytesArms, indexedUnionArms, lowerIndexedUnionMember, lowerIndexedUnionNumberRead, lowerIndexedUnionRead, } from "./indexed-unions.js";
7
- import { declaredMemberOf, isPromisePrototypeRead, lowerUnionKeyedRead, } from "./expressions/property-access.js";
8
- import { hostedStorageView, hostsAll } from "./expressions/hosted-narrowing.js";
9
+ import { declaredMemberOf, fenceDatePrototypeWrite, isPromisePrototypeRead, lowerUnionKeyedRead, } from "./expressions/property-access.js";
10
+ import { hostedStorageView, hostsAll, recordViewHosted } from "./expressions/hosted-narrowing.js";
11
+ import { assertionViewCopy, bindingIdentityUse, bindingWrite } from "./divergences.js";
9
12
  import { requestGeneralStreamSurface } from "./general-streams.js";
10
13
  import { lowerForAwaitDynStream, nodeStreamInterfaceSide } from "./dyn-streams.js";
11
14
  import { lowerForAwaitValueStream } from "./builtins/hash-stream.js";
12
15
  import { lowerChildPropertyWrite } from "./handle-properties.js";
13
16
  import { matchAllRowsReadByElements, storedMatchAllRowsReadByElements, } from "./containers/match-row-uses.js";
14
- import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
15
- import { runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
17
+ import { dynUndefinedExpr, nodeThrowExpr, numLit, strLit, varRef } from "../../ir/build.js";
18
+ import { literalFieldKeys, runtimeKeyPatternRead } from "./expressions/keyed-field-targets.js";
16
19
  import { declaresHoistedBinding, staticCondition } from "./static-typeof.js";
17
20
  import { lowerCollectionSpread } from "./containers/collection-methods.js";
18
21
  import { lowerEventObjectPropertyWrite } from "./lower-event-target.js";
19
22
  import { lowerDynObjectLiteral } from "./expressions/object-literals.js";
20
23
  import { importMetaBindingSource } from "./import-meta.js";
24
+ import { nullishEmptyPatternSource } from "./nullish-empty-pattern.js";
21
25
  import { anyResidueReplacedBy } from "./any-collection-residue.js";
22
26
  import { iteratorCanStep, iteratorValue } from "./iterator-consumption.js";
23
27
  import { notIterableSpelling } from "./iterable-spelling.js";
@@ -31,21 +35,23 @@ import { isWebStreamValueInJavaScript, typeInvolvesWebStream } from "./builtins/
31
35
  import * as ts from "../ts7/adapter.js";
32
36
  import { lowerOptionalIndex } from "./undefined-index.js";
33
37
  import { processDataMemberValue, programReadsExitCode } from "./builtins/process.js";
38
+ import { heldEnvValueType, refuseHeldEnvCopyHold } from "./builtins/environment.js";
34
39
  import { requireInitFlagStmt } from "./require-initialization.js";
35
40
  import { isJsonRequireDecl } from "./json-require.js";
36
41
  import { isTimeValueDateDeclaration } from "./date-values.js";
37
42
  import { bindingSource } from "../binding-source.js";
38
- import { lowerConstructorReturn } from "./constructor-returns.js";
43
+ import { clearPendingPrimitiveReturn, lowerConstructorReturn } from "./constructor-returns.js";
39
44
  import { statementGroupKey } from "./type-failure.js";
40
45
  import { cjsExportValueByName, cjsNamespaceDestructureOf, cjsTableMethodEntry, inlineProgramRequireOf, requireNestedPatternsOf, splitRequireAssignmentOf, splitRequireBindingOf, splitRequireBindingOfIdent, splitRequireEarlyReadOf, wholeExportSymbolOfModule, } from "./cjs-inline-require.js";
41
46
  import { cjsExportMemberWriteGlobalOf, isCjsExportsIdentifier, isCjsModuleExports, isFreshExportsReset, } from "./cjs-exports-object.js";
42
47
  import { isDeadTscHelperDecl, tscInteropBindingOfDecl } from "./cjs-tsc-interop.js";
43
48
  import { arrayValueRead, arrayValueStore, arrayValueType, unionArrayValueRead, lowerSafeIndexRead, } from "./array-values.js";
44
49
  import { lowerForAwaitGenerator, lowerForOfGenerator, lowerYieldStarStatement, } from "./lower-generators.js";
45
- import { classAsyncGeneratorIterator, lowerForAwaitBuiltin } from "./lower-async-iteration.js";
46
- import { BOOL, BYTES_U8, CAUGHT, DATE_T, DYN, F64, SEARCH_PARAMS_T, STRING, UNDEFINED_T, VOID, arrayOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
50
+ import { classAsyncGeneratorIterator, isNodeReadableIteratorSource, isWebReadableIteratorSource, lowerForAwaitBuiltin, } from "./lower-async-iteration.js";
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";
47
52
  import { PoisonError, boundIdentifiersOf, dynFallbackType, neverTaintedJsType, staticImportNamespaceType, } from "./lowerer.js";
48
53
  import { enforceLibBoundary, lowerSurplusCalls } from "./lib-boundary.js";
54
+ import { isBuiltinIdentityToken, isPrimitiveValueType, lowerPrimitiveBaseDelete, } from "./primitive-throws.js";
49
55
  import { cjsExportAssignmentOf, cjsExportChainOf, cjsVoidInitPreambleReals, cjsExportDiscardReason, cjsExportTargetLiteral, isCjsJsFile, isEsModuleStamp, isJsSourceFile, locOf, requireEarlyReference, requireSpecOf, } from "../program.js";
50
56
  import { isStrictCode } from "./strict-mode.js";
51
57
  import { markSloppyRecordWrites } from "./frozen-records.js";
@@ -58,7 +64,7 @@ import { lowerForOfArrayIter, lowerForOfMap, lowerForOfSearchParams, lowerForOfS
58
64
  import { lowerForOfHelperChain } from "./containers/iterator-helpers.js";
59
65
  import { objectIterOverIndexShape } from "./containers/indexed-objects.js";
60
66
  import { strCharsCall } from "./containers/array-construction.js";
61
- 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";
62
68
  import { bindingNeverReassigned, deadUnmappableBinding, fileWritesBinding, nullishExprUnitOf, nullishGenericBindingUnitOf, } from "./binding-analysis.js";
63
69
  import { hasExplicitJsDocReturn } from "./function-returns.js";
64
70
  import { recordKeysArrayCall } from "./lower-calls.js";
@@ -734,8 +740,11 @@ function lowerOneStatement(lowerer, stmt, out, usingMarkers, diagsBefore, deferF
734
740
  if (deferFences && lowerer.diagSink === null && lowerer.diags.length > diagsBefore) {
735
741
  const flushed = lowerer.diags.splice(diagsBefore);
736
742
  const ice = flushed.filter((d) => d.code === "SC9001");
737
- lowerer.diags.push(...ice);
738
- lowerer.runtimeFences.push(...flushed.filter((d) => d.code !== "SC9001"));
743
+ for (const d of ice)
744
+ lowerer.diags.push(d);
745
+ for (const d of flushed)
746
+ if (d.code !== "SC9001")
747
+ lowerer.runtimeFences.push(d);
739
748
  }
740
749
  }
741
750
  /** Whether a statement list belongs to a function body (at any block
@@ -883,6 +892,11 @@ export function predeclareForwardCapture(lowerer, symbol) {
883
892
  lowerer.isStdlibGlobal(decl.initializer.expression.expression, "Object"))) &&
884
893
  lowerer.dynConvertible(type))
885
894
  type = DYN;
895
+ // An island handle binding holds a checked-dynamic value whatever its
896
+ // declared type says: its own declaration lowers as one, and so must
897
+ // the slot a closure captured first.
898
+ if (islandHandleBinding(lowerer, decl.name))
899
+ type = DYN;
886
900
  if (!TDZ_KINDS.has(type.kind) || isUnitType(type))
887
901
  return false;
888
902
  const name = decl.name.text;
@@ -995,8 +1009,11 @@ export function predeclareForwardFnDecl(lowerer, symbol) {
995
1009
  }
996
1010
  catch (e) {
997
1011
  entry.ctx.hoistedFnDecls.delete(decl);
998
- if (previousSink !== null)
999
- previousSink.push(...lowerer.diags.splice(diagsBefore));
1012
+ if (previousSink !== null) {
1013
+ const flushed = lowerer.diags.splice(diagsBefore);
1014
+ for (const d of flushed)
1015
+ previousSink.push(d);
1016
+ }
1000
1017
  throw e;
1001
1018
  }
1002
1019
  finally {
@@ -1023,7 +1040,9 @@ function hostVariableDeclarationOf(name) {
1023
1040
  while (ts.isBindingElement(n) || ts.isArrayBindingPattern(n) || ts.isObjectBindingPattern(n)) {
1024
1041
  n = n.parent;
1025
1042
  }
1026
- return ts.isVariableDeclaration(n) ? n : null;
1043
+ // A catch parameter is a VariableDeclaration of the CatchClause: its
1044
+ // bindings are scoped to the clause, and each execution makes new ones.
1045
+ return ts.isVariableDeclaration(n) && !ts.isCatchClause(n.parent) ? n : null;
1027
1046
  }
1028
1047
  /** `for (var x of ...)` loop variables: the ONE function-scoped binding
1029
1048
  * every for-of desugar must ASSIGN per iteration instead of declaring a
@@ -1483,10 +1502,12 @@ const THROWN_AS_DYN = new Set([
1483
1502
  ]);
1484
1503
  /** A `return` at the top level of a CommonJS module (preflight admits it
1485
1504
  * there only): it ends the module's evaluation, and its value is
1486
- * evaluated and discarded, as Node's module wrapper does. Top-level
1487
- * bindings and export assignments after it would be left uninitialized
1488
- * where Node leaves them in their temporal dead zone or absent, so a
1489
- * module with any keeps a refusal. Null for a return inside a function. */
1505
+ * evaluated and discarded, as Node's module wrapper does. Bindings
1506
+ * declared after it stay uninitialized when it is taken, which only code
1507
+ * that exists by then can observe: a function created before the return,
1508
+ * or a hoisted function declaration. A module whose such functions read a
1509
+ * later binding, or that assigns exports after the return, keeps a
1510
+ * refusal. Null for a return inside a function. */
1490
1511
  function lowerModuleLevelReturn(lowerer, stmt) {
1491
1512
  let top = stmt;
1492
1513
  while (top.parent !== undefined && !ts.isSourceFile(top.parent)) {
@@ -1498,9 +1519,25 @@ function lowerModuleLevelReturn(lowerer, stmt) {
1498
1519
  if (sf === undefined || !ts.isSourceFile(sf))
1499
1520
  return null;
1500
1521
  const stmts = sf.statements.nodes;
1501
- const later = stmts.slice(stmts.indexOf(top) + 1);
1502
- if (later.some((s) => ts.isVariableStatement(s) || ts.isClassDeclaration(s) || cjsExportAssignmentOf(s) !== null)) {
1503
- lowerer.unsupported("SC1090", stmt, "a top-level return in a CommonJS module that declares variables or classes, or assigns exports, after it");
1522
+ const index = stmts.indexOf(top);
1523
+ const later = stmts.slice(index + 1);
1524
+ if (later.some((s) => cjsExportAssignmentOf(s) !== null)) {
1525
+ lowerer.unsupported("SC1090", stmt, "a top-level return in a CommonJS module that assigns exports after it");
1526
+ }
1527
+ const laterBindings = laterModuleBindings(lowerer, later);
1528
+ if (laterBindings.size > 0) {
1529
+ // Functions that exist when the return is taken: every function in the
1530
+ // statements up to the return, and the hoisted declarations after it.
1531
+ const reachable = [
1532
+ ...stmts.slice(0, index + 1),
1533
+ ...later.filter((s) => ts.isFunctionDeclaration(s)),
1534
+ ];
1535
+ const read = reachable
1536
+ .map((s) => functionReadOf(lowerer, s, laterBindings, ts.isFunctionDeclaration(s)))
1537
+ .find((r) => r !== null);
1538
+ if (read) {
1539
+ lowerer.unsupported("SC1090", read, `reading '${read.text}', declared after a top-level CommonJS return, from a function that can run once the return is taken`);
1540
+ }
1504
1541
  }
1505
1542
  const loc = locOf(stmt);
1506
1543
  const ret = { kind: "return", value: null, loc };
@@ -1512,6 +1549,50 @@ function lowerModuleLevelReturn(lowerer, stmt) {
1512
1549
  loc,
1513
1550
  };
1514
1551
  }
1552
+ /** The module-scope bindings `stmts` declare: variables and classes, with
1553
+ * `var` declarations in nested blocks. Bindings inside functions are not
1554
+ * module-scope and are skipped. */
1555
+ function laterModuleBindings(lowerer, stmts) {
1556
+ const bindings = new Set();
1557
+ const addName = (name) => {
1558
+ if (ts.isIdentifier(name)) {
1559
+ const symbol = lowerer.checker.getSymbolAtLocation(name);
1560
+ if (symbol)
1561
+ bindings.add(symbol);
1562
+ return;
1563
+ }
1564
+ for (const element of name.elements.nodes) {
1565
+ if (ts.isBindingElement(element) && element.name)
1566
+ addName(element.name);
1567
+ }
1568
+ };
1569
+ const visit = (node) => {
1570
+ if (ts.isFunctionLike(node) || ts.isClassStaticBlockDeclaration(node))
1571
+ return;
1572
+ if (ts.isVariableDeclaration(node))
1573
+ addName(node.name);
1574
+ if (ts.isClassDeclaration(node) && node.name)
1575
+ addName(node.name);
1576
+ ts.forEachChild(node, visit);
1577
+ };
1578
+ for (const stmt of stmts)
1579
+ visit(stmt);
1580
+ return bindings;
1581
+ }
1582
+ /** The first identifier inside a function or class in `node` (anywhere in
1583
+ * `node` when `inFunction`) that reads one of `bindings`, or null. */
1584
+ function functionReadOf(lowerer, node, bindings, inFunction) {
1585
+ if (inFunction && ts.isIdentifier(node)) {
1586
+ const symbol = lowerer.resolveValueSymbol(node);
1587
+ return symbol && bindings.has(symbol) ? node : null;
1588
+ }
1589
+ // Class bodies count as functions: field initializers run per instance.
1590
+ const nested = inFunction ||
1591
+ ts.isFunctionLike(node) ||
1592
+ ts.isClassDeclaration(node) ||
1593
+ ts.isClassExpression(node);
1594
+ return (ts.forEachChild(node, (child) => functionReadOf(lowerer, child, bindings, nested) ?? undefined) ?? null);
1595
+ }
1515
1596
  export function lowerStmt(lowerer, stmt) {
1516
1597
  if (ownPrototypeResetStatement(lowerer, stmt))
1517
1598
  return { kind: "block", body: [], loc: locOf(stmt) };
@@ -1647,6 +1728,39 @@ export function lowerStmt(lowerer, stmt) {
1647
1728
  // observed empty returns even when JSDoc omits undefined. Any remaining
1648
1729
  // incompatible boundary keeps the ordinary per-statement refusal.
1649
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
+ };
1650
1764
  if (stmt.expression) {
1651
1765
  // A constructor's returned object replaces the constructed `this`.
1652
1766
  if (lowerer.currentClass?.ctor) {
@@ -1654,7 +1768,7 @@ export function lowerStmt(lowerer, stmt) {
1654
1768
  if (constructorReturn !== null)
1655
1769
  return constructorReturn;
1656
1770
  }
1657
- return lowerer.lowerReturnStmt(stmt.expression, locOf(stmt));
1771
+ return withClearedPending(lowerer.lowerReturnStmt(stmt.expression, locOf(stmt)));
1658
1772
  }
1659
1773
  else if (lowerer.ctx.returnType.kind === "union") {
1660
1774
  value = lowerer.wrappedUndefined(lowerer.ctx.returnType, locOf(stmt));
@@ -1670,8 +1784,8 @@ export function lowerStmt(lowerer, stmt) {
1670
1784
  }
1671
1785
  // An async generator's bare return has no operand to await.
1672
1786
  if (lowerer.ctx.isAsync === true && lowerer.ctx.generator)
1673
- return { kind: "return", value, awaited: true, loc: locOf(stmt) };
1674
- 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) });
1675
1789
  }
1676
1790
  if (ts.isBreakStatement(stmt) || ts.isContinueStatement(stmt)) {
1677
1791
  const kw = ts.isBreakStatement(stmt) ? "break" : "continue";
@@ -1865,6 +1979,11 @@ function lowerVarDeclarator(lowerer, stmt, decl, isConst, isLet) {
1865
1979
  if (lowerer.externalTypes.has(spec))
1866
1980
  lowerer.externalHostFence(spec, decl, false);
1867
1981
  if (ts.isSourceFile(stmt.parent)) {
1982
+ // `const x = require("<island>")` and `const { name } = …`: the
1983
+ // island module loads here, at the statement (lower-node-island.ts).
1984
+ const island = lowerIslandRequireAtStatement(lowerer, decl);
1985
+ if (island !== null)
1986
+ return [island];
1868
1987
  const init = lowerer.requireInitStmt(spec, decl);
1869
1988
  const out = init ? [init] : [];
1870
1989
  // Nested patterns destructure the named export's value right after
@@ -1883,6 +2002,12 @@ function lowerVarDeclarator(lowerer, stmt, decl, isConst, isLet) {
1883
2002
  // same routing top-level requires use, and no statement remains.
1884
2003
  // Relative requires keep the fence: their module-init-at-position
1885
2004
  // semantics needs storage this model doesn't represent.
2005
+ // A nested require of an island package is an ordinary binding of the
2006
+ // island module, loaded at the statement (lower-node-island.ts).
2007
+ if (isIslandRequireSpec(lowerer, ts.getSourceFileOfNode(decl).fileName, spec)) {
2008
+ const lowered = lowerer.lowerVarDecl(decl, isLet);
2009
+ return lowered ? [lowered] : [];
2010
+ }
1886
2011
  if (canonicalBuiltinModule(spec) !== null) {
1887
2012
  return canonicalBuiltinModule(spec) === "punycode"
1888
2013
  ? [lowerer.punycodeRequireWarning(decl)]
@@ -2142,6 +2267,7 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
2142
2267
  return tokenBound;
2143
2268
  }
2144
2269
  let init = importMetaBindingSource(lowerer, decl.name, decl.initializer) ??
2270
+ nullishEmptyPatternSource(lowerer, decl.name, decl.initializer) ??
2145
2271
  lowerer.lowerExpr(decl.initializer);
2146
2272
  const parseArgsDynObject = init.type.kind === "dyn" &&
2147
2273
  isParseArgsDynCheckerType(lowerer, lowerer.typeOf(decl.initializer));
@@ -2187,13 +2313,26 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
2187
2313
  }
2188
2314
  }
2189
2315
  const out = [];
2316
+ // V8's destructuring TypeError spells STATIC sources: an identifier
2317
+ // source reads "<name> is not iterable", an identifier-callee call
2318
+ // "<name> is not a function or its return value is not iterable";
2319
+ // everything else (property reads, method calls, parameters) gets the
2320
+ // runtime kind wording — exactly V8's CallPrinter behavior. The DYN
2321
+ // pattern arm and the unit arms of a narrowed union consume this.
2322
+ const src = decl.initializer;
2323
+ const dynSpell = ts.isIdentifier(src)
2324
+ ? `${src.text} is not iterable`
2325
+ : ts.isCallExpression(src) && ts.isIdentifier(src.expression)
2326
+ ? `${src.expression.text} is not a function or its return value is not iterable`
2327
+ : undefined;
2190
2328
  // JS: a union source with exactly ONE destructurable arm beside unit
2191
2329
  // arms (`nameAndArgs.match(re)` — `RegExpMatchArray | null`, the
2192
2330
  // always-matches idiom) destructures through a VALIDATED narrow: the
2193
- // unit arms throw at runtime exactly where Node's TypeError would
2194
- // (the message is the fence's — a unit value here is the failure
2195
- // path either way). TypeScript keeps the fence: narrowing first is
2196
- // the annotated fix.
2331
+ // unit arms throw Node's TypeError, through the checks a dyn source
2332
+ // takes (RequireObjectCoercible for an object pattern, GetIterator for
2333
+ // an array pattern). An object pattern whose source has no V8
2334
+ // spelling keeps the fence. TypeScript keeps the fence: narrowing
2335
+ // first is the annotated fix.
2197
2336
  if (isJsSourceFile(ts.getSourceFileOfNode(decl)) && init.type.kind === "union") {
2198
2337
  const def = lowerer.unions.get(init.type.unionId);
2199
2338
  const dataArms = (def?.arms ?? []).filter((a) => !isUnitType(a));
@@ -2204,9 +2343,56 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
2204
2343
  def.arms.every((a) => a === arm || isUnitType(a)) &&
2205
2344
  (arm.kind === "array" || arm.kind === "record")) {
2206
2345
  const tag = def.arms.indexOf(arm);
2346
+ const unionId = init.type.unionId;
2207
2347
  const utmp = lowerer.declareHiddenLocal("%destrU", init.type);
2208
2348
  out.push({ kind: "varDecl", localId: utmp.id, init, loc });
2209
2349
  const uref = { kind: "varRef", localId: utmp.id, type: init.type, loc };
2350
+ // The failure branch holds one of the unit arms: the check reads it
2351
+ // as the dyn null or undefined it is, so the data arm needs no dyn
2352
+ // form (a record holding a generator has none).
2353
+ const unitValue = () => {
2354
+ const unitOf = (t) => lowerer.coerceToExpected({ kind: "unitLit", unit: t.kind === "nullT" ? "null" : "undefined", type: t, loc }, DYN);
2355
+ const units = def.arms.filter(isUnitType);
2356
+ const last = units[units.length - 1];
2357
+ return units.slice(0, -1).reduceRight((rest, t) => ({
2358
+ kind: "ternary",
2359
+ cond: {
2360
+ kind: "unionIsTag",
2361
+ unionId,
2362
+ tag: def.arms.indexOf(t),
2363
+ negated: false,
2364
+ value: uref,
2365
+ type: BOOL,
2366
+ loc,
2367
+ },
2368
+ then: unitOf(t),
2369
+ else_: rest,
2370
+ type: DYN,
2371
+ loc,
2372
+ }), unitOf(last));
2373
+ };
2374
+ const spelling = destrSpellingOf(src);
2375
+ const check = ts.isArrayBindingPattern(decl.name)
2376
+ ? {
2377
+ kind: "dynIterN",
2378
+ value: unitValue(),
2379
+ count: decl.name.elements.nodes.length,
2380
+ ...(dynSpell ? { notIterableMessage: dynSpell } : {}),
2381
+ type: DYN,
2382
+ loc,
2383
+ }
2384
+ : firstReadsWithDefault(decl.name)
2385
+ ? firstKeyRead(lowerer, decl.name, unitValue, loc)
2386
+ : spelling !== null
2387
+ ? {
2388
+ kind: "dynDestrCheck",
2389
+ value: unitValue(),
2390
+ spelling,
2391
+ ...firstPatternProp(lowerer, decl.name),
2392
+ type: DYN,
2393
+ loc,
2394
+ }
2395
+ : null;
2210
2396
  out.push({
2211
2397
  kind: "if",
2212
2398
  cond: {
@@ -2219,6 +2405,7 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
2219
2405
  loc,
2220
2406
  },
2221
2407
  then: [
2408
+ ...(check !== null ? [{ kind: "exprStmt", expr: check, loc }] : []),
2222
2409
  {
2223
2410
  kind: "runtimeFence",
2224
2411
  code: "SC1031",
@@ -2241,58 +2428,40 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
2241
2428
  // value: RequireObjectCoercible with V8's own TypeError ("Cannot
2242
2429
  // destructure property 'a' of 'f(...)' as it is null.") for the source
2243
2430
  // spellings the assignment form reproduces; other sources are refused,
2244
- // as in the assignment form. JavaScript files keep their existing
2245
- // per-read errors, except that a runtime computed first key checks the
2246
- // source first: Node throws before it evaluates any key, and V8's bare
2247
- // message names the source.
2248
- const jsRuntimeKeyCheck = init.type.kind === "dyn" &&
2431
+ // as in the assignment form. A JavaScript object pattern over a dyn
2432
+ // source checks the source first in the same way when V8 can spell it,
2433
+ // so a null or undefined source throws Node's message before any key
2434
+ // is read or evaluated; other sources keep their per-read errors. V8
2435
+ // skips the check when the first element has a default and a static
2436
+ // key: the read of that key throws ("Cannot read properties of null
2437
+ // (reading 'a')"), and so does the lowering's.
2438
+ const jsSourceCheck = init.type.kind === "dyn" &&
2249
2439
  ts.isObjectBindingPattern(decl.name) &&
2250
2440
  isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
2251
- (decl.name.elements.nodes.length === 0 || startsWithRuntimeKey(lowerer, decl.name)) &&
2252
2441
  destrSpellingOf(decl.initializer) !== null;
2253
- if (jsRuntimeKeyCheck ||
2442
+ if ((jsSourceCheck ||
2254
2443
  (init.type.kind === "dyn" &&
2255
2444
  ts.isObjectBindingPattern(decl.name) &&
2256
2445
  !isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
2257
- lowerer.anyOrigin(decl.initializer))) {
2446
+ lowerer.anyOrigin(decl.initializer))) &&
2447
+ !firstReadsWithDefault(decl.name)) {
2258
2448
  const spelling = destrSpellingOf(decl.initializer);
2259
2449
  if (spelling === null) {
2260
2450
  lowerer.unsupported("SC1031", decl.initializer, "destructuring declaration from an `any` source whose expression spelling is unsupported (use a variable, ordinary property chain, or ordinary call)");
2261
2451
  }
2262
- const first = decl.name.elements.nodes[0];
2263
- const firstKey = first === undefined || first.dotDotDotToken !== undefined
2264
- ? undefined
2265
- : (first.propertyName ?? first.name);
2266
- // V8 names the first property when its key is an identifier, a string
2267
- // or a number; a computed first key takes the bare (source-only) form.
2268
- const firstProp = firstKey === undefined || ts.isComputedPropertyName(firstKey)
2269
- ? undefined
2270
- : (patternKeyNameOf(lowerer, firstKey) ?? undefined);
2271
2452
  out.push({
2272
2453
  kind: "exprStmt",
2273
2454
  expr: {
2274
2455
  kind: "dynDestrCheck",
2275
2456
  value: { kind: "varRef", localId: tmp.id, type: init.type, loc },
2276
2457
  spelling,
2277
- ...(firstProp !== undefined ? { firstProp } : {}),
2458
+ ...firstPatternProp(lowerer, decl.name),
2278
2459
  type: init.type,
2279
2460
  loc,
2280
2461
  },
2281
2462
  loc,
2282
2463
  });
2283
2464
  }
2284
- // V8's destructuring TypeError spells STATIC sources: an identifier
2285
- // source reads "<name> is not iterable", an identifier-callee call
2286
- // "<name> is not a function or its return value is not iterable";
2287
- // everything else (property reads, method calls, parameters) gets the
2288
- // runtime kind wording — exactly V8's CallPrinter behavior. Only the
2289
- // DYN pattern arm consumes this.
2290
- const src = decl.initializer;
2291
- const dynSpell = ts.isIdentifier(src)
2292
- ? `${src.text} is not iterable`
2293
- : ts.isCallExpression(src) && ts.isIdentifier(src.expression)
2294
- ? `${src.expression.text} is not a function or its return value is not iterable`
2295
- : undefined;
2296
2465
  lowerer.lowerBindingPattern(decl.name, () => ({ kind: "varRef", localId: tmp.id, type: init.type, loc }), init.type, isLet, out, dynSpell, parseArgsDynObject);
2297
2466
  return out;
2298
2467
  }
@@ -3198,6 +3367,10 @@ export function lowerBindingPattern(lowerer, pattern, srcRef, srcType, isLet, ou
3198
3367
  type: fieldType,
3199
3368
  loc,
3200
3369
  };
3370
+ // A field some partial record assertion leaves unwritten (a partial
3371
+ // record view, partial-assertions.ts): the element read throws the
3372
+ // catchable TypeError instead of reading a slot the view lacks.
3373
+ value = partialFieldRead(lowerer, srcRef(), srcType.shapeId, propName, fieldType, loc) ?? value;
3201
3374
  // `{ tld = "localhost" }`: the element default applies exactly when
3202
3375
  // the field holds the undefined arm — the same undefined test and
3203
3376
  // narrow/retag as a defaulted parameter's prologue (declareParams).
@@ -4643,9 +4816,13 @@ export function lowerVarDeclList(lowerer, list) {
4643
4816
  const out = [];
4644
4817
  for (const decl of list.declarations.nodes) {
4645
4818
  if (ts.isArrayBindingPattern(decl.name) || ts.isObjectBindingPattern(decl.name)) {
4646
- // Destructuring produces nested initialization blocks; copying
4647
- // their captured bindings still needs a distinct head-scope plan.
4648
- lowerer.unsupported("SC1031", decl.name, "let/const destructuring in for-loop initializers (declare the pattern before the loop, or use var)");
4819
+ // The pattern desugars to a flat statement list whose bindings are
4820
+ // ordinary head declarations (`for (let [a, b] = xs; ...)`: `%destr`
4821
+ // plus `a`, `b`), so the loop emitter finds them as head lets and
4822
+ // freshens the captured ones per iteration like any other
4823
+ // declarator (emit-statements: capturedLets).
4824
+ out.push(...lowerer.lowerDestructuringDecl(decl, isLet));
4825
+ continue;
4649
4826
  }
4650
4827
  const lowered = lowerer.lowerVarDecl(decl, isLet);
4651
4828
  if (!lowered)
@@ -4861,20 +5038,30 @@ function evolvingArrayHolderType(lowerer, decl) {
4861
5038
  return null;
4862
5039
  return evolvingArrayHold(lowerer, decl.initializer) === null ? null : DYN;
4863
5040
  }
4864
- /** A single static type for an initializer-less JavaScript `let` whose
4865
- * later plain writes all agree. An evolving JS local reads as `undefined`
4866
- * until control flow proves a write, so a scalar slot is sound only when
4867
- * every ordinary use already has that concrete flow type. Any closure
4868
- * capture stays checked-dynamic: it can observe the local before an outer
4869
- * assignment, and the checker deliberately leaves captured evolving lets
4870
- * broad. */
4871
- function inferredEvolvingLetType(lowerer, decl) {
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. */
5055
+ export function inferredEvolvingLetType(lowerer, decl) {
4872
5056
  if (!ts.isIdentifier(decl.name))
4873
5057
  return null;
4874
5058
  const symbol = lowerer.checker.getSymbolAtLocation(decl.name);
4875
5059
  const scope = decl.parent?.parent?.parent;
4876
5060
  if (symbol === undefined || (!ts.isBlock(scope) && !ts.isSourceFile(scope)))
4877
5061
  return null;
5062
+ // Another module reads an exported binding, which this scan does not see.
5063
+ if (ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export)
5064
+ return null;
4878
5065
  // A shorthand property's name (`{ width }`) resolves to the property
4879
5066
  // symbol, but it reads the binding: the checker's shorthand-value symbol.
4880
5067
  const refersToBinding = (node) => (ts.isShorthandPropertyAssignment(node.parent) && node.parent.name === node
@@ -4904,13 +5091,25 @@ function inferredEvolvingLetType(lowerer, decl) {
4904
5091
  const writes = [];
4905
5092
  const reads = [];
4906
5093
  let invalid = false;
4907
- ts.walkPreorder(scope, (node) => {
4908
- if (node !== scope && ts.isFunctionLike(node)) {
4909
- if (captures(node))
4910
- invalid = true;
5094
+ let captured = false;
5095
+ // The capturing closure being scanned: reads inside one carry the
5096
+ // checker's broad type, so only its writes are collected.
5097
+ let closure = null;
5098
+ const visit = (node) => {
5099
+ if (node !== scope && node !== closure && ts.isFunctionLike(node)) {
5100
+ if (captures(node)) {
5101
+ captured = true;
5102
+ const outer = closure;
5103
+ closure = node;
5104
+ ts.walkPreorder(node, visit);
5105
+ closure = outer;
5106
+ }
4911
5107
  return "skip";
4912
5108
  }
4913
- 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)) {
4914
5113
  let left = node.left;
4915
5114
  while (ts.isParenthesizedExpression(left))
4916
5115
  left = left.expression;
@@ -4919,9 +5118,7 @@ function inferredEvolvingLetType(lowerer, decl) {
4919
5118
  invalid = true;
4920
5119
  return "stop";
4921
5120
  }
4922
- if (ts.isCallExpression(node.right) &&
4923
- (implicitMethodCallInfersReturn(lowerer, node.right) ||
4924
- isJsSourceFile(ts.getSourceFileOfNode(node.right)))) {
5121
+ if (ts.isCallExpression(node.right) && !stdlibDeclaredCall(lowerer, node.right)) {
4925
5122
  invalid = true;
4926
5123
  return "stop";
4927
5124
  }
@@ -4935,7 +5132,7 @@ function inferredEvolvingLetType(lowerer, decl) {
4935
5132
  return "stop";
4936
5133
  }
4937
5134
  const mapped = lowerer.mapTypeOf(lowerer.typeOf(node.right));
4938
- if (!mapped || mapped.kind === "dyn" || mapped.kind === "void" || isUnitType(mapped)) {
5135
+ if (!mapped || mapped.kind === "dyn" || mapped.kind === "void") {
4939
5136
  invalid = true;
4940
5137
  return "stop";
4941
5138
  }
@@ -4948,23 +5145,69 @@ function inferredEvolvingLetType(lowerer, decl) {
4948
5145
  invalid = true;
4949
5146
  return "stop";
4950
5147
  }
4951
- if (ts.isIdentifier(node) &&
5148
+ if (closure === null &&
5149
+ ts.isIdentifier(node) &&
4952
5150
  node !== decl.name &&
4953
5151
  refersToBinding(node) &&
4954
5152
  !isPlainAssignmentTarget(node)) {
4955
5153
  reads.push(node);
4956
5154
  }
4957
5155
  return undefined;
4958
- });
4959
- const first = writes[0];
4960
- if (invalid || first === undefined || !writes.every((write) => typeEquals(write, first)))
5156
+ };
5157
+ ts.walkPreorder(scope, visit);
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)
4961
5173
  return null;
4962
- return reads.every((read) => {
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.
5186
+ if (!reads.every((read) => {
4963
5187
  const mapped = lowerer.mapTypeOf(lowerer.typeOf(read));
4964
- return mapped !== null && typeEquals(mapped, first);
4965
- })
4966
- ? first
4967
- : null;
5188
+ return (mapped !== null && armsOf(mapped).every((arm) => arms.some((own) => typeEquals(own, arm))));
5189
+ }))
5190
+ return null;
5191
+ if (!captured)
5192
+ return storage;
5193
+ if (!DYN_HANDLE_KINDS.has(value.kind))
5194
+ return null;
5195
+ lowerer.closureDynLets.add(symbol);
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]) };
5201
+ }
5202
+ /** Whether a call's resolved signature is declared in the standard library
5203
+ * (`spawn(...)`), so its declared return type is the value's type. Calls of
5204
+ * JavaScript functions, and implicit generic methods, infer theirs, and a
5205
+ * `require(...)` result is a module rather than a value of its type. */
5206
+ function stdlibDeclaredCall(lowerer, call) {
5207
+ if (implicitMethodCallInfersReturn(lowerer, call) || requireSpecOf(call) !== null)
5208
+ return false;
5209
+ const declaration = lowerer.checker.getResolvedSignature(call)?.declaration;
5210
+ return declaration !== undefined && lowerer.isStdlibFile(ts.getSourceFileOfNode(declaration));
4968
5211
  }
4969
5212
  export function lowerVarDecl(lowerer, decl, isLet) {
4970
5213
  // --provenance-sources: an elided pure-annotated dead const emits
@@ -5001,6 +5244,10 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5001
5244
  }
5002
5245
  if (!ts.isIdentifier(decl.name))
5003
5246
  lowerer.unsupported("SC1031", decl.name);
5247
+ // A binding that holds `process.env` under any type but the env record
5248
+ // is a snapshot copy whose reads would drift from Node's live table
5249
+ // (refuseHeldEnvCopyHold); refuse it here, at the hold itself.
5250
+ refuseHeldEnvCopyHold(lowerer, decl.name, decl);
5004
5251
  {
5005
5252
  const alias = lowerTupleAliasDecl(lowerer, decl);
5006
5253
  if (alias)
@@ -5136,11 +5383,11 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5136
5383
  }
5137
5384
  // `const h = id` — an ALIAS of a generic function: the alias's symbol
5138
5385
  // registers the target's info (calls and pinned values resolve like
5139
- // the target's own name), the binding has no runtime value, and the
5140
- // statement emits nothing (collectGlobals skipped module-scope
5141
- // 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).
5142
5389
  if (bindingGenericFnAliasInfoOf(lowerer, decl))
5143
- return null;
5390
+ return genericAliasPresenceStore(lowerer, decl);
5144
5391
  // `const stored = overloadedDeclaration`: no runtime slot is needed;
5145
5392
  // calls project onto the declaration's implementation ABI and value
5146
5393
  // reads reuse its interned closure identity.
@@ -5262,6 +5509,12 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5262
5509
  raw.type.kind === "dyn" &&
5263
5510
  (g.type.kind === "record" ||
5264
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)) ||
5265
5518
  (ts.isIdentifier(decl.name) &&
5266
5519
  jsBindingKeepsCheckedObject(lowerer, decl.name, g.type) &&
5267
5520
  (existingValueForm(decl.initializer) || jsHoldsDynObject(lowerer, decl.initializer)))))
@@ -5275,6 +5528,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5275
5528
  g.type = raw.type;
5276
5529
  notePreservedLayout(lowerer, decl);
5277
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;
5278
5543
  const arithmetic = raw.type.kind === "union" ? lowerer.unions.get(raw.type.unionId)?.arms : undefined;
5279
5544
  if (arithmetic?.length === 2 &&
5280
5545
  arithmetic.every((a) => a.kind === "f64" || a.kind === "string" || a.kind === "bool") &&
@@ -5287,6 +5552,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5287
5552
  lowerer.runtimeOptionalArithmeticGlobals.add(g);
5288
5553
  }
5289
5554
  const init = lowerer.coerceInto(decl.initializer, raw, g.type);
5555
+ refuseAssertionViewWrite(lowerer, decl);
5290
5556
  return {
5291
5557
  kind: "assign",
5292
5558
  localId: g.id,
@@ -5328,12 +5594,13 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5328
5594
  // `let x: number;` — declared, uninitialized. tsc guarantees no read
5329
5595
  // before assignment (TS2454) and rejects uninitialized const (TS1155).
5330
5596
  // Unannotated `let x;` is an evolving `any` — the checked-dynamic
5331
- // binding fallback (irTypeOf → dynFallbackType).
5597
+ // binding fallback (irTypeOf → dynFallbackType) unless its writes agree
5598
+ // on a type.
5332
5599
  // Undefined-armed unions (`let x: string | undefined;`) are readable
5333
5600
  // immediately (the type covers the unassigned state), so they
5334
5601
  // initialize to the interned undefined arm like an omitted optional.
5335
5602
  let type = lowerer.irTypeOf(decl.name);
5336
- if (type.kind === "dyn" && isLet && isJsSourceFile(ts.getSourceFileOfNode(decl))) {
5603
+ if (type.kind === "dyn" && isLet && decl.type === undefined) {
5337
5604
  type = inferredEvolvingLetType(lowerer, decl) ?? type;
5338
5605
  }
5339
5606
  // `var v: void;` / `let x: undefined;` — a unit-only binding rides
@@ -5444,6 +5711,19 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5444
5711
  type = init.type;
5445
5712
  notePreservedLayout(lowerer, decl);
5446
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;
5720
+ // A JavaScript binding assigned values outside its declared type
5721
+ // (analyzeJsWidenedBindings in lowerer.ts) holds them as checked-dynamic.
5722
+ {
5723
+ const symbol = lowerer.resolveValueSymbol(decl.name);
5724
+ if (symbol && lowerer.jsWidenedBindings.has(symbol))
5725
+ type = DYN;
5726
+ }
5447
5727
  // A typed-arguments function expression (typed-arguments.ts): the
5448
5728
  // checker types the binding variadic, but its value has the fixed
5449
5729
  // signature every use asserts.
@@ -5494,9 +5774,18 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5494
5774
  const keepsAssertedObject = init.type.kind === "dyn" &&
5495
5775
  !decl.type &&
5496
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);
5497
5785
  if (expandsObject ||
5498
5786
  preservesObjectIdentity ||
5499
5787
  keepsAssertedObject ||
5788
+ keepsPromiseStaticValue ||
5500
5789
  (isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
5501
5790
  !decl.type &&
5502
5791
  isNativeBuiltinValueInitializer(lowerer, decl.initializer))) {
@@ -5793,13 +6082,9 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5793
6082
  // the stored type hosts (`const view: Route & { order: number } = ...`)
5794
6083
  // keeps it too: coercing into the annotated layout would copy the
5795
6084
  // value and read members the writes have not created yet.
5796
- if (!isLet &&
5797
- decl.initializer &&
5798
- isAssertionInitializer(decl.initializer) &&
5799
- (settledType.kind === "union" || settledType.kind === "record") &&
5800
- (init.type.kind === "union" || init.type.kind === "record") &&
5801
- hostsAll(lowerer, init.type, settledType)) {
6085
+ if (!isLet && assertionKeepsStorageLayout(lowerer, decl, init.type, settledType)) {
5802
6086
  settledType = init.type;
6087
+ notePreservedLayout(lowerer, decl);
5803
6088
  }
5804
6089
  // An exact class behind a generic interface keeps its native
5805
6090
  // representation so generic calls can specialize against its body.
@@ -5828,6 +6113,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
5828
6113
  // Slot coercion: `const r: A | B = bValue;` wraps implicitly; width
5829
6114
  // subtyping (`const p: {a: number} = wider;`) is rejected, not coerced.
5830
6115
  init = lowerer.coerceInto(decl.initializer, init, settledType);
6116
+ refuseAssertionViewWrite(lowerer, decl);
5831
6117
  const local = lowerer.declareLocal(decl.name, decl.name.text, settledType, isLet);
5832
6118
  if (runtimeStringArithmetic && init.type.kind === "union") {
5833
6119
  lowerer.runtimeOptionalArithmeticLocals.add(lowerer.runtimeOptionalRootOf(local));
@@ -5877,6 +6163,17 @@ function inferredOptionalRecordType(lowerer, decl, declared, actual) {
5877
6163
  return declared;
5878
6164
  return actual;
5879
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
+ }
5880
6177
  function lowerVariableInitializer(lowerer, node, expected) {
5881
6178
  let value = node;
5882
6179
  while (ts.isParenthesizedExpression(value) ||
@@ -6129,10 +6426,14 @@ export function jsBindingHasOpenWrites(lowerer, decl) {
6129
6426
  return false;
6130
6427
  if (candidates.some((node) => (lowerer.typeOf(node.right).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0))
6131
6428
  return true;
6132
- // A `+=` of a string turns a number or boolean binding into a string
6133
- // (`n += "px"`); the checker keeps the declared type.
6429
+ // A `+=` of a string, or of a value that may be one, turns a number or
6430
+ // boolean binding into a string (`n += "px"`); the checker keeps the
6431
+ // declared type.
6432
+ const mayBeString = (type) => type.flags & ts.TypeFlags.Union
6433
+ ? constituentTypes(type).some(mayBeString)
6434
+ : (type.flags & ts.TypeFlags.StringLike) !== 0;
6134
6435
  if (candidates.some((node) => node.operatorToken.kind === ts.SyntaxKind.PlusEqualsToken &&
6135
- (lowerer.typeOf(node.right).flags & ts.TypeFlags.StringLike) !== 0)) {
6436
+ mayBeString(lowerer.typeOf(node.right)))) {
6136
6437
  const declared = lowerer.mapTypeOf(lowerer.typeOf(decl.name));
6137
6438
  if (declared?.kind === "f64" || declared?.kind === "bool")
6138
6439
  return true;
@@ -6163,6 +6464,11 @@ export function jsBindingHasOpenWrites(lowerer, decl) {
6163
6464
  return false;
6164
6465
  return differing.some((node) => {
6165
6466
  const written = lowerer.mapTypeOf(lowerer.typeOf(node.right));
6467
+ // A union a primitive binding cannot hold (`x = c ? 1 : "a"` into
6468
+ // `var x = 0`).
6469
+ if (written?.kind === "union" &&
6470
+ (declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string"))
6471
+ return true;
6166
6472
  return (written !== null &&
6167
6473
  written.kind !== "dyn" &&
6168
6474
  written.kind !== "union" &&
@@ -6480,10 +6786,15 @@ function lowerBranchSwitch(lowerer, stmt, disc, labels, compare) {
6480
6786
  * === "string"/"number"/"boolean"`), reads under a proven narrow
6481
6787
  * (caughtRead bridges them with caughtNarrow, verified at run time like
6482
6788
  * unionNarrow), and rethrow (`throw e`). Unsupported raw uses and
6483
- * assignments are fenced (SC1063 and friends); destructuring patterns
6484
- * are SC1062. Captures retain the snapshot beyond the catch scope.
6485
- * The `: any` / `: unknown` annotations tsc admits both
6486
- * lower the same way (tsc narrows either through the tests).
6789
+ * assignments are fenced (SC1063 and friends). The `: any` /
6790
+ * `: unknown` annotations tsc admits both lower the same way (tsc
6791
+ * narrows either through the tests). Captures retain the snapshot
6792
+ * beyond the catch scope.
6793
+ * - `catch ([a])` / `catch ({ p })` binds the thrown value through a
6794
+ * destructuring pattern: the exception cell keeps its hidden CAUGHT
6795
+ * local, and the pattern reads its checked-dynamic view
6796
+ * (caughtToDyn), so a JS catch parameter that destructures lowers the
6797
+ * way the same pattern does over an `any` source.
6487
6798
  * - `finally` runs on normal completion, exception paths, and every
6488
6799
  * abrupt completion that crosses it. Return values are snapshotted
6489
6800
  * before cleanup; an abrupt completion inside the finally replaces the
@@ -6496,9 +6807,6 @@ export function lowerTry(lowerer, stmt) {
6496
6807
  let catchLocalId = null;
6497
6808
  if (stmt.catchClause) {
6498
6809
  const vd = stmt.catchClause.variableDeclaration;
6499
- if (vd && !ts.isIdentifier(vd.name)) {
6500
- lowerer.unsupported("SC1062", vd);
6501
- }
6502
6810
  if (vd && ts.isIdentifier(vd.name)) {
6503
6811
  lowerer.scopes.push(new Map());
6504
6812
  try {
@@ -6511,7 +6819,59 @@ export function lowerTry(lowerer, stmt) {
6511
6819
  }
6512
6820
  }
6513
6821
  else {
6514
- catchBody = lowerer.lowerScopedBlock(stmt.catchClause.block);
6822
+ lowerer.scopes.push(new Map());
6823
+ try {
6824
+ if (vd) {
6825
+ // `catch ([a])` / `catch ({ a })`: the thrown value crosses into
6826
+ // the checked-dynamic tree and the pattern binds through the same
6827
+ // per-read fences a dyn source takes — GetIterator for an array
6828
+ // pattern (positions past the end bind undefined, an iterator
6829
+ // with values left closes) and RequireObjectCoercible plus keyed
6830
+ // reads for an object pattern. The hidden CAUGHT local is the
6831
+ // exception cell every other catch path binds; the dyn conversion
6832
+ // is its identity-preserving view (caughtToDyn).
6833
+ const loc = locOf(vd);
6834
+ const local = lowerer.declareHiddenLocal("%caught", CAUGHT);
6835
+ catchLocalId = local.id;
6836
+ const tmp = lowerer.declareHiddenLocal("%destr", DYN);
6837
+ const out = [
6838
+ {
6839
+ kind: "varDecl",
6840
+ localId: tmp.id,
6841
+ init: { kind: "caughtToDyn", value: varRef(local.id, CAUGHT, loc), type: DYN, loc },
6842
+ loc,
6843
+ },
6844
+ ];
6845
+ // V8 spells the catch parameter's source '.catch' in the
6846
+ // RequireObjectCoercible TypeError ("Cannot destructure property
6847
+ // 'a' of '.catch' as it is null."), except when the first element
6848
+ // has a default: V8 reads that key first, so a nullish source
6849
+ // throws the read's TypeError, which the pattern's own first read
6850
+ // throws.
6851
+ if (ts.isObjectBindingPattern(vd.name) && !firstReadsWithDefault(vd.name))
6852
+ out.push({
6853
+ kind: "exprStmt",
6854
+ expr: {
6855
+ kind: "dynDestrCheck",
6856
+ value: varRef(tmp.id, DYN, loc),
6857
+ spelling: ".catch",
6858
+ ...firstPatternProp(lowerer, vd.name),
6859
+ type: DYN,
6860
+ loc,
6861
+ },
6862
+ loc,
6863
+ });
6864
+ lowerer.lowerBindingPattern(vd.name, () => varRef(tmp.id, DYN, loc), DYN, true, // catch bindings are mutable
6865
+ out);
6866
+ catchBody = [...out, ...lowerer.lowerScopedBlock(stmt.catchClause.block)];
6867
+ }
6868
+ else {
6869
+ catchBody = lowerer.lowerScopedBlock(stmt.catchClause.block);
6870
+ }
6871
+ }
6872
+ finally {
6873
+ lowerer.scopes.pop();
6874
+ }
6515
6875
  }
6516
6876
  }
6517
6877
  const finallyBody = stmt.finallyBlock ? lowerer.lowerScopedBlock(stmt.finallyBlock) : null;
@@ -6524,13 +6884,67 @@ export function lowerTry(lowerer, stmt) {
6524
6884
  loc: locOf(stmt),
6525
6885
  };
6526
6886
  }
6887
+ /** The refusal for `delete` of an optional `unknown`/`any` field, whose
6888
+ * slot is the checked-dynamic one and so has no ABSENT state to write. */
6889
+ const OPTIONAL_CHECKED_DYN_DELETE = "'delete' of optional 'unknown'/'any' fields (the checked-dynamic slot has no absent state yet — an omitted such field already reads as present)";
6890
+ /** TypeScript's declaration marks property `name` of `receiver` optional
6891
+ * (`?:`), in every union constituent. A mapped IR type cannot tell an
6892
+ * optional `unknown`/`any` field from a required one — both ride the
6893
+ * checked-dynamic slot — so a refused `delete`'s real reason comes from
6894
+ * the declaration. */
6895
+ function declaredOptionalProperty(lowerer, receiver, name) {
6896
+ const receiverType = lowerer.typeOf(receiver);
6897
+ const parts = receiverType.flags & ts.TypeFlags.Union ? constituentTypes(receiverType) : [receiverType];
6898
+ return parts.every((part) => {
6899
+ const property = lowerer.checker.getPropertyOfType(part, name);
6900
+ return property !== undefined && (property.flags & ts.SymbolFlags.Optional) !== 0;
6901
+ });
6902
+ }
6903
+ /** `type` — a record or a union whose every arm is a non-tuple record —
6904
+ * declares `name` in the checked-dynamic slot, which has no ABSENT state:
6905
+ * an optional such field cannot be removed by a `delete`. */
6906
+ function declaresCheckedDynField(lowerer, type, name) {
6907
+ if (type.kind === "record") {
6908
+ const shape = lowerer.shapes.get(type.shapeId);
6909
+ if (!shape || shape.tuple)
6910
+ return false;
6911
+ return shape.fields.find((f) => f.name === name)?.type.kind === "dyn";
6912
+ }
6913
+ if (type.kind !== "union")
6914
+ return false;
6915
+ const arms = lowerer.unions.get(type.unionId)?.arms ?? [];
6916
+ return arms.length > 0 && arms.every((arm) => declaresCheckedDynField(lowerer, arm, name));
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
+ }
6527
6939
  /** Statement-position `delete`: process.env keys → process.envUnset
6528
6940
  * (unsetenv), pure `Record<string, T>` keys → recordKeyDelete (the
6529
6941
  * overflow Map delete), declared OPTIONAL fields → the field's ABSENT
6530
6942
  * state (the slot reads undefined and no longer counts as an own
6531
6943
  * property). Everything else
6532
- * fences with the honest reason — a required field is a struct slot no
6533
- * runtime can remove. */
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
6947
+ * checked-dynamic slot, which has no ABSENT state yet. */
6534
6948
  function lowerDeleteStatement(lowerer, expr) {
6535
6949
  const loc = locOf(expr);
6536
6950
  let target = expr.expression;
@@ -6539,6 +6953,9 @@ function lowerDeleteStatement(lowerer, expr) {
6539
6953
  if (!ts.isElementAccessExpression(target) && !ts.isPropertyAccessExpression(target)) {
6540
6954
  lowerer.unsupported("SC1090", expr, "'delete' of non-property expressions");
6541
6955
  }
6956
+ // Deleting a member of `Date.prototype` is a write through the read-only
6957
+ // prototype value (property-access.ts's fence).
6958
+ fenceDatePrototypeWrite(lowerer, target);
6542
6959
  fenceNodeModuleMutation(lowerer, target, "delete");
6543
6960
  if (ts.isPropertyAccessExpression(target) && target.name.text === "cause") {
6544
6961
  const field = lowerer.fieldTarget(target);
@@ -6564,7 +6981,8 @@ function lowerDeleteStatement(lowerer, expr) {
6564
6981
  return { kind: "strLit", value: target.name.text, type: STRING, loc: locOf(target.name) };
6565
6982
  }
6566
6983
  const keyNode = target.argumentExpression;
6567
- let key = lowerer.isProcessEnv(target.expression)
6984
+ let key = lowerer.isProcessEnv(target.expression) ||
6985
+ heldEnvValueType(lowerer, target.expression) !== null
6568
6986
  ? lowerEnvironmentKey(lowerer, keyNode)
6569
6987
  : lowerer.lowerExpr(keyNode);
6570
6988
  if (key.type.kind === "dyn") {
@@ -6578,7 +6996,8 @@ function lowerDeleteStatement(lowerer, expr) {
6578
6996
  }
6579
6997
  return key;
6580
6998
  };
6581
- if (lowerer.isProcessEnv(target.expression)) {
6999
+ if (lowerer.isProcessEnv(target.expression) ||
7000
+ heldEnvValueType(lowerer, target.expression) !== null) {
6582
7001
  return {
6583
7002
  kind: "exprStmt",
6584
7003
  expr: { kind: "libCall", fn: "process.envUnset", args: [lowerKey()], type: VOID, loc },
@@ -6595,6 +7014,18 @@ function lowerDeleteStatement(lowerer, expr) {
6595
7014
  return unionDelete;
6596
7015
  }
6597
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
+ }
6598
7029
  // `delete this.stack` in an Error subclass that declares a `stack`
6599
7030
  // accessor (quickjs-wasi's JSException): V8 gives each error an own
6600
7031
  // `stack` that shadows the accessor, and the delete removes it so reads
@@ -6670,6 +7101,19 @@ function lowerDeleteStatement(lowerer, expr) {
6670
7101
  loc,
6671
7102
  };
6672
7103
  }
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);
7110
+ // An OPTIONAL `unknown`/`any` field rides the checked-dynamic slot,
7111
+ // which has no ABSENT state yet (an omitted such field already reads as
7112
+ // present), so it cannot delete. Name that reason instead of calling
7113
+ // the field required or blaming the receiver.
7114
+ const optionalCheckedDynDelete = constantKey !== null &&
7115
+ declaresCheckedDynField(lowerer, obj.type, constantKey) &&
7116
+ declaredOptionalProperty(lowerer, target.expression, constantKey);
6673
7117
  if (obj.type.kind === "record") {
6674
7118
  const shape = lowerer.shapes.get(obj.type.shapeId);
6675
7119
  if (shape?.indexValue && shape.fields.length === 0 && !shape.tuple) {
@@ -6682,13 +7126,8 @@ function lowerDeleteStatement(lowerer, expr) {
6682
7126
  // while a later write makes it present again. Constant keys only
6683
7127
  // (dot access or a literal bracket); required fields keep the honest
6684
7128
  // fence below.
6685
- const fieldName = ts.isPropertyAccessExpression(target)
6686
- ? target.name.text
6687
- : ts.isStringLiteral(target.argumentExpression)
6688
- ? target.argumentExpression.text
6689
- : null;
6690
- const field = fieldName !== null && !shape?.tuple
6691
- ? shape?.fields.find((f) => f.name === fieldName)
7129
+ const field = constantKey !== null && !shape?.tuple
7130
+ ? shape?.fields.find((f) => f.name === constantKey)
6692
7131
  : undefined;
6693
7132
  if (field) {
6694
7133
  const absent = lowerer.absentFieldValue(field.type, loc);
@@ -6706,9 +7145,32 @@ function lowerDeleteStatement(lowerer, expr) {
6706
7145
  if (shape?.indexValue) {
6707
7146
  lowerer.unsupported("SC1090", expr, "'delete' of hybrid index-signature keys (declared struct slots and overflow entries answer differently — model deletable dynamic keys with a pure Record<string, T>)");
6708
7147
  }
6709
- lowerer.unsupported("SC1090", expr, "'delete' of required record fields (a monomorphic shape cannot remove its slot — only optional fields delete, becoming the undefined arm)");
7148
+ if (optionalCheckedDynDelete) {
7149
+ lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
7150
+ }
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)");
7160
+ }
7161
+ if (optionalCheckedDynDelete) {
7162
+ lowerer.unsupported("SC1090", expr, OPTIONAL_CHECKED_DYN_DELETE);
7163
+ }
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)");
6710
7172
  }
6711
- lowerer.unsupported("SC1090", expr, `'delete' on '${lowerer.fmt(obj.type)}' receivers (process.env keys and pure Record<string, T> keys delete)`);
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)`);
6712
7174
  }
6713
7175
  /** True when the `var`/`let` binding `nameNode` names cannot change after
6714
7176
  * the top-level CommonJS export statement `exportNode` that exports it by
@@ -7384,6 +7846,13 @@ export function lowerExprStatement(lowerer, expr) {
7384
7846
  return { kind: "exprStmt", expr: urlWrite, loc: locOf(expr) };
7385
7847
  }
7386
7848
  if (opKind === ts.SyntaxKind.EqualsToken) {
7849
+ // A write through `Date.prototype` or one of its members keeps its
7850
+ // fence: the prototype value is a read surface (property-access.ts).
7851
+ if (ts.isPropertyAccessExpression(expr.left) || ts.isElementAccessExpression(expr.left))
7852
+ fenceDatePrototypeWrite(lowerer, expr.left);
7853
+ const staticPrivateWrite = lowerStaticPrivateAssignment(lowerer, expr);
7854
+ if (staticPrivateWrite)
7855
+ return { kind: "exprStmt", expr: staticPrivateWrite, loc: locOf(expr) };
7387
7856
  const callableWrite = lowerNativeFunctionAssignment(lowerer, expr);
7388
7857
  if (callableWrite)
7389
7858
  return { kind: "exprStmt", expr: callableWrite, loc: locOf(expr) };
@@ -7431,7 +7900,12 @@ export function lowerExprStatement(lowerer, expr) {
7431
7900
  // (Node stringifies everything; a non-string RHS fences instead
7432
7901
  // of diverging from Node). The computed-key form lands in
7433
7902
  // lowerElementWrite.
7434
- if (lowerer.isProcessEnv(expr.left.expression) && !expr.left.questionDotToken) {
7903
+ // The same setenv for a value HELD from process.env (`const env =
7904
+ // process.env; env.X = v`): the hold aliases the live table, as
7905
+ // Node's does.
7906
+ if (!expr.left.questionDotToken &&
7907
+ (lowerer.isProcessEnv(expr.left.expression) ||
7908
+ heldEnvValueType(lowerer, expr.left.expression) !== null)) {
7435
7909
  const loc = locOf(expr);
7436
7910
  const key = {
7437
7911
  kind: "strLit",
@@ -7901,6 +8375,39 @@ export function lowerExprStatement(lowerer, expr) {
7901
8375
  };
7902
8376
  }
7903
8377
  }
8378
+ // process.stdout.write = fn (and stderr): replace the stream object's
8379
+ // write slot. Every later write to the stream — console output, typed
8380
+ // write calls (programPatchesStdio), runtime writers — goes through it.
8381
+ if (ts.isPropertyAccessExpression(expr.left) && expr.left.name.text === "write") {
8382
+ const recv = expr.left.expression;
8383
+ const stream = ts.isPropertyAccessExpression(recv)
8384
+ ? lowerer.stdlibGlobalMember(recv, "process")
8385
+ : null;
8386
+ if (stream === "stdout" || stream === "stderr") {
8387
+ const loc = locOf(expr);
8388
+ return {
8389
+ kind: "exprStmt",
8390
+ expr: {
8391
+ kind: "libCall",
8392
+ fn: "dyn.keySet",
8393
+ args: [
8394
+ {
8395
+ kind: "libCall",
8396
+ fn: "process.stdioSlot",
8397
+ args: [numLit(stream === "stdout" ? 1 : 2, loc)],
8398
+ type: DYN,
8399
+ loc,
8400
+ },
8401
+ strLit("write", locOf(expr.left.name)),
8402
+ lowerer.lowerExprExpecting(expr.right, DYN),
8403
+ ],
8404
+ type: VOID,
8405
+ loc,
8406
+ },
8407
+ loc,
8408
+ };
8409
+ }
8410
+ }
7904
8411
  if (!ts.isIdentifier(expr.left)) {
7905
8412
  lowerer.unsupported("SC1090", expr.left, "assignment to non-variables");
7906
8413
  }
@@ -7933,6 +8440,8 @@ export function lowerExprStatement(lowerer, expr) {
7933
8440
  const compound = COMPOUND_ASSIGN_OPS[opKind];
7934
8441
  if (compound !== undefined) {
7935
8442
  // Desugar `x op= e` to `x = x op e` — reads x before e, like JS.
8443
+ if (ts.isPropertyAccessExpression(expr.left) || ts.isElementAccessExpression(expr.left))
8444
+ fenceDatePrototypeWrite(lowerer, expr.left);
7936
8445
  if (ts.isElementAccessExpression(expr.left)) {
7937
8446
  // `this[kLimit] += v` — a declared symbol-keyed class field is
7938
8447
  // the dotted compound in element spelling. Array and byte-view
@@ -7974,6 +8483,7 @@ export function lowerExprStatement(lowerer, expr) {
7974
8483
  (expr.operator === ts.SyntaxKind.PlusPlusToken ||
7975
8484
  expr.operator === ts.SyntaxKind.MinusMinusToken)) {
7976
8485
  if (ts.isPropertyAccessExpression(expr.operand) || ts.isElementAccessExpression(expr.operand)) {
8486
+ fenceDatePrototypeWrite(lowerer, expr.operand);
7977
8487
  // Statement and value positions share ToNumeric and reference order.
7978
8488
  // Namespace/expando globals retain their direct binding path below.
7979
8489
  const binding = ts.isPropertyAccessExpression(expr.operand)
@@ -8193,6 +8703,45 @@ export function lowerDestructuringAssign(lowerer, target, init, blame, loc) {
8193
8703
  const parts = destructuringAssignInto(lowerer, target, init, null, blame, loc);
8194
8704
  return { kind: "block", body: parts.stmts, loc };
8195
8705
  }
8706
+ /** An object pattern whose first element has a default and a static key
8707
+ * (`{ a = 1 }`, `{ a: b = 1 }`): V8 reads that key without checking the
8708
+ * source first, so a null or undefined source throws the read's TypeError. */
8709
+ function firstReadsWithDefault(pattern) {
8710
+ const first = pattern.elements.nodes[0];
8711
+ return (first !== undefined &&
8712
+ first.dotDotDotToken === undefined &&
8713
+ first.initializer !== undefined &&
8714
+ !(first.propertyName !== undefined && ts.isComputedPropertyName(first.propertyName)));
8715
+ }
8716
+ /** The read of the first key of a pattern that `firstReadsWithDefault`
8717
+ * accepts, over a dyn source: on null or undefined it throws the read's
8718
+ * TypeError, as V8 does. Null when the key has no static name. */
8719
+ function firstKeyRead(lowerer, pattern, source, loc) {
8720
+ const { firstProp } = firstPatternProp(lowerer, pattern);
8721
+ if (firstProp === undefined)
8722
+ return null;
8723
+ return {
8724
+ kind: "dynKeyGet",
8725
+ key: { kind: "strLit", value: firstProp, type: STRING, loc },
8726
+ value: source(),
8727
+ type: DYN,
8728
+ loc,
8729
+ };
8730
+ }
8731
+ /** The first property V8 names in an object pattern's destructuring
8732
+ * TypeError ("Cannot destructure property 'a' of ..."): an identifier,
8733
+ * string or numeric first key. A computed first key, a rest element or
8734
+ * an empty pattern takes the bare (source-only) form. */
8735
+ function firstPatternProp(lowerer, pattern) {
8736
+ const first = pattern.elements.nodes[0];
8737
+ const firstKey = first === undefined || first.dotDotDotToken !== undefined
8738
+ ? undefined
8739
+ : (first.propertyName ?? first.name);
8740
+ const firstProp = firstKey === undefined || ts.isComputedPropertyName(firstKey)
8741
+ ? undefined
8742
+ : (patternKeyNameOf(lowerer, firstKey) ?? undefined);
8743
+ return firstProp !== undefined ? { firstProp } : {};
8744
+ }
8196
8745
  /** V8's spelling of a destructuring RHS in its TypeError message
8197
8746
  * ("Cannot destructure 'a' as it is undefined.") — plain identifiers
8198
8747
  * spell their name (parens unwrap), `this`, property chains and
@@ -8341,8 +8890,8 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
8341
8890
  ts.isBinaryExpression(rhsInner) &&
8342
8891
  rhsInner.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
8343
8892
  (ts.isObjectLiteralExpression(rhsInner.left) || ts.isArrayLiteralExpression(rhsInner.left));
8344
- if (!checkedByInner) {
8345
- const spelling = rhs === null ? null : destrSpellingOf(rhs);
8893
+ if (!checkedByInner && rhs !== null) {
8894
+ const spelling = destrSpellingOf(rhs);
8346
8895
  if (spelling === null) {
8347
8896
  lowerer.unsupported("SC1031", blame, "destructuring assignment from a checked-dynamic source whose expression spelling is unsupported (use a variable, ordinary property chain, or ordinary call)");
8348
8897
  }
@@ -8373,20 +8922,57 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
8373
8922
  }
8374
8923
  for (const prop of target.properties.nodes) {
8375
8924
  const piece = destructAssignPiece(lowerer, prop);
8376
- const read = {
8925
+ const propLoc = locOf(prop);
8926
+ let read = {
8377
8927
  kind: "dynKeyGet",
8378
- key: { kind: "strLit", value: piece.field, type: STRING, loc: locOf(prop) },
8928
+ key: { kind: "strLit", value: piece.field, type: STRING, loc: propLoc },
8379
8929
  value: tmpRef(),
8380
8930
  type: DYN,
8381
- loc: locOf(prop),
8931
+ loc: propLoc,
8382
8932
  };
8933
+ if (piece.dflt !== undefined) {
8934
+ // `{ x = 1 }` / `{ x: y = 1 }`: the default fires on the undefined
8935
+ // read and is evaluated lazily, exactly the declaration path's
8936
+ // checked-dynamic default.
8937
+ const readTmp = lowerer.declareHiddenLocal("%destr", DYN);
8938
+ out.push({ kind: "varDecl", localId: readTmp.id, init: read, loc: propLoc });
8939
+ const readRef = { kind: "varRef", localId: readTmp.id, type: DYN, loc: propLoc };
8940
+ read = {
8941
+ kind: "ternary",
8942
+ cond: { kind: "dynTest", test: "undefined", value: readRef, type: BOOL, loc: propLoc },
8943
+ then: lowerer.coerceInto(piece.dflt, lowerer.lowerExpr(piece.dflt), DYN),
8944
+ else_: readRef,
8945
+ type: DYN,
8946
+ loc: propLoc,
8947
+ };
8948
+ }
8383
8949
  out.push({
8384
8950
  kind: "assign",
8385
8951
  localId: piece.target.id,
8386
8952
  value: lowerer.coerceInto(prop, read, piece.target.type),
8387
- loc: locOf(prop),
8953
+ loc: propLoc,
8388
8954
  });
8389
8955
  }
8956
+ if (rhs === null && target.properties.nodes.length === 0) {
8957
+ // A pattern with no reads still owes the source's own coercion, and a
8958
+ // PRE-LOWERED source (`for ({} of …)`) has no source text: V8 reads
8959
+ // the value instead of spelling it ("Cannot read properties of null").
8960
+ for (const unit of ["null", "undefined"]) {
8961
+ out.push({
8962
+ kind: "if",
8963
+ cond: { kind: "dynTest", test: unit, value: tmpRef(), type: BOOL, loc },
8964
+ then: [
8965
+ {
8966
+ kind: "exprStmt",
8967
+ expr: nodeThrowExpr(1, "", `Cannot read properties of ${unit}`, VOID, loc),
8968
+ loc,
8969
+ },
8970
+ ],
8971
+ else_: null,
8972
+ loc,
8973
+ });
8974
+ }
8975
+ }
8390
8976
  return { stmts: out, value };
8391
8977
  }
8392
8978
  if (target.properties.nodes.length === 0) {
@@ -8860,10 +9446,11 @@ function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
8860
9446
  function destructAssignPiece(lowerer, prop) {
8861
9447
  let fieldName;
8862
9448
  let bindTo;
9449
+ let dflt;
8863
9450
  if (ts.isShorthandPropertyAssignment(prop)) {
8864
- if (prop.objectAssignmentInitializer) {
8865
- lowerer.unsupported("SC1031", prop, "destructuring assignment with defaults (assign, then apply the default)");
8866
- }
9451
+ // `{ x = 1 }`: the shorthand's default (the checker's name resolution
9452
+ // still answers the outer binding through the shorthand).
9453
+ dflt = prop.objectAssignmentInitializer;
8867
9454
  fieldName = prop.name.text;
8868
9455
  bindTo = prop.name;
8869
9456
  }
@@ -8874,7 +9461,12 @@ function destructAssignPiece(lowerer, prop) {
8874
9461
  lowerer.unsupported("SC1031", prop, "destructuring assignment with computed keys that do not fold to one property name");
8875
9462
  }
8876
9463
  fieldName = folded ?? "";
9464
+ // `{ x: y = 1 }`: a defaulted target, the AssignmentPattern spelling.
8877
9465
  bindTo = prop.initializer;
9466
+ if (ts.isBinaryExpression(bindTo) && bindTo.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
9467
+ dflt = bindTo.right;
9468
+ bindTo = bindTo.left;
9469
+ }
8878
9470
  }
8879
9471
  else {
8880
9472
  lowerer.unsupported("SC1031", prop, "destructuring assignment with rest or spread properties");
@@ -8895,7 +9487,7 @@ function destructAssignPiece(lowerer, prop) {
8895
9487
  if (!target) {
8896
9488
  lowerer.rejectUnresolved(bindTo, `assignment to '${bindTo.text}' (not a writable local or module global)`);
8897
9489
  }
8898
- return { field: fieldName, target };
9490
+ return { field: fieldName, target, ...(dflt !== undefined ? { dflt } : {}) };
8899
9491
  }
8900
9492
  /** The ARRAY half of destructuring assignment: element assigns from a
8901
9493
  * tuple/array/checked-dynamic source pushed into `out` (see
@@ -9238,7 +9830,12 @@ export function lowerForOf(lowerer, stmt) {
9238
9830
  }
9239
9831
  const awaitArray = !!stmt.awaitModifier && lowerer.mapTypeOf(lowerer.typeOf(stmt.expression))?.kind === "array";
9240
9832
  if (stmt.awaitModifier && !awaitArray) {
9241
- {
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)) {
9242
9839
  const genT = lowerer.stageSourceType(stmt.expression) ??
9243
9840
  lowerer.mapTypeOf(lowerer.typeOf(stmt.expression));
9244
9841
  if (genT?.kind === "generator" && genT.async) {
@@ -11174,7 +11771,55 @@ function lowerForIn(lowerer, stmt) {
11174
11771
  receiver = lowerer.coerceToExpected(receiver, DYN);
11175
11772
  }
11176
11773
  }
11774
+ return lowerForInReceiver(lowerer, stmt, labels, receiver);
11775
+ }
11776
+ /** for-in over the lowered `receiver` of `stmt`. */
11777
+ function lowerForInReceiver(lowerer, stmt, labels, receiver) {
11778
+ const loc = locOf(stmt);
11177
11779
  const recvT = receiver.type;
11780
+ // A receiver that may be null or undefined: for-in visits nothing for
11781
+ // either, and walks a present value as its own type. The receiver is
11782
+ // evaluated once.
11783
+ if (recvT.kind === "union") {
11784
+ const arms = lowerer.unions.get(recvT.unionId)?.arms ?? [];
11785
+ const present = arms.filter((arm) => arm.kind !== "undefinedT" && arm.kind !== "nullT");
11786
+ if (present.length === 1 && present.length < arms.length) {
11787
+ const arm = present[0];
11788
+ const tag = lowerer.armTag(recvT.unionId, arm);
11789
+ const recv = lowerer.declareHiddenLocal("%innullable", recvT);
11790
+ const ref = varRef(recv.id, recvT, loc);
11791
+ const narrowed = {
11792
+ kind: "unionNarrow",
11793
+ unionId: recvT.unionId,
11794
+ tag,
11795
+ value: ref,
11796
+ type: arm,
11797
+ loc,
11798
+ };
11799
+ return {
11800
+ kind: "block",
11801
+ body: [
11802
+ { kind: "varDecl", localId: recv.id, init: receiver, loc },
11803
+ {
11804
+ kind: "if",
11805
+ cond: {
11806
+ kind: "unionIsTag",
11807
+ unionId: recvT.unionId,
11808
+ tag,
11809
+ negated: false,
11810
+ value: ref,
11811
+ type: BOOL,
11812
+ loc,
11813
+ },
11814
+ then: [lowerForInReceiver(lowerer, stmt, labels, narrowed)],
11815
+ else_: null,
11816
+ loc,
11817
+ },
11818
+ ],
11819
+ loc,
11820
+ };
11821
+ }
11822
+ }
11178
11823
  if (recvT.kind === "dyn") {
11179
11824
  const recv = lowerer.declareHiddenLocal("%indyn", DYN);
11180
11825
  const ref = { kind: "varRef", localId: recv.id, type: DYN, loc };
@@ -11845,4 +12490,54 @@ function isAssertionInitializer(node) {
11845
12490
  e = e.expression;
11846
12491
  return ts.isAsExpression(e) || ts.isTypeAssertion(e);
11847
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
+ }
11848
12543
  //# sourceMappingURL=lower-stmts.js.map