@scriptc/compiler 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (492) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +832 -55
  2. package/dist/backend/cycle-analysis.js +6 -1
  3. package/dist/backend/cycle-analysis.js.map +1 -1
  4. package/dist/backend/executable-features.js +1 -0
  5. package/dist/backend/executable-features.js.map +1 -1
  6. package/dist/backend/literals.d.ts +7 -0
  7. package/dist/backend/literals.js +32 -0
  8. package/dist/backend/literals.js.map +1 -1
  9. package/dist/backend/literals.test.js +17 -1
  10. package/dist/backend/literals.test.js.map +1 -1
  11. package/dist/backend/llvm/alloc.d.ts +15 -4
  12. package/dist/backend/llvm/alloc.js +63 -25
  13. package/dist/backend/llvm/alloc.js.map +1 -1
  14. package/dist/backend/llvm/alloc.test.js +62 -2
  15. package/dist/backend/llvm/alloc.test.js.map +1 -1
  16. package/dist/backend/llvm/appended-array-literals.d.ts +2 -0
  17. package/dist/backend/llvm/appended-array-literals.js +109 -0
  18. package/dist/backend/llvm/appended-array-literals.js.map +1 -0
  19. package/dist/backend/llvm/appended-array-literals.test.d.ts +1 -0
  20. package/dist/backend/llvm/appended-array-literals.test.js +90 -0
  21. package/dist/backend/llvm/appended-array-literals.test.js.map +1 -0
  22. package/dist/backend/llvm/array-search.d.ts +8 -0
  23. package/dist/backend/llvm/array-search.js +52 -0
  24. package/dist/backend/llvm/array-search.js.map +1 -0
  25. package/dist/backend/llvm/array-search.test.d.ts +1 -0
  26. package/dist/backend/llvm/array-search.test.js +72 -0
  27. package/dist/backend/llvm/array-search.test.js.map +1 -0
  28. package/dist/backend/llvm/call-lifetimes.d.ts +11 -1
  29. package/dist/backend/llvm/call-lifetimes.js +74 -4
  30. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  31. package/dist/backend/llvm/call-lifetimes.test.js +54 -0
  32. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  33. package/dist/backend/llvm/classes.js +97 -38
  34. package/dist/backend/llvm/classes.js.map +1 -1
  35. package/dist/backend/llvm/classes.test.js +2 -2
  36. package/dist/backend/llvm/common.d.ts +1 -1
  37. package/dist/backend/llvm/common.js +1 -1
  38. package/dist/backend/llvm/dense-array-access.d.ts +5 -0
  39. package/dist/backend/llvm/dense-array-access.js +18 -13
  40. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  41. package/dist/backend/llvm/dense-array-access.test.js +15 -2
  42. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  43. package/dist/backend/llvm/dyn.d.ts +6 -0
  44. package/dist/backend/llvm/dyn.js +84 -11
  45. package/dist/backend/llvm/dyn.js.map +1 -1
  46. package/dist/backend/llvm/emitter.d.ts +108 -16
  47. package/dist/backend/llvm/emitter.js +598 -108
  48. package/dist/backend/llvm/emitter.js.map +1 -1
  49. package/dist/backend/llvm/emitter.test.js +26 -3
  50. package/dist/backend/llvm/emitter.test.js.map +1 -1
  51. package/dist/backend/llvm/expr-async.js +174 -7
  52. package/dist/backend/llvm/expr-async.js.map +1 -1
  53. package/dist/backend/llvm/expr-bytes.js +11 -0
  54. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  55. package/dist/backend/llvm/expr-callbacks.d.ts +8 -0
  56. package/dist/backend/llvm/expr-callbacks.js +96 -2
  57. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  58. package/dist/backend/llvm/expr-calls.d.ts +12 -1
  59. package/dist/backend/llvm/expr-calls.js +133 -54
  60. package/dist/backend/llvm/expr-calls.js.map +1 -1
  61. package/dist/backend/llvm/expr-containers.d.ts +7 -0
  62. package/dist/backend/llvm/expr-containers.js +80 -22
  63. package/dist/backend/llvm/expr-containers.js.map +1 -1
  64. package/dist/backend/llvm/expr-context.d.ts +2 -0
  65. package/dist/backend/llvm/expr-control.d.ts +8 -0
  66. package/dist/backend/llvm/expr-control.js +103 -69
  67. package/dist/backend/llvm/expr-control.js.map +1 -1
  68. package/dist/backend/llvm/expr-dynamic.js +21 -10
  69. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  70. package/dist/backend/llvm/expr-primitives.d.ts +7 -0
  71. package/dist/backend/llvm/expr-primitives.js +53 -51
  72. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  73. package/dist/backend/llvm/expr-records.js +19 -5
  74. package/dist/backend/llvm/expr-records.js.map +1 -1
  75. package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
  76. package/dist/backend/llvm/expr-stream-bridges.js +111 -39
  77. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  78. package/dist/backend/llvm/expr-stream-bridges.test.js +49 -1
  79. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
  80. package/dist/backend/llvm/expr-stream-callbacks.d.ts +13 -2
  81. package/dist/backend/llvm/expr-stream-callbacks.js +80 -5
  82. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  83. package/dist/backend/llvm/inline-unions.d.ts +48 -0
  84. package/dist/backend/llvm/inline-unions.js +134 -0
  85. package/dist/backend/llvm/inline-unions.js.map +1 -0
  86. package/dist/backend/llvm/inline-unions.test.d.ts +1 -0
  87. package/dist/backend/llvm/inline-unions.test.js +124 -0
  88. package/dist/backend/llvm/inline-unions.test.js.map +1 -0
  89. package/dist/backend/llvm/int32-abi.d.ts +18 -2
  90. package/dist/backend/llvm/int32-abi.js +23 -2
  91. package/dist/backend/llvm/int32-abi.js.map +1 -1
  92. package/dist/backend/llvm/int32-abi.test.js +75 -1
  93. package/dist/backend/llvm/int32-abi.test.js.map +1 -1
  94. package/dist/backend/llvm/integer-remainder.d.ts +28 -5
  95. package/dist/backend/llvm/integer-remainder.js +80 -9
  96. package/dist/backend/llvm/integer-remainder.js.map +1 -1
  97. package/dist/backend/llvm/lib-dispatch.js +170 -28
  98. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  99. package/dist/backend/llvm/lib-filesystem.js +181 -5
  100. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  101. package/dist/backend/llvm/lib-network.js +9 -6
  102. package/dist/backend/llvm/lib-network.js.map +1 -1
  103. package/dist/backend/llvm/lib-process.js +2 -2
  104. package/dist/backend/llvm/lib-process.js.map +1 -1
  105. package/dist/backend/llvm/lib-shared.js +208 -9
  106. package/dist/backend/llvm/lib-shared.js.map +1 -1
  107. package/dist/backend/llvm/lib-stream.js +97 -0
  108. package/dist/backend/llvm/lib-stream.js.map +1 -1
  109. package/dist/backend/llvm/local-array-reads.js +12 -6
  110. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  111. package/dist/backend/llvm/local-array-reads.test.js +6 -3
  112. package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
  113. package/dist/backend/llvm/local-union-storage.d.ts +26 -2
  114. package/dist/backend/llvm/local-union-storage.js +132 -12
  115. package/dist/backend/llvm/local-union-storage.js.map +1 -1
  116. package/dist/backend/llvm/local-union-storage.test.js +107 -1
  117. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  118. package/dist/backend/llvm/loop-array-borrows.d.ts +8 -2
  119. package/dist/backend/llvm/loop-array-borrows.js +93 -13
  120. package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
  121. package/dist/backend/llvm/map-number-lookup.d.ts +20 -0
  122. package/dist/backend/llvm/map-number-lookup.js +66 -0
  123. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  124. package/dist/backend/llvm/map-number-lookup.test.d.ts +1 -0
  125. package/dist/backend/llvm/map-number-lookup.test.js +102 -0
  126. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -0
  127. package/dist/backend/llvm/map-read-lifetimes.js +1 -0
  128. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  129. package/dist/backend/llvm/publish.d.ts +4 -0
  130. package/dist/backend/llvm/publish.js +3 -1
  131. package/dist/backend/llvm/publish.js.map +1 -1
  132. package/dist/backend/llvm/record-results.d.ts +29 -0
  133. package/dist/backend/llvm/record-results.js +260 -0
  134. package/dist/backend/llvm/record-results.js.map +1 -0
  135. package/dist/backend/llvm/reference-effects.js +15 -0
  136. package/dist/backend/llvm/reference-effects.js.map +1 -1
  137. package/dist/backend/llvm/reference-writes.js +29 -9
  138. package/dist/backend/llvm/reference-writes.js.map +1 -1
  139. package/dist/backend/llvm/regions.d.ts +68 -0
  140. package/dist/backend/llvm/regions.js +314 -0
  141. package/dist/backend/llvm/regions.js.map +1 -0
  142. package/dist/backend/llvm/regions.test.d.ts +1 -0
  143. package/dist/backend/llvm/regions.test.js +173 -0
  144. package/dist/backend/llvm/regions.test.js.map +1 -0
  145. package/dist/backend/llvm/serialized-ir-emission.test.js +2 -0
  146. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  147. package/dist/backend/llvm/shapes.d.ts +86 -13
  148. package/dist/backend/llvm/shapes.js +208 -54
  149. package/dist/backend/llvm/shapes.js.map +1 -1
  150. package/dist/backend/llvm/shapes.test.js +68 -9
  151. package/dist/backend/llvm/shapes.test.js.map +1 -1
  152. package/dist/backend/llvm/split-loops.js +1 -1
  153. package/dist/backend/llvm/split-loops.js.map +1 -1
  154. package/dist/backend/llvm/stack-objects.d.ts +29 -0
  155. package/dist/backend/llvm/stack-objects.js +142 -0
  156. package/dist/backend/llvm/stack-objects.js.map +1 -0
  157. package/dist/backend/llvm/stack-objects.test.d.ts +1 -0
  158. package/dist/backend/llvm/stack-objects.test.js +255 -0
  159. package/dist/backend/llvm/stack-objects.test.js.map +1 -0
  160. package/dist/backend/llvm/string-reads.d.ts +4 -1
  161. package/dist/backend/llvm/string-reads.js +89 -9
  162. package/dist/backend/llvm/string-reads.js.map +1 -1
  163. package/dist/backend/llvm/switch-dispatch.js +5 -4
  164. package/dist/backend/llvm/switch-dispatch.js.map +1 -1
  165. package/dist/backend/llvm/walkers.d.ts +13 -0
  166. package/dist/backend/llvm/walkers.js +108 -10
  167. package/dist/backend/llvm/walkers.js.map +1 -1
  168. package/dist/backend/may-throw.js +10 -4
  169. package/dist/backend/may-throw.js.map +1 -1
  170. package/dist/backend/native/contracts.d.ts +7 -2
  171. package/dist/backend/native/executable.js +28 -2
  172. package/dist/backend/native/executable.js.map +1 -1
  173. package/dist/backend/native/library.js +1 -1
  174. package/dist/backend/native/library.js.map +1 -1
  175. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  176. package/dist/backend/native/runtime-inputs.js +3 -0
  177. package/dist/backend/native/runtime-inputs.js.map +1 -1
  178. package/dist/backend/native-link-info-core.d.ts +1 -0
  179. package/dist/backend/native-link-info-core.js.map +1 -1
  180. package/dist/backend/native-toolchain.test.js +1 -1
  181. package/dist/backend/native-toolchain.test.js.map +1 -1
  182. package/dist/backend/runtime-abi.d.ts +2 -2
  183. package/dist/backend/runtime-abi.js +2 -2
  184. package/dist/backend/runtime-pack-core.d.ts +1 -0
  185. package/dist/backend/runtime-pack-core.js +1 -0
  186. package/dist/backend/runtime-pack-core.js.map +1 -1
  187. package/dist/backend/runtime-pack-targets.test.js +1 -1
  188. package/dist/backend/runtime-pack.test.js +1 -1
  189. package/dist/backend/target-diagnostics.js +17 -0
  190. package/dist/backend/target-diagnostics.js.map +1 -1
  191. package/dist/backend/target-diagnostics.test.js +16 -0
  192. package/dist/backend/target-diagnostics.test.js.map +1 -1
  193. package/dist/compat/fetch-profile.js +4 -4
  194. package/dist/compat/fetch-profile.js.map +1 -1
  195. package/dist/contracts/check.js +2 -0
  196. package/dist/contracts/check.js.map +1 -1
  197. package/dist/coverage/report.js +1 -1
  198. package/dist/coverage/report.js.map +1 -1
  199. package/dist/diagnostics/diagnostic.d.ts +6 -5
  200. package/dist/diagnostics/diagnostic.js +7 -6
  201. package/dist/diagnostics/diagnostic.js.map +1 -1
  202. package/dist/executable/executable-cache.d.ts +1 -0
  203. package/dist/executable/executable-cache.js.map +1 -1
  204. package/dist/frontend/builtin-modules.d.ts +1 -1
  205. package/dist/frontend/builtin-modules.js +1 -0
  206. package/dist/frontend/builtin-modules.js.map +1 -1
  207. package/dist/frontend/comptime-node.js +2 -2
  208. package/dist/frontend/comptime-node.js.map +1 -1
  209. package/dist/frontend/experimental-import.d.ts +12 -0
  210. package/dist/frontend/experimental-import.js +63 -0
  211. package/dist/frontend/experimental-import.js.map +1 -0
  212. package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
  213. package/dist/frontend/lowering/binding-analysis.js +1 -1
  214. package/dist/frontend/lowering/builtin-calls.d.ts +6 -1
  215. package/dist/frontend/lowering/builtin-calls.js +36 -0
  216. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  217. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  218. package/dist/frontend/lowering/builtins/arguments.js +8 -4
  219. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  220. package/dist/frontend/lowering/builtins/blob.d.ts +20 -0
  221. package/dist/frontend/lowering/builtins/blob.js +167 -0
  222. package/dist/frontend/lowering/builtins/blob.js.map +1 -0
  223. package/dist/frontend/lowering/builtins/child-process-async.d.ts +2 -2
  224. package/dist/frontend/lowering/builtins/child-process-async.js +2 -2
  225. package/dist/frontend/lowering/builtins/child-process-methods.js +1 -1
  226. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  227. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -1
  228. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  229. package/dist/frontend/lowering/builtins/compression.js +3 -2
  230. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  231. package/dist/frontend/lowering/builtins/console.d.ts +16 -6
  232. package/dist/frontend/lowering/builtins/console.js +33 -9
  233. package/dist/frontend/lowering/builtins/console.js.map +1 -1
  234. package/dist/frontend/lowering/builtins/crypto.js +415 -120
  235. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  236. package/dist/frontend/lowering/builtins/errors.js +20 -0
  237. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  238. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +10 -0
  239. package/dist/frontend/lowering/builtins/filesystem-calls.js +89 -1
  240. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  241. package/dist/frontend/lowering/builtins/filesystem.d.ts +16 -7
  242. package/dist/frontend/lowering/builtins/filesystem.js +97 -15
  243. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  244. package/dist/frontend/lowering/builtins/fs-glob.d.ts +23 -0
  245. package/dist/frontend/lowering/builtins/fs-glob.js +224 -0
  246. package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -0
  247. package/dist/frontend/lowering/builtins/json.d.ts +2 -2
  248. package/dist/frontend/lowering/builtins/json.js +13 -4
  249. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  250. package/dist/frontend/lowering/builtins/key-object.d.ts +13 -0
  251. package/dist/frontend/lowering/builtins/key-object.js +56 -0
  252. package/dist/frontend/lowering/builtins/key-object.js.map +1 -0
  253. package/dist/frontend/lowering/builtins/module-calls.js +60 -12
  254. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  255. package/dist/frontend/lowering/builtins/numbers.d.ts +1 -0
  256. package/dist/frontend/lowering/builtins/numbers.js +17 -0
  257. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  258. package/dist/frontend/lowering/builtins/operating-system.d.ts +18 -0
  259. package/dist/frontend/lowering/builtins/operating-system.js +361 -1
  260. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  261. package/dist/frontend/lowering/builtins/performance.d.ts +25 -3
  262. package/dist/frontend/lowering/builtins/performance.js +340 -5
  263. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  264. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  265. package/dist/frontend/lowering/builtins/process.js +122 -17
  266. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  267. package/dist/frontend/lowering/builtins/promises.js +109 -2
  268. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  269. package/dist/frontend/lowering/builtins/properties.d.ts +0 -7
  270. package/dist/frontend/lowering/builtins/properties.js +39 -11
  271. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  272. package/dist/frontend/lowering/builtins/readline.d.ts +23 -8
  273. package/dist/frontend/lowering/builtins/readline.js +266 -90
  274. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  275. package/dist/frontend/lowering/builtins/text-codecs.d.ts +3 -4
  276. package/dist/frontend/lowering/builtins/text-codecs.js +3 -4
  277. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  278. package/dist/frontend/lowering/builtins/url.d.ts +8 -0
  279. package/dist/frontend/lowering/builtins/url.js +36 -0
  280. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  281. package/dist/frontend/lowering/call-arguments.js +1 -1
  282. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  283. package/dist/frontend/lowering/call-signatures.js +20 -2
  284. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  285. package/dist/frontend/lowering/checked-promise-all.d.ts +10 -3
  286. package/dist/frontend/lowering/checked-promise-all.js +52 -6
  287. package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
  288. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +8 -3
  289. package/dist/frontend/lowering/class-dynamic-dispatch.js +159 -32
  290. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  291. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
  292. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  293. package/dist/frontend/lowering/class-protocol-dispatch.d.ts +45 -0
  294. package/dist/frontend/lowering/class-protocol-dispatch.js +516 -0
  295. package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -0
  296. package/dist/frontend/lowering/coercions/structural-plans.js +2 -1
  297. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  298. package/dist/frontend/lowering/coercions/structural.js +3 -3
  299. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  300. package/dist/frontend/lowering/collation-repertoire.js +6 -5
  301. package/dist/frontend/lowering/collation-repertoire.js.map +1 -1
  302. package/dist/frontend/lowering/containers/array-callbacks.js +33 -6
  303. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  304. package/dist/frontend/lowering/containers/array-construction.js +8 -4
  305. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  306. package/dist/frontend/lowering/containers/array-methods.d.ts +0 -7
  307. package/dist/frontend/lowering/containers/array-methods.js +43 -2
  308. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  309. package/dist/frontend/lowering/containers/array-pipelines.js +1 -1
  310. package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
  311. package/dist/frontend/lowering/containers/bytes.js +38 -26
  312. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  313. package/dist/frontend/lowering/containers/for-of.d.ts +1 -1
  314. package/dist/frontend/lowering/containers/for-of.js +5 -1
  315. package/dist/frontend/lowering/containers/for-of.js.map +1 -1
  316. package/dist/frontend/lowering/containers/indexed-objects.js +1 -1
  317. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  318. package/dist/frontend/lowering/containers/string-and-regexp.js +91 -0
  319. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  320. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  321. package/dist/frontend/lowering/crypto-tables.js +77 -12
  322. package/dist/frontend/lowering/crypto-tables.js.map +1 -1
  323. package/dist/frontend/lowering/cycle-initialization.d.ts +18 -2
  324. package/dist/frontend/lowering/cycle-initialization.js +166 -12
  325. package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
  326. package/dist/frontend/lowering/deferred-module-initializers.js +7 -2
  327. package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
  328. package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
  329. package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
  330. package/dist/frontend/lowering/expressions/nullish-assignment.js +10 -0
  331. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
  332. package/dist/frontend/lowering/expressions/object-literals.js +21 -68
  333. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  334. package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
  335. package/dist/frontend/lowering/generator-delegation.js +231 -10
  336. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  337. package/dist/frontend/lowering/generic-functions.d.ts +2 -2
  338. package/dist/frontend/lowering/generic-functions.js +2 -2
  339. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  340. package/dist/frontend/lowering/http2-constants.js +1 -1
  341. package/dist/frontend/lowering/lifetime-regions.d.ts +11 -0
  342. package/dist/frontend/lowering/lifetime-regions.js +216 -0
  343. package/dist/frontend/lowering/lifetime-regions.js.map +1 -0
  344. package/dist/frontend/lowering/lower-array-sort.d.ts +40 -3
  345. package/dist/frontend/lowering/lower-array-sort.js +661 -194
  346. package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
  347. package/dist/frontend/lowering/lower-array-sort.test.js +103 -4
  348. package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
  349. package/dist/frontend/lowering/lower-assert.js +2 -2
  350. package/dist/frontend/lowering/lower-async-iteration.d.ts +6 -3
  351. package/dist/frontend/lowering/lower-async-iteration.js +248 -2
  352. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  353. package/dist/frontend/lowering/lower-calls.js +173 -111
  354. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  355. package/dist/frontend/lowering/lower-classes.d.ts +12 -5
  356. package/dist/frontend/lowering/lower-classes.js +156 -11
  357. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  358. package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
  359. package/dist/frontend/lowering/lower-comptime.js +4 -4
  360. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  361. package/dist/frontend/lowering/lower-console.d.ts +13 -0
  362. package/dist/frontend/lowering/lower-console.js +460 -4
  363. package/dist/frontend/lowering/lower-console.js.map +1 -1
  364. package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -0
  365. package/dist/frontend/lowering/lower-event-emitter.js +124 -38
  366. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  367. package/dist/frontend/lowering/lower-event-target.d.ts +63 -0
  368. package/dist/frontend/lowering/lower-event-target.js +362 -0
  369. package/dist/frontend/lowering/lower-event-target.js.map +1 -0
  370. package/dist/frontend/lowering/lower-expando.js +2 -2
  371. package/dist/frontend/lowering/lower-exprs.js +247 -42
  372. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  373. package/dist/frontend/lowering/lower-generators.d.ts +15 -7
  374. package/dist/frontend/lowering/lower-generators.js +183 -99
  375. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  376. package/dist/frontend/lowering/lower-inspect.d.ts +8 -1
  377. package/dist/frontend/lowering/lower-inspect.js +247 -28
  378. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  379. package/dist/frontend/lowering/lower-mixins.js +1 -1
  380. package/dist/frontend/lowering/lower-modules.d.ts +1 -1
  381. package/dist/frontend/lowering/lower-modules.js +27 -17
  382. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  383. package/dist/frontend/lowering/lower-namespaces.d.ts +2 -2
  384. package/dist/frontend/lowering/lower-namespaces.js +2 -2
  385. package/dist/frontend/lowering/lower-server.js +39 -14
  386. package/dist/frontend/lowering/lower-server.js.map +1 -1
  387. package/dist/frontend/lowering/lower-stdlib.d.ts +11 -1
  388. package/dist/frontend/lowering/lower-stdlib.js +45 -4
  389. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  390. package/dist/frontend/lowering/lower-stmts.d.ts +2 -2
  391. package/dist/frontend/lowering/lower-stmts.js +112 -23
  392. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  393. package/dist/frontend/lowering/lower-stream.js +234 -22
  394. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  395. package/dist/frontend/lowering/lower-timers.js +1 -1
  396. package/dist/frontend/lowering/lowerer.d.ts +45 -6
  397. package/dist/frontend/lowering/lowerer.js +360 -48
  398. package/dist/frontend/lowering/lowerer.js.map +1 -1
  399. package/dist/frontend/lowering/native-ffi.js +2 -2
  400. package/dist/frontend/lowering/native-ffi.js.map +1 -1
  401. package/dist/frontend/lowering/regex-span-reads.d.ts +12 -0
  402. package/dist/frontend/lowering/regex-span-reads.js +164 -0
  403. package/dist/frontend/lowering/regex-span-reads.js.map +1 -0
  404. package/dist/frontend/lowering/runtime-optional-records.d.ts +115 -0
  405. package/dist/frontend/lowering/runtime-optional-records.js +715 -0
  406. package/dist/frontend/lowering/runtime-optional-records.js.map +1 -0
  407. package/dist/frontend/lowering/runtime-optional-records.test.d.ts +1 -0
  408. package/dist/frontend/lowering/runtime-optional-records.test.js +175 -0
  409. package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -0
  410. package/dist/frontend/lowering/surfaces.d.ts +7 -3
  411. package/dist/frontend/lowering/surfaces.js +385 -32
  412. package/dist/frontend/lowering/surfaces.js.map +1 -1
  413. package/dist/frontend/lowering/var-hoisting.d.ts +3 -0
  414. package/dist/frontend/lowering/var-hoisting.js +261 -0
  415. package/dist/frontend/lowering/var-hoisting.js.map +1 -0
  416. package/dist/frontend/module-syntax.d.ts +1 -1
  417. package/dist/frontend/module-syntax.js +1 -1
  418. package/dist/frontend/npm-static-prune.js +1 -1
  419. package/dist/frontend/npm-static-prune.js.map +1 -1
  420. package/dist/frontend/npm-static-rewrite-syntax.js +4 -3
  421. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
  422. package/dist/frontend/pipeline.js +6 -4
  423. package/dist/frontend/pipeline.js.map +1 -1
  424. package/dist/frontend/program.d.ts +6 -5
  425. package/dist/frontend/program.js +42 -22
  426. package/dist/frontend/program.js.map +1 -1
  427. package/dist/frontend/program.test.js +13 -0
  428. package/dist/frontend/program.test.js.map +1 -1
  429. package/dist/frontend/resolve.js +1 -1
  430. package/dist/frontend/ts7/adapter.js +1 -1
  431. package/dist/frontend/ts7/ast-bytes.d.ts +1 -1
  432. package/dist/frontend/ts7/ast-bytes.js +1 -1
  433. package/dist/frontend/ts7/semantic-json.d.ts +1 -1
  434. package/dist/frontend/ts7/semantic-json.js +1 -1
  435. package/dist/frontend/ts7/semantic-json.js.map +1 -1
  436. package/dist/frontend/ts7/world-check.js +1 -1
  437. package/dist/frontend/tsc-codes.js +2 -2
  438. package/dist/frontend/tsc-codes.js.map +1 -1
  439. package/dist/frontend/type-mapper.d.ts +28 -1
  440. package/dist/frontend/type-mapper.js +288 -30
  441. package/dist/frontend/type-mapper.js.map +1 -1
  442. package/dist/index.js +6 -4
  443. package/dist/index.js.map +1 -1
  444. package/dist/ir/analysis.d.ts +12 -6
  445. package/dist/ir/analysis.js +26 -10
  446. package/dist/ir/analysis.js.map +1 -1
  447. package/dist/ir/analysis.test.js +15 -3
  448. package/dist/ir/analysis.test.js.map +1 -1
  449. package/dist/ir/builtin-effects.js +108 -2
  450. package/dist/ir/builtin-effects.js.map +1 -1
  451. package/dist/ir/builtin-signatures.d.ts +1 -1
  452. package/dist/ir/builtin-signatures.js +436 -53
  453. package/dist/ir/builtin-signatures.js.map +1 -1
  454. package/dist/ir/function-references.test.js +1 -0
  455. package/dist/ir/function-references.test.js.map +1 -1
  456. package/dist/ir/int32-slots.js +2 -0
  457. package/dist/ir/int32-slots.js.map +1 -1
  458. package/dist/ir/intrinsic-signatures.js +2 -0
  459. package/dist/ir/intrinsic-signatures.js.map +1 -1
  460. package/dist/ir/ir.d.ts +129 -36
  461. package/dist/ir/ir.js +42 -1
  462. package/dist/ir/ir.js.map +1 -1
  463. package/dist/ir/runtime-features.d.ts +1 -0
  464. package/dist/ir/runtime-features.js +116 -5
  465. package/dist/ir/runtime-features.js.map +1 -1
  466. package/dist/ir/scalar-records.js +1 -2
  467. package/dist/ir/scalar-records.js.map +1 -1
  468. package/dist/ir/serialize.js +1 -1
  469. package/dist/ir/serialize.js.map +1 -1
  470. package/dist/ir/traverse.js +1 -0
  471. package/dist/ir/traverse.js.map +1 -1
  472. package/dist/ir/validate.js +250 -34
  473. package/dist/ir/validate.js.map +1 -1
  474. package/dist/ir/validate.test.js +125 -0
  475. package/dist/ir/validate.test.js.map +1 -1
  476. package/dist/library/fence-eval.d.ts +1 -1
  477. package/dist/library/fence-eval.js +5 -4
  478. package/dist/library/fence-eval.js.map +1 -1
  479. package/dist/library/ir-policy.js +11 -4
  480. package/dist/library/ir-policy.js.map +1 -1
  481. package/dist/library/library-profile.js +13 -13
  482. package/dist/library/library-profile.js.map +1 -1
  483. package/dist/library/prepare.js +1 -1
  484. package/dist/library/prepare.js.map +1 -1
  485. package/dist/library/sidecar.js +3 -3
  486. package/dist/library/sidecar.js.map +1 -1
  487. package/dist/native/prepare.js +3 -2
  488. package/dist/native/prepare.js.map +1 -1
  489. package/dist/native/sanitizer.test.js +1 -0
  490. package/dist/native/sanitizer.test.js.map +1 -1
  491. package/package.json +20 -20
  492. package/surface-manifest.json +537 -142
