Lock in behaviour for previously reported parse bugs - #9
Open
tarebyte wants to merge 4 commits into
Open
Conversation
Several reported parse bugs already produce the right tree but have no corpus coverage, so nothing stops them regressing. - Binary operator method names. `def !=(other)` used to produce an ERROR while `def ==(other)` parsed; cover `!=`, `==` and `<=>` alongside the existing unary operator method name test. - `...` at the start of an expression. It opens a beginless range, and must not be mistaken for argument forwarding when it appears as the first thing in a method body. - Un-terminated heredoc identifier. `<<~"BASH` with no closing quote used to abort the scanner; it now yields a bare `heredoc_beginning`. - Dot call syntax. `x.(123)` is a call, and `x.(123)(456)` — which Ruby rejects — must stay an error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The `def foo; ... 3; end` case is already covered verbatim in test/corpus/declarations.txt, so the added expressions.txt copy was redundant. The heredoc case had been shortened by one repeated line pair, which drops it below the scanner state size needed to trigger the deserialization assertion it is meant to guard. Use the complete source from the issue instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ac21705f-befb-4606-9c83-657e3e9ea0dc
The examples directory is a local checkout of the ruby/spec corpus used for differential testing. A symlink to it was committed by mistake; it points outside the repository and is meaningless to anyone else. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ac21705f-befb-4606-9c83-657e3e9ea0dc
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
Adds corpus tests only — no grammar or scanner changes.
def !=(other)used to produce anERRORwhiledef ==(other)parsed.test/corpus/declarations.txtalready coversdef ==anddef !=(other)inside "class with operators"; this adds<=>as a method name, which was not covered, and groups the three together next to the existing unary operator method name test.x.(123)andx.()had no corpus coverage at all. Added alongside an:errorcase asserting thatx.(123)(456)— which Ruby rejects — stays an error.<<~"BASHwith no closing quote used to abort the scanner withAssertion failed: (size == length). Uses the complete source from the issue, because a shortened version does not build up enough scanner state to trigger the crash.Validation
:errorcase was confirmed to fail when the source is changed to something that parses cleanly.x.(123)is aCallNodenamedcall, and Ruby rejectsx.(123)(456)with "unexpected '('".Known limitation
The heredoc case locks in that the parser returns
(program (heredoc_beginning))with no error node, even thoughruby -cand Prism both reject the source as an unterminated heredoc identifier. This test guards against the scanner crash regressing; it does not assert that the resulting tree is correct. Making the parser surface a syntax error here is a separate change.References
Covers tree-sitter#73 (dot call syntax) and tree-sitter#269 (heredoc scanner crash).
!=from tree-sitter#174 and the... 3beginless range from tree-sitter#237 are already covered onmaster—!=intest/corpus/declarations.txt"class with operators", and... 3attest/corpus/declarations.txt:577. No test is added for the range case.