Repository navigation
fix: refuse a result nested inside another type - #250
Conversation
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>
There was a problem hiding this comment.
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
gravity represents a
resultwith Go's multiple return values (T, error, orerroralone), which only a function's results can carry. Aresultin 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, erroras 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
resultin 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