]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: make backingArrayPtrLen to return typecheck-ed nodes
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 9 Aug 2023 18:51:17 +0000 (01:51 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 9 Aug 2023 19:30:45 +0000 (19:30 +0000)
Fixes #61908

Change-Id: Ief8e3a6c42c0644c9f71ebef5f28a294cd7c153f
Reviewed-on: https://go-review.googlesource.com/c/go/+/517936
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/compile/internal/walk/walk.go
test/fixedbugs/issue61908.go [new file with mode: 0644]

index 8e4aa985bbc2487741162f5248d3288218deeb6b..21cccaacf82eca05e8fa0d88a4f4c4caf8fa17b5 100644 (file)
@@ -275,8 +275,10 @@ func backingArrayPtrLen(n ir.Node) (ptr, length ir.Node) {
        } else {
                ptr.SetType(n.Type().Elem().PtrTo())
        }
+       ptr.SetTypecheck(1)
        length = ir.NewUnaryExpr(base.Pos, ir.OLEN, n)
        length.SetType(types.Types[types.TINT])
+       length.SetTypecheck(1)
        return ptr, length
 }
 
diff --git a/test/fixedbugs/issue61908.go b/test/fixedbugs/issue61908.go
new file mode 100644 (file)
index 0000000..f5d3bce
--- /dev/null
@@ -0,0 +1,16 @@
+// compile
+
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func f(p []byte) int {
+       switch "" < string(p) {
+       case true:
+               return 0
+       default:
+               return 1
+       }
+}