From 063aff900ca150b80930c8de76f11d7e6488222f Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 27 Apr 2024 21:52:14 +0200 Subject: [PATCH] fix: parenthesized expression as receiver (#78) Fixes #77. --- check/check.go | 2 ++ .../script/parenthesized_expression.txtar | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 testdata/script/parenthesized_expression.txtar diff --git a/check/check.go b/check/check.go index 39de800..b1704e4 100644 --- a/check/check.go +++ b/check/check.go @@ -913,6 +913,8 @@ func recvPrefix(recv *ast.FieldList) string { return expr.Name + "." case *ast.IndexExpr: return expr.X.(*ast.Ident).Name + "." + case *ast.ParenExpr: + return expr.X.(*ast.Ident).Name + "." case *ast.IndexListExpr: return expr.X.(*ast.Ident).Name + "." default: diff --git a/testdata/script/parenthesized_expression.txtar b/testdata/script/parenthesized_expression.txtar new file mode 100644 index 0000000..b544387 --- /dev/null +++ b/testdata/script/parenthesized_expression.txtar @@ -0,0 +1,20 @@ +! exec unparam . +cmp stdout stdout.golden + +-- go.mod -- +module testdata.tld/foo + +go 1.18 +-- stdout.golden -- +foo.go:7:37: (*FooType).multImplsMethod - a is unused +-- foo.go -- +package foo + +var DoWork func() + +type FooType int + +func (f *(FooType)) multImplsMethod(a int) int64 { + DoWork() + return 3 +}