| 34 | } |
| 35 | |
| 36 | func getEllipsisRHSExpansion(expr ast.Expr) (*ast.CompositeLit, error) { |
| 37 | var ident *ast.Ident |
| 38 | |
| 39 | sel, ok := expr.(*ast.SelectorExpr) |
| 40 | if ok { |
| 41 | ident, ok = sel.X.(*ast.Ident) |
| 42 | } else { |
| 43 | ident, ok = expr.(*ast.Ident) |
| 44 | } |
| 45 | if !ok { |
| 46 | return nil, fmt.Errorf("unknown identifier") |
| 47 | } |
| 48 | |
| 49 | inlineAssignment, ok := ident.Obj.Decl.(*ast.AssignStmt) |
| 50 | if !ok { |
| 51 | return nil, fmt.Errorf("expected assignment statement") |
| 52 | } |
| 53 | if len(inlineAssignment.Rhs) != 1 { |
| 54 | return nil, fmt.Errorf("unexpected RHS expression length") |
| 55 | } |
| 56 | |
| 57 | slice, ok := inlineAssignment.Rhs[0].(*ast.CompositeLit) |
| 58 | if !ok { |
| 59 | return nil, fmt.Errorf("expected composite literal") |
| 60 | } |
| 61 | return slice, nil |
| 62 | } |
| 63 | |
| 64 | func countArgs(call *ast.CallExpr) (int, error) { |
| 65 | if call.Ellipsis == token.NoPos { |