@scriptc/compiler 0.4.2 → 0.4.4

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 (726) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +470 -66
  2. package/dist/backend/cycle-analysis.d.ts +4 -1
  3. package/dist/backend/cycle-analysis.js +6 -4
  4. package/dist/backend/cycle-analysis.js.map +1 -1
  5. package/dist/backend/cycle-analysis.test.js +55 -0
  6. package/dist/backend/cycle-analysis.test.js.map +1 -1
  7. package/dist/backend/cycle-mutability.d.ts +7 -0
  8. package/dist/backend/cycle-mutability.js +19 -1
  9. package/dist/backend/cycle-mutability.js.map +1 -1
  10. package/dist/backend/executable-features.js +2 -0
  11. package/dist/backend/executable-features.js.map +1 -1
  12. package/dist/backend/immutability.d.ts +6 -3
  13. package/dist/backend/immutability.js +33 -29
  14. package/dist/backend/immutability.js.map +1 -1
  15. package/dist/backend/library-pack.js +1 -0
  16. package/dist/backend/library-pack.js.map +1 -1
  17. package/dist/backend/llvm/alloc.d.ts +16 -1
  18. package/dist/backend/llvm/alloc.js +54 -4
  19. package/dist/backend/llvm/alloc.js.map +1 -1
  20. package/dist/backend/llvm/appended-array-literals.d.ts +2 -1
  21. package/dist/backend/llvm/appended-array-literals.js +44 -36
  22. package/dist/backend/llvm/appended-array-literals.js.map +1 -1
  23. package/dist/backend/llvm/appended-array-literals.test.js +4 -3
  24. package/dist/backend/llvm/appended-array-literals.test.js.map +1 -1
  25. package/dist/backend/llvm/array-search.d.ts +4 -3
  26. package/dist/backend/llvm/array-search.js +21 -9
  27. package/dist/backend/llvm/array-search.js.map +1 -1
  28. package/dist/backend/llvm/blocks.d.ts +1 -1
  29. package/dist/backend/llvm/blocks.js +2 -2
  30. package/dist/backend/llvm/blocks.js.map +1 -1
  31. package/dist/backend/llvm/byte-windows.js +2 -0
  32. package/dist/backend/llvm/byte-windows.js.map +1 -1
  33. package/dist/backend/llvm/bytes-alias.d.ts +6 -1
  34. package/dist/backend/llvm/bytes-alias.js +8 -2
  35. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  36. package/dist/backend/llvm/bytes-loop-versions.d.ts +47 -5
  37. package/dist/backend/llvm/bytes-loop-versions.js +479 -32
  38. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  39. package/dist/backend/llvm/bytes-loop-versions.test.js +263 -2
  40. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  41. package/dist/backend/llvm/checked-value-lifetimes.js +2 -0
  42. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  43. package/dist/backend/llvm/classes.d.ts +7 -5
  44. package/dist/backend/llvm/classes.js +44 -20
  45. package/dist/backend/llvm/classes.js.map +1 -1
  46. package/dist/backend/llvm/classes.test.js +167 -7
  47. package/dist/backend/llvm/classes.test.js.map +1 -1
  48. package/dist/backend/llvm/common.d.ts +9 -3
  49. package/dist/backend/llvm/common.js +9 -3
  50. package/dist/backend/llvm/common.js.map +1 -1
  51. package/dist/backend/llvm/constant-callbacks.d.ts +2 -1
  52. package/dist/backend/llvm/constant-callbacks.js +83 -52
  53. package/dist/backend/llvm/constant-callbacks.js.map +1 -1
  54. package/dist/backend/llvm/counted-loops.d.ts +7 -0
  55. package/dist/backend/llvm/counted-loops.js +18 -0
  56. package/dist/backend/llvm/counted-loops.js.map +1 -1
  57. package/dist/backend/llvm/debug-info.js +2 -5
  58. package/dist/backend/llvm/debug-info.js.map +1 -1
  59. package/dist/backend/llvm/dense-array-access.d.ts +39 -8
  60. package/dist/backend/llvm/dense-array-access.js +222 -52
  61. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  62. package/dist/backend/llvm/dense-array-access.test.js +36 -0
  63. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  64. package/dist/backend/llvm/dense-array-loops.d.ts +17 -1
  65. package/dist/backend/llvm/dense-array-loops.js +194 -5
  66. package/dist/backend/llvm/dense-array-loops.js.map +1 -1
  67. package/dist/backend/llvm/dense-array-loops.test.js +90 -1
  68. package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
  69. package/dist/backend/llvm/dyn-handle-tags.test.js +6 -1
  70. package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
  71. package/dist/backend/llvm/dyn.d.ts +30 -0
  72. package/dist/backend/llvm/dyn.js +373 -70
  73. package/dist/backend/llvm/dyn.js.map +1 -1
  74. package/dist/backend/llvm/emit-function.js +13 -28
  75. package/dist/backend/llvm/emit-function.js.map +1 -1
  76. package/dist/backend/llvm/emit-journal.d.ts +93 -0
  77. package/dist/backend/llvm/emit-journal.js +170 -0
  78. package/dist/backend/llvm/emit-journal.js.map +1 -0
  79. package/dist/backend/llvm/emit-module.js +211 -33
  80. package/dist/backend/llvm/emit-module.js.map +1 -1
  81. package/dist/backend/llvm/emit-statements.d.ts +0 -4
  82. package/dist/backend/llvm/emit-statements.js +268 -84
  83. package/dist/backend/llvm/emit-statements.js.map +1 -1
  84. package/dist/backend/llvm/emitter-state.d.ts +7 -0
  85. package/dist/backend/llvm/emitter-state.js +14 -0
  86. package/dist/backend/llvm/emitter-state.js.map +1 -0
  87. package/dist/backend/llvm/emitter.d.ts +186 -37
  88. package/dist/backend/llvm/emitter.js +733 -90
  89. package/dist/backend/llvm/emitter.js.map +1 -1
  90. package/dist/backend/llvm/emitter.test.js +65 -7
  91. package/dist/backend/llvm/emitter.test.js.map +1 -1
  92. package/dist/backend/llvm/expr-async.js +11 -13
  93. package/dist/backend/llvm/expr-async.js.map +1 -1
  94. package/dist/backend/llvm/expr-bytes.js +48 -20
  95. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  96. package/dist/backend/llvm/expr-callbacks.js +47 -0
  97. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  98. package/dist/backend/llvm/expr-calls.js +28 -14
  99. package/dist/backend/llvm/expr-calls.js.map +1 -1
  100. package/dist/backend/llvm/expr-containers.d.ts +14 -2
  101. package/dist/backend/llvm/expr-containers.js +143 -37
  102. package/dist/backend/llvm/expr-containers.js.map +1 -1
  103. package/dist/backend/llvm/expr-context.d.ts +14 -0
  104. package/dist/backend/llvm/expr-dynamic.js +18 -11
  105. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  106. package/dist/backend/llvm/expr-primitives.js +119 -38
  107. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  108. package/dist/backend/llvm/expr-primitives.test.js +11 -6
  109. package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
  110. package/dist/backend/llvm/expr-records.d.ts +12 -0
  111. package/dist/backend/llvm/expr-records.js +106 -0
  112. package/dist/backend/llvm/expr-records.js.map +1 -1
  113. package/dist/backend/llvm/expr-stream-bridges.d.ts +2 -2
  114. package/dist/backend/llvm/expr-stream-bridges.js +210 -69
  115. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  116. package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
  117. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  118. package/dist/backend/llvm/expr-stream-callbacks.d.ts +2 -2
  119. package/dist/backend/llvm/expr-stream-callbacks.js +74 -20
  120. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  121. package/dist/backend/llvm/int32-kind-loops.d.ts +39 -0
  122. package/dist/backend/llvm/int32-kind-loops.js +106 -0
  123. package/dist/backend/llvm/int32-kind-loops.js.map +1 -0
  124. package/dist/backend/llvm/integer-or-nan-indexes.test.d.ts +1 -0
  125. package/dist/backend/llvm/integer-or-nan-indexes.test.js +118 -0
  126. package/dist/backend/llvm/integer-or-nan-indexes.test.js.map +1 -0
  127. package/dist/backend/llvm/integer-values.d.ts +25 -1
  128. package/dist/backend/llvm/integer-values.js +95 -0
  129. package/dist/backend/llvm/integer-values.js.map +1 -1
  130. package/dist/backend/llvm/js-ic.d.ts +1 -1
  131. package/dist/backend/llvm/js-ic.js +1 -1
  132. package/dist/backend/llvm/js-ic.js.map +1 -1
  133. package/dist/backend/llvm/key-orders.d.ts +7 -0
  134. package/dist/backend/llvm/key-orders.js +33 -0
  135. package/dist/backend/llvm/key-orders.js.map +1 -0
  136. package/dist/backend/llvm/lib-connect.js +4 -0
  137. package/dist/backend/llvm/lib-connect.js.map +1 -1
  138. package/dist/backend/llvm/lib-datagram.js +11 -0
  139. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  140. package/dist/backend/llvm/lib-dispatch.js +213 -5
  141. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  142. package/dist/backend/llvm/lib-filesystem.js +4 -4
  143. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  144. package/dist/backend/llvm/lib-http2.js +4 -0
  145. package/dist/backend/llvm/lib-http2.js.map +1 -1
  146. package/dist/backend/llvm/lib-lookup.js +16 -6
  147. package/dist/backend/llvm/lib-lookup.js.map +1 -1
  148. package/dist/backend/llvm/lib-process.js +37 -1
  149. package/dist/backend/llvm/lib-process.js.map +1 -1
  150. package/dist/backend/llvm/lib-shared.js +94 -2
  151. package/dist/backend/llvm/lib-shared.js.map +1 -1
  152. package/dist/backend/llvm/lib-stream.js +35 -5
  153. package/dist/backend/llvm/lib-stream.js.map +1 -1
  154. package/dist/backend/llvm/local-array-reads.js +115 -19
  155. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  156. package/dist/backend/llvm/local-array-reads.test.js +14 -0
  157. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  158. package/dist/backend/llvm/loop-state.d.ts +33 -0
  159. package/dist/backend/llvm/loop-state.js +42 -0
  160. package/dist/backend/llvm/loop-state.js.map +1 -0
  161. package/dist/backend/llvm/map-number-lookup.d.ts +26 -8
  162. package/dist/backend/llvm/map-number-lookup.js +91 -31
  163. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  164. package/dist/backend/llvm/map-number-lookup.test.js +55 -0
  165. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  166. package/dist/backend/llvm/map-read-lifetimes.js +4 -2
  167. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  168. package/dist/backend/llvm/nullable-unions.d.ts +2 -1
  169. package/dist/backend/llvm/nullable-unions.js +15 -3
  170. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  171. package/dist/backend/llvm/publish.d.ts +10 -0
  172. package/dist/backend/llvm/publish.js +15 -3
  173. package/dist/backend/llvm/publish.js.map +1 -1
  174. package/dist/backend/llvm/receivers.js +6 -1
  175. package/dist/backend/llvm/receivers.js.map +1 -1
  176. package/dist/backend/llvm/record-results.d.ts +1 -9
  177. package/dist/backend/llvm/record-results.js +2 -11
  178. package/dist/backend/llvm/record-results.js.map +1 -1
  179. package/dist/backend/llvm/reference-effects.js +3 -0
  180. package/dist/backend/llvm/reference-effects.js.map +1 -1
  181. package/dist/backend/llvm/reference-writes.d.ts +7 -2
  182. package/dist/backend/llvm/reference-writes.js +89 -72
  183. package/dist/backend/llvm/reference-writes.js.map +1 -1
  184. package/dist/backend/llvm/running-extrema.d.ts +11 -0
  185. package/dist/backend/llvm/running-extrema.js +115 -0
  186. package/dist/backend/llvm/running-extrema.js.map +1 -0
  187. package/dist/backend/llvm/running-extrema.test.d.ts +1 -0
  188. package/dist/backend/llvm/running-extrema.test.js +89 -0
  189. package/dist/backend/llvm/running-extrema.test.js.map +1 -0
  190. package/dist/backend/llvm/shapes.d.ts +71 -15
  191. package/dist/backend/llvm/shapes.js +224 -40
  192. package/dist/backend/llvm/shapes.js.map +1 -1
  193. package/dist/backend/llvm/shapes.test.js +53 -7
  194. package/dist/backend/llvm/shapes.test.js.map +1 -1
  195. package/dist/backend/llvm/speculative-integers.d.ts +6 -0
  196. package/dist/backend/llvm/speculative-integers.js +2 -2
  197. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  198. package/dist/backend/llvm/stack-captures.js +1 -5
  199. package/dist/backend/llvm/stack-captures.js.map +1 -1
  200. package/dist/backend/llvm/stack-objects.d.ts +3 -2
  201. package/dist/backend/llvm/stack-objects.js +5 -2
  202. package/dist/backend/llvm/stack-objects.js.map +1 -1
  203. package/dist/backend/llvm/string-reads.d.ts +12 -0
  204. package/dist/backend/llvm/string-reads.js +44 -0
  205. package/dist/backend/llvm/string-reads.js.map +1 -1
  206. package/dist/backend/llvm/union-repr.d.ts +4 -3
  207. package/dist/backend/llvm/union-repr.js +6 -5
  208. package/dist/backend/llvm/union-repr.js.map +1 -1
  209. package/dist/backend/llvm/walk-borrows.d.ts +3 -0
  210. package/dist/backend/llvm/walk-borrows.js +46 -41
  211. package/dist/backend/llvm/walk-borrows.js.map +1 -1
  212. package/dist/backend/llvm/walkers.d.ts +3 -0
  213. package/dist/backend/llvm/walkers.js +101 -65
  214. package/dist/backend/llvm/walkers.js.map +1 -1
  215. package/dist/backend/llvm/wrapping-sums.d.ts +16 -1
  216. package/dist/backend/llvm/wrapping-sums.js +126 -0
  217. package/dist/backend/llvm/wrapping-sums.js.map +1 -1
  218. package/dist/backend/may-throw.d.ts +8 -10
  219. package/dist/backend/may-throw.js +14 -10
  220. package/dist/backend/may-throw.js.map +1 -1
  221. package/dist/backend/native/contracts.d.ts +5 -0
  222. package/dist/backend/native/executable.js +7 -0
  223. package/dist/backend/native/executable.js.map +1 -1
  224. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  225. package/dist/backend/native/runtime-inputs.js +1 -0
  226. package/dist/backend/native/runtime-inputs.js.map +1 -1
  227. package/dist/backend/native-codegen-core.d.ts +5 -3
  228. package/dist/backend/native-codegen-core.js +13 -6
  229. package/dist/backend/native-codegen-core.js.map +1 -1
  230. package/dist/backend/native-codegen.test.js +6 -4
  231. package/dist/backend/native-codegen.test.js.map +1 -1
  232. package/dist/backend/native-link-info-core.d.ts +4 -0
  233. package/dist/backend/native-link-info-core.js.map +1 -1
  234. package/dist/backend/publication.d.ts +12 -1
  235. package/dist/backend/publication.js +37 -14
  236. package/dist/backend/publication.js.map +1 -1
  237. package/dist/backend/publication.test.js +30 -0
  238. package/dist/backend/publication.test.js.map +1 -1
  239. package/dist/backend/result-slots.d.ts +16 -0
  240. package/dist/backend/result-slots.js +23 -0
  241. package/dist/backend/result-slots.js.map +1 -0
  242. package/dist/backend/runtime-abi.d.ts +2 -2
  243. package/dist/backend/runtime-abi.js +2 -2
  244. package/dist/backend/runtime-pack-core.d.ts +1 -0
  245. package/dist/backend/runtime-pack-core.js +1 -0
  246. package/dist/backend/runtime-pack-core.js.map +1 -1
  247. package/dist/backend/runtime-pack-targets.test.js +2 -1
  248. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  249. package/dist/backend/runtime-pack.test.js +2 -1
  250. package/dist/backend/runtime-pack.test.js.map +1 -1
  251. package/dist/backend/stack-observations.d.ts +2 -1
  252. package/dist/backend/stack-observations.js +67 -42
  253. package/dist/backend/stack-observations.js.map +1 -1
  254. package/dist/backend/target-cpu.d.ts +26 -0
  255. package/dist/backend/target-cpu.js +98 -0
  256. package/dist/backend/target-cpu.js.map +1 -0
  257. package/dist/backend/target-cpu.test.d.ts +1 -0
  258. package/dist/backend/target-cpu.test.js +38 -0
  259. package/dist/backend/target-cpu.test.js.map +1 -0
  260. package/dist/backend/target-diagnostics.js +5 -3
  261. package/dist/backend/target-diagnostics.js.map +1 -1
  262. package/dist/backend/warm-cache.js +1 -0
  263. package/dist/backend/warm-cache.js.map +1 -1
  264. package/dist/cli/command.js +20 -1
  265. package/dist/cli/command.js.map +1 -1
  266. package/dist/cli/usage.d.ts +4 -1
  267. package/dist/cli/usage.js +10 -3
  268. package/dist/cli/usage.js.map +1 -1
  269. package/dist/compat/fetch-profile.js +1 -1
  270. package/dist/compat/fetch-profile.js.map +1 -1
  271. package/dist/compile-types.d.ts +7 -0
  272. package/dist/contracts/check.js +4 -3
  273. package/dist/contracts/check.js.map +1 -1
  274. package/dist/contracts/int32-elements.js +10 -2
  275. package/dist/contracts/int32-elements.js.map +1 -1
  276. package/dist/coverage/report.js +12 -3
  277. package/dist/coverage/report.js.map +1 -1
  278. package/dist/diagnostics/diagnostic.d.ts +4 -0
  279. package/dist/diagnostics/diagnostic.js +1 -1
  280. package/dist/diagnostics/diagnostic.js.map +1 -1
  281. package/dist/diagnostics/envelope.d.ts +3 -0
  282. package/dist/diagnostics/envelope.js +1 -0
  283. package/dist/diagnostics/envelope.js.map +1 -1
  284. package/dist/executable/executable-cache.d.ts +5 -0
  285. package/dist/executable/executable-cache.js +5 -0
  286. package/dist/executable/executable-cache.js.map +1 -1
  287. package/dist/executable/executable-cache.test.js +3 -0
  288. package/dist/executable/executable-cache.test.js.map +1 -1
  289. package/dist/frontend/decl-projection.d.ts +41 -0
  290. package/dist/frontend/decl-projection.js +949 -0
  291. package/dist/frontend/decl-projection.js.map +1 -0
  292. package/dist/frontend/decl-projection.test.d.ts +1 -0
  293. package/dist/frontend/decl-projection.test.js +30 -0
  294. package/dist/frontend/decl-projection.test.js.map +1 -0
  295. package/dist/frontend/dts-paths.d.ts +15 -0
  296. package/dist/frontend/dts-paths.js +25 -0
  297. package/dist/frontend/dts-paths.js.map +1 -1
  298. package/dist/frontend/input-tracker.d.ts +6 -0
  299. package/dist/frontend/input-tracker.js +51 -28
  300. package/dist/frontend/input-tracker.js.map +1 -1
  301. package/dist/frontend/input-tracker.test.js +19 -0
  302. package/dist/frontend/input-tracker.test.js.map +1 -1
  303. package/dist/frontend/lowering/array-values.js +100 -2
  304. package/dist/frontend/lowering/array-values.js.map +1 -1
  305. package/dist/frontend/lowering/builtins/async-context.d.ts +8 -2
  306. package/dist/frontend/lowering/builtins/async-context.js +62 -3
  307. package/dist/frontend/lowering/builtins/async-context.js.map +1 -1
  308. package/dist/frontend/lowering/builtins/child-process-methods.js +46 -15
  309. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  310. package/dist/frontend/lowering/builtins/child-process.js +13 -2
  311. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  312. package/dist/frontend/lowering/builtins/crypto.js +87 -10
  313. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  314. package/dist/frontend/lowering/builtins/dates.js +4 -1
  315. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  316. package/dist/frontend/lowering/builtins/filesystem-calls.js +3 -3
  317. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  318. package/dist/frontend/lowering/builtins/fs-glob.js +6 -3
  319. package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -1
  320. package/dist/frontend/lowering/builtins/fs-paths.d.ts +43 -5
  321. package/dist/frontend/lowering/builtins/fs-paths.js +245 -93
  322. package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -1
  323. package/dist/frontend/lowering/builtins/global-namespace-keys.d.ts +3 -0
  324. package/dist/frontend/lowering/builtins/global-namespace-keys.js +122 -0
  325. package/dist/frontend/lowering/builtins/global-namespace-keys.js.map +1 -0
  326. package/dist/frontend/lowering/builtins/module-calls.js +6 -3
  327. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  328. package/dist/frontend/lowering/builtins/numbers.js +9 -1
  329. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  330. package/dist/frontend/lowering/builtins/promises.d.ts +7 -1
  331. package/dist/frontend/lowering/builtins/promises.js +236 -139
  332. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  333. package/dist/frontend/lowering/builtins/readline.d.ts +5 -1
  334. package/dist/frontend/lowering/builtins/readline.js +35 -3
  335. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  336. package/dist/frontend/lowering/builtins/url.js +24 -1
  337. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  338. package/dist/frontend/lowering/builtins/webassembly.js +6 -3
  339. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  340. package/dist/frontend/lowering/call-signatures.js +0 -1
  341. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  342. package/dist/frontend/lowering/cjs-exports-object.js +1 -1
  343. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  344. package/dist/frontend/lowering/cjs-inline-require.d.ts +32 -0
  345. package/dist/frontend/lowering/cjs-inline-require.js +307 -4
  346. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  347. package/dist/frontend/lowering/class-callbacks.d.ts +5 -2
  348. package/dist/frontend/lowering/class-callbacks.js +82 -12
  349. package/dist/frontend/lowering/class-callbacks.js.map +1 -1
  350. package/dist/frontend/lowering/class-construction.d.ts +4 -1
  351. package/dist/frontend/lowering/class-construction.js +17 -3
  352. package/dist/frontend/lowering/class-construction.js.map +1 -1
  353. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +49 -2
  354. package/dist/frontend/lowering/class-dynamic-dispatch.js +880 -108
  355. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  356. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +47 -0
  357. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  358. package/dist/frontend/lowering/class-iterables.d.ts +2 -1
  359. package/dist/frontend/lowering/class-iterables.js +9 -1
  360. package/dist/frontend/lowering/class-iterables.js.map +1 -1
  361. package/dist/frontend/lowering/class-method-mutations.js +83 -24
  362. package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
  363. package/dist/frontend/lowering/class-protocols.d.ts +25 -0
  364. package/dist/frontend/lowering/class-protocols.js +183 -1
  365. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  366. package/dist/frontend/lowering/class-prototypes.js +31 -2
  367. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  368. package/dist/frontend/lowering/class-runtime-statics.d.ts +9 -3
  369. package/dist/frontend/lowering/class-runtime-statics.js +29 -4
  370. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  371. package/dist/frontend/lowering/coercions/structural-plans.js +48 -1
  372. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  373. package/dist/frontend/lowering/coercions/structural.js +91 -1
  374. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  375. package/dist/frontend/lowering/completion-callbacks.d.ts +4 -0
  376. package/dist/frontend/lowering/completion-callbacks.js +146 -0
  377. package/dist/frontend/lowering/completion-callbacks.js.map +1 -0
  378. package/dist/frontend/lowering/containers/array-callback-call.js +2 -2
  379. package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
  380. package/dist/frontend/lowering/containers/array-callbacks.d.ts +5 -4
  381. package/dist/frontend/lowering/containers/array-callbacks.js +345 -24
  382. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  383. package/dist/frontend/lowering/containers/array-concat.js +10 -0
  384. package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
  385. package/dist/frontend/lowering/containers/array-construction.js +5 -0
  386. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  387. package/dist/frontend/lowering/containers/array-methods.js +26 -3
  388. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  389. package/dist/frontend/lowering/containers/array-pipelines.js +19 -8
  390. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  391. package/dist/frontend/lowering/containers/bytes.d.ts +25 -17
  392. package/dist/frontend/lowering/containers/bytes.js +455 -46
  393. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  394. package/dist/frontend/lowering/containers/callback-arguments.js +3 -0
  395. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  396. package/dist/frontend/lowering/containers/collection-methods.js +7 -2
  397. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  398. package/dist/frontend/lowering/containers/filter-predicates.d.ts +6 -0
  399. package/dist/frontend/lowering/containers/filter-predicates.js +205 -0
  400. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -0
  401. package/dist/frontend/lowering/containers/indexed-objects.d.ts +0 -12
  402. package/dist/frontend/lowering/containers/indexed-objects.js +46 -7
  403. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  404. package/dist/frontend/lowering/containers/string-and-regexp.js +55 -9
  405. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  406. package/dist/frontend/lowering/containers/string-replacement.js +43 -19
  407. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
  408. package/dist/frontend/lowering/date-values.d.ts +11 -0
  409. package/dist/frontend/lowering/date-values.js +207 -0
  410. package/dist/frontend/lowering/date-values.js.map +1 -0
  411. package/dist/frontend/lowering/dispatch-sites.js +15 -1
  412. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  413. package/dist/frontend/lowering/divergences.js +9 -1
  414. package/dist/frontend/lowering/divergences.js.map +1 -1
  415. package/dist/frontend/lowering/error-methods.js +47 -2
  416. package/dist/frontend/lowering/error-methods.js.map +1 -1
  417. package/dist/frontend/lowering/expressions/array-literals.js +53 -0
  418. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  419. package/dist/frontend/lowering/expressions/binary.js +100 -28
  420. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  421. package/dist/frontend/lowering/expressions/element-access.js +169 -13
  422. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  423. package/dist/frontend/lowering/expressions/identifiers.js +64 -5
  424. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  425. package/dist/frontend/lowering/expressions/narrowing.js +95 -1
  426. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  427. package/dist/frontend/lowering/expressions/nullish-assignment.js +3 -1
  428. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  429. package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -0
  430. package/dist/frontend/lowering/expressions/object-literals.js +138 -51
  431. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  432. package/dist/frontend/lowering/expressions/optional-chains.js +12 -0
  433. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  434. package/dist/frontend/lowering/expressions/property-access.js +168 -10
  435. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  436. package/dist/frontend/lowering/expressions/relational.js +212 -33
  437. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  438. package/dist/frontend/lowering/expressions/typeof.js +6 -0
  439. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  440. package/dist/frontend/lowering/expressions/union-fields.js +4 -0
  441. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  442. package/dist/frontend/lowering/expressions/updates.js +39 -3
  443. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  444. package/dist/frontend/lowering/frozen-records.d.ts +28 -0
  445. package/dist/frontend/lowering/frozen-records.js +322 -0
  446. package/dist/frontend/lowering/frozen-records.js.map +1 -0
  447. package/dist/frontend/lowering/function-returns.js +64 -0
  448. package/dist/frontend/lowering/function-returns.js.map +1 -1
  449. package/dist/frontend/lowering/generic-functions.js +7 -2
  450. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  451. package/dist/frontend/lowering/indexed-unions.d.ts +54 -0
  452. package/dist/frontend/lowering/indexed-unions.js +401 -0
  453. package/dist/frontend/lowering/indexed-unions.js.map +1 -0
  454. package/dist/frontend/lowering/iterable-values.d.ts +49 -0
  455. package/dist/frontend/lowering/iterable-values.js +297 -0
  456. package/dist/frontend/lowering/iterable-values.js.map +1 -0
  457. package/dist/frontend/lowering/iterator-adapters.js +186 -1
  458. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  459. package/dist/frontend/lowering/js-class-fields.d.ts +8 -0
  460. package/dist/frontend/lowering/js-class-fields.js +45 -10
  461. package/dist/frontend/lowering/js-class-fields.js.map +1 -1
  462. package/dist/frontend/lowering/key-order-witness.d.ts +18 -3
  463. package/dist/frontend/lowering/key-order-witness.js +974 -48
  464. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  465. package/dist/frontend/lowering/key-order-witness.test.js +530 -10
  466. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  467. package/dist/frontend/lowering/lower-assert.js +15 -3
  468. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  469. package/dist/frontend/lowering/lower-async-iteration.js +4 -1
  470. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  471. package/dist/frontend/lowering/lower-calls.d.ts +7 -0
  472. package/dist/frontend/lowering/lower-calls.js +462 -44
  473. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  474. package/dist/frontend/lowering/lower-classes.d.ts +11 -2
  475. package/dist/frontend/lowering/lower-classes.js +324 -69
  476. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  477. package/dist/frontend/lowering/lower-dgram.js +3 -1
  478. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  479. package/dist/frontend/lowering/lower-exprs.js +215 -3
  480. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  481. package/dist/frontend/lowering/lower-functions.d.ts +11 -0
  482. package/dist/frontend/lowering/lower-functions.js +83 -0
  483. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  484. package/dist/frontend/lowering/lower-generators.js +42 -32
  485. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  486. package/dist/frontend/lowering/lower-global-value.js +6 -3
  487. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  488. package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
  489. package/dist/frontend/lowering/lower-inspect.js +53 -17
  490. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  491. package/dist/frontend/lowering/lower-modules.js +53 -5
  492. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  493. package/dist/frontend/lowering/lower-namespaces.js +5 -1
  494. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  495. package/dist/frontend/lowering/lower-server.js +2 -2
  496. package/dist/frontend/lowering/lower-server.js.map +1 -1
  497. package/dist/frontend/lowering/lower-stdlib.d.ts +5 -0
  498. package/dist/frontend/lowering/lower-stdlib.js +30 -0
  499. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  500. package/dist/frontend/lowering/lower-stmts.d.ts +23 -0
  501. package/dist/frontend/lowering/lower-stmts.js +553 -81
  502. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  503. package/dist/frontend/lowering/lower-stream.d.ts +20 -2
  504. package/dist/frontend/lowering/lower-stream.js +1483 -156
  505. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  506. package/dist/frontend/lowering/lowerer.d.ts +107 -8
  507. package/dist/frontend/lowering/lowerer.js +381 -36
  508. package/dist/frontend/lowering/lowerer.js.map +1 -1
  509. package/dist/frontend/lowering/module-namespace-elements.d.ts +11 -1
  510. package/dist/frontend/lowering/module-namespace-elements.js +82 -5
  511. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  512. package/dist/frontend/lowering/new-target.d.ts +12 -0
  513. package/dist/frontend/lowering/new-target.js +280 -0
  514. package/dist/frontend/lowering/new-target.js.map +1 -0
  515. package/dist/frontend/lowering/object-factory-new.d.ts +5 -0
  516. package/dist/frontend/lowering/object-factory-new.js +20 -6
  517. package/dist/frontend/lowering/object-factory-new.js.map +1 -1
  518. package/dist/frontend/lowering/overload-choice.d.ts +33 -0
  519. package/dist/frontend/lowering/overload-choice.js +190 -0
  520. package/dist/frontend/lowering/overload-choice.js.map +1 -0
  521. package/dist/frontend/lowering/surfaces.d.ts +3 -0
  522. package/dist/frontend/lowering/surfaces.js +73 -8
  523. package/dist/frontend/lowering/surfaces.js.map +1 -1
  524. package/dist/frontend/lowering/undefined-index.d.ts +27 -0
  525. package/dist/frontend/lowering/undefined-index.js +82 -0
  526. package/dist/frontend/lowering/undefined-index.js.map +1 -0
  527. package/dist/frontend/lowering/var-hoisting.js +29 -13
  528. package/dist/frontend/lowering/var-hoisting.js.map +1 -1
  529. package/dist/frontend/lowering/width-lift.d.ts +18 -0
  530. package/dist/frontend/npm-static-bundled-chunks.js +9 -11
  531. package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
  532. package/dist/frontend/npm-static-bundled-chunks.test.js +6 -5
  533. package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
  534. package/dist/frontend/npm-static-rewrite-syntax.js +9 -1
  535. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  536. package/dist/frontend/npm-static.js +4 -20
  537. package/dist/frontend/npm-static.js.map +1 -1
  538. package/dist/frontend/package-shims.d.ts +3 -0
  539. package/dist/frontend/package-shims.js +71 -8
  540. package/dist/frontend/package-shims.js.map +1 -1
  541. package/dist/frontend/pipeline.js +19 -11
  542. package/dist/frontend/pipeline.js.map +1 -1
  543. package/dist/frontend/process-fork.d.ts +25 -0
  544. package/dist/frontend/process-fork.js +2 -0
  545. package/dist/frontend/process-fork.js.map +1 -0
  546. package/dist/frontend/program-analysis.d.ts +5 -1
  547. package/dist/frontend/program-analysis.js +5 -0
  548. package/dist/frontend/program-analysis.js.map +1 -1
  549. package/dist/frontend/program.d.ts +21 -6
  550. package/dist/frontend/program.js +681 -83
  551. package/dist/frontend/program.js.map +1 -1
  552. package/dist/frontend/program.test.js +43 -3
  553. package/dist/frontend/program.test.js.map +1 -1
  554. package/dist/frontend/token-equivalence.d.ts +3 -0
  555. package/dist/frontend/token-equivalence.js +409 -0
  556. package/dist/frontend/token-equivalence.js.map +1 -0
  557. package/dist/frontend/token-equivalence.test.d.ts +1 -0
  558. package/dist/frontend/token-equivalence.test.js +67 -0
  559. package/dist/frontend/token-equivalence.test.js.map +1 -0
  560. package/dist/frontend/ts7/ast-node.d.ts +22 -0
  561. package/dist/frontend/ts7/ast-node.js +1048 -103
  562. package/dist/frontend/ts7/ast-node.js.map +1 -1
  563. package/dist/frontend/ts7/ast-node.test.js +24 -0
  564. package/dist/frontend/ts7/ast-node.test.js.map +1 -1
  565. package/dist/frontend/ts7/ast-wire.d.ts +4 -3
  566. package/dist/frontend/ts7/ast-wire.js +34 -24
  567. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  568. package/dist/frontend/ts7/ast-wire.test.js +23 -0
  569. package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
  570. package/dist/frontend/ts7/checker-backend.d.ts +3 -4
  571. package/dist/frontend/ts7/checker-backend.js +2 -2
  572. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  573. package/dist/frontend/ts7/checker-backend.test.js +5 -9
  574. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  575. package/dist/frontend/ts7/checker.d.ts +4 -0
  576. package/dist/frontend/ts7/checker.js +7 -0
  577. package/dist/frontend/ts7/checker.js.map +1 -1
  578. package/dist/frontend/ts7/lib-diagnostics.d.ts +24 -0
  579. package/dist/frontend/ts7/lib-diagnostics.js +307 -0
  580. package/dist/frontend/ts7/lib-diagnostics.js.map +1 -0
  581. package/dist/frontend/ts7/lib-diagnostics.test.d.ts +1 -0
  582. package/dist/frontend/ts7/lib-diagnostics.test.js +199 -0
  583. package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -0
  584. package/dist/frontend/ts7/program-host.d.ts +7 -0
  585. package/dist/frontend/ts7/program-host.js +25 -2
  586. package/dist/frontend/ts7/program-host.js.map +1 -1
  587. package/dist/frontend/ts7/semantic-model.d.ts +3 -0
  588. package/dist/frontend/ts7/semantic-model.js +5 -0
  589. package/dist/frontend/ts7/semantic-model.js.map +1 -1
  590. package/dist/frontend/ts7/semantic-model.test.js +6 -1
  591. package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
  592. package/dist/frontend/ts7/semantic-types.d.ts +1 -1
  593. package/dist/frontend/ts7/semantic-types.js +1 -1
  594. package/dist/frontend/ts7/semantic-types.js.map +1 -1
  595. package/dist/frontend/ts7/session.d.ts +14 -1
  596. package/dist/frontend/ts7/session.js +22 -0
  597. package/dist/frontend/ts7/session.js.map +1 -1
  598. package/dist/frontend/type-mapper.d.ts +13 -1
  599. package/dist/frontend/type-mapper.js +229 -20
  600. package/dist/frontend/type-mapper.js.map +1 -1
  601. package/dist/index.d.ts +0 -5
  602. package/dist/index.js +46 -4
  603. package/dist/index.js.map +1 -1
  604. package/dist/ir/analysis.js +5 -3
  605. package/dist/ir/analysis.js.map +1 -1
  606. package/dist/ir/array-length-stability.d.ts +4 -0
  607. package/dist/ir/array-length-stability.js +19 -6
  608. package/dist/ir/array-length-stability.js.map +1 -1
  609. package/dist/ir/array-length-stability.test.js +24 -0
  610. package/dist/ir/array-length-stability.test.js.map +1 -1
  611. package/dist/ir/builtin-effects.d.ts +7 -0
  612. package/dist/ir/builtin-effects.js +60 -0
  613. package/dist/ir/builtin-effects.js.map +1 -1
  614. package/dist/ir/builtin-signatures.d.ts +6 -4
  615. package/dist/ir/builtin-signatures.js +222 -13
  616. package/dist/ir/builtin-signatures.js.map +1 -1
  617. package/dist/ir/callback-specialization.d.ts +2 -1
  618. package/dist/ir/callback-specialization.js +23 -18
  619. package/dist/ir/callback-specialization.js.map +1 -1
  620. package/dist/ir/char-unit-locals.d.ts +19 -0
  621. package/dist/ir/char-unit-locals.js +185 -0
  622. package/dist/ir/char-unit-locals.js.map +1 -0
  623. package/dist/ir/char-unit-locals.test.d.ts +1 -0
  624. package/dist/ir/char-unit-locals.test.js +94 -0
  625. package/dist/ir/char-unit-locals.test.js.map +1 -0
  626. package/dist/ir/final-fields.d.ts +2 -1
  627. package/dist/ir/final-fields.js +14 -16
  628. package/dist/ir/final-fields.js.map +1 -1
  629. package/dist/ir/function-references.d.ts +2 -0
  630. package/dist/ir/function-references.js +2 -0
  631. package/dist/ir/function-references.js.map +1 -1
  632. package/dist/ir/function-references.test.js +3 -0
  633. package/dist/ir/function-references.test.js.map +1 -1
  634. package/dist/ir/initializer-bindings.d.ts +2 -1
  635. package/dist/ir/initializer-bindings.js +27 -20
  636. package/dist/ir/initializer-bindings.js.map +1 -1
  637. package/dist/ir/int32-arrays.d.ts +108 -0
  638. package/dist/ir/int32-arrays.js +831 -0
  639. package/dist/ir/int32-arrays.js.map +1 -0
  640. package/dist/ir/int32-slots.d.ts +24 -2
  641. package/dist/ir/int32-slots.js +266 -57
  642. package/dist/ir/int32-slots.js.map +1 -1
  643. package/dist/ir/int32-slots.test.js +33 -0
  644. package/dist/ir/int32-slots.test.js.map +1 -1
  645. package/dist/ir/integer-loops.d.ts +3 -3
  646. package/dist/ir/integer-loops.js +28 -10
  647. package/dist/ir/integer-loops.js.map +1 -1
  648. package/dist/ir/integer-loops.test.js +10 -0
  649. package/dist/ir/integer-loops.test.js.map +1 -1
  650. package/dist/ir/integer-ranges.d.ts +5 -0
  651. package/dist/ir/integer-ranges.js +125 -12
  652. package/dist/ir/integer-ranges.js.map +1 -1
  653. package/dist/ir/integer-ranges.test.js +30 -0
  654. package/dist/ir/integer-ranges.test.js.map +1 -1
  655. package/dist/ir/ir.d.ts +83 -10
  656. package/dist/ir/ir.js +77 -6
  657. package/dist/ir/ir.js.map +1 -1
  658. package/dist/ir/ir.test.js +23 -2
  659. package/dist/ir/ir.test.js.map +1 -1
  660. package/dist/ir/js-ic.d.ts +4 -0
  661. package/dist/ir/js-ic.js +17 -1
  662. package/dist/ir/js-ic.js.map +1 -1
  663. package/dist/ir/js-ic.test.js +46 -0
  664. package/dist/ir/js-ic.test.js.map +1 -1
  665. package/dist/ir/node-index.d.ts +57 -0
  666. package/dist/ir/node-index.js +215 -0
  667. package/dist/ir/node-index.js.map +1 -0
  668. package/dist/ir/paired-while-loops.d.ts +25 -0
  669. package/dist/ir/paired-while-loops.js +335 -0
  670. package/dist/ir/paired-while-loops.js.map +1 -0
  671. package/dist/ir/paired-while-loops.test.d.ts +1 -0
  672. package/dist/ir/paired-while-loops.test.js +163 -0
  673. package/dist/ir/paired-while-loops.test.js.map +1 -0
  674. package/dist/ir/parameter-versions.d.ts +25 -0
  675. package/dist/ir/parameter-versions.js +300 -0
  676. package/dist/ir/parameter-versions.js.map +1 -0
  677. package/dist/ir/runtime-features.d.ts +34 -13
  678. package/dist/ir/runtime-features.js +177 -39
  679. package/dist/ir/runtime-features.js.map +1 -1
  680. package/dist/ir/serialize.d.ts +12 -2
  681. package/dist/ir/serialize.js +16 -3
  682. package/dist/ir/serialize.js.map +1 -1
  683. package/dist/ir/serialize.test.js +17 -0
  684. package/dist/ir/serialize.test.js.map +1 -1
  685. package/dist/ir/traverse.js +18 -6
  686. package/dist/ir/traverse.js.map +1 -1
  687. package/dist/ir/validate.js +167 -40
  688. package/dist/ir/validate.js.map +1 -1
  689. package/dist/library/ir-policy.js +3 -0
  690. package/dist/library/ir-policy.js.map +1 -1
  691. package/dist/native/cache.d.ts +6 -1
  692. package/dist/native/cache.js +28 -5
  693. package/dist/native/cache.js.map +1 -1
  694. package/dist/native/cache.test.js +16 -2
  695. package/dist/native/cache.test.js.map +1 -1
  696. package/dist/native/cli.js +21 -1
  697. package/dist/native/cli.js.map +1 -1
  698. package/dist/native/compiler.js +8 -6
  699. package/dist/native/compiler.js.map +1 -1
  700. package/dist/native/executable-cache.d.ts +1 -1
  701. package/dist/native/executable-cache.js +2 -2
  702. package/dist/native/executable-cache.js.map +1 -1
  703. package/dist/native/prepare.d.ts +4 -2
  704. package/dist/native/prepare.js +130 -32
  705. package/dist/native/prepare.js.map +1 -1
  706. package/dist/native/prepare.test.js +96 -20
  707. package/dist/native/prepare.test.js.map +1 -1
  708. package/dist/native/sanitizer.test.js +2 -0
  709. package/dist/native/sanitizer.test.js.map +1 -1
  710. package/dist/native/text-file.d.ts +13 -3
  711. package/dist/native/text-file.js +63 -9
  712. package/dist/native/text-file.js.map +1 -1
  713. package/dist/native/text-file.test.d.ts +1 -0
  714. package/dist/native/text-file.test.js +49 -0
  715. package/dist/native/text-file.test.js.map +1 -0
  716. package/dist/native/toolchain.js +4 -4
  717. package/dist/native/toolchain.js.map +1 -1
  718. package/dist/native/toolchain.test.js +3 -3
  719. package/dist/native/toolchain.test.js.map +1 -1
  720. package/package.json +21 -21
  721. package/shims/chalk/v5.ts +688 -0
  722. package/shims/hono-node-server/v2.ts +645 -0
  723. package/shims/hot-shots/client.ts +1126 -0
  724. package/shims/hot-shots/v8-unix-dgram.ts +8 -0
  725. package/shims/hot-shots/v8.ts +8 -0
  726. package/surface-manifest.json +27 -7
