fix(r): strip backticks from R6 class name when typing $new() receivers

The R grammar yields an identifier whose text keeps its backticks, so
`Foo`$new() produced calleeName "`Foo`" while the class-name set holds the
bare name. Apply rBareName, as declaredClassName already does. Found in bot
review round 5 (PR #3513, comment 4348423277).
This commit is contained in:
Mick Cooney 2026-10-22 18:22:33 +01:00
parent 5eea3c7196
commit 5cee573baf
2 changed files with 8 additions and 1 deletions

View file

@ -273,7 +273,7 @@ const scanConstructorBinding: ConstructorBindingScanner = (node) => {
const className = children[0];
const method = children[1];
if (className?.type === 'identifier' && method?.text === 'new') {
return { varName: lhs.text, calleeName: className.text };
return { varName: lhs.text, calleeName: rBareName(className.text) };
}
}
}

View file

@ -185,6 +185,13 @@ describe('R type environment: only an assignment binds a type', () => {
});
});
it('scans a backticked R6 class name as the bare class name', () => {
expect(constructorBinding('obj <- `Foo`$new()')).toEqual({
varName: 'obj',
calleeName: 'Foo',
});
});
it.each(['+', '==', '->'])('scans nothing for `obj %s Foo$new()`', (op) => {
expect(constructorBinding(`obj ${op} Foo$new()`)).toBeUndefined();
expect(constructorBinding(`obj ${op} new("Foo")`)).toBeUndefined();