Skip to content

test: pin every enum case in every position, both directions - #237

Open
robfischer1 wants to merge 1 commit into
arcjet:mainfrom
robfischer1:enum-discriminant-coverage
Open

robfischer1 wants to merge 1 commit into
arcjet:mainfrom
robfischer1:enum-discriminant-coverage

Conversation

@robfischer1

Copy link
Copy Markdown

#228 fixed the I32Store8 panic for a discriminant of 2 or more:

invalid int8 value encountered

The memory example covers it as a record field. This PR adds a five-case enum through every position, in both directions:

  • On the export side: a flat parameter and result, a list, a record field and an option.
  • On the host side: a parameter, a result, a list<record> result and an option.

Measured against 2dc1000: TestEveryCaseInEveryPosition/2 fails with the panic.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K99bnsYaj3w4MMWSF5hTMu

Stock gravity 0.0.3 (2dc1000, the commit the spike patched) stored an
enum into guest memory through I32Store8's 0/1 switch, written for bool,
and panicked on any discriminant of 2 or more:

    panic: invalid int8 value encountered (recovered by wazero)

Upstream fixed the store in arcjet#228 (8119322, 2026-10-03), which this fork
imports, so this commit adds no code: it pins the fix across every
position an enum takes, which arcjet#228's memory example covers only as a
record field. A five-case enum crosses a flat parameter and result, a
list, a record field and an option on the export side, and an import's
parameter, result, list<record> result and option on the host side.

Tests: the enum-discriminants example's TestEveryCaseInEveryPosition and
TestEveryCaseInLists. Measured against bindings from stock 2dc1000: the
generation and go vet pass and TestEveryCaseInEveryPosition/2 fails with
the panic above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arcjet-review arcjet-review Bot added the needs review Awaiting human review label Oct 7, 2026
@robfischer1
robfischer1 requested a review from a team as a code owner October 7, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review Awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant