]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow export/import OSLICE2ARRPTR
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 21 Apr 2021 08:42:05 +0000 (15:42 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 21 Apr 2021 09:07:09 +0000 (09:07 +0000)
Updates #395
Fixes #45665

Change-Id: Iaf053c0439a573e9193d40942fbdb22ac3b4d3bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/312070
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go
test/fixedbugs/issue45665.go [new file with mode: 0644]

index 6a56abb1b99b28eb9d7c101a5518e74b9141b5af..5955b3d358db317e97cfd086713628f2ccec860d 100644 (file)
@@ -1677,7 +1677,7 @@ func (w *exportWriter) expr(n ir.Node) {
                        w.op(ir.OEND)
                }
 
-       case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR:
+       case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR, ir.OSLICE2ARRPTR:
                n := n.(*ir.ConvExpr)
                if go117ExportTypes {
                        w.op(n.Op())
index 8c197215d7244b854c97dde1f7e7118cf4900e22..642abe61baeb022be73d5dda1692aef67059b3aa 100644 (file)
@@ -1262,7 +1262,7 @@ func (r *importReader) node() ir.Node {
                }
                return n
 
-       case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR:
+       case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR, ir.OSLICE2ARRPTR:
                if !go117ExportTypes && op != ir.OCONV {
                        //      unreachable - mapped to OCONV case by exporter
                        goto error
diff --git a/test/fixedbugs/issue45665.go b/test/fixedbugs/issue45665.go
new file mode 100644 (file)
index 0000000..2981a49
--- /dev/null
@@ -0,0 +1,15 @@
+// compile
+
+// 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
+
+func main() {
+       Get([]string{"a", "b"})
+}
+
+func Get(ss []string) *[2]string {
+       return (*[2]string)(ss)
+}