Skip to content

Commit b2a56b7

Browse files
cuonglmgopherbot
authored andcommitted
cmd/compile: make backingArrayPtrLen to return typecheck-ed nodes
Fixes #61908 Change-Id: Ief8e3a6c42c0644c9f71ebef5f28a294cd7c153f Reviewed-on: https://go-review.googlesource.com/c/go/+/517936 Run-TryBot: Cuong Manh Le <[email protected]> Auto-Submit: Cuong Manh Le <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 58447d7 commit b2a56b7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/cmd/compile/internal/walk/walk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ func backingArrayPtrLen(n ir.Node) (ptr, length ir.Node) {
275275
} else {
276276
ptr.SetType(n.Type().Elem().PtrTo())
277277
}
278+
ptr.SetTypecheck(1)
278279
length = ir.NewUnaryExpr(base.Pos, ir.OLEN, n)
279280
length.SetType(types.Types[types.TINT])
281+
length.SetTypecheck(1)
280282
return ptr, length
281283
}
282284

test/fixedbugs/issue61908.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// compile
2+
3+
// Copyright 2023 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
func f(p []byte) int {
10+
switch "" < string(p) {
11+
case true:
12+
return 0
13+
default:
14+
return 1
15+
}
16+
}

0 commit comments

Comments
 (0)