Commit b58178a
feat(effects+codegen): implement interpreter effect dispatch + BUG-005 WasmGC silent-fallback fix
BUG-005 (codegen_gc.ml):
- Add `UnboundFunction of string` error variant; replace the silent drop+null
fallback in `ExprApp (ExprVar id, args)` when the function is absent from
`func_indices` — was producing valid but semantically wrong WASM with no
diagnostic.
- Replace the silent drop+null fallback in `ExprApp (callee, args)` (indirect /
higher-order calls) with `UnsupportedFeature`; call_ref is not yet wired.
- Add `UnboundFunction` case to `format_codegen_error`.
Effects runtime (interp.ml):
- `eval_decl TopEffect`: register each effect op as a `PerformEffect`-raising
`VBuiltin` so that calling an op actually propagates the effect. Previously
the entire `TopEffect` branch was a no-op, making all effect ops unbound.
- Fix multi-arg bug in `ExprHandle` dispatch: `arg_vals` was wrapping multiple
args into a `VTuple` before binding against handler patterns, making any
effect op with ≥ 2 params silently fail the `fold_left2` length check.
- Bind the resume continuation under `"__resume__"` in the handler env so that
the `resume expr` keyword form (`ExprResume`) can find it regardless of what
name the programmer chose for the continuation parameter.
- `ExprResume`: look up `"__resume__"` in env and call it; fall back to
returning the arg value when used outside a handler (safe no-op semantics).
Effects runtime (codegen_gc.ml — WasmGC):
- `TopEffect`: register each op as an `unreachable` stub function with correct
func_indices entry so subsequent function indices are not shifted and direct
calls trap rather than producing a link error.
- `ExprHandle`: replace silent body-only compilation (which dropped all handler
arms) with an explicit `UnsupportedFeature` error; full dispatch requires the
WASM EH proposal or a CPS transform, neither of which is present yet.
- `ExprResume`: same — reject explicitly rather than emitting the bare arg value.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 7987f79 commit b58178a
2 files changed
Lines changed: 139 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
355 | 359 | | |
356 | 360 | | |
357 | 361 | | |
358 | | - | |
359 | | - | |
360 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
361 | 367 | | |
362 | 368 | | |
363 | 369 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
| |||
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
742 | | - | |
743 | | - | |
744 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
745 | 759 | | |
746 | 760 | | |
747 | 761 | | |
748 | 762 | | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
754 | 772 | | |
755 | 773 | | |
756 | 774 | | |
| |||
1104 | 1122 | | |
1105 | 1123 | | |
1106 | 1124 | | |
1107 | | - | |
| 1125 | + | |
1108 | 1126 | | |
1109 | 1127 | | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1110 | 1165 | | |
1111 | 1166 | | |
1112 | 1167 | | |
| |||
1144 | 1199 | | |
1145 | 1200 | | |
1146 | 1201 | | |
| 1202 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
262 | 260 | | |
263 | 261 | | |
264 | | - | |
| 262 | + | |
| 263 | + | |
265 | 264 | | |
266 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
267 | 280 | | |
268 | 281 | | |
269 | 282 | | |
| |||
272 | 285 | | |
273 | 286 | | |
274 | 287 | | |
275 | | - | |
| 288 | + | |
276 | 289 | | |
277 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
278 | 297 | | |
279 | 298 | | |
280 | 299 | | |
281 | 300 | | |
282 | 301 | | |
283 | 302 | | |
284 | 303 | | |
285 | | - | |
286 | | - | |
287 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
288 | 311 | | |
289 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
290 | 317 | | |
291 | 318 | | |
292 | 319 | | |
| |||
865 | 892 | | |
866 | 893 | | |
867 | 894 | | |
868 | | - | |
869 | | - | |
| 895 | + | |
| 896 | + | |
870 | 897 | | |
871 | 898 | | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
872 | 913 | | |
873 | 914 | | |
874 | 915 | | |
| |||
0 commit comments