Skip to content

Commit 6ffefb6

Browse files
antonsyndclaude
andcommitted
chore(codegen): fix convention violations from plan implementation review
- Use PythonNames.Self constant instead of magic "self" string in ResolveExpressionTypeFromSymbols (RoslynEmitter.Expressions.cs) - Remove redundant _sourceVariableNames.Add in GenerateCatchClauses (already collected by CollectSourceVariableNames pre-gen pass) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d10419e commit 6ffefb6

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

src/Sharpy.Compiler/CodeGen/RoslynEmitter.Expressions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private ExpressionSyntax GenerateStringLiteral(StringLiteral literal)
255255
{
256256
// For self.x, look up on the current type
257257
if (memberAccess.Object is Identifier obj
258-
&& string.Equals(obj.Name, "self", StringComparison.OrdinalIgnoreCase)
258+
&& string.Equals(obj.Name, PythonNames.Self, StringComparison.OrdinalIgnoreCase)
259259
&& _currentTypeSymbol is not null)
260260
{
261261
var field = _currentTypeSymbol.Fields.Find(f => f.Name == memberAccess.Member);

src/Sharpy.Compiler/CodeGen/RoslynEmitter.Statements.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,8 +1827,6 @@ private List<CatchClauseSyntax> GenerateCatchClauses(ImmutableArray<ExceptHandle
18271827
? $"{baseName}_{_variableVersions[baseName]}"
18281828
: baseName;
18291829

1830-
_sourceVariableNames.Add(baseName);
1831-
18321830
var catchBlock = Block(handler.Body.SelectMany(GenerateBodyStatements));
18331831
var declaration = CatchDeclaration(exceptionType, Identifier(exceptionVar));
18341832

0 commit comments

Comments
 (0)