1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:40:06 -07:00
go/test/fixedbugs/issue48289.go
Dan Scales b9e1a24581 cmd/compile: fix case where init info of OAS node is dropped
When an OAS node is converted to an OSELRECV2 node in tcSelect(), the
possible DCL node in the Init field was being dropped, since a
completely new node was being created and the Init field was not set. I
don't expect n.Init() to be set for the ORECV case, but the code now
deals with that too.

Fixed bug in both tcSelect() and transformSelect().

Fixes #48289

Change-Id: I09918a70f7cbaa4aa9a17546169f908a8787df15
Reviewed-on: https://go-review.googlesource.com/c/go/+/348569
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-09-09 19:17:02 +00:00

29 lines
449 B
Go

// run
// 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
import "fmt"
func main() {
ch := make(chan int, 1)
var ptrs [2]*int
for i := range ptrs {
ch <- i
select {
case x := <-ch:
ptrs[i] = &x
}
}
for i, ptr := range ptrs {
if *ptr != i {
panic(fmt.Sprintf("got *ptr %d, want %d", *ptr, i))
}
}
}