Skip to content

Lock in behaviour for previously reported parse bugs - #9

Open
tarebyte wants to merge 4 commits into
masterfrom
test/lock-in-fixed-issue-behavior
Open

Lock in behaviour for previously reported parse bugs#9
tarebyte wants to merge 4 commits into
masterfrom
test/lock-in-fixed-issue-behavior

Conversation

@tarebyte

@tarebyte tarebyte commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Adds corpus tests only — no grammar or scanner changes.

  • Binary operator method names. def !=(other) used to produce an ERROR while def ==(other) parsed. test/corpus/declarations.txt already covers def == and def !=(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.
  • Dot call syntax. x.(123) and x.() had no corpus coverage at all. Added alongside an :error case asserting that x.(123)(456) — which Ruby rejects — stays an error.
  • Un-terminated heredoc identifier. <<~"BASH with no closing quote used to abort the scanner with Assertion 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

  • 336 corpus parses and 5 highlight files, zero failures.
  • The :error case was confirmed to fail when the source is changed to something that parses cleanly.
  • Expected trees were checked against Prism, not just against current parser output: x.(123) is a CallNode named call, and Ruby rejects x.(123)(456) with "unexpected '('".

Known limitation

The heredoc case locks in that the parser returns (program (heredoc_beginning)) with no error node, even though ruby -c and 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 ... 3 beginless range from tree-sitter#237 are already covered on master!= in test/corpus/declarations.txt "class with operators", and ... 3 at test/corpus/declarations.txt:577. No test is added for the range case.

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>
tarebyte and others added 3 commits August 24, 2026 08:56
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant