fix: wire ensure-or fallback and raise Go coverage#118
Conversation
Ensure `or bad(...)` / nominal error payloads are emitted on ensure failure
instead of a generic errors.New message. Preserve deferred providers wiring
flags across typechecker re-init and skip assignability checks for unknown
wiring keys while defer is enabled. Coerce string aliases when Assertion.BaseType
is a direct builtin. Add broad unit-test coverage (inline snippets and hooks
for goload, safefs, forstpkg, cmd/forst test) so merged Go coverage reaches
79.8%.
fix(transformer): wire ensure-or fallback in Go codegen
transformErrorStatement now lowers custom ensure failure expressions via
transformEnsureErrorFallback / ensureFailureErrorExpr. Nominal errors like
or NotOk({ msg: "bad" }) emit composite literals, not NotOk(NotOk{...}).
Example:
```forst
func f(row Int): Result(String, Error) {
ensure row is GreaterThan(-1) or bad("too small")
return "ok"
}
```
fix(typechecker): preserve deferred wiring state across providers re-init
initProvidersInference no longer drops DeferWiringRootCheck or ForstPackage
when CheckTypes re-initializes the providers engine. Unknown wiring keys
during deferred merge skip type assignability until post-merge revalidation.
Example:
```forst
with { BadKey: &NopLogger {} } {
use logger: Logger
}
```
test: expand unit coverage across cmd and internal packages
Add pipeline and direct unit tests for transformer/go (providers, shapes,
ensure builtins, cross-package wiring), typechecker inference/providers,
generators, goload, safefs, forstpkg, modulecheck, providersgraph, and
cmd/forst CLI paths. Introduce test hooks where OS/filesystem branches are
hard to reach from unit tests alone.
|
Warning Review limit reached
More reviews will be available in 50 minutes and 4 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (78)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Reject lowercase identifiers after ensure-or at parse time so error handlers follow the same exported-name convention as constraints and nominal errors. Update parser and transformer tests accordingly. Also update the generate-commit-message skill to forbid code examples in commit message output. BREAKING CHANGE: lowercase ensure-or handlers are now parse errors; rename handlers to start with an uppercase letter.
Replace unchecked defer os.Chdir and Close calls with t.Cleanup and explicit error discard, rename unused test parameters to _, switch WriteString(fmt.Sprintf(...)) to fmt.Fprintf, remove dead go:fix inline helpers, and inline a ptrTypeIdent call so errcheck, revive, staticcheck, govet, and unused linters pass. fix(parser): allow lowercase ensure or error handlers Drop the rule requiring ensure or handlers to start with an uppercase letter. Lowercase variable passthrough (or err) and function calls (or invalidMove(...)) are valid and used in examples; the restriction broke ensure.ft, tictactoe, and downstream module typechecking.
Ensure
or bad(...)/ nominal error payloads are emitted on ensure failure instead of a generic errors.New message. Preserve deferred providers wiring flags across typechecker re-init and skip assignability checks for unknown wiring keys while defer is enabled. Coerce string aliases when Assertion.BaseType is a direct builtin. Add broad unit-test coverage (inline snippets and hooks for goload, safefs, forstpkg, cmd/forst test) so merged Go coverage reaches 79.8%.fix(transformer): wire ensure-or fallback in Go codegen
transformErrorStatement now lowers custom ensure failure expressions via transformEnsureErrorFallback / ensureFailureErrorExpr. Nominal errors like or NotOk({ msg: "bad" }) emit composite literals, not NotOk(NotOk{...}).
Example:
fix(typechecker): preserve deferred wiring state across providers re-init
initProvidersInference no longer drops DeferWiringRootCheck or ForstPackage when CheckTypes re-initializes the providers engine. Unknown wiring keys during deferred merge skip type assignability until post-merge revalidation.
Example:
test: expand unit coverage across cmd and internal packages
Add pipeline and direct unit tests for transformer/go (providers, shapes, ensure builtins, cross-package wiring), typechecker inference/providers, generators, goload, safefs, forstpkg, modulecheck, providersgraph, and cmd/forst CLI paths. Introduce test hooks where OS/filesystem branches are hard to reach from unit tests alone.