From fbb47e81c1f24a8b9cb84430e9561ace60580af1 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 4 May 2022 11:56:10 -0700 Subject: [PATCH] cmd/compile/internal/syntax: minor cleanups in extractName Backport the recommended changes suggested in CL 403937. Change-Id: I3ac29c90977e33899881838825da033627344ed2 Reviewed-on: https://go-review.googlesource.com/c/go/+/403853 Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Gopher Robot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/syntax/parser.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index aaeb2a23c6f46..22b1816307710 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -683,14 +683,14 @@ func extractName(x Expr, force bool) (*Name, Expr) { } switch x.Op { case Mul: - if name, _ := x.X.(*Name); name != nil && (isTypeElem(x.Y) || force) { + if name, _ := x.X.(*Name); name != nil && (force || isTypeElem(x.Y)) { // x = name *x.Y op := *x op.X, op.Y = op.Y, nil // change op into unary *op.Y return name, &op } case Or: - if name, lhs := extractName(x.X, isTypeElem(x.Y) || force); name != nil && lhs != nil { // note: lhs should never be nil + if name, lhs := extractName(x.X, force || isTypeElem(x.Y)); name != nil && lhs != nil { // x = name lhs|x.Y op := *x op.X = lhs @@ -699,7 +699,7 @@ func extractName(x Expr, force bool) (*Name, Expr) { } case *CallExpr: if name, _ := x.Fun.(*Name); name != nil { - if len(x.ArgList) == 1 && !x.HasDots && (isTypeElem(x.ArgList[0]) || force) { + if len(x.ArgList) == 1 && !x.HasDots && (force || isTypeElem(x.ArgList[0])) { // x = name "(" x.ArgList[0] ")" return name, x.ArgList[0] }