Commit 29678cf
authored
fix(emit-format): handle chained method call in
## 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 callsformatCallExpr (#181)1 parent 314ead1 commit 29678cf
2 files changed
+25
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
323 | 334 | | |
324 | 335 | | |
325 | 336 | | |
| |||
0 commit comments