Repository navigation
hy-check: preserve the option[T] wrapper through index, deref, receive, select, range, and aliases (fixes #753) - #1788
Open
swappysh wants to merge 1 commit into
Conversation
…e, select, range, and aliases (fixes limitlessprojects#753) `Checker::shape_of_type` folded `option[T]` to `shape_of_type(T)` and the expression helpers never resynthesized the wrapper for an operand that was not a bare ident, so an `option[chan int]` or `option[atomic.int64]` reached the send/recv/range and address-of checks as its bare payload: - `xs[0] <- 1`, `<-xs[0]`, `for v in xs[0]`, `m["k"]`, `*p`, `h.opt`, a channel receive, a select receive arm, and a type alias were all treated as the payload type, so `HYB-E3007` (send/recv) and `HYB-E2008` (range) were skipped. - The payload being sendable made `&xs[0]`, `&h.opt`, `p`, and a struct with an `option[...]` field read as sendable, skipping `HYB-E3001` / `E3103` / `E3104` across a task boundary. `expr_is_option`, `ty_of_expr`, and `multi_value_tys` now recognize `Index`, `Deref`, `Field`, `Receive`, `SelectRecv`, `ForKind::Iterate`, and aliases, and reassigning `none` keeps the declared wrapper. `shape_of_type` keeps the outer wrapper for pointer and container element positions instead of collapsing it. Tests: 10 regressions in `compiler/crates/hy-check/tests/recv_operand_soundness.rs` (5 fail on the previous `main`). Gates: cargo test --workspace green; corpus 127/127 (tripwire not fired); differential FULL AGREEMENT (41/41 accept, 86/86 reject). Refs limitlessprojects#755 (same fix, closed by the queue sweeper).
Author
|
Payout address EVM (ETH / Base / Arbitrum / Polygon / BSC): USDT-TRC20 (Tron) alternative, same seed, if that rail is preferred: |
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shape_of_typefoldedoption[T]to its payload, and the expression helpers never re-synthesized the wrapper for an operand that was not a bare identifier. Anoption[chan int]oroption[atomic.int64]reached the send/recv/range and address-of checks as the bare payload, so accepted programs raced with 0 diagnostics.Fixes #753.
Root cause
hy-check/src/shape.rs:shape_of_typerecursively foldedoption[T]toshape_of_type(T)for pointer, slice, array, map, and chan element positions.expr_is_optiondid not handleExpr::Index,Expr::Deref,Expr::Field,Expr::Receive,Expr::Paren,Expr::Move, and did not resolvetypealiases.ty_of_exprandmulti_value_tysdid not synthesize aTypeExprforExpr::Index,Expr::Deref,Expr::Receive, orExpr::Field;SelectRecvandForKind::IteratepassedNoneas the binding type;opt = noneoverwrote a specific wrapper withoption[any].Fix
Preserve the outer
option[...]wrapper inshape_of_type, teachexpr_is_option/ty_of_expr/multi_value_tysthe indexed, dereferenced, field, receive, select and range forms plus aliases, keep the declared wrapper onnonereassignment, and thread the wrapper throughsendability.rs,recv.rs,range_iter.rs,emit_guard.rs,loans.rs, andclosures.rs.Tests
compiler/crates/hy-check/tests/recv_operand_soundness.rs, 10 regressions, 5 of which fail on the previousmain.Gates
cargo test --workspacefromcompiler, green.Refs #755 (the same fix, closed by the queue sweeper).