@@ -1,4 +1,6 @@
1
+ import { isDeclBoundaryFile } from "../decl-projection.js";
1
2
  import { relieveHeapPressure } from "../../heap-pressure.js";
3
+ import { moduleNamespaceObject } from "./module-namespace-elements.js";
2
4
  import { keyedHelperName } from "./stable-names.js";
3
5
  import { positionTag, StructuralPositions } from "./structural-positions.js";
4
6
  import { onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
@@ -12,6 +14,7 @@ import { internTableType, lowerInternTableCall, lowerInternTableNew } from "./in
12
14
  import { lowerThreadSlotsCall, lowerThreadSlotsNew, threadSlotsType } from "./thread-slots.js";
13
15
  import { isExperimentalDeclarationFile } from "../experimental-import.js";
14
16
  import { checkCycleBindingAccesses, refuseUncheckedCycleReads, } from "./cycle-initialization.js";
17
+ import { bindCompletionCallbacks } from "./completion-callbacks.js";
15
18
  import { isJsonRequireDecl } from "./json-require.js";
16
19
  import { checkRequireBindingAccesses, } from "./require-initialization.js";
17
20
  import { identityPreservingWidening } from "./coercions/identity.js";
@@ -39,6 +42,7 @@ import { valueStreamOf } from "./builtins/hash-stream.js";
39
42
  import { lowerNetAddressCall, lowerNetAddressNew } from "./builtins/net-address.js";
40
43
  import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
41
44
  import { iteratorSlotAdapter } from "./iterator-adapters.js";
45
+ import { iterableSlotValue } from "./iterable-values.js";
42
46
  import { lowerBuiltinCall } from "./builtin-calls.js";
43
47
  import { CoercionState } from "./coercions/state.js";
44
48
  import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocker, objToRecordPlan, recordToClassPlan, } from "./coercions/structural-plans.js";
