Repository navigation
fix(codegen): Err stores its payload at .value, like every other variant - #791
Merged
Merged
Conversation
The Bun/JS, plain-JS and Lua runtime preludes built Err as { tag, error },
but every match lowering reads a single-payload constructor at `.value`
(gen_pattern_test / gen_pattern_bindings in all three backends). So an
`Err(m)` arm bound `m` to undefined (nil in Lua): any program that reported
an error message through Result printed "undefined". Found while writing
kyX (metadatastician/kyx), whose fail-closed errors travel as Err strings.
Fixed at the source: the three preludes now build Err with `value`, the
same field Ok and Some use. Nothing in the repo reads `.error`.
Test: tests/codegen-bun/result_payload.{affine,harness.mjs} binds the Err
payload directly and inside a nested Some(Err(m)) pattern. It fails before
this change and passes after. tools/run_codegen_bun_tests.sh now compiles
each harness's own subject, not only host_profile, so new Bun harnesses
are actually exercised. The Lua backend is changed for consistency but not
run here (no Lua interpreter in this environment).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136P7ZnvMV5Ghe7LUf3oc6N
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
In the Bun/JS, plain-JS and Lua backends, an
Err(m)match arm boundmtoundefined(nilin Lua). The runtime preludes builtErras{ tag, error }, but every match lowering reads a single-payload constructor at.value, asOkandSomeuse. Any program that carried an error message throughResultprintedundefined.Found while writing kyX (metadatastician/kyx), the estate's A2ML→deed projection compiler, which reports fail-closed errors as
Errstrings.Changes
lib/codegen_deno.ml,lib/js_codegen.ml,lib/lua_codegen.ml:Errstoresvalue. Nothing in the repo reads.error.tests/codegen-bun/result_payload.{affine,harness.mjs}: new regression test. It binds the Err payload directly and insideSome(Err(m)).tools/run_codegen_bun_tests.sh: compiles each harness's own subject, not justhost_profile, so new Bun harnesses actually run.Testing
tools/run_codegen_bun_tests.sh: the new harness fails before the fix (got undefined) and passes after (2 harnesses green).dune runtest: all 570 alcotest cases pass. Theres-to-affinewalker suites fail identically on unmodifiedmainin this environment, so they are unrelated.Generated by Claude Code