Commit 387afea
`string_length : String -> Int / Pure` is declared as a primitive in three
places that AffineScript programs traverse during the compile pipeline:
* stdlib/effects.affine — the surface declaration
* lib/resolve.ml — recognises the name during resolution
* lib/typecheck.ml — types it as String -> Int / EPure
…but the runtime `VBuiltin` entry in lib/interp.ml's
`create_initial_env` was missing. Programs calling `string_length`
compiled cleanly and failed at run with:
Unbound variable: string_length
This broke two E2E test suites on main:
- E2E STDLIB-04e Pure #332 / "string_length(\"hello\") == 5"
- E2E STDLIB-04b error #329 / divergence assertion
(`lookup` used `string_length(k) > 0` as a guard — the missing
binding produced the wrong eval_error variant, so the test
`RuntimeError "empty key"` assertion saw an Unbound variable
instead.)
Wire the builtin as `String.length` of an OCaml `VString`. Matches the
codegen-Deno path (`(s).length`) and the resolve/typecheck layers'
existing assumptions about the surface.
Found via affinescript#361's build-job CI red after the bench/dune +
fixture-exemption fixes cleared the other two baselines; this stdlib
bug was latent under those failures.
Refs #332 (STDLIB-04e pure externs), Refs #329 (STDLIB-04b throws extern).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b89eb1a commit 387afea
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
626 | 640 | | |
627 | 641 | | |
628 | 642 | | |
| |||
0 commit comments