Commit 6b89ed4
committed
fix(interp): eval_decl handles FnExtern (#328 build-failure root cause)
The `TopFn fd` arm of `eval_decl` matched `fd.fd_body` against only
`FnBlock` and `FnExpr`, leaving `FnExtern` unmatched. Every prior interp
test imported externs via `use effects::{…}` so the case never fired;
the bug was latent.
The STDLIB-04a (#328) hermetic tests are the first to include an inline
`extern fn make_ref<T>(x: T) -> Ref<T> / Mut;` declaration in the source
they hand to `Interp.eval_program`. That triggers the missing arm and
raises "Pattern matching failed" at `lib/interp.ml:1010`, which is the
"2 failures!" reported by `dune runtest` on every PR since #334.
Fix: wrap the body lowering in an outer `match fd.fd_body with`. The
`FnExtern` arm returns `Ok env` (externs are runtime-bound via
`create_initial_env`'s `VBuiltin` table — `panic`/`error`/`make_ref`/
`get`/`set`/etc. — not via the AST). The inner `FnBlock|FnExpr` arm
keeps the existing closure construction; an `FnExtern` fall-through is
unreachable per the outer guard and asserted to make that explicit to
the reader.
This unbreaks main: the 2 failing tests
(`#328 make_ref/set/get round-trip (Int)` and `(String)`) now have a
defined evaluation path. The codegen-only test of the same trio
already passed (it bypasses interp).
Refs #328.1 parent d4522e4 commit 6b89ed4
1 file changed
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
1037 | | - | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1038 | 1049 | | |
1039 | 1050 | | |
1040 | 1051 | | |
| |||
0 commit comments