Skip to content

Commit 5f1df26

Browse files
committed
cmd/compile: allow export/import OSLICE2ARRPTR
Updates #395 Fixes #45665 Change-Id: Iaf053c0439a573e9193d40942fbdb22ac3b4d3bb Reviewed-on: https://go-review.googlesource.com/c/go/+/312070 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 7735ec9 commit 5f1df26

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/cmd/compile/internal/typecheck/iexport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ func (w *exportWriter) expr(n ir.Node) {
16771677
w.op(ir.OEND)
16781678
}
16791679

1680-
case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR:
1680+
case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR, ir.OSLICE2ARRPTR:
16811681
n := n.(*ir.ConvExpr)
16821682
if go117ExportTypes {
16831683
w.op(n.Op())

src/cmd/compile/internal/typecheck/iimport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ func (r *importReader) node() ir.Node {
12621262
}
12631263
return n
12641264

1265-
case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR:
1265+
case ir.OCONV, ir.OCONVIFACE, ir.OCONVNOP, ir.OBYTES2STR, ir.ORUNES2STR, ir.OSTR2BYTES, ir.OSTR2RUNES, ir.ORUNESTR, ir.OSLICE2ARRPTR:
12661266
if !go117ExportTypes && op != ir.OCONV {
12671267
// unreachable - mapped to OCONV case by exporter
12681268
goto error

test/fixedbugs/issue45665.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile
2+
3+
// Copyright 2021 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
func main() {
10+
Get([]string{"a", "b"})
11+
}
12+
13+
func Get(ss []string) *[2]string {
14+
return (*[2]string)(ss)
15+
}

0 commit comments

Comments
 (0)