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
{{ message }}
Repository navigation
[soundness] Channel direction never enforced for close() and
ange: <-chan T close and chan<- T range accepted (0 diagnostics) and emit Go that does not compile #94
PR #91 (issue #89) correctly enforces channel DIRECTION at send and receive sites (HYB-E3008). However, two other direction-sensitive operations - close() and for . range - are never checked: the checker accepts programs that emit Go go vet rejects, breaking the accepted-should-emit-buildable-Go contract in exactly the way #89 documented for send/recv.
Repro 1 - close() on a receive-only channel
fn main() {
c := make(chan int, 1)
var rc <-chan int = c
close(rc)
}
hyb check (main 8fb9238 AND fix-89-chan-direction 92f53fb): OK (0 diagnostics).
hyb build --emit-go emits:
package main
funcmain() {
c:=make(chanint, 1)
varrc<-chanint=cclose(rc)
}
go vet on the emitted file:
invalid operation: cannot close receive-only channel rc (variable of type <-chan int)
Go spec: "The channel must be bidirectional or send-only." A <-chan T binding has no send capability, so close is illegal.
Note: defer close(rc) is the same bug (parser wraps it as Expr::Call to close) - also accepted, also invalid.
Repro 2 - range over a send-only channel
fn main() {
c := make(chan int, 1)
var sc chan<- int = c
for v in sc {
fmt.println(v)
}
}
close-site: after resolving the callee to builtin close, if the argument's declared direction is ChanDir::Recv ? reject (cannot close a receive-only channel). Wire into the statement/expression-statement call path (Stmt::Expr with Expr::Call{Ident("close")}) and Defer (which is also a Call expression).
range-site: in the Stmt::For { ForKind::Iterate } handler, if the iterated expression's declared direction is ChanDir::Send ? reject (cannot range over a send-only channel).
Both are type contracts (like E3008) - managed should NOT suppress them. A new code (e.g. HYB-E3009 or extend E3008 with an op parameter) keeps the registry sorted.
Activity
fix(hy-check): enforce channel direction at close() and range sites (c…
gelismarvel commentedon Oct 17, 2026
/claim #94
Fixes #94
Submitting verified fix PR for #94.
fix(hy-check): also enforce HYB-E3008 channel direction at send and r…
fix: resolve Channel direction never enforced for close() and range: …
fix(hy-check): also enforce HYB-E3008 channel direction at send and r…
Merge pr-443 (exantiv, fixes limitlessprojects#89, fixes limitlesspro…