Skip to content

Commit 39d5e01

Browse files
hyperpolymathclaude
andcommitted
docs(affinescript-deno-test): record two codegen bugs discovered in pilot
Writing the first AffineScript-native test suite for double-track-browser (commit b1f3b80) surfaced two AffineScript codegen bugs worth pinning in the README so future contributors to the harness don't re-discover them cold: 1. Match-on-enum with distinct zero-arity constructors per arm emits invalid WASM (stack imbalance, rejected by WebAssembly.compile). 2. Reading a non-first struct field from a function parameter returns 0 regardless of the actual value. First-field reads work fine. Both are OCaml codegen issues upstream in lib/codegen.ml; estate-wide tracking lives in ~/Desktop/AI-WORK-todo.md §11. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 641a3c8 commit 39d5e01

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • affinescript-ecosystem/affinescript-deno-test

affinescript-ecosystem/affinescript-deno-test/README.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ return is unmarshalled by hand (AffineScript compiles `Bool` → i32, 0/1).
157157
Record<string, Record<string, ImportValue>>` option, then unify both paths
158158
behind `AffineModule`.
159159

160+
=== Known AffineScript codegen bugs blocking richer test idioms
161+
162+
Discovered 2026-04-19 while writing the double-track-browser lifecycle
163+
test pilot. Both are compiler bugs, not harness bugs — fixing them is
164+
upstream OCaml work on `developer-ecosystem/nextgen-languages/affinescript/
165+
lib/codegen.ml`.
166+
167+
* **Enum-in-match codegen**: a `match` on an enum that returns distinct
168+
zero-arity constructors across arms produces invalid WASM (stack
169+
imbalance). The ideal form `match s { Uninitialised => Initialised(),
170+
... }` must currently be downgraded to a tagged struct.
171+
* **Parameter struct-field reads**: `s.field_1_or_later` where `s` is a
172+
function parameter of struct type returns 0 regardless of the actual
173+
value. First-field reads (`s.tag`) work. Workaround: pass scalars
174+
instead of structs when possible, or read fields from let-bound locals
175+
before calling into helpers.
176+
177+
Scaling the harness to richer application-state test suites is gated
178+
on both. Estate-wide tracking in
179+
`~/Desktop/AI-WORK-todo.md` §11.
180+
160181
== Why AffineScript rather than ReScript?
161182

162183
ReScript is the estate's default TypeScript replacement and has a mature

0 commit comments

Comments
 (0)