@elaraai/east 0.0.1-beta.9 → 1.0.0

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 (410) hide show
  1. package/LICENSE.md +15 -666
  2. package/README.md +113 -88
  3. package/dist/src/analyze.d.ts +3 -0
  4. package/dist/src/analyze.d.ts.map +1 -1
  5. package/dist/src/analyze.js +223 -111
  6. package/dist/src/analyze.js.map +1 -1
  7. package/dist/src/analyze.spec.d.ts +2 -0
  8. package/dist/src/analyze.spec.d.ts.map +1 -0
  9. package/dist/src/analyze.spec.js +445 -0
  10. package/dist/src/analyze.spec.js.map +1 -0
  11. package/dist/src/ast.d.ts +54 -35
  12. package/dist/src/ast.d.ts.map +1 -1
  13. package/dist/src/ast_to_ir.coerce_to.spec.d.ts +15 -0
  14. package/dist/src/ast_to_ir.coerce_to.spec.d.ts.map +1 -0
  15. package/dist/src/ast_to_ir.coerce_to.spec.js +420 -0
  16. package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -0
  17. package/dist/src/ast_to_ir.d.ts +18 -4
  18. package/dist/src/ast_to_ir.d.ts.map +1 -1
  19. package/dist/src/ast_to_ir.js +233 -178
  20. package/dist/src/ast_to_ir.js.map +1 -1
  21. package/dist/src/builtins.d.ts +1 -1
  22. package/dist/src/builtins.d.ts.map +1 -1
  23. package/dist/src/builtins.js +194 -2
  24. package/dist/src/builtins.js.map +1 -1
  25. package/dist/src/comparison.d.ts +2 -2
  26. package/dist/src/comparison.d.ts.map +1 -1
  27. package/dist/src/comparison.js +115 -40
  28. package/dist/src/comparison.js.map +1 -1
  29. package/dist/src/comparison.spec.d.ts +2 -0
  30. package/dist/src/comparison.spec.d.ts.map +1 -0
  31. package/dist/src/comparison.spec.js +1200 -0
  32. package/dist/src/comparison.spec.js.map +1 -0
  33. package/dist/src/compile.d.ts +31 -9
  34. package/dist/src/compile.d.ts.map +1 -1
  35. package/dist/src/compile.js +1048 -548
  36. package/dist/src/compile.js.map +1 -1
  37. package/dist/src/containers/matrix.d.ts +15 -0
  38. package/dist/src/containers/matrix.d.ts.map +1 -0
  39. package/dist/src/containers/matrix.js +15 -0
  40. package/dist/src/containers/matrix.js.map +1 -0
  41. package/dist/src/containers/ref.d.ts.map +1 -1
  42. package/dist/src/containers/ref.js +1 -1
  43. package/dist/src/containers/ref.js.map +1 -1
  44. package/dist/src/containers/sortedmap.spec.d.ts +2 -0
  45. package/dist/src/containers/sortedmap.spec.d.ts.map +1 -0
  46. package/dist/src/containers/sortedmap.spec.js +180 -0
  47. package/dist/src/containers/sortedmap.spec.js.map +1 -0
  48. package/dist/src/containers/sortedset.spec.d.ts +2 -0
  49. package/dist/src/containers/sortedset.spec.d.ts.map +1 -0
  50. package/dist/src/containers/sortedset.spec.js +228 -0
  51. package/dist/src/containers/sortedset.spec.js.map +1 -0
  52. package/dist/src/containers/variant.d.ts.map +1 -1
  53. package/dist/src/containers/variant.js +1 -1
  54. package/dist/src/containers/variant.js.map +1 -1
  55. package/dist/src/containers/variant.spec.d.ts +2 -0
  56. package/dist/src/containers/variant.spec.d.ts.map +1 -0
  57. package/dist/src/containers/variant.spec.js +217 -0
  58. package/dist/src/containers/variant.spec.js.map +1 -0
  59. package/dist/src/datetime_format/parse.spec.d.ts +6 -0
  60. package/dist/src/datetime_format/parse.spec.d.ts.map +1 -0
  61. package/dist/src/datetime_format/parse.spec.js +379 -0
  62. package/dist/src/datetime_format/parse.spec.js.map +1 -0
  63. package/dist/src/datetime_format/print.spec.d.ts +6 -0
  64. package/dist/src/datetime_format/print.spec.d.ts.map +1 -0
  65. package/dist/src/datetime_format/print.spec.js +257 -0
  66. package/dist/src/datetime_format/print.spec.js.map +1 -0
  67. package/dist/src/datetime_format/tokenize.spec.d.ts +2 -0
  68. package/dist/src/datetime_format/tokenize.spec.d.ts.map +1 -0
  69. package/dist/src/datetime_format/tokenize.spec.js +508 -0
  70. package/dist/src/datetime_format/tokenize.spec.js.map +1 -0
  71. package/dist/src/datetime_format/types.d.ts +23 -23
  72. package/dist/src/default.d.ts.map +1 -1
  73. package/dist/src/default.js +33 -0
  74. package/dist/src/default.js.map +1 -1
  75. package/dist/src/default.spec.d.ts +2 -0
  76. package/dist/src/default.spec.d.ts.map +1 -0
  77. package/dist/src/default.spec.js +178 -0
  78. package/dist/src/default.spec.js.map +1 -0
  79. package/dist/src/eastir.d.ts +7 -0
  80. package/dist/src/eastir.d.ts.map +1 -1
  81. package/dist/src/eastir.js +55 -7
  82. package/dist/src/eastir.js.map +1 -1
  83. package/dist/src/error.d.ts +14 -4
  84. package/dist/src/error.d.ts.map +1 -1
  85. package/dist/src/error.js +28 -3
  86. package/dist/src/error.js.map +1 -1
  87. package/dist/src/example.d.ts +87 -0
  88. package/dist/src/example.d.ts.map +1 -0
  89. package/dist/src/example.js +18 -0
  90. package/dist/src/example.js.map +1 -0
  91. package/dist/src/expr/array.d.ts +43 -1
  92. package/dist/src/expr/array.d.ts.map +1 -1
  93. package/dist/src/expr/array.js +103 -53
  94. package/dist/src/expr/array.js.map +1 -1
  95. package/dist/src/expr/ast.d.ts +1 -1
  96. package/dist/src/expr/ast.d.ts.map +1 -1
  97. package/dist/src/expr/ast.js +112 -54
  98. package/dist/src/expr/ast.js.map +1 -1
  99. package/dist/src/expr/asyncfunction.d.ts.map +1 -1
  100. package/dist/src/expr/asyncfunction.js +6 -4
  101. package/dist/src/expr/asyncfunction.js.map +1 -1
  102. package/dist/src/expr/blob.d.ts +48 -0
  103. package/dist/src/expr/blob.d.ts.map +1 -1
  104. package/dist/src/expr/blob.js +63 -8
  105. package/dist/src/expr/blob.js.map +1 -1
  106. package/dist/src/expr/block.d.ts +213 -12
  107. package/dist/src/expr/block.d.ts.map +1 -1
  108. package/dist/src/expr/block.js +796 -293
  109. package/dist/src/expr/block.js.map +1 -1
  110. package/dist/src/expr/boolean.d.ts +44 -0
  111. package/dist/src/expr/boolean.d.ts.map +1 -1
  112. package/dist/src/expr/boolean.js +58 -6
  113. package/dist/src/expr/boolean.js.map +1 -1
  114. package/dist/src/expr/datetime.d.ts +135 -0
  115. package/dist/src/expr/datetime.d.ts.map +1 -1
  116. package/dist/src/expr/datetime.js +184 -34
  117. package/dist/src/expr/datetime.js.map +1 -1
  118. package/dist/src/expr/dict.d.ts +47 -2
  119. package/dist/src/expr/dict.d.ts.map +1 -1
  120. package/dist/src/expr/dict.js +122 -61
  121. package/dist/src/expr/dict.js.map +1 -1
  122. package/dist/src/expr/expr.d.ts +3 -1
  123. package/dist/src/expr/expr.d.ts.map +1 -1
  124. package/dist/src/expr/expr.js +4 -3
  125. package/dist/src/expr/expr.js.map +1 -1
  126. package/dist/src/expr/float.d.ts +153 -0
  127. package/dist/src/expr/float.d.ts.map +1 -1
  128. package/dist/src/expr/float.js +191 -17
  129. package/dist/src/expr/float.js.map +1 -1
  130. package/dist/src/expr/function.d.ts +7 -2
  131. package/dist/src/expr/function.d.ts.map +1 -1
  132. package/dist/src/expr/function.js +6 -4
  133. package/dist/src/expr/function.js.map +1 -1
  134. package/dist/src/expr/index.d.ts +186 -2
  135. package/dist/src/expr/index.d.ts.map +1 -1
  136. package/dist/src/expr/index.js +183 -2
  137. package/dist/src/expr/index.js.map +1 -1
  138. package/dist/src/expr/integer.d.ts +180 -0
  139. package/dist/src/expr/integer.d.ts.map +1 -1
  140. package/dist/src/expr/integer.js +189 -18
  141. package/dist/src/expr/integer.js.map +1 -1
  142. package/dist/src/expr/libs/array.js +3 -3
  143. package/dist/src/expr/libs/array.js.map +1 -1
  144. package/dist/src/expr/libs/blob.js +3 -3
  145. package/dist/src/expr/libs/blob.js.map +1 -1
  146. package/dist/src/expr/libs/dict.js +1 -1
  147. package/dist/src/expr/libs/dict.js.map +1 -1
  148. package/dist/src/expr/libs/matrix.d.ts +17 -0
  149. package/dist/src/expr/libs/matrix.d.ts.map +1 -0
  150. package/dist/src/expr/libs/matrix.js +60 -0
  151. package/dist/src/expr/libs/matrix.js.map +1 -0
  152. package/dist/src/expr/libs/set.js +1 -1
  153. package/dist/src/expr/libs/set.js.map +1 -1
  154. package/dist/src/expr/libs/string.d.ts.map +1 -1
  155. package/dist/src/expr/libs/string.js +2 -1
  156. package/dist/src/expr/libs/string.js.map +1 -1
  157. package/dist/src/expr/libs/vector.d.ts +16 -0
  158. package/dist/src/expr/libs/vector.d.ts.map +1 -0
  159. package/dist/src/expr/libs/vector.js +44 -0
  160. package/dist/src/expr/libs/vector.js.map +1 -0
  161. package/dist/src/expr/matrix.d.ts +109 -0
  162. package/dist/src/expr/matrix.d.ts.map +1 -0
  163. package/dist/src/expr/matrix.js +224 -0
  164. package/dist/src/expr/matrix.js.map +1 -0
  165. package/dist/src/expr/recursive.d.ts +83 -0
  166. package/dist/src/expr/recursive.d.ts.map +1 -0
  167. package/dist/src/expr/recursive.js +99 -0
  168. package/dist/src/expr/recursive.js.map +1 -0
  169. package/dist/src/expr/ref.js +5 -5
  170. package/dist/src/expr/ref.js.map +1 -1
  171. package/dist/src/expr/set.d.ts +44 -2
  172. package/dist/src/expr/set.d.ts.map +1 -1
  173. package/dist/src/expr/set.js +102 -52
  174. package/dist/src/expr/set.js.map +1 -1
  175. package/dist/src/expr/string.d.ts +134 -0
  176. package/dist/src/expr/string.d.ts.map +1 -1
  177. package/dist/src/expr/string.js +173 -23
  178. package/dist/src/expr/string.js.map +1 -1
  179. package/dist/src/expr/struct.d.ts +1 -1
  180. package/dist/src/expr/struct.d.ts.map +1 -1
  181. package/dist/src/expr/struct.js +2 -2
  182. package/dist/src/expr/struct.js.map +1 -1
  183. package/dist/src/expr/types.d.ts +12 -9
  184. package/dist/src/expr/types.d.ts.map +1 -1
  185. package/dist/src/expr/variant.d.ts +108 -11
  186. package/dist/src/expr/variant.d.ts.map +1 -1
  187. package/dist/src/expr/variant.js +76 -38
  188. package/dist/src/expr/variant.js.map +1 -1
  189. package/dist/src/expr/vector.d.ts +102 -0
  190. package/dist/src/expr/vector.d.ts.map +1 -0
  191. package/dist/src/expr/vector.js +202 -0
  192. package/dist/src/expr/vector.js.map +1 -0
  193. package/dist/src/fuzz.d.ts +36 -2
  194. package/dist/src/fuzz.d.ts.map +1 -1
  195. package/dist/src/fuzz.js +409 -77
  196. package/dist/src/fuzz.js.map +1 -1
  197. package/dist/src/index.d.ts +4 -0
  198. package/dist/src/index.d.ts.map +1 -1
  199. package/dist/src/index.js +4 -0
  200. package/dist/src/index.js.map +1 -1
  201. package/dist/src/internal.d.ts +12 -2
  202. package/dist/src/internal.d.ts.map +1 -1
  203. package/dist/src/internal.js +13 -2
  204. package/dist/src/internal.js.map +1 -1
  205. package/dist/src/ir.d.ts +1754 -1484
  206. package/dist/src/ir.d.ts.map +1 -1
  207. package/dist/src/ir.js +51 -34
  208. package/dist/src/ir.js.map +1 -1
  209. package/dist/src/ir.spec.d.ts +2 -0
  210. package/dist/src/ir.spec.d.ts.map +1 -0
  211. package/dist/src/ir.spec.js +35 -0
  212. package/dist/src/ir.spec.js.map +1 -0
  213. package/dist/src/location.d.ts +56 -17
  214. package/dist/src/location.d.ts.map +1 -1
  215. package/dist/src/location.js +226 -29
  216. package/dist/src/location.js.map +1 -1
  217. package/dist/src/location.spec.d.ts +2 -0
  218. package/dist/src/location.spec.d.ts.map +1 -0
  219. package/dist/src/location.spec.js +102 -0
  220. package/dist/src/location.spec.js.map +1 -0
  221. package/dist/src/patch/apply.d.ts +15 -0
  222. package/dist/src/patch/apply.d.ts.map +1 -0
  223. package/dist/src/patch/apply.js +352 -0
  224. package/dist/src/patch/apply.js.map +1 -0
  225. package/dist/src/patch/compose.d.ts +15 -0
  226. package/dist/src/patch/compose.d.ts.map +1 -0
  227. package/dist/src/patch/compose.js +448 -0
  228. package/dist/src/patch/compose.js.map +1 -0
  229. package/dist/src/patch/diff.d.ts +15 -0
  230. package/dist/src/patch/diff.d.ts.map +1 -0
  231. package/dist/src/patch/diff.js +347 -0
  232. package/dist/src/patch/diff.js.map +1 -0
  233. package/dist/src/patch/fuzz.d.ts +73 -0
  234. package/dist/src/patch/fuzz.d.ts.map +1 -0
  235. package/dist/src/patch/fuzz.js +159 -0
  236. package/dist/src/patch/fuzz.js.map +1 -0
  237. package/dist/src/patch/index.d.ts +32 -0
  238. package/dist/src/patch/index.d.ts.map +1 -0
  239. package/dist/src/patch/index.js +48 -0
  240. package/dist/src/patch/index.js.map +1 -0
  241. package/dist/src/patch/invert.d.ts +15 -0
  242. package/dist/src/patch/invert.d.ts.map +1 -0
  243. package/dist/src/patch/invert.js +284 -0
  244. package/dist/src/patch/invert.js.map +1 -0
  245. package/dist/src/patch/merge.d.ts +56 -0
  246. package/dist/src/patch/merge.d.ts.map +1 -0
  247. package/dist/src/patch/merge.js +586 -0
  248. package/dist/src/patch/merge.js.map +1 -0
  249. package/dist/src/patch/merge.spec.d.ts +2 -0
  250. package/dist/src/patch/merge.spec.d.ts.map +1 -0
  251. package/dist/src/patch/merge.spec.js +1139 -0
  252. package/dist/src/patch/merge.spec.js.map +1 -0
  253. package/dist/src/patch/patch.spec.d.ts +2 -0
  254. package/dist/src/patch/patch.spec.d.ts.map +1 -0
  255. package/dist/src/patch/patch.spec.js +452 -0
  256. package/dist/src/patch/patch.spec.js.map +1 -0
  257. package/dist/src/patch/path.d.ts +115 -0
  258. package/dist/src/patch/path.d.ts.map +1 -0
  259. package/dist/src/patch/path.js +192 -0
  260. package/dist/src/patch/path.js.map +1 -0
  261. package/dist/src/patch/path.spec.d.ts +6 -0
  262. package/dist/src/patch/path.spec.d.ts.map +1 -0
  263. package/dist/src/patch/path.spec.js +322 -0
  264. package/dist/src/patch/path.spec.js.map +1 -0
  265. package/dist/src/patch/prune.d.ts +77 -0
  266. package/dist/src/patch/prune.d.ts.map +1 -0
  267. package/dist/src/patch/prune.js +115 -0
  268. package/dist/src/patch/prune.js.map +1 -0
  269. package/dist/src/patch/prune.spec.d.ts +6 -0
  270. package/dist/src/patch/prune.spec.d.ts.map +1 -0
  271. package/dist/src/patch/prune.spec.js +473 -0
  272. package/dist/src/patch/prune.spec.js.map +1 -0
  273. package/dist/src/patch/type_of_patch.d.ts +25 -0
  274. package/dist/src/patch/type_of_patch.d.ts.map +1 -0
  275. package/dist/src/patch/type_of_patch.js +144 -0
  276. package/dist/src/patch/type_of_patch.js.map +1 -0
  277. package/dist/src/patch/types.d.ts +220 -0
  278. package/dist/src/patch/types.d.ts.map +1 -0
  279. package/dist/src/patch/types.js +62 -0
  280. package/dist/src/patch/types.js.map +1 -0
  281. package/dist/src/patch/validate.d.ts +44 -0
  282. package/dist/src/patch/validate.d.ts.map +1 -0
  283. package/dist/src/patch/validate.js +190 -0
  284. package/dist/src/patch/validate.js.map +1 -0
  285. package/dist/src/patch/validate.spec.d.ts +6 -0
  286. package/dist/src/patch/validate.spec.d.ts.map +1 -0
  287. package/dist/src/patch/validate.spec.js +225 -0
  288. package/dist/src/patch/validate.spec.js.map +1 -0
  289. package/dist/src/patch/walk.d.ts +121 -0
  290. package/dist/src/patch/walk.d.ts.map +1 -0
  291. package/dist/src/patch/walk.js +385 -0
  292. package/dist/src/patch/walk.js.map +1 -0
  293. package/dist/src/patch/walk.spec.d.ts +6 -0
  294. package/dist/src/patch/walk.spec.d.ts.map +1 -0
  295. package/dist/src/patch/walk.spec.js +621 -0
  296. package/dist/src/patch/walk.spec.js.map +1 -0
  297. package/dist/src/platform.d.ts +6 -0
  298. package/dist/src/platform.d.ts.map +1 -1
  299. package/dist/src/platform.spec.d.ts +2 -0
  300. package/dist/src/platform.spec.d.ts.map +1 -0
  301. package/dist/src/platform.spec.js +330 -0
  302. package/dist/src/platform.spec.js.map +1 -0
  303. package/dist/src/serialization/beast.d.ts.map +1 -1
  304. package/dist/src/serialization/beast.js +12 -0
  305. package/dist/src/serialization/beast.js.map +1 -1
  306. package/dist/src/serialization/beast.spec.d.ts +6 -0
  307. package/dist/src/serialization/beast.spec.d.ts.map +1 -0
  308. package/dist/src/serialization/beast.spec.js +406 -0
  309. package/dist/src/serialization/beast.spec.js.map +1 -0
  310. package/dist/src/serialization/beast2/index.d.ts +50 -0
  311. package/dist/src/serialization/beast2/index.d.ts.map +1 -0
  312. package/dist/src/serialization/beast2/index.js +756 -0
  313. package/dist/src/serialization/beast2/index.js.map +1 -0
  314. package/dist/src/serialization/beast2/index.spec.d.ts +6 -0
  315. package/dist/src/serialization/beast2/index.spec.d.ts.map +1 -0
  316. package/dist/src/serialization/beast2/index.spec.js +528 -0
  317. package/dist/src/serialization/beast2/index.spec.js.map +1 -0
  318. package/dist/src/serialization/beast2/sourcemap-table.d.ts +29 -0
  319. package/dist/src/serialization/beast2/sourcemap-table.d.ts.map +1 -0
  320. package/dist/src/serialization/beast2/sourcemap-table.js +82 -0
  321. package/dist/src/serialization/beast2/sourcemap-table.js.map +1 -0
  322. package/dist/src/serialization/beast2/string-table.d.ts +16 -0
  323. package/dist/src/serialization/beast2/string-table.d.ts.map +1 -0
  324. package/dist/src/serialization/beast2/string-table.js +38 -0
  325. package/dist/src/serialization/beast2/string-table.js.map +1 -0
  326. package/dist/src/serialization/beast2/type-table.d.ts +86 -0
  327. package/dist/src/serialization/beast2/type-table.d.ts.map +1 -0
  328. package/dist/src/serialization/beast2/type-table.js +618 -0
  329. package/dist/src/serialization/beast2/type-table.js.map +1 -0
  330. package/dist/src/serialization/beast2/value-table.d.ts +40 -0
  331. package/dist/src/serialization/beast2/value-table.d.ts.map +1 -0
  332. package/dist/src/serialization/beast2/value-table.js +157 -0
  333. package/dist/src/serialization/beast2/value-table.js.map +1 -0
  334. package/dist/src/serialization/binary-utils.d.ts +33 -0
  335. package/dist/src/serialization/binary-utils.d.ts.map +1 -1
  336. package/dist/src/serialization/binary-utils.js +157 -0
  337. package/dist/src/serialization/binary-utils.js.map +1 -1
  338. package/dist/src/serialization/csv.d.ts +17 -17
  339. package/dist/src/serialization/csv.d.ts.map +1 -1
  340. package/dist/src/serialization/csv.js +10 -8
  341. package/dist/src/serialization/csv.js.map +1 -1
  342. package/dist/src/serialization/csv.spec.d.ts +2 -0
  343. package/dist/src/serialization/csv.spec.d.ts.map +1 -0
  344. package/dist/src/serialization/csv.spec.js +556 -0
  345. package/dist/src/serialization/csv.spec.js.map +1 -0
  346. package/dist/src/serialization/east-inferred.spec.d.ts +2 -0
  347. package/dist/src/serialization/east-inferred.spec.d.ts.map +1 -0
  348. package/dist/src/serialization/east-inferred.spec.js +322 -0
  349. package/dist/src/serialization/east-inferred.spec.js.map +1 -0
  350. package/dist/src/serialization/east.d.ts +1 -1
  351. package/dist/src/serialization/east.d.ts.map +1 -1
  352. package/dist/src/serialization/east.js +178 -26
  353. package/dist/src/serialization/east.js.map +1 -1
  354. package/dist/src/serialization/east.spec.d.ts +2 -0
  355. package/dist/src/serialization/east.spec.d.ts.map +1 -0
  356. package/dist/src/serialization/east.spec.js +1548 -0
  357. package/dist/src/serialization/east.spec.js.map +1 -0
  358. package/dist/src/serialization/index.d.ts +1 -2
  359. package/dist/src/serialization/index.d.ts.map +1 -1
  360. package/dist/src/serialization/index.js +1 -2
  361. package/dist/src/serialization/index.js.map +1 -1
  362. package/dist/src/serialization/json.d.ts +1 -1
  363. package/dist/src/serialization/json.d.ts.map +1 -1
  364. package/dist/src/serialization/json.js +123 -24
  365. package/dist/src/serialization/json.js.map +1 -1
  366. package/dist/src/serialization/json.spec.d.ts +2 -0
  367. package/dist/src/serialization/json.spec.d.ts.map +1 -0
  368. package/dist/src/serialization/json.spec.js +1297 -0
  369. package/dist/src/serialization/json.spec.js.map +1 -0
  370. package/dist/src/type_of_type.d.ts +72 -35
  371. package/dist/src/type_of_type.d.ts.map +1 -1
  372. package/dist/src/type_of_type.is_data.spec.d.ts +6 -0
  373. package/dist/src/type_of_type.is_data.spec.d.ts.map +1 -0
  374. package/dist/src/type_of_type.is_data.spec.js +221 -0
  375. package/dist/src/type_of_type.is_data.spec.js.map +1 -0
  376. package/dist/src/type_of_type.js +355 -80
  377. package/dist/src/type_of_type.js.map +1 -1
  378. package/dist/src/type_of_type.to_etv.spec.d.ts +6 -0
  379. package/dist/src/type_of_type.to_etv.spec.d.ts.map +1 -0
  380. package/dist/src/type_of_type.to_etv.spec.js +263 -0
  381. package/dist/src/type_of_type.to_etv.spec.js.map +1 -0
  382. package/dist/src/types.d.ts +82 -12
  383. package/dist/src/types.d.ts.map +1 -1
  384. package/dist/src/types.error.spec.d.ts +2 -0
  385. package/dist/src/types.error.spec.d.ts.map +1 -0
  386. package/dist/src/types.error.spec.js +665 -0
  387. package/dist/src/types.error.spec.js.map +1 -0
  388. package/dist/src/types.js +663 -156
  389. package/dist/src/types.js.map +1 -1
  390. package/dist/src/types.spec.d.ts +2 -0
  391. package/dist/src/types.spec.d.ts.map +1 -0
  392. package/dist/src/types.spec.js +946 -0
  393. package/dist/src/types.spec.js.map +1 -0
  394. package/dist/src/walker.d.ts +65 -0
  395. package/dist/src/walker.d.ts.map +1 -0
  396. package/dist/src/walker.js +165 -0
  397. package/dist/src/walker.js.map +1 -0
  398. package/dist/src/walker.spec.d.ts +6 -0
  399. package/dist/src/walker.spec.d.ts.map +1 -0
  400. package/dist/src/walker.spec.js +109 -0
  401. package/dist/src/walker.spec.js.map +1 -0
  402. package/package.json +16 -38
  403. package/dist/src/serialization/beast2-stream.d.ts +0 -38
  404. package/dist/src/serialization/beast2-stream.d.ts.map +0 -1
  405. package/dist/src/serialization/beast2-stream.js +0 -670
  406. package/dist/src/serialization/beast2-stream.js.map +0 -1
  407. package/dist/src/serialization/beast2.d.ts +0 -41
  408. package/dist/src/serialization/beast2.d.ts.map +0 -1
  409. package/dist/src/serialization/beast2.js +0 -495
  410. package/dist/src/serialization/beast2.js.map +0 -1
