Repository navigation
fix(ruby) do not read Name::method as a Name: symbol - #4573
Open
clark719664 wants to merge 1 commit into
Open
clark719664 wants to merge 1 commit into
clark719664 wants to merge 1 commit into
Conversation
The `identifier:` symbol rule matched the first colon of a scope resolution operator whenever the left-hand side was not a CamelCase class reference, so `A::a_method` and `an_alias::a_method` were highlighted as the symbols `A:` + `:a_method`. The existing `::` swallow rule never got a chance because the symbol match started one character earlier. Require that the colon is not followed by another colon, so hash-key symbols (`name:`) still match and `Name::method` falls through to the `::` rule. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Assisted-by: Claude Fable 5.1 (high)
This branch has not been deployed
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.
Resolves #4516
Changes
Confirms the report: on
main,A::a_method(sym: 1)andan_alias::a_method(sym: 5)highlightA:/an_alias:and:a_methodas symbols, andA::B::C.newgivesA:+:B. The::swallow rule added in #4463 only helps when the left-hand side is consumed first by the CamelCase class-reference rule (Foo::Bar); for a single capital letter or a lowercase receiver, theidentifier:symbol rule matches one character earlier and wins.ruby.js: theidentifier(!|?)?:symbol rule now requires that the colon is not followed by another colon (:(?!:)), so hash-key symbols (name:,sym:) still match andName::methodfalls through to the existing::rule.test/markup/ruby/symbols: three added cases (A::a_method(sym: 1),an_alias::a_method(sym: 5),A::B::C.new). All previous expectations in that file are unchanged.CHANGES.mdentry.Verification (Node 24, Windows):
npm run build && mocha test: the extendedshould markup symbolstest fails onmainand passes with this change; the full suite is 1650 passing, 3 pending.a = :symbol,{ hash_key: 1 },b[:hash_key],def m(sym: 123),cond ? a : b,a ? :yes : :no,{ "k": 1, k2: 2 }all highlight as before.eslint src/languages/ruby.jsreports the same single parsing error as onmain(pre-existing, unrelated to this change).Note: the
CHANGES.mdhunk sits next to the one in #4572; whichever lands second will need a trivial rebase.Assisted-by: Claude Fable 5.1 (high). This change was developed with an AI coding assistant (Claude Code) and reviewed by Clark.
Checklist
🤖 Generated with Claude Code