Repository navigation
Conversation
Dimany4
force-pushed
the
fix-send-operand-kinds-2577
branch
from
November 1, 2026 03:18
781c429 to
9efd2ce
Compare
Dimany4
force-pushed
the
fix-send-operand-kinds-2577
branch
from
November 1, 2026 04:14
9efd2ce to
8f179ca
Compare
…ixes limitlessprojects#2577) A channel send never compared the sent value with the element type of the channel, so `var ch chan float64; var i int = 1; ch <- i` passed `hyb check` and failed `go build` (`cannot use i (variable of type int) as float64 value in send`). The report described the `select` arm; `Stmt::Send` had the same hole, and both sites now call the same check. The check reuses the rules the assignment family already applies: `kinds_conflict` plus the untyped-int-to-float carve-out, reported as HYB-E1002 with the `value in send` wording of the emitted Go. It stands down inside `managed`, the audited escape hatch, exactly like the boundary rules, which is why buildable.rs now raises the depth it already tracks. Tests: compiler/crates/hy-check/tests/send_operand_kinds_2577.rs (both sites; untyped literals, constant expressions and untyped named constants stay accepted, typed `const k int = 2` and typed variables are refused, `managed` parity pinned).
Dimany4
force-pushed
the
fix-send-operand-kinds-2577
branch
from
November 2, 2026 02:45
8f179ca to
f6d1d5e
Compare
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.
Fixes #2577.
A channel send never compared the sent value with the element type of the channel, so
var ch chan float64; var i int = 1; ch <- ipassedhyb checkand failedgo buildwithcannot use i (variable of type int) as float64 value in send. The report named theselectarm — the plain send had the same hole, and both sites are covered here.Fix
check_send_operand_kinds(chan, value, span)inbuildable.rs, called fromStmt::SendandSelectArmKind::Send. It reuseskinds_conflict()— the [soundness] P2: 16 accepted-but-unbuildable type/shape bypasses in the buildable operand pass (HYB-E1002) #682 "a value of kindgotdoes not satisfy a declared type of kindwant" predicate the assignment family already uses — so every operand-kind mismatch is covered (string→chan int, a map →chan int, …), not only theint/float64pair, and there is no second type table to keep in sync.kinds_conflictfails open on(Float, Int), because an untyped int constant is assignable to a float target (var f float64 = 1builds). The send narrows it with the checker's existingis_untyped_int_const(), the same predicate the assignment rules use — soch <- 1,ch <- 1 + 2andch <- kforconst k = 2(file-level or fn-local) stay accepted, while a typedconst k int = 2and a typedintvariable are rejected, exactly as Go does.managed(...)the check returns early, as the boundary rules do (--report-managedrecords the site, HYB-E8001).Collectorholdsckas a shared reference, so the walk cannot raise the checker's own counter; the nesting depth is tracked in the walk instead, withStmt::Managedbumping it aroundblock_scoped(). Without that parity the new check broke the lib suite'sfc_closure_boundary_send_inside_managed_escapes.Int → Chan(Float)only. This change is built on the shared predicate, covers both send sites, and keeps the hatch parity; the two should not be counted as two root causes.Evidence
ch <- i(typedint→chan float64)select { ch <- i: default: }ch <- s(string→chan int)ch <- kforconst k int = 2(typed)ch <- 1(untyped literal)ch <- 1 + 2(constant expression)ch <- kforconst k = 2(untyped, fn-local and file-level)ch <- fforvar f float64ch <- iforvar i int→chan intmanaged(...)compiler/crates/hy-check/tests/send_operand_kinds_2577.rs— 9 tests, all green: four rejects (plain send, select arm,string→chan int, typed constant at both sites), four accept-control groups (untyped literal, constant expression, untyped named constant, matching/float operands), one pinning themanaged(...)stand-down.cargo test -p hy-check --test send_operand_kinds_2577→ 9/9 green on this head; CI runs the full package suite on it.tools/corpus_harness.py): the earlier head of this branch measured 128/130 with the same two pre-existing failures asmain(10-a5-http-handler-capture.hy,local-composite-chan-recv-reject-e2008.hy),tripwire: not fired; the send sites are the only behaviour this diff touches.buildable.rs(+69/−1: the check, the local depth field, the two call sites) plus the new test file. No other crate is touched.