Fix NoMethodError in Magik lexer's method_name state - #2328
Merged
Merged
Conversation
The regex-caching class methods that comment 2318 review threads targeted were already removed in favor of local variables; this call was missed and would raise NoMethodError at lex time.
sebastiaanspeck
force-pushed
the
patch-1
branch
from
August 27, 2026 21:13
58c2412 to
4cc0657
Compare
This was referenced Aug 27, 2026
Member
|
I'm a little shocked that the tests didn't catch this. Does the visual spec never trigger this state? |
Contributor
Author
The tests caught it, but it was ignored(?) - https://github.com/rouge-ruby/rouge/actions/runs/32947811182/job/98230454981 and https://github.com/rouge-ruby/rouge/actions/runs/32947811182/job/98230455001 |
Member
|
Hm, the action ran but it never made its way to the PR. Incredible. |
UlyssesZh
pushed a commit
to UlyssesZh/rouge
that referenced
this pull request
Aug 28, 2026
* Add missing _locking keyword to Magik lexer _locking is a real keyword (used in _protect _locking <expr>) that was missing from KEYWORDS, so it highlighted as a plain identifier instead of Keyword. Confirmed against a live Magik session. Also drops _recursive from the same list to keep this change focused on the one clear, verifiable gap. * Integrate rouge-ruby#2328
UlyssesZh
pushed a commit
to UlyssesZh/rouge
that referenced
this pull request
Aug 28, 2026
* Fix over-greedy character-literal regex in Magik lexer %[^\s]+ consumed everything up to the next whitespace, so a character literal immediately followed by punctuation (e.g. %a.foo) was lexed as one Literal::String::Char token instead of a character literal plus a separate slot access. Replaced with %(?:\w+|\W), matching Magik's actual CHARACTER_REGEXP (used by magik-tools' MagikGrammar and the same pattern the Magik TextMate grammar documents). Verified against a live Magik session and tree-sitter-magik that %a.foo parses as two tokens (character literal "%a", then a call to .foo), and that the existing character-literal samples (%q, %u000A, %newline, %space, %tab, ...) still lex identically. * Integrate rouge-ruby#2328
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.
Follow-up to #2318.
state :method_namestill calledMagik.identifier, a leftover from an earlier revision of that PR that cached regexes as memoized class methods (the style @jneen's review comments on #2318 asked to move away from). That refactor was done for every other regex in the file, but this one call site was missed.Since
RegexLexerevaluates a state'srulearguments eagerly when the state is first loaded,Magik.identifierraisesNoMethodError: undefined method 'identifier' for class Rouge::Lexers::Magikas soon as:method_nameis entered - i.e. on any input containing_method, not just the new[]-method syntax. Verified against a clean checkout of currentmain(909e8ca):This fix replaces the stale class-method reference with the
identifierlocal variable already used everywhere else in the file. It's a one-line change with no other effect: the sample file round-trips through the lexer with no errors, and no other tokenization changes sinceidentifieris the exact same regexMagik.identifierwas aliasing.