Skip to content

fix(emit-format): handle chained method call in formatCallExpr#181

Merged
notJoon merged 1 commit into
mainfrom
fix/handle-chained-methid-call
Dec 23, 2025
Merged

fix(emit-format): handle chained method call in formatCallExpr#181
notJoon merged 1 commit into
mainfrom
fix/handle-chained-methid-call

Conversation

@notJoon

@notJoon notJoon commented Dec 23, 2025

Copy link
Copy Markdown
Member

Summary

  • Fix panic when processing chained method calls (e.g., ctx.Caller().String()) in emit format rule
  • Add formatEmitExpr helper to safely handle various ast.Expr types

Problem

The formatCallExpr function assumed SelectorExpr.X is always *ast.Ident, causing a panic when encountering chained method calls like obj.Method().AnotherMethod() where X is *ast.CallExpr.

Changes

  • Replace unsafe type assertion with formatEmitExpr helper that handles *ast.Ident, *ast.CallExpr, and *ast.SelectorExpr
  • Add test case for chained method calls

@notJoon notJoon added the bug bug label Dec 23, 2025
@notJoon notJoon merged commit 29678cf into main Dec 23, 2025
6 checks passed
@notJoon notJoon deleted the fix/handle-chained-methid-call branch December 23, 2025 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant