diff --git a/compiler/internal/build/_overlay/go/parser/resolver.go b/compiler/internal/build/_overlay/go/parser/resolver.go index a7338135..cba6ee65 100644 --- a/compiler/internal/build/_overlay/go/parser/resolver.go +++ b/compiler/internal/build/_overlay/go/parser/resolver.go @@ -136,7 +136,7 @@ func (r *resolver) declare(decl, data any, scope *ast.Scope, kind ast.ObjKind, i obj.Decl = decl obj.Data = data // Identifiers (for receiver type parameters) are written to the scope, but - // never set as the resolved object. See issue #50956. + // never set as the resolved object. See go.dev/issue/50956. if _, ok := decl.(*ast.Ident); !ok { ident.Obj = obj } @@ -209,7 +209,7 @@ func (r *resolver) resolve(ident *ast.Ident, collectUnresolved bool) { } assert(obj.Name != "", "obj with no name") // Identifiers (for receiver type parameters) are written to the scope, - // but never set as the resolved object. See issue #50956. + // but never set as the resolved object. See go.dev/issue/50956. if _, ok := obj.Decl.(*ast.Ident); !ok { ident.Obj = obj } @@ -232,9 +232,19 @@ func (r *resolver) walkExprs(list []ast.Expr) { } } +func Unparen(e ast.Expr) ast.Expr { + for { + paren, ok := e.(*ast.ParenExpr) + if !ok { + return e + } + e = paren.X + } +} + func (r *resolver) walkLHS(list []ast.Expr) { for _, expr := range list { - expr := unparen(expr) + expr := Unparen(expr) if _, ok := expr.(*ast.Ident); !ok && expr != nil { ast.Walk(r, expr) } @@ -285,7 +295,7 @@ func (r *resolver) Visit(node ast.Node) ast.Visitor { } for _, e := range n.Elts { if kv, _ := e.(*ast.KeyValueExpr); kv != nil { - // See issue #45160: try to resolve composite lit keys, but don't + // See go.dev/issue/45160: try to resolve composite lit keys, but don't // collect them as unresolved if resolution failed. This replicates // existing behavior when resolving during parsing. if ident, _ := kv.Key.(*ast.Ident); ident != nil {