Repository navigation
fix: newline-sensitive <- fusion and send-target classification (closes #77) - #86
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
|
Landed on |
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 #77.
What was wrong
Two cooperating gaps turned ordinary snippets into programs that
hyb checkaccepted with 0 diagnostics andhyb build --emit-gothen emitted as invalid Go (noop() <- done—noop() (no value) used as value), breaking the accepted-subset contract that every accepted program emits buildable Go.<-into the previous expression statement. Hybrid has no Go-style automatic semicolon insertion, sonoop()on one line and<-doneon the next fused into a singleStmt::Send(noop() <- done). In Go, a statement starting with<-expris a receive; a<-on a new line never continues the previous statement.chan_elem_shapeonly classified the sent value; nothing required the channel expression to resolve to a channel shape. A deliberatenoop() <- 1(void call as target) passed with 0 diagnostics.What this PR does
<-fusion now requires the<-token to sit on the same source line as the end of the expression list (Parser::same_line_as_prev, using the existing line/col spans — no lexer change). A next-line<-starts a receive-expression statement of its own. Sends whose value wraps onto the next line still parse as one send.Checker::check_send_target(sendability.rs) classifies every send target before the value check-site:chan T→ proceed as before;send-target-not-channel, registry entry added, rule O4/A1c, fail-fast — the value check is skipped since the site is ill-typed);Like E3004/E3006, an ill-typed target is not a sendability doubt —
manageddoes not suppress it.Tests
hy-syntaxparser tests: newline before a receive does not fuse; same-linech <- 1still fuses; a wrapped send value stays one send.hy-check/tests/send_target.rs(6 tests): the newline-recv drain idiom is two statements and accepted; the void-call send is rejected (E3005/E3007); a map target is rejected E3007; select-arm and closure-body twins are rejected; a real channel send + drain stays accepted.Gates
cargo test --workspace: all green.OK (0 diagnostics).noop()and<-doneas two statements;hyb buildon the map-target repro refuses (exit 1).Merge note
Corpus numbering: this PR adds no corpus files (its repros live in unit/integration tests), so it does not touch
parse_all.rsor VERDICTS.md and has no merge seam with PR #74 (slot 28) or PR #83 (slots 29–30).