@@ -4,7 +4,7 @@
4
4
  * an ICE that points at source is a gift to whoever debugs it.
5
5
  */
6
6
  import { validByteNumberToken } from "./byte-numbers.js";
7
- import { arrayOf, BYTES_ELEMENT_NAME, BOOL, BYTES_U8, bytesOf, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, ffiClassType, ffiSourceParamTypes, isDynTypedRefType, isFfiCallbackParam, isFfiContextParam, isFfiReleaseParam, isJsonSafeType, isJsonStringifySafeType, isRefCounted, isSortValuesElement, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, REF_TRUTHY_KINDS, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, shapeHasAccessorSlots, STRING, typeEquals, typeKey, unionContainerArmsOk, VOID, } from "./ir.js";
7
+ import { arrayOf, BYTES_ELEMENT_NAME, BOOL, BYTES_U8, bytesOf, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, ffiClassType, ffiSourceParamTypes, isDirentShape, isDynTypedRefType, isFfiCallbackParam, isFfiContextParam, isFfiReleaseParam, isJsonSafeType, isJsonStringifySafeType, isRefCounted, isSortValuesElement, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, REF_TRUTHY_KINDS, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, shapeHasAccessorSlots, STRING, typeEquals, typeKey, unionContainerArmsOk, VOID, } from "./ir.js";
8
8
  import { DYN_CLASS_PROPERTIES } from "./ir.js";
