mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
test: add failing test case for inlined type switches
The unified frontend ICEs when inlining a function that contains a function literal, which captures both a type switch case variable and another variable. Updates #54912. Change-Id: I0e16d371ed5df48a70823beb0bf12110a5a17266 Reviewed-on: https://go-review.googlesource.com/c/go/+/428917 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
2c45feb4d7
commit
10ffb27528
18
test/fixedbugs/issue54912.dir/a.go
Normal file
18
test/fixedbugs/issue54912.dir/a.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
// Test that inlining a function literal that captures both a type
|
||||||
|
// switch case variable and another local variable works correctly.
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
func F(p *int, x any) func() {
|
||||||
|
switch x := x.(type) {
|
||||||
|
case int:
|
||||||
|
return func() {
|
||||||
|
*p += x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
11
test/fixedbugs/issue54912.dir/main.go
Normal file
11
test/fixedbugs/issue54912.dir/main.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2022 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
|
||||||
|
|
||||||
|
import "test/a"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
a.F(new(int), 0)()
|
||||||
|
}
|
7
test/fixedbugs/issue54912.go
Normal file
7
test/fixedbugs/issue54912.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// rundir
|
||||||
|
|
||||||
|
// Copyright 2022 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 ignored
|
@ -2021,6 +2021,8 @@ var unifiedFailures = setOf(
|
|||||||
"closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
|
"closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
|
||||||
"escape4.go", // unified IR can inline f5 and f6; test doesn't expect this
|
"escape4.go", // unified IR can inline f5 and f6; test doesn't expect this
|
||||||
|
|
||||||
|
"fixedbugs/issue54912.go", // ICE when inlined type switch case variable captured in function literal
|
||||||
|
|
||||||
"typeparam/issue47631.go", // unified IR can handle local type declarations
|
"typeparam/issue47631.go", // unified IR can handle local type declarations
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user