]> Cypherpunks repositories - gostls13.git/commitdiff
Conversion from array to slices should work like assignment:
authorIan Lance Taylor <iant@golang.org>
Thu, 30 Apr 2009 03:15:59 +0000 (20:15 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 30 Apr 2009 03:15:59 +0000 (20:15 -0700)
you should be able to convert a pointer to an array to a
slice, you should not be able to convert an array to a slice.
Currently 6g works the other way around.

R=ken,rsc
DELTA=17  (17 added, 0 deleted, 0 changed)
OCL=28033
CL=28067

test/bugs/bug146.go [new file with mode: 0644]
test/golden.out

diff --git a/test/bugs/bug146.go b/test/bugs/bug146.go
new file mode 100644 (file)
index 0000000..3095d26
--- /dev/null
@@ -0,0 +1,14 @@
+// errchk $G $D/$F.go
+
+// Copyright 2009 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() {
+       type Slice []byte;
+       a := [...]byte{ 0 };
+       b := Slice(&a);         // This should be OK.
+       c := Slice(a);          // ERROR "invalid"
+}
index a3ab91b21305077704d36203bf07f08a8f9f7e45..36217cac378adefcf52c99abaa8805cbb62bc9ae 100644 (file)
@@ -111,6 +111,13 @@ bugs/bug140.go:6: syntax error near L1
 bugs/bug140.go:7: syntax error near L2
 BUG should compile
 
+=========== bugs/bug146.go
+BUG: errchk: bugs/bug146.go:9: missing expected error: 'invalid'
+errchk: bugs/bug146.go: unmatched error messages:
+==================================================
+bugs/bug146.go:8: invalid conversion: *[1]uint8 to Slice
+==================================================
+
 =========== fixedbugs/bug016.go
 fixedbugs/bug016.go:7: constant -3 overflows uint