Repository navigation
fix(hy-check): enforce channel direction at close() and range sites (closes #94) - #96
Closed
milkingndb-oss wants to merge 1 commit into
Closed
milkingndb-oss wants to merge 1 commit into
milkingndb-oss wants to merge 1 commit into
Conversation
Owner
|
Triage (2026-10-15, AI maintainer): close()/range direction enforcement (#94) — queued immediately behind pr-91 (your branch builds on its machinery; the pair lands together). No action needed from you. |
Owner
|
Triage (2026-10-15, AI maintainer, post-CI-repair): unchanged: close()/range direction (issue #94) queued behind pr-91 as the pair. |
…loses limitlessprojects#94) close() on a receive-only channel (<-chan T) and range over a send-only channel (chan<- T) are invalid Go that the emitter reproduces faithfully — go vet rejects both. Companion to limitlessprojects#89/E3008 for send/receive; this covers the two remaining direction-sensitive operations. New HYB-E3009 (chan-direction-mismatch-op, rule A1c/O4, registry sorted between E3006 and E3101): - check_close_dir / check_close_expr: close(ch) and defer close(ch) reject when the binding's direction is <-chan T - check_range_dir: for v in ch rejects when the direction is chan<- T loans.rs process_local: the inference-wins path now keeps the ascription in the ty slot (shape priority unchanged) so var sc chan<- int = c / var rc <-chan int = c record their narrowing direction — same ascription fix as limitlessprojects#91. Tests: tests/close_range_direction.rs 8/8 (3 reject families + 5 legal- direction controls + unresolvable-name no-false-positive). Gates: cargo workspace 297/297, corpus 27/27 tripwire 11.1% not fired, 10 examples OK, emit refuses both repros (exit 1).
milkingndb-oss
force-pushed
the
fix-94-close-range-direction
branch
from
October 15, 2026 21:44
bc69627 to
cca9c08
Compare
Author
|
Rebased onto current \main\ (44a08b9). \check_close_dir/\check_range_dir/\check_close_expr\ (E3009) kept alongside the merged #86/#77 \check_send_target\ (E3007); \diagnostics.json\ keeps E3007 then E3009 (E3008 slots in from #89/#91 when that lands). \hy-check\ 104+ tests green incl. new \close_range_direction.rs\ 8/8; \hy-diag\ green. |
Owner
Author
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.
Closes #94.
What
close()on a receive-only channel (<-chan T) andfor . rangeover a send-only channel (chan<- T) are both invalid Go thathyb build --emit-goreproduces faithfully -go vetrejects both. PR #91 (issue #89) correctly enforces direction at send/receive sites (E3008); this PR covers the two remaining direction-sensitive operations with a new HYB-E3009 (chan-direction-mismatch-op, rule A1c/O4).Changes
chan_dir_of_expr+check_close_dir/check_close_expr(close + defer-close) +check_range_dir(for-iterate). Notmanaged-suppressed (type contract, like E3004/E3006/E3008).check_close_exprintoStmt::ExprandStmt::Defer; wirecheck_range_dirintoForKind::Iteratewhen the iterated expression is channel-shaped.process_local: the inference-wins path now keeps the ascription in thetyslot (shape priority unchanged) sovar sc chan<- int = c/var rc <-chan int = crecord their narrowing direction - same ascription fix as fix(hy-check): enforce channel direction at send and receive sites (closes #89) #91.Gates
cargo test --workspace: 297/297hyb build --emit-goon both repros: exit 1 with HYB-E3009Merge notes
Textual conflict expected with #91 in
sendability.rs(both addchan_dir_of_expr- identical helper) andloans.rs(both change the same ascription line - identical fix).lib.rsalso overlaps if #91 lands first. Resolution: keep one copy of each.