Skip to content

Fix 35 grammar bugs and add comprehensive test coverage (575 tests)#22

Merged
jeanpaulsio merged 4 commits into
mainfrom
fix/grammar-bug-list
Mar 27, 2026
Merged

Fix 35 grammar bugs and add comprehensive test coverage (575 tests)#22
jeanpaulsio merged 4 commits into
mainfrom
fix/grammar-bug-list

Conversation

@jeanpaulsio

Copy link
Copy Markdown
Owner

Summary

  • Fix 35 grammar bugs across 8 root causes: bare rescue in method bodies, lambda without params, setter assignment (self.x = val), Constant(args) method calls, and more
  • 575 passing tests across 7 test suites with 72 documented skips for known limitations
  • Indent service fixes: private def / protected def now recognized as block openers; mixed do/end + {} nesting tracked correctly

Test coverage breakdown

Suite Pass Skip Total
Grammar (Lezer fileTests) 105 0 105
Indent (ruby-indent-cases.md) 247 30 277
Highlight (Part 1) 139 24 163
Grammar accuracy + perf (Parts 7, 9) 39 2 41
Fold (Part 2) 25 6 31
Completion (Part 6) 10 10 20
Integration (Part 8) 10 0 10

Grammar fixes

  • Bare rescue inside method body without begin
  • Lambda without params (-> { body })
  • Setter assignment via dot (self.email = value)
  • Constants as method calls (URI(url), Integer("42"))
  • super highlighted as keyword
  • External tokenizer fixes for edge cases

Test plan

  • npm run build && npm test — 105 Lezer fileTests pass
  • node test/indent.test.mjs — 247 pass, 0 fail
  • node test/highlight.test.mjs — 139 pass, 0 fail
  • node test/grammar.test.mjs — 39 pass, 0 fail
  • node test/fold.test.mjs — 25 pass, 0 fail
  • node test/completion.test.mjs — 10 pass, 0 fail
  • node test/integration.test.mjs — 10 pass, 0 fail

🤖 Generated with Claude Code

jeanpaulsio and others added 4 commits March 26, 2026 16:32
Resolve all bugs from grammar-bug-list.md traced to 8 root causes:

- Root Cause B: whitespace/semicolons — newlines and semicolons as skip tokens
- Root Cause A: hash symbol-key shorthand — KeywordParam/KeywordArg with colonOp
- Root Cause C: bare method calls — Rails DSL methods, raise as bareMethod
- Root Cause G: rescue clause — bare rescue (=> e), multiple exception classes
- Root Cause D: operators — bitwise/shift via external tokenizers, token precedence
  DFA fix (AssignOp above ArithOp), greaterThanTokenizer for >/>=/>>/>>= family
- Root Cause H: block pass — BlockPassExpression in ParenExpression, BlockParam GLR
- Root Cause E: scoped class names — className with :: separators, GLR on Constant
- Root Cause F: statements as expressions — if/unless/case/begin in expression via GLR

Additional fixes:
- BUG-009: statements as expressions (x = if/case/begin)
- BUG-012: Rails DSL bare methods (validates, has_many, before_action, etc.)
- BUG-017: operator method definitions (def <=>, def [], def []=)
- BUG-018: while/until/for do — @extend<Identifier,"do"> with !loopBody precedence
- BUG-022: setter method definitions (def name=)
- BUG-024: match operators (=~, !~, ===)
- BUG-031: block pass (&block) in method calls
- BUG-034: expanded symbol tokenizer (:foo?, :foo!, :"quoted", operator symbols)

91 fileTests pass, lint clean. 87/89 comprehensive bug reproductions pass.
- MethodBody now supports implicit rescue/ensure (no begin wrapper needed)
- Lambda ParamList is now optional, fixing `-> { expr }` syntax
- Fixes BUG-010 (bare rescue) and BUG-012d (scope with lambda)
- 94 tests passing
Fix Constant(args) as method call (e.g. URI(url)), self.method= setter
assignment, folding for def/class/module blocks, trailing dot method
chain continuation indent, and super keyword highlighting.

Add 6 test suites: grammar (105), integration (10), highlight (31),
indent (51), fold (16), completion (10) — 223 total tests. Update
README with expanded known limitations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 247 indent tests covering all 32 sections of ruby-indent-cases.md
- Add 139 highlight tests covering all Part 1 spec sections (1.1-1.11)
- Add 39 grammar accuracy + performance tests (Parts 7 and 9)
- Expand fold tests to 25 cases covering Part 2 (2.1-2.11)
- Expand completion tests with Part 6 context cases
- Fix INDENT_AFTER to recognize `private def`, `protected def`, etc.
- Fix deindent scanner to track {}/do-end nesting separately

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jeanpaulsio jeanpaulsio merged commit 3227543 into main Mar 27, 2026
1 check passed
@jeanpaulsio jeanpaulsio deleted the fix/grammar-bug-list branch March 27, 2026 01:23
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