@@ -1,24 +1,89 @@
1
- import { printLocationValue } from "./ir.js";
2
- import { printLocation } from "./location.js";
3
1
  import { toEastTypeValue } from "./type_of_type.js";
4
- import { ArrayType, DictType, FunctionType, isSubtype, isTypeEqual, NeverType, NullType, printType, RefType, SetType, StructType, VariantType } from "./types.js";
2
+ import { ArrayType, DictType, FunctionType, getTypeId, isSubtype, isTypeEqual, NeverType, NullType, printType, RefType, SetType, StructType, VariantType, VectorType, MatrixType } from "./types.js";
5
3
  import { variant } from "./containers/variant.js";
6
4
  import { applyTypeParameters, Builtins } from "./builtins.js";
7
5
  /** @internal An exception throw for the purpose of early loop continue */
8
6
  export class OutOfScopeException extends Error {
9
7
  definedLocation;
10
8
  constructor(definedLocation) {
11
- super(`Variable defined at ${printLocation(definedLocation)} is out of scope here`);
9
+ super(`Variable defined at loc_id ${definedLocation} is out of scope here`);
12
10
  this.definedLocation = definedLocation;
13
11
  }
14
12
  }
15
- // TODO we should probably redo type checking exhaustively here?
16
- function toLocationValue(location) {
17
- return {
18
- filename: location.filename,
19
- line: BigInt(location.line),
20
- column: BigInt(location.column),
21
- };
13
+ /**
14
+ * Coerce an IR value from `source_type` to `target_type`. When both are
15
+ * `StructType` or both are `VariantType` AND `value_ir` is the matching
16
+ * literal shape (a `Struct` / `Variant` IR node), recursively rewrite each
17
+ * child and rebuild the outer IR with the wider declared type — no outer
18
+ * `As` wrapper. Otherwise (primitives, variable references, invariant
19
+ * containers), emit a single outer `As`, matching legacy behaviour.
20
+ *
21
+ * Narrow→wide compound widening is only possible for Struct (covariant fields)
22
+ * and Variant (subset + covariant cases). All mutable-container parameters
23
+ * (Array/Set/Dict/Vector/Matrix/Ref) are invariant per isSubtypeImpl.
24
+ *
25
+ * @internal
26
+ */
27
+ export function coerce_to(value_ir, source_type, target_type, loc_id, visited) {
28
+ if (isTypeEqual(source_type, target_type))
29
+ return value_ir;
30
+ if (!isSubtype(source_type, target_type)) {
31
+ throw new Error(`Cannot coerce value of type ${printType(source_type)} to ${printType(target_type)} at loc_id ${loc_id}`);
32
+ }
33
+ const sid = getTypeId(source_type);
34
+ const tid = getTypeId(target_type);
35
+ const pair_key = `${sid ?? "?"}:${tid ?? "?"}`;
36
+ if (visited !== undefined && visited.has(pair_key)) {
37
+ return variant("As", {
38
+ type: toEastTypeValue(target_type),
39
+ value: value_ir,
40
+ loc_id,
41
+ });
42
+ }
43
+ const visited2 = visited ?? new Set();
44
+ visited2.add(pair_key);
45
+ let s = source_type;
46
+ let t = target_type;
47
+ if (s.type === "Recursive")
48
+ s = s.node;
49
+ if (t.type === "Recursive")
50
+ t = t.node;
51
+ if (value_ir.type === "Struct" && s.type === "Struct" && t.type === "Struct") {
52
+ const s_fields = s.fields;
53
+ const t_fields = t.fields;
54
+ const new_fields = value_ir.value.fields.map(({ name, value: field_ir }) => {
55
+ const s_field = s_fields[name];
56
+ const t_field = t_fields[name];
57
+ if (s_field === undefined || t_field === undefined) {
58
+ return { name, value: field_ir };
59
+ }
60
+ return { name, value: coerce_to(field_ir, s_field, t_field, loc_id, visited2) };
61
+ });
62
+ return variant("Struct", {
63
+ type: toEastTypeValue(target_type),
64
+ loc_id: value_ir.value.loc_id,
65
+ fields: new_fields,
66
+ });
67
+ }
68
+ if (value_ir.type === "Variant" && s.type === "Variant" && t.type === "Variant") {
69
+ const case_name = value_ir.value.case;
70
+ const s_case = s.cases[case_name];
71
+ const t_case = t.cases[case_name];
72
+ const inner = (s_case !== undefined && t_case !== undefined)
73
+ ? coerce_to(value_ir.value.value, s_case, t_case, loc_id, visited2)
74
+ : value_ir.value.value;
75
+ return variant("Variant", {
76
+ type: toEastTypeValue(target_type),
77
+ loc_id: value_ir.value.loc_id,
78
+ case: case_name,
79
+ value: inner,
80
+ });
81
+ }
82
+ return variant("As", {
83
+ type: toEastTypeValue(target_type),
84
+ value: value_ir,
85
+ loc_id,
86
+ });
22
87
  }
23
88
  /** Perform scope resolution and type checking on `AST`, produce `IR` ready for serialization, compilation or evaluation.
24
89
  *
@@ -37,7 +102,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
37
102
  return ir;
38
103
  }
39
104
  else {
40
- throw new OutOfScopeException(ast.location);
105
+ throw new OutOfScopeException(ast.loc_id);
41
106
  }
42
107
  }
43
108
  }
@@ -47,30 +112,22 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
47
112
  const variable = variant("Variable", {
48
113
  type: toEastTypeValue(ast.variable.type),
49
114
  name: `_${ctx.n_vars}`,
50
- location: toLocationValue(ast.variable.location),
115
+ loc_id: ast.variable.loc_id,
51
116
  mutable: ast.variable.mutable,
52
117
  captured: false,
53
118
  });
54
- // Insert As node if value type doesn't exactly match variable type
55
- // This ensures the IR has exact types everywhere
56
119
  if (!isTypeEqual(ast.value.type, ast.variable.type)) {
57
- // Validate subtype relationship before inserting As node
58
- // This catches type errors early at AST level
59
120
  if (!isSubtype(ast.value.type, ast.variable.type)) {
60
121
  throw new Error(`Cannot initialize variable of type ${printType(ast.variable.type)} ` +
61
- `with value of type ${printType(ast.value.type)} at ${printLocation(ast.location)}`);
122
+ `with value of type ${printType(ast.value.type)} at loc_id ${ast.loc_id}`);
62
123
  }
63
- value = variant("As", {
64
- type: toEastTypeValue(ast.variable.type),
65
- value,
66
- location: toLocationValue(ast.location),
67
- });
124
+ value = coerce_to(value, ast.value.type, ast.variable.type, ast.loc_id);
68
125
  }
69
126
  ctx.n_vars += 1;
70
127
  ctx.local_ctx.set(ast.variable, variable);
71
128
  return variant("Let", {
72
129
  type: toEastTypeValue(ast.type),
73
- location: toLocationValue(ast.location),
130
+ loc_id: ast.loc_id,
74
131
  variable,
75
132
  value,
76
133
  });
@@ -79,28 +136,19 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
79
136
  // Fetch the variable from context
80
137
  const variable = ast_to_ir(ast.variable, ctx);
81
138
  if (!variable.value.mutable) {
82
- throw new Error(`Variable defined const at ${printLocationValue(variable.value.location)} is being reassigned at ${printLocation(ast.location)}`);
139
+ throw new Error(`Variable defined const at loc_id ${variable.value.loc_id} is being reassigned at loc_id ${ast.loc_id}`);
83
140
  }
84
141
  let value = ast_to_ir(ast.value, ctx);
85
- // Get the variable's type from the IR node
86
- const variableType = variable.value.type;
87
- // Insert As node if value type doesn't exactly match variable type
88
- // This ensures the IR has exact types everywhere
89
142
  if (!isTypeEqual(ast.value.type, ast.variable.type)) {
90
- // Validate subtype relationship before inserting As node
91
143
  if (!isSubtype(ast.value.type, ast.variable.type)) {
92
144
  throw new Error(`Cannot assign value of type ${printType(ast.value.type)} ` +
93
- `to variable of type ${printType(ast.variable.type)} at ${printLocation(ast.location)}`);
145
+ `to variable of type ${printType(ast.variable.type)} at loc_id ${ast.loc_id}`);
94
146
  }
95
- value = variant("As", {
96
- type: variableType,
97
- value,
98
- location: toLocationValue(ast.location),
99
- });
147
+ value = coerce_to(value, ast.value.type, ast.variable.type, ast.loc_id);
100
148
  }
101
149
  return variant("Assign", {
102
150
  type: toEastTypeValue(ast.type),
103
- location: toLocationValue(ast.location),
151
+ loc_id: ast.loc_id,
104
152
  variable,
105
153
  value,
106
154
  });
@@ -113,7 +161,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
113
161
  ctx.n_loops = ctx2.n_loops;
114
162
  return variant("Block", {
115
163
  type: toEastTypeValue(ast.type),
116
- location: toLocationValue(ast.location),
164
+ loc_id: ast.loc_id,
117
165
  statements,
118
166
  });
119
167
  }
@@ -122,33 +170,28 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
122
170
  const builtin_name = ast.builtin;
123
171
  const builtin_def = Builtins[builtin_name];
124
172
  if (!builtin_def) {
125
- throw new Error(`Unknown builtin function '${builtin_name}' at ${printLocation(ast.location)}`);
173
+ throw new Error(`Unknown builtin function '${builtin_name}' at loc_id ${ast.loc_id}`);
126
174
  }
127
175
  if (builtin_def.type_parameters.length !== ast.type_parameters.length) {
128
- throw new Error(`Builtin function '${builtin_name}' expected ${builtin_def.type_parameters.length} type parameters, got ${ast.type_parameters.length} at ${printLocation(ast.location)}`);
176
+ throw new Error(`Builtin function '${builtin_name}' expected ${builtin_def.type_parameters.length} type parameters, got ${ast.type_parameters.length} at loc_id ${ast.loc_id}`);
129
177
  }
130
178
  const type_map = new Map(builtin_def.type_parameters.map((name, i) => [name, ast.type_parameters[i]]));
131
179
  if (ast.arguments.length !== builtin_def.inputs.length) {
132
- throw new Error(`Builtin function '${builtin_name}' expected ${builtin_def.inputs.length} arguments, got ${ast.arguments.length} at ${printLocation(ast.location)}`);
180
+ throw new Error(`Builtin function '${builtin_name}' expected ${builtin_def.inputs.length} arguments, got ${ast.arguments.length} at loc_id ${ast.loc_id}`);
133
181
  }
134
182
  return variant("Builtin", {
135
183
  type: toEastTypeValue(ast.type),
136
- location: toLocationValue(ast.location),
184
+ loc_id: ast.loc_id,
137
185
  builtin: ast.builtin,
138
186
  type_parameters: ast.type_parameters.map(tp => toEastTypeValue(tp)),
139
187
  arguments: ast.arguments.map((arg, i) => {
140
188
  let arg_ir = ast_to_ir(arg, ctx);
141
189
  const expectedType = applyTypeParameters(builtin_def.inputs[i], type_map, [], []);
142
- // Now check type compatibility
143
190
  if (arg.type.type !== "Never" && !isTypeEqual(arg.type, expectedType)) {
144
191
  if (!isSubtype(arg.type, expectedType)) {
145
- throw new Error(`Builtin ${builtin_name} with type parameters [${ast.type_parameters.map(tp => printType(tp)).join(", ")}] argument ${i} of type ${printType(arg.type)} is not compatible with expected type ${printType(expectedType)} at ${printLocation(ast.location)}`);
192
+ throw new Error(`Builtin ${builtin_name} with type parameters [${ast.type_parameters.map(tp => printType(tp)).join(", ")}] argument ${i} of type ${printType(arg.type)} is not compatible with expected type ${printType(expectedType)} at loc_id ${ast.loc_id}`);
146
193
  }
147
- arg_ir = variant("As", {
148
- type: toEastTypeValue(arg.type),
149
- value: arg_ir,
150
- location: toLocationValue(ast.location),
151
- });
194
+ arg_ir = coerce_to(arg_ir, arg.type, expectedType, ast.loc_id);
152
195
  }
153
196
  return arg_ir;
154
197
  }),
@@ -156,37 +199,35 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
156
199
  }
157
200
  else if (ast.ast_type === "Platform") {
158
201
  if (ctx.async === false && ast.async === true) {
159
- throw new Error(`Async platform call not allowed outside async function at ${printLocation(ast.location)}`);
202
+ throw new Error(`Async platform call not allowed outside async function at loc_id ${ast.loc_id}`);
160
203
  }
161
204
  return variant("Platform", {
162
205
  type: toEastTypeValue(ast.type),
163
- location: toLocationValue(ast.location),
206
+ loc_id: ast.loc_id,
164
207
  name: ast.name,
208
+ type_parameters: ast.type_parameters.map(tp => toEastTypeValue(tp)),
165
209
  arguments: ast.arguments.map(ast => ast_to_ir(ast, ctx)), // type equality handled at Expr/AST level
166
210
  async: ast.async,
211
+ optional: ast.optional,
167
212
  });
168
213
  }
169
214
  else if (ast.ast_type === "Struct") {
170
215
  return variant("Struct", {
171
216
  type: toEastTypeValue(ast.type),
172
- location: toLocationValue(ast.location),
217
+ loc_id: ast.loc_id,
173
218
  fields: Object.entries(ast.fields).map(([name, fieldAst]) => {
174
219
  let value = ast_to_ir(fieldAst, ctx);
175
220
  const expectedType = ast.type.fields[name];
176
221
  if (!expectedType) {
177
- throw new Error(`Struct type does not have field '${name}' at ${printLocation(ast.location)}`);
222
+ throw new Error(`Struct type does not have field '${name}' at loc_id ${ast.loc_id}`);
178
223
  }
179
224
  if (!isTypeEqual(fieldAst.type, expectedType)) {
180
225
  if (isSubtype(fieldAst.type, expectedType)) {
181
- value = variant("As", {
182
- type: toEastTypeValue(expectedType),
183
- value,
184
- location: toLocationValue(ast.location),
185
- });
226
+ value = coerce_to(value, fieldAst.type, expectedType, ast.loc_id);
186
227
  }
187
228
  else {
188
229
  throw new Error(`Cannot assign field '${name}' of type ${printType(ast.type.fields[name])} ` +
189
- `with value of type ${printType(fieldAst.type)} at ${printLocation(ast.location)}`);
230
+ `with value of type ${printType(fieldAst.type)} at loc_id ${ast.loc_id}`);
190
231
  }
191
232
  }
192
233
  return { name, value };
@@ -196,7 +237,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
196
237
  else if (ast.ast_type === "GetField") {
197
238
  return variant("GetField", {
198
239
  type: toEastTypeValue(ast.type),
199
- location: toLocationValue(ast.location),
240
+ loc_id: ast.loc_id,
200
241
  struct: ast_to_ir(ast.struct, ctx),
201
242
  field: ast.field,
202
243
  });
@@ -206,20 +247,16 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
206
247
  let value = ast_to_ir(ast.value, ctx);
207
248
  if (!isTypeEqual(ast.value.type, expectedType)) {
208
249
  if (isSubtype(ast.value.type, expectedType)) {
209
- value = variant("As", {
210
- type: toEastTypeValue(expectedType),
211
- value,
212
- location: toLocationValue(ast.location),
213
- });
250
+ value = coerce_to(value, ast.value.type, expectedType, ast.loc_id);
214
251
  }
215
252
  else {
216
253
  throw new Error(`Cannot assign case '${ast.case}' of type ${printType(expectedType)} ` +
217
- `with value of type ${printType(ast.value.type)} at ${printLocation(ast.location)}`);
254
+ `with value of type ${printType(ast.value.type)} at loc_id ${ast.loc_id}`);
218
255
  }
219
256
  }
220
257
  return variant("Variant", {
221
258
  type: toEastTypeValue(ast.type),
222
- location: toLocationValue(ast.location),
259
+ loc_id: ast.loc_id,
223
260
  case: ast.case,
224
261
  value,
225
262
  });
@@ -229,7 +266,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
229
266
  const param = variant("Variable", {
230
267
  type: toEastTypeValue(parameter.type),
231
268
  name: `_${ctx.n_vars}`,
232
- location: toLocationValue(parameter.location),
269
+ loc_id: parameter.loc_id,
233
270
  mutable: parameter.mutable, // false...
234
271
  captured: false,
235
272
  });
@@ -243,9 +280,21 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
243
280
  const body = ast_to_ir(ast.body, ctx2);
244
281
  ctx.n_vars = ctx2.n_vars;
245
282
  ctx.n_loops = ctx2.n_loops;
283
+ // Propagate captures: if this function captured something from ctx.parent_ctx,
284
+ // then the enclosing function also needs to capture it
285
+ for (const capturedVar of captures) {
286
+ // Check if this variable came from our parent context (not defined locally in enclosing function)
287
+ for (const [_astVar, ir] of ctx.parent_ctx) {
288
+ if (ir === capturedVar) {
289
+ // This capture came from an outer scope, so enclosing function must also capture it
290
+ ctx.captures.add(capturedVar);
291
+ break;
292
+ }
293
+ }
294
+ }
246
295
  return variant("Function", {
247
296
  type: toEastTypeValue(ast.type),
248
- location: toLocationValue(ast.location),
297
+ loc_id: ast.loc_id,
249
298
  parameters,
250
299
  captures: [...captures],
251
300
  body,
@@ -256,7 +305,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
256
305
  const param = variant("Variable", {
257
306
  type: toEastTypeValue(parameter.type),
258
307
  name: `_${ctx.n_vars}`,
259
- location: toLocationValue(parameter.location),
308
+ loc_id: parameter.loc_id,
260
309
  mutable: parameter.mutable, // false...
261
310
  captured: false,
262
311
  });
@@ -270,9 +319,21 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
270
319
  const body = ast_to_ir(ast.body, ctx2);
271
320
  ctx.n_vars = ctx2.n_vars;
272
321
  ctx.n_loops = ctx2.n_loops;
322
+ // Propagate captures: if this function captured something from ctx.parent_ctx,
323
+ // then the enclosing function also needs to capture it
324
+ for (const capturedVar of captures) {
325
+ // Check if this variable came from our parent context (not defined locally in enclosing function)
326
+ for (const [_astVar, ir] of ctx.parent_ctx) {
327
+ if (ir === capturedVar) {
328
+ // This capture came from an outer scope, so enclosing function must also capture it
329
+ ctx.captures.add(capturedVar);
330
+ break;
331
+ }
332
+ }
333
+ }
273
334
  return variant("AsyncFunction", {
274
335
  type: toEastTypeValue(ast.type),
275
- location: toLocationValue(ast.location),
336
+ loc_id: ast.loc_id,
276
337
  parameters,
277
338
  captures: [...captures],
278
339
  body,
@@ -283,20 +344,16 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
283
344
  // TODO - what about widening the result with As?
284
345
  return variant("Call", {
285
346
  type: toEastTypeValue(ast.type),
286
- location: toLocationValue(ast.location),
347
+ loc_id: ast.loc_id,
287
348
  function: ast_to_ir(ast.function, ctx),
288
349
  arguments: ast.arguments.map((argument, i) => {
289
350
  let arg = ast_to_ir(argument, ctx);
290
351
  const expectedType = ast.function.type.inputs[i];
291
352
  if (!isTypeEqual(argument.type, expectedType)) {
292
353
  if (!isSubtype(argument.type, expectedType)) {
293
- throw new Error(`Argument ${i} of type ${printType(argument.type)} is not compatible with expected type ${printType(expectedType)} at ${printLocation(ast.location)}`);
354
+ throw new Error(`Argument ${i} of type ${printType(argument.type)} is not compatible with expected type ${printType(expectedType)} at loc_id ${ast.loc_id}`);
294
355
  }
295
- arg = variant("As", {
296
- type: toEastTypeValue(expectedType),
297
- value: arg,
298
- location: toLocationValue(ast.location),
299
- });
356
+ arg = coerce_to(arg, argument.type, expectedType, ast.loc_id);
300
357
  }
301
358
  return arg;
302
359
  }),
@@ -304,26 +361,22 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
304
361
  }
305
362
  else if (ast.ast_type === "CallAsync") {
306
363
  if (ctx.async === false) {
307
- throw new Error(`Async function call not allowed outside async function at ${printLocation(ast.location)}`);
364
+ throw new Error(`Async function call not allowed outside async function at loc_id ${ast.loc_id}`);
308
365
  }
309
366
  // TODO - type equality could have been handled at Expr/AST level instead
310
367
  // TODO - what about widening the result with As?
311
368
  return variant("CallAsync", {
312
369
  type: toEastTypeValue(ast.type),
313
- location: toLocationValue(ast.location),
370
+ loc_id: ast.loc_id,
314
371
  function: ast_to_ir(ast.function, ctx),
315
372
  arguments: ast.arguments.map((argument, i) => {
316
373
  let arg = ast_to_ir(argument, ctx);
317
374
  const expectedType = ast.function.type.inputs[i];
318
375
  if (!isTypeEqual(argument.type, expectedType)) {
319
376
  if (!isSubtype(argument.type, expectedType)) {
320
- throw new Error(`Argument ${i} of type ${printType(argument.type)} is not compatible with expected type ${printType(expectedType)} at ${printLocation(ast.location)}`);
377
+ throw new Error(`Argument ${i} of type ${printType(argument.type)} is not compatible with expected type ${printType(expectedType)} at loc_id ${ast.loc_id}`);
321
378
  }
322
- arg = variant("As", {
323
- type: toEastTypeValue(expectedType),
324
- value: arg,
325
- location: toLocationValue(ast.location),
326
- });
379
+ arg = coerce_to(arg, argument.type, expectedType, ast.loc_id);
327
380
  }
328
381
  return arg;
329
382
  }),
@@ -334,17 +387,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
334
387
  let value = ast_to_ir(ast.value, ctx);
335
388
  if (!isTypeEqual(ast.value.type, valueType)) {
336
389
  if (!isSubtype(ast.value.type, valueType)) {
337
- throw new Error(`Ref value of type ${printType(ast.value.type)} is not compatible with expected type ${printType(valueType)} at ${printLocation(ast.location)}`);
390
+ throw new Error(`Ref value of type ${printType(ast.value.type)} is not compatible with expected type ${printType(valueType)} at loc_id ${ast.loc_id}`);
338
391
  }
339
- value = variant("As", {
340
- type: toEastTypeValue(valueType),
341
- value,
342
- location: toLocationValue(ast.location),
343
- });
392
+ value = coerce_to(value, ast.value.type, valueType, ast.loc_id);
344
393
  }
345
394
  return variant("NewRef", {
346
395
  type: toEastTypeValue(ast.type),
347
- location: toLocationValue(ast.location),
396
+ loc_id: ast.loc_id,
348
397
  value,
349
398
  });
350
399
  }
@@ -352,18 +401,14 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
352
401
  const valueType = ast.type.value;
353
402
  return variant("NewArray", {
354
403
  type: toEastTypeValue(ast.type),
355
- location: toLocationValue(ast.location),
404
+ loc_id: ast.loc_id,
356
405
  values: ast.values.map((v, i) => {
357
406
  let value = ast_to_ir(v, ctx);
358
407
  if (!isTypeEqual(v.type, valueType)) {
359
408
  if (!isSubtype(v.type, valueType)) {
360
- throw new Error(`Array value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(valueType)} at ${printLocation(ast.location)}`);
409
+ throw new Error(`Array value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(valueType)} at loc_id ${ast.loc_id}`);
361
410
  }
362
- value = variant("As", {
363
- type: toEastTypeValue(valueType),
364
- value,
365
- location: toLocationValue(ast.location),
366
- });
411
+ value = coerce_to(value, v.type, valueType, ast.loc_id);
367
412
  }
368
413
  return value;
369
414
  }),
@@ -373,18 +418,14 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
373
418
  const keyType = ast.type.key;
374
419
  return variant("NewSet", {
375
420
  type: toEastTypeValue(ast.type),
376
- location: toLocationValue(ast.location),
421
+ loc_id: ast.loc_id,
377
422
  values: ast.values.map((k, i) => {
378
423
  let key = ast_to_ir(k, ctx);
379
424
  if (!isTypeEqual(k.type, keyType)) {
380
425
  if (!isSubtype(k.type, keyType)) {
381
- throw new Error(`Set key at entry ${i} of type ${printType(k.type)} is not compatible with expected type ${printType(keyType)} at ${printLocation(ast.location)}`);
426
+ throw new Error(`Set key at entry ${i} of type ${printType(k.type)} is not compatible with expected type ${printType(keyType)} at loc_id ${ast.loc_id}`);
382
427
  }
383
- key = variant("As", {
384
- type: toEastTypeValue(keyType),
385
- value: key,
386
- location: toLocationValue(ast.location),
387
- });
428
+ key = coerce_to(key, k.type, keyType, ast.loc_id);
388
429
  }
389
430
  return key;
390
431
  }),
@@ -395,29 +436,21 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
395
436
  const valueType = ast.type.value;
396
437
  return variant("NewDict", {
397
438
  type: toEastTypeValue(ast.type),
398
- location: toLocationValue(ast.location),
439
+ loc_id: ast.loc_id,
399
440
  values: ast.values.map(([k, v], i) => {
400
441
  let key = ast_to_ir(k, ctx);
401
442
  if (!isTypeEqual(k.type, keyType)) {
402
443
  if (!isSubtype(k.type, keyType)) {
403
- throw new Error(`Dict key at entry ${i} of type ${printType(k.type)} is not compatible with expected type ${printType(keyType)} at ${printLocation(ast.location)}`);
444
+ throw new Error(`Dict key at entry ${i} of type ${printType(k.type)} is not compatible with expected type ${printType(keyType)} at loc_id ${ast.loc_id}`);
404
445
  }
405
- key = variant("As", {
406
- type: toEastTypeValue(keyType),
407
- value: key,
408
- location: toLocationValue(ast.location),
409
- });
446
+ key = coerce_to(key, k.type, keyType, ast.loc_id);
410
447
  }
411
448
  let value = ast_to_ir(v, ctx);
412
449
  if (!isTypeEqual(v.type, valueType)) {
413
450
  if (!isSubtype(v.type, valueType)) {
414
- throw new Error(`Dict value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(valueType)} at ${printLocation(ast.location)}`);
451
+ throw new Error(`Dict value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(valueType)} at loc_id ${ast.loc_id}`);
415
452
  }
416
- value = variant("As", {
417
- type: toEastTypeValue(valueType),
418
- value,
419
- location: toLocationValue(ast.location),
420
- });
453
+ value = coerce_to(value, v.type, valueType, ast.loc_id);
421
454
  }
422
455
  ;
423
456
  return { key, value };
@@ -443,13 +476,9 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
443
476
  ctx.n_loops = ctx_branch.n_loops;
444
477
  if (branch.body.type.type !== "Never" && !isTypeEqual(branch.body.type, ast.type)) {
445
478
  if (!isSubtype(branch.body.type, ast.type)) {
446
- throw new Error(`If branch body of type ${printType(branch.body.type)} is not compatible with expected type ${printType(ast.type)} at ${printLocation(ast.location)}`);
479
+ throw new Error(`If branch body of type ${printType(branch.body.type)} is not compatible with expected type ${printType(ast.type)} at loc_id ${ast.loc_id}`);
447
480
  }
448
- branch_body = variant("As", {
449
- type: toEastTypeValue(ast.type),
450
- value: branch_body,
451
- location: toLocationValue(ast.location),
452
- });
481
+ branch_body = coerce_to(branch_body, branch.body.type, ast.type, ast.loc_id);
453
482
  }
454
483
  return { predicate, body: branch_body };
455
484
  });
@@ -469,17 +498,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
469
498
  ctx.n_loops = ctx_else.n_loops;
470
499
  if (ast.else_body.type.type !== "Never" && !isTypeEqual(ast.else_body.type, ast.type)) {
471
500
  if (!isSubtype(ast.else_body.type, ast.type)) {
472
- throw new Error(`Else branch body of type ${printType(ast.else_body.type)} is not compatible with expected type ${printType(ast.type)} at ${printLocation(ast.location)}`);
501
+ throw new Error(`Else branch body of type ${printType(ast.else_body.type)} is not compatible with expected type ${printType(ast.type)} at loc_id ${ast.loc_id}`);
473
502
  }
474
- else_body = variant("As", {
475
- type: toEastTypeValue(ast.type),
476
- value: else_body,
477
- location: toLocationValue(ast.location),
478
- });
503
+ else_body = coerce_to(else_body, ast.else_body.type, ast.type, ast.loc_id);
479
504
  }
480
505
  return variant("IfElse", {
481
506
  type: toEastTypeValue(ast.type),
482
- location: toLocationValue(ast.location),
507
+ loc_id: ast.loc_id,
483
508
  ifs,
484
509
  else_body,
485
510
  });
@@ -487,7 +512,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
487
512
  else if (ast.ast_type === "Error") {
488
513
  return variant("Error", {
489
514
  type: variant("Never", null),
490
- location: toLocationValue(ast.location),
515
+ loc_id: ast.loc_id,
491
516
  message: ast_to_ir(ast.message, ctx),
492
517
  });
493
518
  }
@@ -510,7 +535,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
510
535
  const message = variant("Variable", {
511
536
  type: toEastTypeValue(ast.message.type),
512
537
  name: `_${ctx.n_vars}`,
513
- location: toLocationValue(ast.message.location),
538
+ loc_id: ast.message.loc_id,
514
539
  mutable: ast.message.mutable, // false...
515
540
  captured: false,
516
541
  });
@@ -518,7 +543,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
518
543
  const stack = variant("Variable", {
519
544
  type: toEastTypeValue(ast.stack.type),
520
545
  name: `_${ctx.n_vars}`,
521
- location: toLocationValue(ast.stack.location),
546
+ loc_id: ast.stack.loc_id,
522
547
  mutable: ast.stack.mutable, // false...
523
548
  captured: false,
524
549
  });
@@ -558,13 +583,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
558
583
  else {
559
584
  finally_body = variant("Value", {
560
585
  type: toEastTypeValue(NullType),
561
- location: toLocationValue(ast.location),
586
+ loc_id: ast.loc_id,
562
587
  value: variant("Null", null),
563
588
  });
564
589
  }
565
590
  return variant("TryCatch", {
566
591
  type: toEastTypeValue(ast.type),
567
- location: toLocationValue(ast.location),
592
+ loc_id: ast.loc_id,
568
593
  try_body,
569
594
  catch_body,
570
595
  message,
@@ -600,26 +625,24 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
600
625
  throw new Error(`Unsupported literal value type: ${typeof ast.value} (expected ${printType(ast.type)})`);
601
626
  }
602
627
  if (type.type !== value.type) {
603
- throw new Error(`Literal value type mismatch at ${printLocation(ast.location)}: expected .${type.type} but got .${value.type}`);
628
+ throw new Error(`Literal value type mismatch at loc_id ${ast.loc_id}: expected .${type.type} but got .${value.type}`);
604
629
  }
605
630
  return variant("Value", {
606
631
  type,
607
- location: toLocationValue(ast.location),
632
+ loc_id: ast.loc_id,
608
633
  value,
609
634
  });
610
635
  }
611
636
  else if (ast.ast_type === "As") {
612
- return variant("As", {
613
- type: toEastTypeValue(ast.type),
614
- location: toLocationValue(ast.location),
615
- value: ast_to_ir(ast.value, ctx),
616
- });
637
+ // Explicit $.as: use coerce_to so nested narrow variants in a literal
638
+ // struct/variant get deep-rewritten just like implicit widening.
639
+ return coerce_to(ast_to_ir(ast.value, ctx), ast.value.type, ast.type, ast.loc_id);
617
640
  }
618
641
  else if (ast.ast_type === "While") {
619
642
  const predicate = ast_to_ir(ast.predicate, ctx);
620
643
  const label = {
621
644
  name: `_${ctx.n_loops}`,
622
- location: toLocationValue(ast.label.location),
645
+ loc_id: ast.label.loc_id,
623
646
  };
624
647
  ctx.n_loops += 1;
625
648
  const ctx2 = {
@@ -638,7 +661,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
638
661
  ctx.n_loops = ctx2.n_loops;
639
662
  return variant("While", {
640
663
  type: variant("Null", null),
641
- location: toLocationValue(ast.location),
664
+ loc_id: ast.loc_id,
642
665
  label,
643
666
  predicate,
644
667
  body,
@@ -648,13 +671,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
648
671
  const array = ast_to_ir(ast.array, ctx);
649
672
  const label = {
650
673
  name: `_${ctx.n_loops}`,
651
- location: toLocationValue(ast.label.location),
674
+ loc_id: ast.label.loc_id,
652
675
  };
653
676
  ctx.n_loops += 1;
654
677
  const value = variant("Variable", {
655
678
  type: toEastTypeValue(ast.value.type),
656
679
  name: `_${ctx.n_vars}`,
657
- location: toLocationValue(ast.value.location),
680
+ loc_id: ast.value.loc_id,
658
681
  mutable: ast.value.mutable, // false...
659
682
  captured: false,
660
683
  });
@@ -662,7 +685,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
662
685
  const key = variant("Variable", {
663
686
  type: toEastTypeValue(ast.key.type),
664
687
  name: `_${ctx.n_vars}`,
665
- location: toLocationValue(ast.key.location),
688
+ loc_id: ast.key.loc_id,
666
689
  mutable: ast.key.mutable, // false...
667
690
  captured: false,
668
691
  });
@@ -683,7 +706,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
683
706
  ctx.n_loops = ctx2.n_loops;
684
707
  return variant("ForArray", {
685
708
  type: variant("Null", null),
686
- location: toLocationValue(ast.location),
709
+ loc_id: ast.loc_id,
687
710
  label,
688
711
  key,
689
712
  value,
@@ -695,13 +718,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
695
718
  const set = ast_to_ir(ast.set, ctx);
696
719
  const label = {
697
720
  name: `_${ctx.n_loops}`,
698
- location: toLocationValue(ast.label.location),
721
+ loc_id: ast.label.loc_id,
699
722
  };
700
723
  ctx.n_loops += 1;
701
724
  const key = variant("Variable", {
702
725
  type: toEastTypeValue(ast.key.type),
703
726
  name: `_${ctx.n_vars}`,
704
- location: toLocationValue(ast.key.location),
727
+ loc_id: ast.key.loc_id,
705
728
  mutable: ast.key.mutable, // false...
706
729
  captured: false,
707
730
  });
@@ -722,7 +745,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
722
745
  ctx.n_loops = ctx2.n_loops;
723
746
  return variant("ForSet", {
724
747
  type: variant("Null", null),
725
- location: toLocationValue(ast.location),
748
+ loc_id: ast.loc_id,
726
749
  label,
727
750
  key,
728
751
  set,
@@ -733,13 +756,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
733
756
  const dict = ast_to_ir(ast.dict, ctx);
734
757
  const label = {
735
758
  name: `_${ctx.n_loops}`,
736
- location: toLocationValue(ast.label.location),
759
+ loc_id: ast.label.loc_id,
737
760
  };
738
761
  ctx.n_loops += 1;
739
762
  const value = variant("Variable", {
740
763
  type: toEastTypeValue(ast.value.type),
741
764
  name: `_${ctx.n_vars}`,
742
- location: toLocationValue(ast.value.location),
765
+ loc_id: ast.value.loc_id,
743
766
  mutable: ast.value.mutable, // false...
744
767
  captured: false,
745
768
  });
@@ -747,7 +770,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
747
770
  const key = variant("Variable", {
748
771
  type: toEastTypeValue(ast.key.type),
749
772
  name: `_${ctx.n_vars}`,
750
- location: toLocationValue(ast.key.location),
773
+ loc_id: ast.key.loc_id,
751
774
  mutable: ast.key.mutable, // false...
752
775
  captured: false,
753
776
  });
@@ -768,7 +791,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
768
791
  ctx.n_loops = ctx2.n_loops;
769
792
  return variant("ForDict", {
770
793
  type: variant("Null", null),
771
- location: toLocationValue(ast.location),
794
+ loc_id: ast.loc_id,
772
795
  label,
773
796
  key,
774
797
  value,
@@ -783,7 +806,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
783
806
  const variable = variant("Variable", {
784
807
  type: toEastTypeValue(v.variable.type),
785
808
  name: `_${ctx.n_vars}`,
786
- location: toLocationValue(v.variable.location),
809
+ loc_id: v.variable.loc_id,
787
810
  mutable: v.variable.mutable, // false...
788
811
  captured: false,
789
812
  });
@@ -804,19 +827,15 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
804
827
  ctx.n_loops = ctx2.n_loops;
805
828
  if (v.body.type.type !== "Never" && !isTypeEqual(v.body.type, ast.type)) {
806
829
  if (!isSubtype(v.body.type, ast.type)) {
807
- throw new Error(`Match case '${k}' body of type ${printType(v.body.type)} is not compatible with expected type ${printType(ast.type)} at ${printLocation(ast.location)}`);
830
+ throw new Error(`Match case '${k}' body of type ${printType(v.body.type)} is not compatible with expected type ${printType(ast.type)} at loc_id ${ast.loc_id}`);
808
831
  }
809
- body = variant("As", {
810
- type: toEastTypeValue(ast.type),
811
- value: body,
812
- location: toLocationValue(ast.location),
813
- });
832
+ body = coerce_to(body, v.body.type, ast.type, ast.loc_id);
814
833
  }
815
834
  cases.push({ case: k, variable, body });
816
835
  }
817
836
  return variant("Match", {
818
837
  type: toEastTypeValue(ast.type),
819
- location: toLocationValue(ast.location),
838
+ loc_id: ast.loc_id,
820
839
  variant: variant_expr,
821
840
  cases,
822
841
  });
@@ -824,7 +843,7 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
824
843
  else if (ast.ast_type === "UnwrapRecursive") {
825
844
  return variant("UnwrapRecursive", {
826
845
  type: toEastTypeValue(ast.type),
827
- location: toLocationValue(ast.location),
846
+ loc_id: ast.loc_id,
828
847
  value: ast_to_ir(ast.value, ctx),
829
848
  });
830
849
  }
@@ -835,14 +854,14 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
835
854
  }
836
855
  const existing = ctx.recursiveASTs.has(ast);
837
856
  if (existing) {
838
- throw new Error(`Circular reference detected when converting AST to IR at ${printLocation(ast.location)}`);
857
+ throw new Error(`Circular reference detected when converting AST to IR at loc_id ${ast.loc_id}`);
839
858
  }
840
859
  // Register before recursing (enables cycle detection)
841
860
  ctx.recursiveASTs.add(ast);
842
861
  // Create WrapRecursive IR node with placeholder
843
862
  const wrapIR = variant("WrapRecursive", {
844
863
  type: toEastTypeValue(ast.type),
845
- location: toLocationValue(ast.location),
864
+ loc_id: ast.loc_id,
846
865
  value: ast_to_ir(ast.value, ctx),
847
866
  });
848
867
  // The user may alias this AST value elsewhere in the tree, just not with a circular reference
@@ -852,35 +871,71 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
852
871
  else if (ast.ast_type === "Break") {
853
872
  const label = ctx.loop_ctx.get(ast.label);
854
873
  if (label === undefined) {
855
- throw new Error(`Label defined at ${printLocation(ast.label.location)} is not in scope at break at ${printLocation(ast.location)}`);
874
+ throw new Error(`Label defined at loc_id ${ast.label.loc_id} is not in scope at break at loc_id ${ast.loc_id}`);
856
875
  }
857
876
  return variant("Break", {
858
877
  type: variant("Never", null),
859
- location: toLocationValue(ast.location),
878
+ loc_id: ast.loc_id,
860
879
  label,
861
880
  });
862
881
  }
863
882
  else if (ast.ast_type === "Continue") {
864
883
  const label = ctx.loop_ctx.get(ast.label);
865
884
  if (label === undefined) {
866
- throw new Error(`Label defined at ${printLocation(ast.label.location)} is not in scope at continue at ${printLocation(ast.location)}`);
885
+ throw new Error(`Label defined at loc_id ${ast.label.loc_id} is not in scope at continue at loc_id ${ast.loc_id}`);
867
886
  }
868
887
  return variant("Continue", {
869
888
  type: variant("Never", null),
870
- location: toLocationValue(ast.location),
889
+ loc_id: ast.loc_id,
871
890
  label,
872
891
  });
873
892
  }
874
893
  else if (ast.ast_type === "Return") {
875
894
  if (!isSubtype(ast.value.type, ctx.output)) {
876
- throw new Error(`Attempted to return value of type ${printType(ast.value.type)} at ${printLocation(ast.location)}, but function expected return type of ${printType(ctx.output)}`);
895
+ throw new Error(`Attempted to return value of type ${printType(ast.value.type)} at loc_id ${ast.loc_id}, but function expected return type of ${printType(ctx.output)}`);
877
896
  }
878
897
  return variant("Return", {
879
898
  type: variant("Never", null),
880
- location: toLocationValue(ast.location),
899
+ loc_id: ast.loc_id,
881
900
  value: ast_to_ir(ast.value, ctx),
882
901
  });
883
902
  }
903
+ else if (ast.ast_type === "NewVector") {
904
+ const elementType = ast.type.element;
905
+ return variant("NewVector", {
906
+ type: toEastTypeValue(ast.type),
907
+ loc_id: ast.loc_id,
908
+ values: ast.values.map((v, i) => {
909
+ let value = ast_to_ir(v, ctx);
910
+ if (!isTypeEqual(v.type, elementType)) {
911
+ if (!isSubtype(v.type, elementType)) {
912
+ throw new Error(`Vector value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(elementType)} at loc_id ${ast.loc_id}`);
913
+ }
914
+ value = coerce_to(value, v.type, elementType, ast.loc_id);
915
+ }
916
+ return value;
917
+ }),
918
+ });
919
+ }
920
+ else if (ast.ast_type === "NewMatrix") {
921
+ const elementType = ast.type.element;
922
+ return variant("NewMatrix", {
923
+ type: toEastTypeValue(ast.type),
924
+ loc_id: ast.loc_id,
925
+ rows: BigInt(ast.rows),
926
+ cols: BigInt(ast.cols),
927
+ values: ast.values.map((v, i) => {
928
+ let value = ast_to_ir(v, ctx);
929
+ if (!isTypeEqual(v.type, elementType)) {
930
+ if (!isSubtype(v.type, elementType)) {
931
+ throw new Error(`Matrix value at entry ${i} of type ${printType(v.type)} is not compatible with expected type ${printType(elementType)} at loc_id ${ast.loc_id}`);
932
+ }
933
+ value = coerce_to(value, v.type, elementType, ast.loc_id);
934
+ }
935
+ return value;
936
+ }),
937
+ });
938
+ }
884
939
  else {
885
940
  throw new Error(`Cannot check ${ast.type}`);
886
941
  }
@@ -888,13 +943,13 @@ export function ast_to_ir(ast, ctx = { local_ctx: new Map(), parent_ctx: new Map
888
943
  catch (e) {
889
944
  if (e instanceof Error) {
890
945
  if (ast.ast_type === "Builtin") {
891
- e.message += `\n at ${ast.ast_type} ${ast.builtin} node located at ${printLocation(ast.location)}`;
946
+ e.message += `\n at ${ast.ast_type} ${ast.builtin} node located at loc_id ${ast.loc_id}`;
892
947
  }
893
948
  else if (ast.ast_type === "Platform") {
894
- e.message += `\n at ${ast.ast_type} ${ast.name} node located at ${printLocation(ast.location)}`;
949
+ e.message += `\n at ${ast.ast_type} ${ast.name} node located at loc_id ${ast.loc_id}`;
895
950
  }
896
951
  else {
897
- e.message += `\n at ${ast.ast_type} node located at ${printLocation(ast.location)}`;
952
+ e.message += `\n at ${ast.ast_type} node located at loc_id ${ast.loc_id}`;
898
953
  }
899
954
  }
900
955
  throw e;