diff --git a/test/escape_iface.go b/test/escape_iface.go index dba08e3cb3..986228129a 100644 --- a/test/escape_iface.go +++ b/test/escape_iface.go @@ -234,16 +234,6 @@ func dotTypeEscape2() { // #13805, #15796 *(&v) = x.(int) *(&v), *(&ok) = y.(int) } - { - i := 0 - j := 0 - var ok bool - var x interface{} = i // ERROR "i does not escape" - var y interface{} = j // ERROR "j does not escape" - - sink = x.(int) // ERROR "x.\(int\) escapes to heap" - sink, *(&ok) = y.(int) - } { i := 0 // ERROR "moved to heap: i" j := 0 // ERROR "moved to heap: j" diff --git a/test/escape_iface_nounified.go b/test/escape_iface_nounified.go new file mode 100644 index 0000000000..1d267bcd18 --- /dev/null +++ b/test/escape_iface_nounified.go @@ -0,0 +1,25 @@ +// errorcheck -0 -m -l +//go:build !goexperiment.unified +// +build !goexperiment.unified + +// Copyright 2015 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 escape + +var sink interface{} + +func dotTypeEscape2() { // #13805, #15796 + { + i := 0 + j := 0 + var ok bool + var x interface{} = i // ERROR "i does not escape" + var y interface{} = j // ERROR "j does not escape" + + sink = x.(int) // ERROR "x.\(int\) escapes to heap" + // BAD: should be "y.\(int\) escapes to heap" too + sink, *(&ok) = y.(int) + } +} diff --git a/test/escape_iface_unified.go b/test/escape_iface_unified.go new file mode 100644 index 0000000000..7ac8e00151 --- /dev/null +++ b/test/escape_iface_unified.go @@ -0,0 +1,25 @@ +// errorcheck -0 -m -l +//go:build goexperiment.unified +// +build goexperiment.unified + +// Copyright 2015 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 escape + +var sink interface{} + +func dotTypeEscape2() { // #13805, #15796 + { + i := 0 + j := 0 + var ok bool + var x interface{} = i // ERROR "i does not escape" + var y interface{} = j // ERROR "j does not escape" + + sink = x.(int) // ERROR "x.\(int\) escapes to heap" + // BAD: should be "y.\(int\) escapes to heap" too + sink, *(&ok) = y.(int) + } +}