@@ -66,9 +70,11 @@ import { bindingInContext, captureContextBinding, declareContextLocal, declareCo
66
70
  import { InternalCompilerError } from "../../errors.js";
67
71
  import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
68
72
  import {} from "./class-protocol-dispatch.js";
69
- import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
73
+ import { ClassDynamicDispatch, boxClassInstancesExactly, trackClassFieldCreation, } from "./class-dynamic-dispatch.js";
70
74
  import { guardClassAttributeWrites } from "./class-attributes.js";
75
+ import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
71
76
  import { applyHandleProperties } from "./handle-properties.js";
77
+ import { installBufferValue } from "./containers/bytes.js";
72
78
  import { ClassProtocols } from "./class-protocols.js";
73
79
  import { earlyReadVarSymbols } from "./var-hoisting.js";
74
80
  import { recordTextCodecClass } from "../../ir/ir.js";
@@ -97,14 +103,14 @@ export { newFnCtx } from "./function-context.js";
97
103
  */
98
104
  import { dirname, relative, resolve } from "node:path";
99
105
  import { bindingSource } from "../binding-source.js";
100
- import { tsgoPath } from "../dts-paths.js";
106
+ import { compilerOwnedFileName, tsgoPath } from "../dts-paths.js";
101
107
  import * as ts from "../ts7/adapter.js";
102
108
  import { isBundledShimForwarder } from "../package-shims.js";
103
109
  import { erasedTypeOnlyImport } from "../type-only-imports.js";
104
110
  import { literalValues } from "../literal-values.js";
105
111
  import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
106
112
  import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
107
- import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
113
+ import { arrayOf, BOOL, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
108
114
  import { provenanceActive } from "../provenance-registry.js";
109
115
  import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
110
116
  import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, erasedOverloadMemberType, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isOverloadedCallableMemberType, isUnitOnlyTsType, isWorkerHandleType, isFetchHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
@@ -112,7 +118,7 @@ import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinF
112
118
  import { builtinClassAliasOf, runtimeClassValueOfType, } from "./builtins/class-values.js";
113
119
  import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
114
120
  import { prepareCjsModuleGraph, usesCjsTopLevelThis } from "./lower-node-module.js";
115
- import { cjsNamespaceModule, cjsWholeExportValueOf, inlineNamespaceRequireOf, inlineProgramRequireOf, } from "./cjs-inline-require.js";
121
+ import { cjsNamespaceModule, cjsWholeExportValueOf, inlineNamespaceRequireOf, inlineProgramRequireOf, splitRequireBindingOf, splitWholeExportAliasTargetOf, } from "./cjs-inline-require.js";
116
122
  import { tscInteropModuleOf } from "./cjs-tsc-interop.js";
117
123
  import { usesCjsExportsIdentity } from "./cjs-exports-object.js";
118
124
  import { registerBuiltinEventTargetClasses } from "./lower-event-target.js";
@@ -120,6 +126,7 @@ import { registerBuiltinErrorClasses, defineClassValueConstruct, runtimeClassCon
120
126
  import { mixinCallClassInfoOf, mixinIntersectionInstanceType, } from "./lower-mixins.js";
121
127
  import { tryLowerExpression } from "./expressions/try-lower-expression.js";
122
128
  import { funcTypeFromParamShapes, isThisParameter, paramShape, paramShapes, checkDefaultParamBodyType, requireExactArityValue, collectSignature, collectSignatureInner, lambdaSignature, } from "./call-signatures.js";
129
+ import { dynamicOverloadChoice, guessedOverloadIdentifier } from "./overload-choice.js";
123
130
  import { implicitAnyParamSymbolsOf, implicitLocalFnNodeOf, implicitMonoFile, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, genericLocalClassBinding, } from "./generic-functions.js";
124
131
  import { bindingNeverReassigned } from "./binding-analysis.js";
125
132
  import { bodyReadsArguments } from "../arguments-usage.js";
@@ -127,7 +134,7 @@ import { completeArgs, wrappedUndefined, undefinedArgFor } from "./call-argument
127
134
  import { bodyReturnType, declaredReturnType } from "./function-returns.js";
128
135
  import { lowerCall, lowerPromiseMethodCall, lowerFilterNarrowCall } from "./lower-calls.js";
129
136
  import { lowerFfiCall, validateFfiImports } from "./native-ffi.js";
130
- import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, } from "./lower-functions.js";
137
+ import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, blockedBodyDiagnostics, } from "./lower-functions.js";
131
138
  import { lowerArrayMethodCall } from "./containers/array-methods.js";
132
139
  import { fuseArrayPipelines } from "./containers/array-pipelines.js";
133
140
  import { lowerMapMethodCall, lowerMapForEachCall, lowerSetMethodCall, lowerSetForEachCall, } from "./containers/collection-methods.js";
@@ -152,7 +159,7 @@ import { lowerBuiltinExtraProperty } from "./builtins/properties.js";
152
159
  import { registerPromisifiedBuiltinDecl } from "./builtins/callable-aliases.js";
153
160
  import { lowerExecFileAsyncCall } from "./builtins/child-process-async.js";
154
161
  import { lowerStringDecoderMethodCall, lowerTextCodecCall } from "./builtins/text-codecs.js";
155
- import { lowerReadlineMethodCall } from "./builtins/readline.js";
162
+ import { isOptionalReadlineCursorRead, lowerReadlineMethodCall } from "./builtins/readline.js";
156
163
  import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
157
164
  import { lowerDisposableStackNew } from "./builtins/disposable-stack.js";
158
165
  import { lowerErrorCodeProperty, lowerErrorFunctionCall } from "./builtins/errors.js";
@@ -165,7 +172,7 @@ import { dateJsonType, isDateJsonSource, lowerDateCall } from "./builtins/dates.
165
172
  import { fsConstantMemberRead, fsConstantsObject, lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
166
173
  import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
167
174
  import { lowerPromiseStaticCall } from "./builtins/promises.js";
168
- import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
175
+ import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticTransformStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
169
176
  import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
170
177
  import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
171
178
  import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
@@ -173,7 +180,7 @@ import { lowerAssertModuleCall, lowerAssertDirectCall } from "./lower-assert.js"
173
180
  import { lowerUtilModuleCall } from "./lower-inspect.js";
174
181
  import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
175
182
  import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
176
- import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, } from "./lower-stmts.js";
183
+ import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, holdsEvolvingArray, } from "./lower-stmts.js";
177
184
  import { lowerExpr, maybeNarrow, lowerUnitComparison, lowerNullishCoalesce, lowerCondition, ensureBool, requireTruthyUnion, eqComparableUnion, lowerIntrinsicProperty, lowerArrayLiteral, lowerElementAccess, lowerElementWrite, lowerRecordKeyRead, ensureString, lowerTemplate, lowerAsExpression, lowerPrefixUnary, lowerBinary, lowerCaughtTypeofTest, caughtRead, caughtLocalOf, caughtToString, lowerInstanceOf, lowerRegexLiteral, lowerFieldRead, lowerUnionProperty, fieldTarget, fieldGetExpr, fieldSetStmt, lowerFieldCompound, uniqueSymbolKeyOf, matchCallbackParamGroupsOf, } from "./lower-exprs.js";
