You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lang): ? early-return on Option (tinygrad port item)
`?` now short-circuits on `Option` (keeps `Some(x)`, early-returns `None`) inside
an `Option`-returning function, mirroring `?` on `Result` (keeps `Ok`, returns
`Err`). Closes the "early return on none" gap from the tinygrad port feedback.
- checker: allow `?` in `Option`-returning functions, and accept an `Option`
operand (RS0013 now names both `Result` and `Option`); the Result error-type
check is unaffected (it only fires for `Result`-returning functions).
- reg VM: `TryResult` keeps `Some(x)` and short-circuits `None` (mirrors the
`Err` path) in addition to the existing `Ok`/`Err`.
- compiled backend: Rust's `?` already handles `Option`, so no lowering change.
Works on owned operands (the common pattern — a call result), at exact parity
with `Result`. `?` on a *borrowed* `read` param is a pre-existing limitation for
both `Result` and `Option` (the borrowed `&T` isn't `Try`); out of scope here.
Tests: pass fixture + VM/compiled parity (`parity_try_on_option_short_circuits_on_none`).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments