]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile/internal/typecheck: use strings.Contains
authorTobias Klauser <tklauser@distanz.ch>
Thu, 5 Oct 2023 15:29:49 +0000 (17:29 +0200)
committerGopher Robot <gobot@golang.org>
Wed, 25 Oct 2023 17:37:01 +0000 (17:37 +0000)
Change-Id: I439268e91288f9a5a0946ac428731cdfa4d111cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/533135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/typecheck/expr.go

index 24c677e753fecbc393ad1b119352a501be2f7bc3..12d1743874caa06514d49dfcac8629a2bba3a3bd 100644 (file)
@@ -241,7 +241,7 @@ func tcCompLit(n *ir.CompLitExpr) (res ir.Node) {
                                // walkClosure(), because the instantiated
                                // function is compiled as if in the source
                                // package of the generic function.
-                               if !(ir.CurFunc != nil && strings.Index(ir.CurFunc.Nname.Sym().Name, "[") >= 0) {
+                               if !(ir.CurFunc != nil && strings.Contains(ir.CurFunc.Nname.Sym().Name, "[")) {
                                        if s != nil && !types.IsExported(s.Name) && s.Pkg != types.LocalPkg {
                                                base.Errorf("implicit assignment of unexported field '%s' in %v literal", s.Name, t)
                                        }