178
185
  import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
179
186
  import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
@@ -629,6 +636,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
629
636
  // travel with them: a failed statement is never left unexplained.
630
637
  const covered = {
631
638
  ...result,
639
+ diagnostics: [...result.diagnostics, ...remainder.reachedBlockedBodyDiagnostics],
632
640
  stats: { ...result.stats, statementsDynamic },
633
641
  unreached: {
634
642
  diagnostics: rem.diagnostics,
@@ -1156,6 +1164,9 @@ export class Lowerer {
1156
1164
  /** Identifiers by spelling, per file, for the generic bindings' use
1157
1165
  * ordering (runsAfterDeclaration). */
1158
1166
  bindingIdentifiers = new Map();
1167
+ /** Per JavaScript file, the declarations of the bindings it assigns an
1168
+ * own `toString` (jsAssignsOwnToString in lower-calls.ts). */
1169
+ ownToStringTargets = new Map();
1159
1170
  /** Per-symbol result of the never-reassigned file scan
1160
1171
  * (bindingNeverReassigned — object-literal generic-method receivers). */
1161
1172
  neverReassignedCache = new Map();
@@ -1414,6 +1425,9 @@ export class Lowerer {
1414
1425
  * and erased instances). */
1415
1426
  erasingDepth = 0;
1416
1427
  localClassInstantiations = [];
1428
+ /** The function-local classes of the program with an `extends` clause, whether lowering collected
1429
+ * them yet or not (new-target.ts); found on first use. */
1430
+ functionLocalSubclasses = undefined;
1417
1431
  /** Instance types (by checker type id) of the local classes generic
1418
1432
  * factory calls return, and the per-instance class each names. */
1419
1433
  localClassInstanceTypes = new Map();
@@ -1508,6 +1522,14 @@ export class Lowerer {
1508
1522
  /** Per CommonJS file using top-level `this`: the global holding the
1509
1523
  * object that stands for its original exports (lowerCjsTopLevelThis). */
1510
1524
  cjsExportsThis = new Map();
1525
+ /** `var m; m = require("./x")` alias bindings (cjs-inline-require.ts).
1526
+ * Null entries cache declarations that keep ordinary storage. */
1527
+ cjsSplitRequireBindings = new Map();
1528
+ /** Per-module whole-export symbol (cjs-inline-require.ts). Null means the
1529
+ * module's exports are a table. */
1530
+ cjsWholeExportSymbols = new Map();
1531
+ /** Per-module live member-export classification (cjs-inline-require.ts). */
1532
+ cjsLiveMemberExports = new Map();
1511
1533
  /** Inline program-module require calls whose %init the enclosing member
1512
1534
  * read or member call is already sequencing (cjs-inline-require.ts). */
1513
1535
  inlineRequireInitDone = new Set();
@@ -1558,6 +1580,10 @@ export class Lowerer {
1558
1580
  runtimeOptionalFields = new Set();
1559
1581
  /** Bindings initialized by a Date's `toJSON()` (analyzeDateJsonResults). */
1560
1582
  dateJsonBindings = new Set();
1583
+ /** isTimeValueDateDeclaration's answers, and the locals that hold a
1584
+ * Date's time value instead of a Date object (date-values.ts). */
1585
+ timeValueDateDecisions = new Map();
1586
+ timeValueDateLocals = new Set();
1561
1587
  /** Record bindings whose flow class reaches storage outside the class:
1562
1588
  * they keep the declared layout, so an initializer from unchecked reads
1563
1589
  * converts once instead of the binding adopting the widened variant. */
@@ -1631,6 +1657,47 @@ export class Lowerer {
1631
1657
  }
1632
1658
  return fallback ?? null;
1633
1659
  }
1660
+ /** A fresh TypeScript data literal (`{ message: "m" }`) passed to a
1661
+ * checked-dynamic parameter of a callee implemented in JavaScript, whose
1662
+ * contract lets it reshape the object: a call through an untyped value, an
1663
+ * untyped parameter of a JavaScript function, or a package-declared
1664
+ * parameter type (a non-library `.d.ts`) that makes one of the literal's
1665
+ * properties optional (zod's `normalizeParams` deletes `params.message`).
1666
+ * No typed alias of a fresh literal exists, so it is built as the plain
1667
+ * object the callee receives instead of a view whose record layout refuses
1668
+ * that delete. Standard-library and TypeScript callees, and literals with
1669
+ * methods or accessors, keep their native storage. */
1670
+ reshapeableContextualLiteral(literal, contextual) {
1671
+ const call = literal.parent;
1672
+ if (call === undefined ||
1673
+ !(ts.isCallExpression(call) || ts.isNewExpression(call)) ||
1674
+ !call.arguments?.nodes.includes(literal) ||
1675
+ literal.properties.nodes.length === 0 ||
1676
+ !literal.properties.nodes.every((prop) => (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&
1677
+ (ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name))))
1678
+ return false;
1679
+ const declaration = this.checker.getResolvedSignature(call)?.declaration;
1680
+ const file = declaration ? ts.getSourceFileOfNode(declaration) : undefined;
1681
+ const untyped = contextual.some((part) => part.flags & ts.TypeFlags.Any);
1682
+ if (file === undefined)
1683
+ return untyped;
1684
+ if (isJsSourceFile(file))
1685
+ return untyped;
1686
+ if (!file.isDeclarationFile || this.isStdlibFile(file))
1687
+ return false;
1688
+ if (untyped)
1689
+ return true;
1690
+ const objects = contextual.filter((part) => part.flags & ts.TypeFlags.Object);
1691
+ if (objects.length === 0)
1692
+ return false;
1693
+ return literal.properties.nodes.some((prop) => {
1694
+ const name = prop.name.text;
1695
+ return objects.every((part) => {
1696
+ const symbol = this.checker.getPropertyOfType(part, name);
1697
+ return symbol !== undefined && (symbol.flags & ts.SymbolFlags.Optional) !== 0;
1698
+ });
1699
+ });
1700
+ }
1634
1701
  /** A TypeScript object literal handed to a JavaScript checked-value
1635
1702
  * parameter whose inferred type is open (`constructor({ factory, ...options
1636
1703
  * } = {})` — the rest element admits any property): the literal names a
@@ -1964,6 +2031,8 @@ export class Lowerer {
1964
2031
  /** Parameters read as `any` in the error-path copy of an error-first
1965
2032
  * callback. */
1966
2033
  anySymbols = new Set();
2034
+ /** overload-choice's answers per call, binding and function. */
2035
+ dynamicOverloadAnswers = new Map();
1967
2036
  /** Error parameters of an error-first callback with a known value in
1968
2037
  * the copy being lowered: true while it holds an Error, false while it
1969
2038
  * holds null (staticCondition folds conditions on them). */
@@ -2038,6 +2107,9 @@ export class Lowerer {
2038
2107
  /** util.inspect's per-type traversal helpers (%util.insp.N), interned
2039
2108
  * by typeKey — the assertHelpers pattern with its own namespace. */
2040
2109
  inspectHelpers = new Map();
2110
+ /** Indexed-union safe-read helpers mapped to their numeric twins, for the
2111
+ * fusion of an immediate ToNumber (tryLowerNumericIndexRead). */
2112
+ indexedUnionNumericTwins = new Map();
2041
2113
  unionLiteralOwners = new Map();
2042
2114
  strippedUndefinedArms = new Map();
2043
2115
  addedUndefinedArms = new Map();
@@ -2068,6 +2140,10 @@ export class Lowerer {
2068
2140
  * checks resolve through this map (stdlibGlobalNameOf), declarations
2069
2141
  * emit nothing. */
2070
2142
  stdlibGlobalAliases = new Map();
2143
+ /** The stdlibGlobalAliases bound through a cast of the global object
2144
+ * (`(globalThis as { Buffer?: B }).Buffer`). Their static type is the
2145
+ * cast's, so their value reads are refused (identifiers.ts). */
2146
+ castGlobalAliases = new Set();
2071
2147
  /** CJS export-table ACCESSORS (`module.exports = { get path() {...} }`),
2072
2148
  * lifted lazily as module-level functions and interned per accessor
2073
2149
  * declaration: member reads call the getter (lower-exprs). */
@@ -2142,10 +2218,32 @@ export class Lowerer {
2142
2218
  /** Named method slots observed before class collection need a callable
2143
2219
  * ABI and shared prototype descriptors instead of call-site specialization. */
2144
2220
  prototypeMethodAccesses = new Map();
2221
+ /** Every site the census found for a name in prototypeMethodAccesses (which
2222
+ * keeps one): reads of the method and writes that may replace it. The
2223
+ * key-order witness asks which replacements can return records. */
2224
+ methodAccessSites = new Map();
2225
+ /** Marks `name` as a method the program may read or replace at `site`. */
2226
+ noteMethodAccess(name, site) {
2227
+ this.prototypeMethodAccesses.set(name, site);
2228
+ this.noteMethodSite(name, site);
2229
+ }
2230
+ /** Records a site for `name` without changing its prototypeMethodAccesses entry. */
2231
+ noteMethodSite(name, site) {
2232
+ const sites = this.methodAccessSites.get(name);
2233
+ if (sites === undefined)
2234
+ this.methodAccessSites.set(name, [site]);
2235
+ else
2236
+ sites.push(site);
2237
+ }
2145
2238
  /** Whether the program reads `Error.prototype`, the checked-dynamic
2146
- * object an ES5 constructor function can inherit from: only then can a
2147
- * value that is not an Error instance be `instanceof Error`. */
2239
+ * object an ES5 constructor function can inherit from, or has a class
2240
+ * whose heritage is evaluated at run time (`extends (Base ?? Error)`):
2241
+ * only then can a value that is not an Error instance be
2242
+ * `instanceof Error`. */
2148
2243
  errorPrototypeValues = false;
2244
+ /** The property names the program assigns on the global object
2245
+ * (property-access.ts), collected on first use. */
2246
+ globalThisWrittenNames = null;
2149
2247
  /** Well-known symbol methods (`sym:iterator`) the program may replace
2150
2248
  * through a symbol-keyed write: an instance or prototype property, or a
2151
2249
  * reflection call. */
@@ -2218,8 +2316,13 @@ export class Lowerer {
2218
2316
  * (builtins/fs-paths.ts): each lowers to the hidden local that holds its
2219
2317
  * value, which is null until the path's lowering has saved it. */
2220
2318
  stagedArguments = new Map();
2221
- /** The staged arguments that follow each such URL path, in order. */
2222
- stagedAfterPath = new Map();
2319
+ /** What each fs path argument of a URL-path call lowers to (the plans
2320
+ * of builtins/fs-paths.ts). */
2321
+ fsPathPlans = new Map();
2322
+ /** The existsSync/fs.promises calls whose converted URL paths are being
2323
+ * lowered into the call itself (lowerFallibleFsUrlCall). A call may be
2324
+ * lowered more than once, and each lowering converts again. */
2325
+ fallibleFsCalls = new Set();
2223
2326
  moduleNsParamOverrides = new Map();
2224
2327
  /** File → qualifier prefix: "" for the entry, "%mI." otherwise. */
2225
2328
  fileTag = new Map();
@@ -2333,6 +2436,12 @@ export class Lowerer {
2333
2436
  // Stack of function contexts (bottom = the function being declared at
2334
2437
  // top level, top = the innermost nested function currently lowering).
2335
2438
  fnStack = [];
2439
+ /** Source ranges of record writes in sloppy-mode code, and of the
2440
+ * absent-state writes of `delete r.f` (markSloppyRecordWrites). */
2441
+ sloppyRecordWrites = new Set();
2442
+ recordFieldDeletes = new Set();
2443
+ /** typeKeys of the array types the program may freeze (IrModule.freezableArrays). */
2444
+ freezableArrays = new Set();
2336
2445
  liftedFns = [];
2337
2446
  /** The first lifted function of each name (liftedFnNamed), for the
2338
2447
  * liftedFns indexed so far. liftedFns only grows. */
@@ -2345,15 +2454,21 @@ export class Lowerer {
2345
2454
  * dispatch revision needs no weak-key identity or process-global state. */
2346
2455
  errorMethodDispatchRevision = null;
2347
2456
  errorPropertyDispatchRevision = null;
2457
+ /** The program defines properties by reflection on an untyped or
2458
+ * Error-shaped target, so an own accessor may replace an error's `name`
2459
+ * or `message`: typed reads and writes of those slots check for one.
2460
+ * Holds the first such call's location. */
2461
+ errorAccessorReflection = null;
2348
2462
  /** Structural source positions (structural-positions.ts) for names that
2349
2463
  * stay the same when unrelated code moves. */
2350
2464
  /** Files are named by their path relative to the entry's directory, so
2351
- * names do not depend on where the program sits, and default library
2352
- * files by their base name: two checkers install them in different
2353
- * directories. */
2465
+ * names do not depend on where the program sits, default library files
2466
+ * by their base name (two checkers install them in different
2467
+ * directories), and the files scriptc ships by their name inside scriptc,
2468
+ * so names do not depend on where scriptc is installed either. */
2354
2469
  positions = new StructuralPositions((sf) => this.program.isSourceFileDefaultLibrary(sf)
2355
2470
  ? `lib:${sf.fileName.slice(sf.fileName.lastIndexOf("/") + 1)}`
2356
- : relative(dirname(this.entry.fileName), sf.fileName));
2471
+ : (compilerOwnedFileName(sf.fileName) ?? relative(dirname(this.entry.fileName), sf.fileName)));
2357
2472
  /** The outermost node whose token span is exactly `loc`, or null. */
2358
2473
  nodeAtLoc(loc) {
2359
2474
  const sf = this.program.getSourceFile(loc.file);
@@ -2381,7 +2496,9 @@ export class Lowerer {
2381
2496
  * before it. */
2382
2497
  closureName(loc, suffix = "", prefix = "%fn") {
2383
2498
  const node = this.nodeAtLoc(loc);
2384
- const where = node === null ? `${loc.file}:${loc.start}:${loc.end}` : this.positions.of(node);
2499
+ const where = node === null
2500
+ ? `${compilerOwnedFileName(loc.file) ?? loc.file}:${loc.start}:${loc.end}`
2501
+ : this.positions.of(node);
2385
2502
  const key = `${prefix}|${this.closureRoot}|${where}|${suffix}`;
2386
2503
  const first = keyedHelperName(this, prefix, key);
2387
2504
  const seen = this.closureNameCounts.get(first) ?? 0;
@@ -2443,6 +2560,9 @@ export class Lowerer {
2443
2560
  * the class and constructed-class counts, it tells caches over the class
2444
2561
  * graph when the graph changed. */
2445
2562
  subclassLinks = 0;
2563
+ /** Function-local classes by the class node they extend, built on first
2564
+ * use (localSubclassesOf in lower-classes.ts). */
2565
+ localSubclassIndex = null;
2446
2566
  /** Set while a subclass constructor's super() call notes its base
2447
2567
  * constructor edge: that edge does not instantiate the base exactly. */
2448
2568
  superConstructorEdge = false;
@@ -2508,7 +2628,20 @@ export class Lowerer {
2508
2628
  if (this.sharedHelpers.size === 0)
2509
2629
  return;
2510
2630
  const shared = new Map([...this.sharedHelpers].map((fn) => [fn.name, fn]));
2511
- const earlier = (left, right) => left.file < right.file || (left.file === right.file && left.start < right.start);
2631
+ // Files scriptc ships compare by their name inside scriptc, so the
2632
+ // choice does not depend on where scriptc is installed.
2633
+ const fileKeys = new Map();
2634
+ const fileKey = (file) => {
2635
+ let key = fileKeys.get(file);
2636
+ if (key === undefined)
2637
+ fileKeys.set(file, (key = compilerOwnedFileName(file) ?? file));
2638
+ return key;
2639
+ };
2640
+ const earlier = (left, right) => {
2641
+ if (left.file === right.file)
2642
+ return left.start < right.start;
2643
+ return fileKey(left.file) < fileKey(right.file);
2644
+ };
2512
2645
  // The earliest use of each shared helper outside the shared helpers, and
2513
2646
  // which shared helpers each shared helper uses.
2514
2647
  const uses = new Map();
@@ -2705,6 +2838,20 @@ export class Lowerer {
2705
2838
  else if (kind === "failed")
2706
2839
  s.failed += 1;
2707
2840
  }
2841
+ /** The program holds the declaration-typed boundary's projection
2842
+ * (decl-projection.ts): user-file record and array values crossing into
2843
+ * dynamic slots (package parameters) box as live capsules, so a value
2844
+ * that comes back through a boundary cast keeps its identity. */
2845
+ declBoundaryMemo = null;
2846
+ get declBoundary() {
2847
+ this.declBoundaryMemo ??= this.program
2848
+ .getSourceFiles()
2849
+ .some((sf) => isDeclBoundaryFile(sf.fileName));
2850
+ return this.declBoundaryMemo;
2851
+ }
2852
+ /** Tracked classes' bag initializers over a typed `this`
2853
+ * (class-dynamic-dispatch.ts recordBagInitializers). */
2854
+ classBagInitializers = new Map();
2708
2855
  constructor(program, entry, moduleOrder, mode = {}) {
2709
2856
  this.program = program;
2710
2857
  this.entry = entry;
@@ -2808,7 +2955,10 @@ export class Lowerer {
2808
2955
  classImplementedProtocol: (type) => this.classImplementedProtocol(type),
2809
2956
  isStdlibFile: this.isStdlibFile,
2810
2957
  isNpmFile: this.isNpmFile,
2811
- isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
2958
+ // The declaration-typed boundary's generated types (decl-projection.ts)
2959
+ // describe data, like an explicitly mapped external type surface.
2960
+ isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))) ||
2961
+ isDeclBoundaryFile(sf.fileName),
2812
2962
  typeMemo: this.typeMemo,
2813
2963
  ...(this.generalNodeStreams ? { generalNodeStreams: true } : {}),
2814
2964
  ...(this.dynNodeStreams ? { dynNodeStreams: true } : {}),
@@ -3076,6 +3226,12 @@ export class Lowerer {
3076
3226
  const cjsValue = this.cjsExportValueSymbol(symbol);
3077
3227
  if (cjsValue)
3078
3228
  symbol = cjsValue;
3229
+ // `var m; m = require("./x"); module.exports = m` over a whole-export
3230
+ // target: TS types the wrapper's export= as `any`, so reconnect it to
3231
+ // the target's value symbol explicitly.
3232
+ const splitAlias = splitWholeExportAliasTargetOf(this, symbol);
3233
+ if (splitAlias)
3234
+ symbol = splitAlias;
3079
3235
  this.flushDeferred(symbol);
3080
3236
  return symbol;
3081
3237
  }
@@ -3189,7 +3345,7 @@ export class Lowerer {
3189
3345
  // exact mappings, while star exports resolve to the mapped declaration
3190
3346
  // owner through externalTypeSpecifiersByFile.
3191
3347
  const moduleSymbol = this.checker.getSymbolAtLocation(sf);
3192
- const exported = moduleSymbol?.getExports().get(exportName);
3348
+ const exported = moduleSymbol?.getExports().get(ts.escapedSymbolName(exportName));
3193
3349
  return this.externalTypeSpecifierOfSymbol(exported, seenSymbols, seenExports);
3194
3350
  }
3195
3351
  externalTypeSpecifierOfNamespaceMember(expr, member) {
@@ -3330,7 +3486,7 @@ export class Lowerer {
3330
3486
  cjsModuleExportSymbol(sf, name) {
3331
3487
  const moduleSym = this.checker.getSymbolAtLocation(sf);
3332
3488
  const exports = moduleSym?.getExports();
3333
- const direct = exports?.get(name);
3489
+ const direct = exports?.get(ts.escapedSymbolName(name));
3334
3490
  if (direct)
3335
3491
  return direct;
3336
3492
  // tsgo represents `module.exports = { ... }` as one `export=` symbol
@@ -3480,8 +3636,10 @@ export class Lowerer {
3480
3636
  return null;
3481
3637
  if (ts.isImportClause(decl))
3482
3638
  return this.cjsDefaultImportDepOf(decl);
3483
- if (!ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name) || !decl.initializer)
3639
+ if (!ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name))
3484
3640
  return null;
3641
+ if (decl.initializer === undefined)
3642
+ return splitRequireBindingOf(this, decl)?.dep ?? null;
3485
3643
  {
3486
3644
  const interop = tscInteropModuleOf(this, expr);
3487
3645
  if (interop !== null)
@@ -3584,6 +3742,10 @@ export class Lowerer {
3584
3742
  if (!ts.isIdentifier(expr))
3585
3743
  return this.cjsModuleRefDepOf(expr) !== null;
3586
3744
  const sym = this.checker.getSymbolAtLocation(expr);
3745
+ const splitDecl = sym?.declarations.find(ts.isVariableDeclaration);
3746
+ const split = splitDecl === undefined ? null : splitRequireBindingOf(this, splitDecl);
3747
+ if (split !== null)
3748
+ return cjsNamespaceModule(this, split.dep);
3587
3749
  if (this.localModuleBindingDepOf(expr) === null)
3588
3750
  return false;
3589
3751
  if (this.createRequireWholeExportSymbolOf(expr) !== null)
@@ -3891,6 +4053,9 @@ export class Lowerer {
3891
4053
  * their external dependencies by name). Null for everything else
3892
4054
  * (builtins load nothing; the rest kept its preflight fence). */
3893
4055
  requireInitStmt(spec, node) {
4056
+ if (this.inlineRequireCycleCalls.has(node)) {
4057
+ this.unsupported("SC1090", node, `require() of '${spec}' while it is still evaluating (a require cycle: Node answers its partial exports, which the static export table does not model)`);
4058
+ }
3894
4059
  if (canonicalBuiltinModule(spec) === "punycode")
3895
4060
  return this.punycodeRequireWarning(node);
3896
4061
  // Project requires resolve within the program; another bare require can
@@ -4551,6 +4716,8 @@ export class Lowerer {
4551
4716
  return true;
4552
4717
  if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
4553
4718
  return true;
4719
+ if (ts.isPropertyAccessExpression(e) && isOptionalReadlineCursorRead(this, e))
4720
+ return true;
4554
4721
  if (isOptionalProcessVersionsRead(this, e))
4555
4722
  return true;
4556
4723
  if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
@@ -5732,7 +5899,10 @@ export class Lowerer {
5732
5899
  }
5733
5900
  if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
5734
5901
  const callbackIndices = hofCallbackIndices(node.expression.name.text, node.arguments.nodes.length >= 2);
5735
- const callback = node.arguments.nodes[0];
5902
+ // `xs.map(((x) => x))`: the parenthesized callback is the arrow.
5903
+ let callback = node.arguments.nodes[0];
5904
+ while (callback !== undefined && ts.isParenthesizedExpression(callback))
5905
+ callback = callback.expression;
5736
5906
  if (callbackIndices !== null && callback !== undefined && !ts.isSpreadElement(callback)) {
5737
5907
  const receiverNode = node.expression.expression;
5738
5908
  const receiverTs = this.typeOf(receiverNode);
@@ -5783,12 +5953,26 @@ export class Lowerer {
5783
5953
  presentSites.set(node, elementsPresent && !reduce);
5784
5954
  if (elementsPresent && reduce && retypeInlineCallback(callback, callbackIndices))
5785
5955
  changed = true;
5786
- if ((method === "reduce" || method === "reduceRight") &&
5787
- ((!elementsPresent && node.arguments.nodes.length < 2) ||
5788
- callbackReturnsOptional(callback))) {
5789
- if (promoteHofCallback(callback, [0, 1]))
5956
+ // The accumulator holds undefined when the callback can return
5957
+ // it, when an initial value can be missing, or when elements can
5958
+ // be absent and there is no initial value. It holds another
5959
+ // primitive when the callback's result can be one at run time
5960
+ // (`missing[0] ?? "fallback"`).
5961
+ const initial = node.arguments.nodes[1];
5962
+ const optional = (!elementsPresent && initial === undefined) ||
5963
+ (initial !== undefined && !ts.isSpreadElement(initial) && mayBeOptional(initial)) ||
5964
+ callbackReturnsOptional(callback);
5965
+ const arithmetic = reduce && (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback))
5966
+ ? lambdaArithmeticReturn(callback)
5967
+ : null;
5968
+ if (reduce && (optional || arithmetic !== null)) {
5969
+ if (optional && promoteHofCallback(callback, [0, 1]))
5790
5970
  changed = true;
5791
- const result = this.runtimeOptionalType(this.irTypeOf(node));
5971
+ let result = this.irTypeOf(node);
5972
+ if (arithmetic !== null)
5973
+ result = joinPrimitiveTypes([result, arithmetic]) ?? result;
5974
+ if (optional)
5975
+ result = this.runtimeOptionalType(result);
5792
5976
  siteDependencies?.read(node);
5793
5977
  const previous = this.runtimeOptionalReduceTypes.get(node);
5794
5978
  if (!previous || !typeEquals(previous, result)) {
@@ -6563,8 +6747,11 @@ export class Lowerer {
6563
6747
  const fn = this.lowerFunction(decl);
6564
6748
  if (fn)
6565
6749
  functions.push(fn);
6566
- else if (this.countsSkips())
6750
+ else if (this.countsSkips()) {
6567
6751
  this.countSkippedBody(decl);
6752
+ if (this.remainder)
6753
+ this.reportBlockedBody(decl);
6754
+ }
6568
6755
  }
6569
6756
  for (const decl of fp.classDecls) {
6570
6757
  const info = this.classes.get(this.classNamer(decl));
@@ -6687,8 +6874,11 @@ export class Lowerer {
6687
6874
  finalizeClassMethodValues(this, functions);
6688
6875
  finalizePrivateBrands(this, functions);
6689
6876
  trackClassFieldCreation(this, functions);
6877
+ boxClassInstancesExactly(this, functions);
6690
6878
  guardClassAttributeWrites(this, functions);
6879
+ guardFrozenWrites(this, functions);
6691
6880
  applyHandleProperties(this, functions);
6881
+ installBufferValue(functions);
6692
6882
  // Globals typed by a class that never REGISTERED (a JS class whose
6693
6883
  // collection fenced — Symbol-keyed fields, an unsupported base): the
6694
6884
  // declaration statement and every use compiled to runtime fences, but
@@ -6790,9 +6980,13 @@ export class Lowerer {
6790
6980
  entry: ENTRY_NAME,
6791
6981
  ...(this.usesWorkers ? { workers: true } : {}),
6792
6982
  ...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
6983
+ ...(this.declBoundary ? { declBoundary: true } : {}),
6793
6984
  ...(this.threadSlotKeys.size > 0
6794
6985
  ? { threadSlotKeys: [...this.threadSlotKeys].sort() }
6795
6986
  : {}),
6987
+ ...(this.freezableArrays.size > 0
6988
+ ? { freezableArrays: [...this.freezableArrays].sort() }
6989
+ : {}),
6796
6990
  ...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
6797
6991
  ...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
6798
6992
  };
@@ -6800,6 +6994,8 @@ export class Lowerer {
6800
6994
  sanitizeUnregisteredClassTypes(module, (name) => this.classes.has(name));
6801
6995
  if (module)
6802
6996
  checkCycleBindingAccesses(this, module);
6997
+ if (module)
6998
+ bindCompletionCallbacks(module);
6803
6999
  // Execution tiers from the final bodies (ir/tiers.ts). Assigned with or
6804
7000
  // without a module: coverage reports the dynamic tier of programs that
6805
7001
  // still have blockers.
@@ -6893,6 +7089,20 @@ export class Lowerer {
6893
7089
  this.bumpFileStat(file, "failed");
6894
7090
  }
6895
7091
  }
7092
+ /** Coverage remainder: the body diagnostics of a function whose
7093
+ * signature blocked (blockedBodyDiagnostics). A function reachable emit
7094
+ * reached (its signature's diagnostics flushed there) reports them with
7095
+ * the reached diagnostics; any other reports them as unreached. */
7096
+ reachedBlockedBodyDiagnostics = [];
7097
+ reportBlockedBody(decl) {
7098
+ const diags = blockedBodyDiagnostics(this, decl);
7099
+ const symbol = declSymbolOf(this, decl);
7100
+ if (symbol && this.alreadyFlushed.has(symbol))
7101
+ this.reachedBlockedBodyDiagnostics.push(...diags);
7102
+ else
7103
+ for (const d of diags)
7104
+ this.pushDiag(d);
7105
+ }
6896
7106
  /** Whether run() counts a signature-blocked declaration in
6897
7107
  * stats.functionsSkipped: whole-program passes and the coverage
6898
7108
  * remainder do; an externally-gated emit pass leaves the counting to the
@@ -7763,6 +7973,16 @@ export class Lowerer {
7763
7973
  typeOf(node) {
7764
7974
  if (this.anySymbols.size > 0 && this.readsAnySymbol(node))
7765
7975
  return this.checker.getAnyType();
7976
+ // A checked-dynamic argument that another overload could take at run
7977
+ // time leaves the resolved overload's return a guess, and JS bindings
7978
+ // initialized with that result hold whatever it was.
7979
+ if ((ts.isCallExpression(node) || ts.isNewExpression(node)) &&
7980
+ dynamicOverloadChoice(this, node))
7981
+ return this.checker.getAnyType();
7982
+ if (ts.isIdentifier(node) &&
7983
+ isJsSourceFile(ts.getSourceFileOfNode(node)) &&
7984
+ guessedOverloadIdentifier(this, node))
7985
+ return this.checker.getAnyType();
7766
7986
  if (ts.isPropertyAccessExpression(node) && isJsSourceFile(ts.getSourceFileOfNode(node))) {
7767
7987
  const receiver = node.expression.kind === ts.SyntaxKind.ThisKeyword && this.fnStack.length > 0
7768
7988
  ? this.resolveThis()?.type
@@ -8190,6 +8410,22 @@ export class Lowerer {
8190
8410
  * type-mapper.ts's chalk-shape mapping — call paths and func-slot coercions
8191
8411
  * share it. */
8192
8412
  hybridCallUnwrap(expr) {
8413
+ // A callable CLASS instance: a class whose merged interface carries a
8414
+ // call signature stores its call behavior in a `%call` field (the
8415
+ // chalk package shim's builder). Calls read the field.
8416
+ if (expr.type.kind === "object") {
8417
+ const callType = this.classes.get(expr.type.className)?.fields.get("%call");
8418
+ if (callType === undefined || callType.kind !== "func")
8419
+ return expr;
8420
+ return {
8421
+ kind: "fieldGet",
8422
+ obj: expr,
8423
+ className: expr.type.className,
8424
+ field: "%call",
8425
+ type: callType,
8426
+ loc: expr.loc,
8427
+ };
8428
+ }
8193
8429
  if (expr.type.kind !== "record")
8194
8430
  return expr;
8195
8431
  const shape = this.shapes.get(expr.type.shapeId);
@@ -8272,6 +8508,20 @@ export class Lowerer {
8272
8508
  }
8273
8509
  if (expr.type.kind === "void" && expected.kind !== "void" && this.neverValued.has(expr))
8274
8510
  return this.divergentValue(expr, expected);
8511
+ // A builtin error constructor global stored in a slot of its class value
8512
+ // type (`{ Parent: Error }`): the class value itself, which a checked
8513
+ // cast of the dynamic constructor value could not produce.
8514
+ if (expected.kind === "classval" &&
8515
+ expr.kind === "libCall" &&
8516
+ expr.fn === "dyn.globalConstructor" &&
8517
+ expr.args[0]?.kind === "strLit" &&
8518
+ `%${expr.args[0].value}` === expected.className) {
8519
+ const info = this.classes.get(expected.className);
8520
+ if (info?.builtinError && info.valueCtorParams !== undefined) {
8521
+ this.defineClassValueConstruct(info);
8522
+ return { kind: "classRef", className: info.def.name, type: expected, loc: expr.loc };
8523
+ }
8524
+ }
8275
8525
  // process.stdout/stderr into a general Writable slot (general-streams.ts).
8276
8526
  const stdioStream = stdioIntoGeneralStream(this, expr, expected);
8277
8527
  if (stdioStream)
@@ -8283,6 +8533,12 @@ export class Lowerer {
8283
8533
  if (adapted)
8284
8534
  return adapted;
8285
8535
  }
8536
+ // Iterable-typed slots: other iterators enter the generator arm.
8537
+ if (expected.kind === "union" && !typeEquals(expr.type, expected)) {
8538
+ const iterable = iterableSlotValue(this, expr, expected);
8539
+ if (iterable)
8540
+ return iterable;
8541
+ }
8286
8542
  // an any-typed slot marshals implicitly (tsc allows the assignment;
8287
8543
  // the marshal is where its semantics live). OUT: an 'any' value
8288
8544
  // flowing into a typed slot compiles to a VALIDATED exit — like every
@@ -8363,6 +8619,11 @@ export class Lowerer {
8363
8619
  // constructor. `require("events")` is the EventEmitter class itself,
8364
8620
  // so its module binding is too (`ReleaseEmitter = EventEmitter` over
8365
8621
  // `const EventEmitter = require("events")`).
8622
+ if (expr.type.kind === "moduleNs" && isJsSourceFileName(expr.loc.file)) {
8623
+ const object = moduleNamespaceObject(this, expr);
8624
+ if (object)
8625
+ return object;
8626
+ }
8366
8627
  if (expr.type.kind === "moduleNs" &&
8367
8628
  expr.type.moduleId === "builtin:events" &&
8368
8629
  isJsSourceFileName(expr.loc.file)) {
@@ -8470,10 +8731,19 @@ export class Lowerer {
8470
8731
  // A HYBRID (function-with-properties) record flowing into a plain
8471
8732
  // func slot extracts its reserved %call field — the chalk shape's
8472
8733
  // "the value IS callable" half (type-mapper.ts's hybrid mapping).
8473
- if (expected.kind === "func" && expr.type.kind === "record") {
8734
+ if (expected.kind === "func" && (expr.type.kind === "record" || expr.type.kind === "object")) {
8474
8735
  const un = this.hybridCallUnwrap(expr);
8475
8736
  if (un !== expr && typeEquals(un.type, expected))
8476
8737
  return un;
8738
+ // A callable class instance (the chalk shim's variadic builder) in a
8739
+ // narrower function slot: its call closure crosses the checked
8740
+ // function boundary, which adapts the arity.
8741
+ if (un !== expr &&
8742
+ expr.type.kind === "object" &&
8743
+ un.type.kind === "func" &&
8744
+ canBoxFuncIntoDyn(un.type, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
8745
+ return this.coerceToExpected({ kind: "dynFrom", value: un, type: DYN, loc: un.loc }, expected);
8746
+ }
8477
8747
  }
8478
8748
  // A zero-param function whose RETURN is a wider record array than the
8479
8749
  // slot's (`getRoutes: () => cachedRoutes` against `() => Narrow[]`):
@@ -9170,6 +9440,40 @@ export class Lowerer {
9170
9440
  }
9171
9441
  return this.coerceInto(node, value, expected);
9172
9442
  }
9443
+ /** The right side of a write to a member of a typed view of the global
9444
+ * object (`(globalThis as typeof globalThis & { k?: T }).k = value`, also
9445
+ * through `??=` and `||=`) that is `value` itself or wraps only it in
9446
+ * parentheses or `satisfies`; null when `value` is not in such a write. */
9447
+ globalViewSlot(value) {
9448
+ let operand = value;
9449
+ while (operand.parent !== undefined &&
9450
+ (ts.isParenthesizedExpression(operand.parent) || ts.isSatisfiesExpression(operand.parent)))
9451
+ operand = operand.parent;
9452
+ const write = operand.parent;
9453
+ if (write === undefined ||
9454
+ !ts.isBinaryExpression(write) ||
9455
+ write.right !== operand ||
9456
+ (write.operatorToken.kind !== ts.SyntaxKind.EqualsToken &&
9457
+ write.operatorToken.kind !== ts.SyntaxKind.QuestionQuestionEqualsToken &&
9458
+ write.operatorToken.kind !== ts.SyntaxKind.BarBarEqualsToken))
9459
+ return null;
9460
+ let target = write.left;
9461
+ while (ts.isParenthesizedExpression(target))
9462
+ target = target.expression;
9463
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target))
9464
+ return null;
9465
+ const receiver = this.typeOf(target.expression);
9466
+ const isGlobal = (type) => {
9467
+ const symbol = type.getSymbol();
9468
+ return (symbol !== undefined &&
9469
+ ts.symbolName(symbol) === "globalThis" &&
9470
+ symbol.declarations.length === 0);
9471
+ };
9472
+ return isGlobal(receiver) ||
9473
+ (receiver.isIntersectionType() && ts.constituentTypes(receiver).some(isGlobal))
9474
+ ? operand
9475
+ : null;
9476
+ }
9173
9477
  /** Lower for a known destination, then apply ordinary value coercion.
9174
9478
  * Fresh arrays and records use the destination layout directly. */
9175
9479
  lowerExprExpecting(node, expected) {
@@ -9237,6 +9541,20 @@ export class Lowerer {
9237
9541
  // belong to the array the program keeps, rather than a typed snapshot.
9238
9542
  if (ts.isArrayLiteralExpression(x) &&
9239
9543
  x.elements.nodes.every((element) => !ts.isSpreadElement(element) && !ts.isOmittedExpression(element))) {
9544
+ // A checked slot that the program declares as a native array (a
9545
+ // member of a typed view of the global object, `typeof globalThis &
9546
+ // { cache?: number[] }`) is read back through that declaration. Build
9547
+ // the native array and store it boxed: every typed read then extracts
9548
+ // that same array (a dynamic literal would be copied on each read,
9549
+ // losing writes such as push).
9550
+ const slot = this.globalViewSlot(x);
9551
+ const slotType = slot ? this.checker.getContextualType(slot) : undefined;
9552
+ const declared = slotType && this.checker.getNonNullableType(slotType);
9553
+ const native = declared && !(declared.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
9554
+ ? this.mapTypeOf(declared)
9555
+ : null;
9556
+ if (native?.kind === "array")
9557
+ return this.coerceInto(node, this.lowerArrayLiteral(x, native), DYN);
9240
9558
  return {
9241
9559
  kind: "dynArrLit",
9242
9560
  elems: x.elements.nodes.map((element) => this.lowerExprExpecting(element, DYN)),
@@ -9263,7 +9581,9 @@ export class Lowerer {
9263
9581
  builtinOption("UrlObject") ||
9264
9582
  builtinOption("URLFormatOptions") ||
9265
9583
  !this.mapTypeOf(this.typeOf(x)) ||
9266
- this.excessJsContextualProperty(x, parts)) {
9584
+ this.excessJsContextualProperty(x, parts) ||
9585
+ this.reshapeableContextualLiteral(x, parts) ||
9586
+ holdsEvolvingArray(this, x)) {
9267
9587
  return lowerDynObjectLiteral(this, x);
9268
9588
  }
9269
9589
  }
@@ -9442,8 +9762,27 @@ export class Lowerer {
9442
9762
  // must not force an intermediate record with incompatible field slots.
9443
9763
  if (this.returnsLiteralIntoDyn(node, expected))
9444
9764
  return this.lowerExprExpecting(node, expected);
9765
+ if (this.returnsFreshCollection(node) && expected.kind !== "void")
9766
+ return this.lowerExprExpecting(node, expected);
9445
9767
  return this.asyncReturnValueOf(node, this.lowerExpr(node), expected);
9446
9768
  }
9769
+ /** An array literal or a `new Map(...)`, `new Set(...)` or `new
9770
+ * Array(...)` of the builtins: a fresh collection, never a thenable, so
9771
+ * an async return takes the declared result type as its construction
9772
+ * layout the way a synchronous return does (`return []` in a function
9773
+ * whose inferred result is `Promise<string[]>`). */
9774
+ returnsFreshCollection(node) {
9775
+ let e = node;
9776
+ while (ts.isParenthesizedExpression(e))
9777
+ e = e.expression;
9778
+ if (ts.isArrayLiteralExpression(e))
9779
+ return true;
9780
+ return (ts.isNewExpression(e) &&
9781
+ ts.isIdentifier(e.expression) &&
9782
+ (this.isStdlibGlobal(e.expression, "Map") ||
9783
+ this.isStdlibGlobal(e.expression, "Set") ||
9784
+ this.isStdlibGlobal(e.expression, "Array")));
9785
+ }
9447
9786
  /** A fresh JS object literal returned into a checked-native (dyn) result,
9448
9787
  * which lowers straight into that storage. */
9449
9788
  returnsLiteralIntoDyn(node, expected) {
@@ -9569,7 +9908,9 @@ export class Lowerer {
9569
9908
  loc,
9570
9909
  };
9571
9910
  }
9572
- if (this.adoptsReturnedPromise() && !this.returnsLiteralIntoDyn(node, expected)) {
9911
+ if (this.adoptsReturnedPromise() &&
9912
+ !this.returnsLiteralIntoDyn(node, expected) &&
9913
+ !this.returnsFreshCollection(node)) {
9573
9914
  // The async return lowers its operand untyped first (a promise
9574
9915
  // adopts before its payload converts); a maybe-promise union needs
9575
9916
  // the statement form, which branches between adoption and fulfillment.
@@ -9955,8 +10296,8 @@ export class Lowerer {
9955
10296
  throw e;
9956
10297
  }
9957
10298
  }
9958
- lowerClassExpression(expr) {
9959
- return lowerClassExpression(this, expr);
10299
+ lowerClassExpression(expr, binding) {
10300
+ return lowerClassExpression(this, expr, binding);
9960
10301
  }
9961
10302
  /* ── the class graph (single inheritance) ─────────────────────────── */
9962
10303
  findMethodOn(info, name) {
@@ -11055,7 +11396,7 @@ export class Lowerer {
11055
11396
  return lowerRecordKeyRead(this, expr, shapeId, shape, includeUndefined);
11056
11397
  }
11057
11398
  lowerElementWrite(expr) {
11058
- return lowerElementWrite(this, expr);
11399
+ return markSloppyRecordWrites(this, lowerElementWrite(this, expr), expr);
11059
11400
  }
11060
11401
  lowerLiveWebValue(node) {
11061
11402
  return lowerLiveWebValue(this, node);
@@ -11354,7 +11695,7 @@ export class Lowerer {
11354
11695
  : null;
11355
11696
  }
11356
11697
  fieldSetStmt(target, value, loc, blame) {
11357
- return fieldSetStmt(this, target, value, loc, blame);
11698
+ return markSloppyRecordWrites(this, fieldSetStmt(this, target, value, loc, blame), blame);
11358
11699
  }
11359
11700
  lowerFieldCompound(access, op, rhsNode, loc) {
11360
11701
  return lowerFieldCompound(this, access, op, rhsNode, loc);
@@ -11384,6 +11725,7 @@ export class Lowerer {
11384
11725
  lowerBlobNew(this, expr) ??
11385
11726
  lowerNetAddressNew(this, expr) ??
11386
11727
  lowerStaticReadableStreamNew(this, expr) ??
11728
+ lowerStaticTransformStreamNew(this, expr) ??
11387
11729
  lowerConsoleNew(this, expr);
11388
11730
  return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
11389
11731
  }
@@ -11796,6 +12138,9 @@ export class Lowerer {
11796
12138
  loc,
11797
12139
  };
11798
12140
  }
12141
+ // The buffer module's Buffer is the global constructor's value.
12142
+ if (bi.module === "buffer" && bi.member === "Buffer")
12143
+ return { kind: "libCall", fn: "buffer.constructor", args: [], type: DYN, loc };
11799
12144
  if (bi.module === "fs" && (bi.member === "realpathSync" || bi.member === "realpathSync.native"))
11800
12145
  return fsRealpathValue(this, bi.member === "realpathSync.native", loc);
11801
12146
  const fn = builtinModuleFnOf(this, bi.module, bi.member);