Commit 7186e06
The codegen-test fixtures tests/codegen/{env_at,arg_at,env_count_and_at}.affine
all reference env_at / arg_at, but those surface names were never wired in
resolve.ml or typecheck.ml — `dune runtest` hits Resolve.UndefinedVariable
before codegen even fires. Latent baseline-rot since commit 58f08b9
(ADR-015 S5) added the wasm IR + helper without completing the surface.
Same shape of fix as #362 (string_length), but a full layer-by-layer wiring
because env_at/arg_at need TWO WASI imports each.
## Changes
* lib/resolve.ml: add `def "env_at"; def "arg_at"`.
* lib/typecheck.ml: bind both as `Int -> String / Time`, matching the
effect row of their count siblings (env_count / arg_count).
* lib/codegen.ml: new ExprApp dispatch right after the env_count/arg_count
handler — allocates 8 locals (n, scratch, count, bufsize, ptrvec, src,
dst, result), looks up the matching sizes_get + get WASI func indices,
and calls Wasi_runtime.gen_str_at_via_get (already present, was just
unreferenced).
* lib/codegen.ml: extend the optional_wasi table with four new rows —
("env_at", "environ_sizes_get"), ("env_at", "environ_get"),
("arg_at", "args_sizes_get"), ("arg_at", "args_get"). Each row's
factory is the existing create_*_import in wasi_runtime.ml.
* lib/codegen.ml: add a dedup pass over optional_wasi keyed by WASI
import name (keep first occurrence). Necessary because env_count +
env_at both want environ_sizes_get; without dedup the wasm would
carry two imports under the same name and instantiation would fail.
The env_count_and_at.affine fixture is the regression test for this
case — its docstring already documented the requirement.
## What this does NOT cover
* Interp.eval_program does not gain env_at / arg_at. Same posture as
env_count / arg_count (also absent from interp). These are WASI-only
surfaces; interp would need a synthetic environ table to simulate
them. Out of scope.
Closes-Refs ADR-015 S5 surface completion; Refs #180 (parent epic),
Refs #339 (the IR-only commit), Refs #361 (originating queue-clearance
incident — this is the 4th baseline-rot iteration after #361 / #362 /
the .hypatia-ignore-format fix).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f1d47e6 commit 7186e06
3 files changed
Lines changed: 75 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
892 | | - | |
| 891 | + | |
893 | 892 | | |
894 | 893 | | |
895 | 894 | | |
| |||
909 | 908 | | |
910 | 909 | | |
911 | 910 | | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
912 | 954 | | |
913 | 955 | | |
914 | 956 | | |
| |||
2564 | 2606 | | |
2565 | 2607 | | |
2566 | 2608 | | |
2567 | | - | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
2568 | 2616 | | |
2569 | 2617 | | |
2570 | 2618 | | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
2571 | 2623 | | |
2572 | 2624 | | |
2573 | 2625 | | |
2574 | 2626 | | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
2575 | 2637 | | |
2576 | 2638 | | |
2577 | 2639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1329 | 1329 | | |
1330 | 1330 | | |
1331 | 1331 | | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
1332 | 1338 | | |
1333 | 1339 | | |
1334 | 1340 | | |
| |||
0 commit comments