Repository navigation
fix(tokenizer): & in executable code is concatenation, not a reference - #870
Merged
msarson merged 2 commits intoNov 25, 2026
Merged
Conversation
The ReferenceVariable pattern /&\s*Name/ was tried at every `&`, so in code `'Rows: ' & Num` became one `& Num` token. Find All References matched that token against '&' + word and missed every `& Num` use, and `& Grp.Field` lost its field access. A space after `&` is legal in a declaration, so the pattern keeps its \s* and is skipped in a CODE section only, where `&` now tokenizes like it already did before a string literal. New ClarionTokenizer.AmpersandConcatInCode.test.ts: 17 tests, 9 fail without the fix. Full server suite 4636 passing, 0 failing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ield Document highlight matched `&Grp` in `'x' &Grp.Field` through the ReferenceVariable branch. With `&` now tokenized as concatenation in code, that is a StructureField `Grp.Field`, which the provider skipped, so those lines lost their highlight. A StructureField branch now highlights the receiver when it is the word, ignoring case, which also covers `Grp.Field` without `&`, never highlighted before. The field name alone is not matched: it would also hit `Other.Field`. 3 new tests, 2 fail without the change. Full suite 4639 passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What happened
Find All References on a local misses every use written after a concatenation
&with a space:And
MESSAGE('Rows: ' & Tally.Rows)loses the field access: References on the GROUP labelTallydoes not list that line.
Root cause
TokenPatterns.ts:PatternMatchertries this pattern at every&, in data and code alike. In code the operator, thespace and the next name become one token:
MESSAGE('Rows: ' & Num)& NumReferenceVariableMESSAGE('Rows: ' &Num)&NumReferenceVariableMESSAGE('Rows: ' & Tally.Rows)& TallyReferenceVariable +RowsVariableReferencesProvidermatches a ReferenceVariable token against'&' + word, so only the no-space formwas found, and
& Tally.Rowsnever produced theTally.RowsStructureField.Dropping the
\s*is not an option: a space after&is legal in a declaration. Clarion 11.1compiles and links
Ref & LONG,Ref & LONG,Ref & SomeGroupTypeandRef & SomeProcType,each accepting
&=and being dereferenced.The fix
ClarionTokenizer.ts, with the other per-pattern context guards:inCodeSectionis the state the tokenizer already keeps (codeSectionSetBy: CODE sets it, DATA,ROUTINE and PROCEDURE/FUNCTION header lines clear it). An
&in code now gets no token, exactly asan
&before a string literal already does today ('a' & 'b'), and the name after it tokenizes asit would anywhere else in code (Variable, StructureField
Tally.Rows, StructurePrefixPRE:Field).&=and& |are unaffected: the pattern never matched them.Every consumer of
TokenType.ReferenceVariablereads it as a declaration (Label &Type, column 0,outside code), with one exception: Document highlight matched
&Grpin'x' &Grp.Fieldthrough itsReferenceVariable branch. That token is now a StructureField
Grp.Field, which the provider skipped,so those lines lost their highlight. The second commit adds a StructureField branch to
DocumentHighlightProvider.ts:This also highlights
Grp.Fieldwithout&, which was never highlighted before.Testing
New
ClarionTokenizer.AmpersandConcatInCode.test.ts, 17 tests:& Num,&Num,& Num & ' rows',& Tally.Rows,&in a ROUTINE with and without a DATAsection, and in a procedure whose header takes
&LONG pX;&LONG/& LONGin a MAP prototype, global, procedure-local andROUTINE DATA declarations, a procedure header parameter, and
& |continuation;Num(every line above) and on the GROUP labelTally;Tally.Rows(with and without&, anycase), a control that another GROUP's
Other.Rowsis not highlighted forTally, and a plainlocal after
&.Without the tokenizer change 9 fail (all the code-section cases and both References tests) and the
8 controls pass. Without the highlight change its 2 receiver tests fail. With both, 20 pass. Full
server suite: 4639 passing, 0 failing, 3 pending.
Sweeps over a 259-file test corpus, before and after:
them with a space after
&, 101 without); no token appears after that was not there before.procedure's
CODEis in column 0 (a separate issue): the misread entry's name changes shape.&, so this onlysays nothing else moved.
&): hover and F12unchanged at all 80. They resolve the word at the cursor without this token.
Distinct result lines 29,258 -> 30,690. Four positions only gained (+420, +21, +6, +2). The fifth,
the built-in
ERRORCODE, gained 785 and lost 65, and all 65 are a class member calledErrorCodeafter
&('Error: ' & Obj.ErrorCode). Before,& Objswallowed the receiver and left a bareErrorCodethat matched the built-in; now it is a member access, asx = Obj.ErrorCodealready was.Scope
Left out on purpose:
&in code. Nothing emits one today ('a' & 'b'has none either), andadding it would change what every token-adjacency check sees.
CODEis in column 0 (seen in the document-symbols sweep)is unrelated to
&and not touched here.RowsinTally.Rows) still returns nothing, as before: bytext alone it cannot tell
Tally.RowsfromOther.Rows.