Skip to content

refactor(ast): unify AstVisitorBase Stmt.Expression handler name (#1250)#1252

Merged
nickna merged 1 commit into
mainfrom
worktree-issue-1250
Jul 5, 2026
Merged

refactor(ast): unify AstVisitorBase Stmt.Expression handler name (#1250)#1252
nickna merged 1 commit into
mainfrom
worktree-issue-1250

Conversation

@nickna

@nickna nickna commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Renames VisitExpressionStmtVisitExpression in the AstVisitorBase analyzer-visitor family, so the handler for Stmt.Expression follows the same mechanical Visit + node-type-name rule used everywhere else (Stmt.VarVisitVar, Expr.BinaryVisitBinary, …).

Stmt.Expression was the only node whose handler name diverged between the two dispatch families:

Family Handler for Stmt.Expression (before)
Analyzer visitors (AstVisitorBase + subclasses) VisitExpressionStmt
Registry dispatch (Interpreter, TypeChecker, via NodeRegistry.AutoRegister's $"Visit{Name}") VisitExpression

This removes the last exception to the uniform naming and the one wrinkle a future source-generator-based dispatch (the road not taken in #1243) would have to special-case.

Changes (4 spots, behavior-neutral)

  • Parsing/Visitors/AstVisitorBase.cs — the Stmt.Expression switch case
  • Parsing/Visitors/AstVisitorBase.cs — the virtual method definition
  • Compilation/StringAccumulatorPromotionAnalyzer.cs — the override
  • Compilation/StringAccumulatorPromotionAnalyzer.cs — the base.VisitExpression(stmt) call

No collision with the existing Interpreter.VisitExpression / TypeChecker.VisitExpression methods — those live on the registry-dispatch types, not in the AstVisitorBase hierarchy.

Testing

  • dotnet build — 0 errors
  • Full xUnit suite — 15415 passed / 0 failed (includes AstDispatchTests, which guards the AstVisitorBase switch via a GetUninitializedObject + NotSupportedException probe)

Pure internal C# method rename with no behavioral surface — the Test262/TSConf conformance suites exercise TypeScript semantics this change cannot affect.

Part of #1094.

Closes #1250

Rename VisitExpressionStmt -> VisitExpression in the analyzer-visitor
family so it matches the mechanical Visit + node-type-name convention
used everywhere else (Stmt.Var -> VisitVar, Expr.Binary -> VisitBinary).

Stmt.Expression was the one node whose handler name diverged between the
two dispatch families: AstVisitorBase's switch called VisitExpressionStmt
while the registry dispatch (Interpreter/TypeChecker via
NodeRegistry.AutoRegister's $"Visit{Name}") uses VisitExpression. This
removes the last exception to the uniform naming and the one wrinkle a
future source-generator-based dispatch would have to special-case.

Behavior-neutral: renames the AstVisitorBase switch case, the virtual
method, and the StringAccumulatorPromotionAnalyzer override + base call.
No collision with the existing Interpreter/TypeChecker VisitExpression
methods, which are not in the AstVisitorBase hierarchy.

Part of #1094.

Closes #1250
@nickna nickna merged commit 85e8298 into main Jul 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify the AstVisitorBase Stmt.Expression handler name (VisitExpressionStmt → VisitExpression)

1 participant