Skip to content

fix: refuse a result nested inside another type - #250

Merged
arcjet-rei merged 1 commit into
mainfrom
rei/fix/ENG-1490-nested-result
Oct 7, 2026
Merged

arcjet-rei merged 1 commit into
mainfrom
rei/fix/ENG-1490-nested-result

Conversation

@arcjet-rei

Copy link
Copy Markdown
Contributor

gravity represents a result with Go's multiple return values (T, error, or error alone), which only a function's results can carry. A result in a record field, a variant case payload, a list element, an option payload or another result's ok type was written out anyway: gravity exited 0, and the Go failed to compile (R uint32, error as a struct field). gravity now refuses these at generation time with a message naming the position, as it already does for the result shapes it cannot generate.

A result in a function's own result is unaffected. Supporting nested results needs a decision on their Go type, which this change does not make.

🤖 Generated with Claude Code

gravity represents a result with Go's multiple return values (`T, error`,
or `error` alone), which only a function's results can carry. A result in
a record field, a variant case payload, a list element, an option
payload or another result's ok type was written out anyway, and gravity
exited 0 with Go that failed to compile (`R uint32, error` as a struct
field). resolve_nested_type now refuses it with a message naming the
position, as gravity already does for the result shapes it cannot
generate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arcjet-rei
arcjet-rei requested a review from a team as a code owner October 7, 2026 19:44

@arcjet-review arcjet-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arcjet Review — 🟢 Low Risk

Decision: Checked

Rationale: The PR makes a small, well-scoped code generation validation change to reject nested WIT result types before emitting invalid Go. The behavior is covered by targeted unit tests for record fields, variant payloads, list elements, option payloads, nested result ok types, and the still-supported top-level function result case. No escalation triggers fired, and the security review found no auth, injection, secrets, cryptography, or OWASP concerns.

Summary of Changes

Adds resolve_nested_type to refuse result types embedded inside other types, updates import analysis and compound type resolution to use it, and adds regression tests for rejected nested result positions while preserving top-level function result support.

Notes

The AI assessed this PR as approvable, but the trust level (1) does not allow auto-approval. A human reviewer must approve this PR.

Review: 0669fdd2 | Model: openai/gpt-5.5 | Powered by Arcjet Review

@arcjet-review arcjet-review Bot removed the needs review Awaiting human review label Oct 7, 2026
@arcjet-rei
arcjet-rei merged commit ee8d0e5 into main Oct 7, 2026
4 checks passed
@arcjet-rei
arcjet-rei deleted the rei/fix/ENG-1490-nested-result branch October 7, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants