1
0
mirror of https://github.com/golang/go synced 2024-09-23 15:30:17 -06: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:
Matthew Dempsky 2022-09-06 19:28:11 -07:00
parent 2c45feb4d7
commit 10ffb27528
4 changed files with 38 additions and 0 deletions

View 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
}

View 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)()
}

View 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

View File

@ -2021,6 +2021,8 @@ var unifiedFailures = setOf(
"closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
"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
)