Skip to content

Commit d0c6d29

Browse files
committed
go/ast/astutil: don't panic trying to copy FuncType
In gh-1134, I argued in favour of extending CopyExpr to use reflection to handle all types, under the assumption that we missed many types. I have now decided against that, for two reasons: 1. There weren't many unhandled types left 2. We cannot copy comments because of limitations in go/ast, and it seems better to refuse generating suggested fixes than to swallow comments. This is a general problem, but function literals are particularly likely to contain comments. Thus, we just add FuncType to the list of types we cannot copy. The effect is that several checks in the quickfix package will not generate suggested fixes in some cases. Closes gh-1134 (cherry picked from commit 8af8898)
1 parent d7e217c commit d0c6d29

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

go/ast/astutil/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ func CopyExpr(node ast.Expr) (ast.Expr, bool) {
218218
case *ast.StructType:
219219
cp := *node
220220
return &cp, true
221-
case *ast.FuncLit:
222-
// TODO(dh): implement copying of function literals.
221+
case *ast.FuncLit, *ast.FuncType:
222+
// TODO(dh): implement copying of function literals and types.
223223
return nil, false
224224
case *ast.ChanType:
225225
var ok bool

0 commit comments

Comments
 (0)