From 45c748f7e61a4044a1f79516746d5851113de251 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 13 Aug 2022 00:44:08 +0700 Subject: [PATCH] test: add test case for issue 53702 The issue is expected to be fixed when Unified IR is enabled by default, so adding a test to make sure thing works correctly. Updates #53702 Change-Id: Id9d7d7ca4506103df0d10785ed5ee170d69988ba Reviewed-on: https://go-review.googlesource.com/c/go/+/423434 TryBot-Result: Gopher Robot Reviewed-by: Matthew Dempsky Reviewed-by: Ian Lance Taylor Run-TryBot: Cuong Manh Le Auto-Submit: Cuong Manh Le --- test/fixedbugs/issue53702.go | 39 ++++++++++++++++++++++++++++++++++++ test/run.go | 1 + 2 files changed, 40 insertions(+) create mode 100644 test/fixedbugs/issue53702.go diff --git a/test/fixedbugs/issue53702.go b/test/fixedbugs/issue53702.go new file mode 100644 index 0000000000000..0b251c2d7be96 --- /dev/null +++ b/test/fixedbugs/issue53702.go @@ -0,0 +1,39 @@ +// run + +// 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 + +type Elem struct{} + +func (*Elem) Wait(callback func()) {} + +type Base struct { + elem [8]*Elem +} + +var g_val = 1 + +func (s *Base) Do() *int { + resp := &g_val + for _, e := range s.elem { + e.Wait(func() { + *resp = 0 + }) + } + return resp +} + +type Sub struct { + *Base +} + +func main() { + a := Sub{new(Base)} + resp := a.Do() + if resp != nil && *resp != 1 { + panic("FAIL") + } +} diff --git a/test/run.go b/test/run.go index 559caee784f22..a6ee1634bbc18 100644 --- a/test/run.go +++ b/test/run.go @@ -1976,6 +1976,7 @@ var types2Failures32Bit = setOf( ) var go118Failures = setOf( + "fixedbugs/issue53702.go", // 1.18 compiler failed with "Value live at entry" error "fixedbugs/issue54343.go", // 1.18 compiler assigns receiver parameter to global variable "typeparam/nested.go", // 1.18 compiler doesn't support function-local types with generics "typeparam/issue51521.go", // 1.18 compiler produces bad panic message and link error