mirror of
https://github.com/golang/go
synced 2024-11-26 16:57:14 -07:00
[dev.typeparams] cmd/compile: handle ONONAME in subster.node
Fixes #46472 Change-Id: I27802978fa0c3bb32a29e452165a6fcac93473bb Reviewed-on: https://go-review.googlesource.com/c/go/+/323731 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
f32f4f58d9
commit
4b10e4c547
@ -350,6 +350,9 @@ func (subst *subster) node(n ir.Node) ir.Node {
|
||||
return v
|
||||
}
|
||||
return x
|
||||
case ir.ONONAME:
|
||||
// This handles the identifier in a type switch guard
|
||||
fallthrough
|
||||
case ir.OLITERAL, ir.ONIL:
|
||||
if x.Sym() != nil {
|
||||
return x
|
||||
|
20
test/typeparam/issue46472.go
Normal file
20
test/typeparam/issue46472.go
Normal file
@ -0,0 +1,20 @@
|
||||
// run -gcflags=-G=3
|
||||
|
||||
// Copyright 2021 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 main
|
||||
|
||||
func foo[T any](d T) {
|
||||
switch v := interface{}(d).(type) {
|
||||
case string:
|
||||
if v != "x" {
|
||||
panic("unexpected v: "+v)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
func main() {
|
||||
foo("x")
|
||||
}
|
Loading…
Reference in New Issue
Block a user