Repository navigation
fix: newline statement boundary for send and validate send channel target (fixes #77) - #78
Closed
rickymulya wants to merge 1 commit into
Closed
rickymulya wants to merge 1 commit into
rickymulya wants to merge 1 commit into
Conversation
…rget (fixes limitlessprojects#77) - hy-syntax: ensure `<-` is on the same line as the channel expression in `parse_simple_stmt` so that a preceding expression statement (e.g. `noop()`) and a subsequent receive expression (e.g. `<-done`) on the next line do not fuse into a bogus send statement `noop() <- done` across lines (LX9). - hy-check: validate that the channel target expression of a send statement resolves to `TypeShape::Chan(_)`; if it is non-channel or unresolvable, emit `HYB-E3005` fail-closed (or `HYB-E8001` inside `managed`) (§8.4 / O4.9). - tests: add parser test `send_does_not_fuse_across_newline` and checker tests `send_to_void_call_callee_is_fail_closed_e3005`, `send_to_non_channel_local_is_fail_closed_e3005`, and `repro_issue_77_two_line_receive_compiles_cleanly`.
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.
Summary
Fixes #77.
Resolves two cooperating gaps that allowed multi-line expressions and receive statements to merge into invalid sends, and allowed send statements targeting non-channel expressions to pass the type checker without diagnostics.
Root Cause & Changes
hy-syntax):Under SPEC-LANGUAGE.md LX9, statements are line-terminated and the parser is newline-sensitive where statements would otherwise merge. In
parse_simple_stmt, when checkingself.at_punct("<-"), we now verify that the<-operator is on the same line as the preceding expression (self.toks[self.pos].span.start.line == self.toks[self.pos - 1].span.end.line). If<-is on a subsequent line, the preceding expression statement completes (e.g.noop()), and<-doneis parsed as a new statement (Stmt::Exprreceive).hy-check):Under SPEC-LANGUAGE.md §8.4 and O4.9 (fail-closed boundary), the channel target of a channel send statement/clause must resolve to a channel shape. We pass
send_chan: Option<&Expr>intocheck_site. If the LHS expression does not resolve toTypeShape::Chan(_), it is treated as unproven/invalid, emittingHYB-E3005(orHYB-E8001insidemanaged).hy-syntax: addedsend_does_not_fuse_across_newline.hy-check: addedsend_to_void_call_callee_is_fail_closed_e3005,send_to_non_channel_local_is_fail_closed_e3005, andrepro_issue_77_two_line_receive_compiles_cleanly.