9
9
  import { unionWideningTags } from "./analysis.js";
10
10
  import { alwaysReturns } from "./control-flow.js";
@@ -55,6 +55,8 @@ export function validateModule(mod) {
55
55
  const moduleLoc = { file: mod.sourceFile, start: 0, end: 0 };
56
56
  if (mod.workers !== undefined && typeof mod.workers !== "boolean")
57
57
  errors.push({ message: "worker execution mode must be a boolean", loc: moduleLoc });
58
+ if (mod.lifetimeRegions !== undefined && mod.lifetimeRegions !== true)
59
+ errors.push({ message: "lifetimeRegions must be true when present", loc: moduleLoc });
58
60
  if (mod.workers && mod.lib !== undefined)
59
61
  errors.push({
60
62
  message: "worker execution requires a native static executable",
@@ -359,6 +361,10 @@ export function validateModule(mod) {
359
361
  if (cls.jsLength !== undefined && (!Number.isSafeInteger(cls.jsLength) || cls.jsLength < 0)) {
360
362
  errors.push({ message: `class ${cls.name}: invalid constructor length`, loc: cls.loc });
361
363
  }
364
+ if (cls.prototypeNames !== undefined &&
365
+ new Set(cls.prototypeNames).size !== cls.prototypeNames.length) {
366
+ errors.push({ message: `class ${cls.name}: duplicate prototype member names`, loc: cls.loc });
367
+ }
362
368
  if (cls.tracksOwnFields &&
363
369
  (cls.runtime ||
364
370
  cls.fields.find((field) => field.name === DYN_CLASS_PROPERTIES)?.type.kind !== "dyn")) {
@@ -854,11 +860,11 @@ export function validateModule(mod) {
854
860
  }
855
861
  }
856
862
  for (const fn of mod.functions) {
857
- validateFunction(fn, functionsByName, ffiByName, classesByName, recordsById, recordValidation, unionsById, globalsById, classValidation, errors, mod.workers === true);
863
+ validateFunction(fn, functionsByName, ffiByName, classesByName, recordsById, recordValidation, unionsById, globalsById, classValidation, errors, mod.workers === true, mod.lifetimeRegions === true);
858
864
  }
859
865
  return errors;
860
866
  }
861
- function validateFunction(fn, functions, ffiByName, classes, records, recordValidation, unions, globals, classValidation, errors, workers) {
867
+ function validateFunction(fn, functions, ffiByName, classes, records, recordValidation, unions, globals, classValidation, errors, workers, lifetimeRegions) {
862
868
  const locals = new Map(fn.locals.map((l) => [l.id, l]));
863
869
  const err = (message, loc) => errors.push({ message: `in ${fn.name}: ${message}`, loc });
864
870
  const asyncCaches = [
@@ -1458,6 +1464,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
1458
1464
  allowed.add("return");
1459
1465
  allowed.add("throw");
1460
1466
  allowed.add("runtimeFence");
1467
+ allowed.add("tryCatch");
1461
1468
  }
1462
1469
  if (e.diverges) {
1463
1470
  const last = e.stmts[e.stmts.length - 1];
@@ -1781,10 +1788,15 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
1781
1788
  if (want)
1782
1789
  expectType(a, want, `regexIntrinsic ${e.method} arg ${i}`);
1783
1790
  });
1784
- if (e.method === "execGroups" && e.args[1]?.kind !== "numLit") {
1785
- err("regexIntrinsic execGroups mask must be a numeric literal", e.loc);
1786
- }
1787
- if (e.method === "match" || e.method === "exec" || e.method === "execGroups") {
1791
+ if ((e.method === "execGroups" || e.method === "execSpans" || e.method === "matchGroups") &&
1792
+ e.args.slice(1).some((mask) => mask.kind !== "numLit")) {
1793
+ err(`regexIntrinsic ${e.method} masks must be numeric literals`, e.loc);
1794
+ }
1795
+ if (e.method === "match" ||
1796
+ e.method === "exec" ||
1797
+ e.method === "execGroups" ||
1798
+ e.method === "execSpans" ||
1799
+ e.method === "matchGroups") {
1788
1800
  // The `string[] | null` union (program-dependent id) — checked
1789
1801
  // by arms, like the libCall case checks process.envGet.
1790
1802
  const def = e.type.kind === "union" ? unions.get(e.type.unionId) : undefined;
@@ -1966,6 +1978,8 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
1966
1978
  buffer: { argTypes: [], minArgs: 0, result: DYN },
1967
1979
  setFromDyn: { argTypes: [DYN, F64], minArgs: 1, result: VOID },
1968
1980
  copyWithin: { argTypes: [F64, F64, F64], minArgs: 3, result: bytesOf(recv.elem) },
1981
+ sortNumeric: { argTypes: [F64], minArgs: 1, result: BOOL },
1982
+ sortCompare: { argTypes: e.args[0] ? [e.args[0].type] : [], minArgs: 1, result: VOID },
1969
1983
  equals: { argTypes: [BYTES_U8], minArgs: 1, result: BOOL },
1970
1984
  compareBuf: { argTypes: [BYTES_U8, F64, F64, F64, F64], minArgs: 1, result: F64 },
1971
1985
  // [needle, align, byteOffset?] — an OMITTED byteOffset is Node's
@@ -2054,6 +2068,19 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2054
2068
  if (want)
2055
2069
  expectType(a, want, `bytesIntrinsic ${e.method} arg ${i}`);
2056
2070
  });
2071
+ const order = e.args[0];
2072
+ if (e.method === "sortNumeric" &&
2073
+ (order?.kind !== "numLit" ||
2074
+ (order.value !== 0 && order.value !== 1 && order.value !== -1)))
2075
+ err("bytesIntrinsic sortNumeric order must be the literal 0, 1 or -1", e.loc);
2076
+ const comparator = e.args[0]?.type;
2077
+ if (e.method === "sortCompare" &&
2078
+ (e.args.length !== 1 ||
2079
+ comparator?.kind !== "func" ||
2080
+ comparator.params.length > 2 ||
2081
+ !comparator.params.every((param) => param.kind === "f64") ||
2082
+ comparator.ret.kind !== "f64"))
2083
+ err("bytesIntrinsic sortCompare comparator must be (number, number) => number", e.loc);
2057
2084
  if (!typeEquals(e.type, sig.result)) {
2058
2085
  err(`bytesIntrinsic ${e.method} result must be ${sig.result.kind}, got ${e.type.kind}`, e.loc);
2059
2086
  }
@@ -2119,9 +2146,15 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2119
2146
  : e.method === "shift"
2120
2147
  ? { argTypes: [], result: e.type } // union-checked below
2121
2148
  : e.method === "sortValues"
2122
- ? { argTypes: [F64, null], result: VOID }
2149
+ ? {
2150
+ argTypes: [F64, null, F64, null],
2151
+ result: VOID,
2152
+ }
2123
2153
  : e.method === "sortDense"
2124
- ? { argTypes: [null, BOOL], result: BOOL }
2154
+ ? {
2155
+ argTypes: [null, BOOL, F64, null],
2156
+ result: BOOL,
2157
+ }
2125
2158
  : { argTypes: [], result: F64 }; // length
2126
2159
  if ((e.method === "sortPrimitive" || e.method === "toSortedPrimitive") &&
2127
2160
  elem.kind !== "string" &&
@@ -2142,6 +2175,25 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2142
2175
  err(`arrIntrinsic ${e.method} comparator must be (elem, elem) => number`, e.loc);
2143
2176
  if (e.method === "sortDense" && e.args[1]?.kind !== "boolLit")
2144
2177
  err("arrIntrinsic sortDense owned flag must be a boolean literal", e.loc);
2178
+ // A recognized comparator's key order: [order] for numbers,
2179
+ // [order, key reader] for record and class elements.
2180
+ const order = e.args[2];
2181
+ if (order) {
2182
+ if (order.kind !== "numLit" || (order.value !== 1 && order.value !== -1))
2183
+ err(`arrIntrinsic ${e.method} key order must be the literal 1 or -1`, e.loc);
2184
+ const key = e.args[3]?.type;
2185
+ if (elem.kind === "f64"
2186
+ ? key !== undefined
2187
+ : elem.kind !== "record" && elem.kind !== "object")
2188
+ err(`arrIntrinsic ${e.method} key order on ${elem.kind} elements`, e.loc);
2189
+ if (elem.kind !== "f64" &&
2190
+ (!key ||
2191
+ key.kind !== "func" ||
2192
+ key.params.length !== 1 ||
2193
+ !typeEquals(key.params[0], elem) ||
2194
+ key.ret.kind !== "f64"))
2195
+ err(`arrIntrinsic ${e.method} key reader must be (elem) => number`, e.loc);
2196
+ }
2145
2197
  }
2146
2198
  if (e.method === "getNumber" && elem.kind !== "f64") {
2147
2199
  err(`arrIntrinsic getNumber requires f64 elements, got ${elem.kind}`, e.loc);
@@ -2188,7 +2240,13 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2188
2240
  // slice's indices and splice's count are optional (omitted args
2189
2241
  // omitted from the IR — backends fill the defaults); everything
2190
2242
  // else is exact.
2191
- const minArgs = e.method === "slice" ? 0 : e.method === "splice" ? 1 : sig.argTypes.length;
2243
+ const minArgs = e.method === "slice"
2244
+ ? 0
2245
+ : e.method === "splice"
2246
+ ? 1
2247
+ : e.method === "sortValues" || e.method === "sortDense"
2248
+ ? 2
2249
+ : sig.argTypes.length;
2192
2250
  if (e.args.length < minArgs || e.args.length > sig.argTypes.length) {
2193
2251
  err(`arrIntrinsic ${e.method}: ${e.args.length} args, expected ${sig.argTypes.length}`, e.loc);
2194
2252
  }
@@ -2294,7 +2352,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2294
2352
  ? { argTypes: [F64], result: key }
2295
2353
  : e.method === "iterValue"
2296
2354
  ? { argTypes: [F64], result: value }
2297
- : { argTypes: [], result: F64 }; // size / iterCount
2355
+ : { argTypes: [], result: F64 }; // size / iterCount / iterStart
2298
2356
  if (e.args.length !== sig.argTypes.length) {
2299
2357
  err(`mapIntrinsic ${e.method}: ${e.args.length} args, expected ${sig.argTypes.length}`, e.loc);
2300
2358
  }
@@ -2345,7 +2403,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2345
2403
  ? { argTypes: [F64], result: elem }
2346
2404
  : e.method === "toArray"
2347
2405
  ? { argTypes: [], result: arrayOf(elem) }
2348
- : { argTypes: [], result: F64 }; // size / iterCount
2406
+ : { argTypes: [], result: F64 }; // size / iterCount / iterStart
2349
2407
  if (e.args.length !== sig.argTypes.length) {
2350
2408
  err(`setIntrinsic ${e.method}: ${e.args.length} args, expected ${sig.argTypes.length}`, e.loc);
2351
2409
  }
@@ -2787,25 +2845,13 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2787
2845
  const want = recordValidation.get(shape.id).initializationFields;
2788
2846
  const seen = new Set();
2789
2847
  for (const f of e.fields) {
2790
- if (f.drop || f.overflow)
2848
+ if (f.overflow)
2791
2849
  checkExpr(f.value);
2792
2850
  else
2793
2851
  checkSlotValue(f.value);
2794
2852
  if (seen.has(f.name))
2795
2853
  err(`recordLit initializes field "${f.name}" twice`, e.loc);
2796
2854
  seen.add(f.name);
2797
- if (f.drop) {
2798
- // A mapping-dropped field (the PromiseSettledResult honest
2799
- // subset): evaluated, never stored — it must NOT name a
2800
- // declared field (that would silently drop a real store),
2801
- // and its value may be any type, void included.
2802
- if (f.overflow)
2803
- err(`recordLit drop entry "${f.name}" flagged overflow too`, e.loc);
2804
- if (want.has(f.name)) {
2805
- err(`recordLit drop entry "${f.name}" shadows a declared field of shape ${shape.id}`, e.loc);
2806
- }
2807
- continue;
2808
- }
2809
2855
  if (f.overflow) {
2810
2856
  // Overflow entries exist only on index-signature shapes, name
2811
2857
  // no declared field, and carry the index-value type exactly
@@ -2827,7 +2873,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
2827
2873
  else
2828
2874
  expectType(f.value, ft, `recordLit field "${f.name}"`);
2829
2875
  }
2830
- if (e.fields.filter((f) => !f.overflow && !f.drop).length !== shape.fields.length) {
2876
+ if (e.fields.filter((f) => !f.overflow).length !== shape.fields.length) {
2831
2877
  err(`recordLit does not initialize every field of shape ${shape.id}`, e.loc);
2832
2878
  }
2833
2879
  break;
@@ -3397,6 +3443,24 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
3397
3443
  err("module.tdzCheck must be void", e.loc);
3398
3444
  return;
3399
3445
  }
3446
+ if (e.name === "region.create" ||
3447
+ e.name === "region.enter" ||
3448
+ e.name === "region.leave" ||
3449
+ e.name === "region.release") {
3450
+ if (!lifetimeRegions)
3451
+ err(`${e.name} outside a lifetimeRegions module`, e.loc);
3452
+ const takesId = e.name === "region.enter" || e.name === "region.release";
3453
+ if (e.args.length !== (takesId ? 1 : 0))
3454
+ err(`${e.name} takes ${takesId ? "one region id" : "no arguments"}`, e.loc);
3455
+ for (const a of e.args) {
3456
+ checkExpr(a);
3457
+ if (a.type.kind !== "f64")
3458
+ err(`${e.name} id must be f64`, e.loc);
3459
+ }
3460
+ if (e.type.kind !== (e.name === "region.create" ? "f64" : "void"))
3461
+ err(`${e.name} has type ${e.name === "region.create" ? "f64" : "void"}`, e.loc);
3462
+ return;
3463
+ }
3400
3464
  if (e.name === "threads.publish") {
3401
3465
  if (e.args.length !== 1)
3402
3466
  err("threads.publish takes exactly one argument", e.loc);
@@ -3440,6 +3504,26 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
3440
3504
  }
3441
3505
  return;
3442
3506
  }
3507
+ if (e.name === "promise.allSettled" || e.name === "promise.any") {
3508
+ if (e.args.length !== 1)
3509
+ err(`${e.name} takes exactly one argument`, e.loc);
3510
+ for (const a of e.args) {
3511
+ checkExpr(a);
3512
+ if (a.type.kind !== "array" || a.type.elem.kind !== "promise") {
3513
+ err(`${a.type.kind} argument to ${e.name} (needs an array of promises)`, a.loc);
3514
+ }
3515
+ else if (e.name === "promise.any" && !typeEquals(a.type.elem, e.type)) {
3516
+ err("promise.any result must be the entries' promise type", e.loc);
3517
+ }
3518
+ }
3519
+ if (e.type.kind !== "promise")
3520
+ err(`${e.name} must be promise-typed`, e.loc);
3521
+ else if (e.name === "promise.allSettled" &&
3522
+ (e.type.inner.kind !== "array" || e.type.inner.elem.kind !== "union")) {
3523
+ err("promise.allSettled result must be a promise of a settled-record union array", e.loc);
3524
+ }
3525
+ return;
3526
+ }
3443
3527
  if (e.name === "promise.reject") {
3444
3528
  // ONE argument: the %Error-rooted reason object (the rejection
3445
3529
  // payload shares the thrown-Error representation — the
@@ -3550,11 +3634,15 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
3550
3634
  e.fn === "stream.pipeline" ||
3551
3635
  e.fn === "stream.pipelineDyn" ||
3552
3636
  e.fn === "sp.pipeline" ||
3637
+ e.fn === "sp.pipelineOpts" ||
3638
+ e.fn === "sp.pipelineOptsSignal" ||
3553
3639
  e.fn === "writable.write" ||
3554
3640
  e.fn === "writable.writeStr" ||
3555
3641
  e.fn === "writable.writeU" ||
3556
3642
  e.fn === "writable.end" ||
3557
- e.fn === "readable.unpipe";
3643
+ e.fn === "readable.unpipe" ||
3644
+ e.fn === "rl.create" ||
3645
+ e.fn === "rl.createSignal";
3558
3646
  if (variadic ? e.args.length < sig.argTypes.length : e.args.length !== sig.argTypes.length) {
3559
3647
  err(`libCall ${e.fn}: ${e.args.length} args, expected ${sig.argTypes.length}`, e.loc);
3560
3648
  }
@@ -3631,6 +3719,23 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
3631
3719
  }
3632
3720
  return true;
3633
3721
  }
3722
+ if (e.fn === "dyn.objEntryPairs") {
3723
+ // Result: the native [string, any][] the backend assembles from the
3724
+ // runtime's owned pair snapshot.
3725
+ const shape = e.type.kind === "array" && e.type.elem.kind === "record"
3726
+ ? records.get(e.type.elem.shapeId)
3727
+ : undefined;
3728
+ const field = (name) => shape?.fields.find((f) => f.name === name)?.type;
3729
+ const ok = shape !== undefined &&
3730
+ shape.tuple === true &&
3731
+ shape.indexValue === undefined &&
3732
+ shape.fields.length === 2 &&
3733
+ field("0")?.kind === "string" &&
3734
+ field("1")?.kind === "dyn";
3735
+ if (!ok)
3736
+ err(`libCall dyn.objEntryPairs must return a [string, any] tuple array`, e.loc);
3737
+ return true;
3738
+ }
3634
3739
  if (e.fn === "fetch.streamFrom") {
3635
3740
  const t = e.args[0]?.type;
3636
3741
  const ok = t?.kind === "string" ||
@@ -4211,10 +4316,14 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4211
4316
  }
4212
4317
  return true;
4213
4318
  }
4214
- if (e.fn === "fs.readdirTypesSync" || e.fn === "fsp.readdirTypes") {
4319
+ if (e.fn === "fs.readdirTypesSync" ||
4320
+ e.fn === "fsp.readdirTypes" ||
4321
+ e.fn === "fs.globTypesSync" ||
4322
+ e.fn === "fsp.globTypes") {
4215
4323
  // Result: the interned Dirent record array — {%dtype: f64,
4216
4324
  // name: string, parentPath: string} rows (canonical field
4217
- // order; the structure lowerFsReaddirTypesCall pinned).
4325
+ // order; the structure lowerFsReaddirTypesCall pinned). The glob
4326
+ // forms answer the array itself.
4218
4327
  const result = e.fn === "fsp.readdirTypes"
4219
4328
  ? e.type.kind === "promise"
4220
4329
  ? e.type.inner
@@ -4223,7 +4332,23 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4223
4332
  const shape = result?.kind === "array" && result.elem.kind === "record"
4224
4333
  ? records.get(result.elem.shapeId)
4225
4334
  : undefined;
4226
- const ok = shape !== undefined &&
4335
+ const ok = shape !== undefined && isDirentShape(shape);
4336
+ if (!ok) {
4337
+ err(`libCall ${e.fn} must return ${e.fn === "fsp.readdirTypes" ? "a promise of " : ""}the Dirent record array`, e.loc);
4338
+ }
4339
+ return true;
4340
+ }
4341
+ if (e.fn === "dir.readSync" || e.fn === "dir.read") {
4342
+ // Result: `Dirent | null` (a promise of it for dir.read) — the
4343
+ // interned Dirent row shape readdirTypesSync uses, or null.
4344
+ const result = e.fn === "dir.read" ? (e.type.kind === "promise" ? e.type.inner : undefined) : e.type;
4345
+ const def = result?.kind === "union" ? unions.get(result.unionId) : undefined;
4346
+ const row = def?.arms.find((a) => a.kind === "record");
4347
+ const shape = row?.kind === "record" ? records.get(row.shapeId) : undefined;
4348
+ const ok = def !== undefined &&
4349
+ def.arms.length === 2 &&
4350
+ def.arms.some((a) => a.kind === "nullT") &&
4351
+ shape !== undefined &&
4227
4352
  !shape.tuple &&
4228
4353
  shape.indexValue === undefined &&
4229
4354
  shape.fields.length === 3 &&
@@ -4234,7 +4359,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4234
4359
  shape.fields[2].name === "parentPath" &&
4235
4360
  shape.fields[2].type.kind === "string";
4236
4361
  if (!ok) {
4237
- err(`libCall ${e.fn} must return ${e.fn === "fsp.readdirTypes" ? "a promise of " : ""}the Dirent record array`, e.loc);
4362
+ err(`libCall ${e.fn} must return ${e.fn === "dir.read" ? "a promise of " : ""}Dirent | null`, e.loc);
4238
4363
  }
4239
4364
  return true;
4240
4365
  }
@@ -4526,6 +4651,31 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4526
4651
  return false;
4527
4652
  }
4528
4653
  function checkLibSpecialCall(e) {
4654
+ if (e.fn === "crypto.randomFillView" || e.fn === "crypto.randomFillViewRest") {
4655
+ // The filled view is the result, at its own element type.
4656
+ const view = e.args[0]?.type;
4657
+ if (view?.kind !== "bytes" || !typeEquals(e.type, view)) {
4658
+ err(`libCall ${e.fn} must return its view argument's type`, e.loc);
4659
+ }
4660
+ return true;
4661
+ }
4662
+ if (e.fn === "crypto.timingSafeEqual") {
4663
+ if (e.args[0]?.type.kind !== "bytes" || e.args[1]?.type.kind !== "bytes")
4664
+ err(`libCall ${e.fn} arguments must be views`, e.loc);
4665
+ }
4666
+ if (e.fn === "crypto.randomFillCb") {
4667
+ if (e.args[0]?.type.kind !== "bytes")
4668
+ err(`libCall ${e.fn} buffer must be a view`, e.loc);
4669
+ if (e.args[4]?.type.kind !== "func")
4670
+ err(`libCall ${e.fn} callback must be a function`, e.loc);
4671
+ }
4672
+ if (e.fn === "crypto.randomFillCbDyn" ||
4673
+ e.fn === "crypto.randomIntCb" ||
4674
+ e.fn === "crypto.generateKeyCb") {
4675
+ const callback = e.args[e.args.length - 1]?.type;
4676
+ if (callback?.kind !== "func")
4677
+ err(`libCall ${e.fn} callback must be a function`, e.loc);
4678
+ }
4529
4679
  if (e.fn === "global.undefRead") {
4530
4680
  // Always throws — the result type is whatever the declared type
4531
4681
  // of the undefined global mapped to (never materialized).
@@ -4557,6 +4707,15 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4557
4707
  }
4558
4708
  return true;
4559
4709
  }
4710
+ if (e.fn === "error.aggregateSetErrors" || e.fn === "error.aggregateErrors") {
4711
+ // Receiver: exactly %AggregateError (subclassing is fenced — the
4712
+ // hidden runtime slot admits no other layout).
4713
+ const recv = e.args[0];
4714
+ if (!recv || recv.type.kind !== "object" || recv.type.className !== "%AggregateError") {
4715
+ err(`libCall ${e.fn} receiver must be %AggregateError`, e.loc);
4716
+ }
4717
+ return true;
4718
+ }
4560
4719
  if (e.fn === "error.newDom") {
4561
4720
  if (e.type.kind !== "object" || e.type.className !== "%DOMException") {
4562
4721
  err(`libCall error.newDom must return %DOMException, got ${e.type.kind}`, e.loc);
@@ -4637,7 +4796,11 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4637
4796
  e.fn === "stream.finished" ||
4638
4797
  e.fn === "stream.finishedDyn" ||
4639
4798
  e.fn === "stream.pipeline" ||
4640
- e.fn === "stream.pipelineDyn") {
4799
+ e.fn === "stream.pipelineDyn" ||
4800
+ e.fn === "stream.addAbortSignal" ||
4801
+ e.fn === "stream.addAbortSignalFn" ||
4802
+ e.fn === "stream.finishedOpts" ||
4803
+ e.fn === "stream.finishedOptsSignal") {
4641
4804
  // Receiver/result: stream-hierarchy objects (a class whose base
4642
4805
  // chain reaches a runtime stream class). Constructors have no
4643
4806
  // receiver — their RESULT names the class; chaining forms
@@ -4654,6 +4817,15 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4654
4817
  }
4655
4818
  return false;
4656
4819
  };
4820
+ if (e.fn === "stream.addAbortSignal" || e.fn === "stream.addAbortSignalFn") {
4821
+ // [stream, signal] (the option) or [signal, stream] (the module
4822
+ // function): the result is the stream argument's type.
4823
+ const s = e.args[e.fn === "stream.addAbortSignal" ? 0 : 1];
4824
+ if (!isStreamObject(s?.type) || !typeEquals(e.type, s.type)) {
4825
+ err(`libCall ${e.fn} must take and return a stream-hierarchy object`, e.loc);
4826
+ }
4827
+ return true;
4828
+ }
4657
4829
  if (e.fn.endsWith(".new")) {
4658
4830
  if (!isStreamObject(e.type)) {
4659
4831
  err(`libCall ${e.fn} must return a stream class, got ${e.type.kind}`, e.loc);
@@ -4686,6 +4858,20 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4686
4858
  err(`libCall ${e.fn} must be void`, e.loc);
4687
4859
  return true;
4688
4860
  }
4861
+ if (e.fn === "stream.finishedOpts" || e.fn === "stream.finishedOptsSignal") {
4862
+ // (recv, readable, writable, error[, signal], cb) → the cleanup
4863
+ // closure; the callback is a func or a checked-dynamic value.
4864
+ if (!isStreamObject(e.args[0]?.type)) {
4865
+ err(`libCall ${e.fn} receiver must be a stream-hierarchy object`, e.loc);
4866
+ }
4867
+ const cbK = e.args[e.args.length - 1]?.type.kind;
4868
+ if (cbK !== "func" && cbK !== "dyn")
4869
+ err(`libCall ${e.fn} callback must be a func or dyn`, e.loc);
4870
+ if (e.type.kind !== "func") {
4871
+ err(`libCall ${e.fn} must return the cleanup closure, got ${e.type.kind}`, e.loc);
4872
+ }
4873
+ return true;
4874
+ }
4689
4875
  if (e.fn === "stream.finished" || e.fn === "stream.finishedDyn") {
4690
4876
  // (recv, cb) → the cleanup closure.
4691
4877
  if (!isStreamObject(e.args[0]?.type)) {
@@ -4792,6 +4978,7 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4792
4978
  e.fn !== "emitter.setDefaultMax" &&
4793
4979
  e.fn !== "emitter.setDefaultMaxChk" &&
4794
4980
  e.fn !== "emitter.getDefaultMax" &&
4981
+ e.fn !== "emitter.errorMonitor" &&
4795
4982
  e.fn !== "emitter.checkListener") {
4796
4983
  // Receiver: an emitter-hierarchy object (the %EventEmitter class
4797
4984
  // itself, or a class whose base chain reaches it). emitter.new
@@ -4960,6 +5147,8 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4960
5147
  }
4961
5148
  }
4962
5149
  }
5150
+ // The yield a `delegate` genResume is checking as its argument.
5151
+ let delegatedYield = null;
4963
5152
  function checkAsyncExpr(e) {
4964
5153
  switch (e.kind) {
4965
5154
  case "awaitExpr": {
@@ -4991,7 +5180,13 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
4991
5180
  }
4992
5181
  // The undefined next-channel has no C value form: such yields are
4993
5182
  // void-typed (statement position only — the frontend fences reads).
4994
- if (e.captureCompletion) {
5183
+ if (e.delegated) {
5184
+ if (delegatedYield !== e)
5185
+ err("delegated yield outside a delegate resume", e.loc);
5186
+ if (e.type.kind !== "void" || e.captureCompletion)
5187
+ err("invalid delegated yield", e.loc);
5188
+ }
5189
+ else if (e.captureCompletion) {
4995
5190
  if (fn.async ||
4996
5191
  e.type.kind !== "dyn" ||
4997
5192
  !typeEquals(e.captureCompletion.returnType, fn.returnType)) {
@@ -5014,6 +5209,26 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
5014
5209
  break;
5015
5210
  }
5016
5211
  const genT = e.gen.type;
5212
+ if (e.mode === "delegate") {
5213
+ if (e.arg !== null) {
5214
+ if (e.arg.kind === "yieldExpr" && e.arg.delegated)
5215
+ delegatedYield = e.arg;
5216
+ else
5217
+ err("genResume delegate argument is not a delegated yield", e.loc);
5218
+ checkExpr(e.arg);
5219
+ delegatedYield = null;
5220
+ }
5221
+ const outer = fn.generator;
5222
+ if (outer === undefined || fn.async || genT.async)
5223
+ err("genResume delegate outside a sync generator body", e.loc);
5224
+ else if (genT.nextT.kind !== "undefinedT" &&
5225
+ genT.nextT.kind !== "dyn" &&
5226
+ !typeEquals(genT.nextT, outer.nextT))
5227
+ err(`genResume delegate into a ${typeKey(genT.nextT)} next-channel from ${typeKey(outer.nextT)}`, e.loc);
5228
+ if (e.type.kind !== "bool" && e.type.kind !== "record")
5229
+ err(`genResume delegate result ${typeKey(e.type)}`, e.loc);
5230
+ break;
5231
+ }
5017
5232
  if (e.arg !== null)
5018
5233
  checkExpr(e.arg);
5019
5234
  if (e.mode === "step" || e.mode === "value" || e.mode === "close") {
@@ -5031,7 +5246,8 @@ function validateFunction(fn, functions, ffiByName, classes, records, recordVali
5031
5246
  if (e.type.kind !== "void")
5032
5247
  err(`genResume close result ${typeKey(e.type)}`, e.loc);
5033
5248
  }
5034
- else if (genT.yieldT.kind === "void" || !typeEquals(e.type, genT.yieldT)) {
5249
+ else if ((genT.yieldT.kind === "void" || !typeEquals(e.type, genT.yieldT)) &&
5250
+ (genT.retT.kind === "void" || !typeEquals(e.type, genT.retT))) {
5035
5251
  err(`genResume value ${typeKey(e.type)} != yield channel ${typeKey(genT.yieldT)}`, e.loc);
5036
5252
  }
5037
5253
  break;