new new & make
R=r
OCL=22166
CL=22166
diff --git a/test/fixedbugs/bug011.go b/test/fixedbugs/bug011.go
index c2d9cde..63673c0 100644
--- a/test/fixedbugs/bug011.go
+++ b/test/fixedbugs/bug011.go
@@ -16,7 +16,7 @@
}
func main() {
- var t *T = new(*T);
+ var t *T = new(T);
t.x = 1;
t.y = 2;
r10 := t.m(1, 3.0);
diff --git a/test/fixedbugs/bug026.go b/test/fixedbugs/bug026.go
index d8a1d778..1d97c18 100644
--- a/test/fixedbugs/bug026.go
+++ b/test/fixedbugs/bug026.go
@@ -18,8 +18,8 @@
func main() {
type I struct { val int; }; // BUG: can't be local; works if global
- v := new(*Vector);
- v.Insert(0, new(*I));
+ v := new(Vector);
+ v.Insert(0, new(I));
}
/*
check: main_sigs_I: not defined
diff --git a/test/fixedbugs/bug027.go b/test/fixedbugs/bug027.go
index 428a4b6..1630050 100644
--- a/test/fixedbugs/bug027.go
+++ b/test/fixedbugs/bug027.go
@@ -15,9 +15,9 @@
}
func New() *Vector {
- v := new(*Vector);
+ v := new(Vector);
v.nelem = 0;
- v.elem = new([]Element, 10);
+ v.elem = make([]Element, 10);
return v;
}
@@ -32,11 +32,11 @@
func main() {
type I struct { val int; };
- i0 := new(*I); i0.val = 0;
- i1 := new(*I); i1.val = 11;
- i2 := new(*I); i2.val = 222;
- i3 := new(*I); i3.val = 3333;
- i4 := new(*I); i4.val = 44444;
+ i0 := new(I); i0.val = 0;
+ i1 := new(I); i1.val = 11;
+ i2 := new(I); i2.val = 222;
+ i3 := new(I); i3.val = 3333;
+ i4 := new(I); i4.val = 44444;
v := New();
print("hi\n");
v.Insert(i4);
diff --git a/test/fixedbugs/bug038.go b/test/fixedbugs/bug038.go
index 444a042..7585376 100644
--- a/test/fixedbugs/bug038.go
+++ b/test/fixedbugs/bug038.go
@@ -9,5 +9,5 @@
func main() {
var z [3]byte;
- z := new(*[3]byte); // BUG redeclaration
+ z := new([3]byte); // BUG redeclaration
}
diff --git a/test/fixedbugs/bug045.go b/test/fixedbugs/bug045.go
index 37c17c1..88c005d 100644
--- a/test/fixedbugs/bug045.go
+++ b/test/fixedbugs/bug045.go
@@ -13,7 +13,7 @@
func main() {
var ta []*T;
- ta = *new(*[1]*T); // TODO: the first * shouldn't be necessary
+ ta = *new([1]*T); // TODO: the first * shouldn't be necessary
ta[0] = nil;
}
/*
diff --git a/test/fixedbugs/bug054.go b/test/fixedbugs/bug054.go
index c121fb5..0ed5d07 100644
--- a/test/fixedbugs/bug054.go
+++ b/test/fixedbugs/bug054.go
@@ -30,12 +30,12 @@
}
func main() {
- v := new(*Vector);
- v.elem = new([]Element, 10);
- t := new(*TStruct);
+ v := new(Vector);
+ v.elem = make([]Element, 10);
+ t := new(TStruct);
t.name = "hi";
v.elem[0] = t;
- s := new(*TStruct);
+ s := new(TStruct);
s.name = "foo";
s.fields = v;
if s.field(0).name != "hi" {
diff --git a/test/fixedbugs/bug058.go b/test/fixedbugs/bug058.go
index 2cfe19d..da47ae5 100644
--- a/test/fixedbugs/bug058.go
+++ b/test/fixedbugs/bug058.go
@@ -10,7 +10,7 @@
var m map[string] *Box;
func main() {
- m := new(map[string] *Box);
+ m := make(map[string] *Box);
s := "foo";
var x *Box = nil;
m[s] = x;
diff --git a/test/fixedbugs/bug059.go b/test/fixedbugs/bug059.go
index 5a29ed1..501616b 100644
--- a/test/fixedbugs/bug059.go
+++ b/test/fixedbugs/bug059.go
@@ -19,11 +19,11 @@
}
func main() {
- m := new(map[string] []string);
+ m := make(map[string] []string);
as := new([2]string);
as[0] = "0";
as[1] = "1";
- m["0"] = as;
+ m["0"] = *as;
a := m["0"];
a[0] = "x";
diff --git a/test/fixedbugs/bug060.go b/test/fixedbugs/bug060.go
index 6d558a4..124e401 100644
--- a/test/fixedbugs/bug060.go
+++ b/test/fixedbugs/bug060.go
@@ -7,7 +7,7 @@
package main
func main() {
- m := new(map[int]int);
+ m := make(map[int]int);
m[0] = 0;
m[0]++;
if m[0] != 1 {
diff --git a/test/fixedbugs/bug067.go b/test/fixedbugs/bug067.go
index 1e747eb..b812f01 100644
--- a/test/fixedbugs/bug067.go
+++ b/test/fixedbugs/bug067.go
@@ -9,7 +9,7 @@
var c chan int
func main() {
- c = new(chan int);
+ c = make(chan int);
go func() { print("ok\n"); c <- 0 } ();
<-c
}
diff --git a/test/fixedbugs/bug069.go b/test/fixedbugs/bug069.go
index 2e53846..950ba8e 100644
--- a/test/fixedbugs/bug069.go
+++ b/test/fixedbugs/bug069.go
@@ -7,12 +7,12 @@
package main
func main(){
- c := new(chan int);
+ c := make(chan int);
ok := false;
i := 0;
i, ok = <-c; // works
- ca := new(*[2]chan int);
+ ca := new([2]chan int);
i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
}
diff --git a/test/fixedbugs/bug075.go b/test/fixedbugs/bug075.go
index c1b8647..fceeef8 100644
--- a/test/fixedbugs/bug075.go
+++ b/test/fixedbugs/bug075.go
@@ -8,8 +8,8 @@
type T struct { m map[int]int }
func main() {
- t := new(*T);
- t.m = new(map[int]int);
+ t := new(T);
+ t.m = make(map[int]int);
var x int;
var ok bool;
x, ok = t.m[0]; //bug075.go:11: bad shape across assignment - cr=1 cl=2
diff --git a/test/fixedbugs/bug084.go b/test/fixedbugs/bug084.go
index 138b6da..2897593 100644
--- a/test/fixedbugs/bug084.go
+++ b/test/fixedbugs/bug084.go
@@ -17,7 +17,7 @@
var arith Service
func main() {
- c := new(chan string);
- a := new(*Service);
+ c := make(chan string);
+ a := new(Service);
go a.Serve(1234);
}
diff --git a/test/fixedbugs/bug098.go b/test/fixedbugs/bug098.go
new file mode 100644
index 0000000..8e790a7
--- /dev/null
+++ b/test/fixedbugs/bug098.go
@@ -0,0 +1,22 @@
+// $G $D/$F.go || echo BUG should compile
+
+// 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
+
+type A []int;
+type M map[int] int;
+
+func main() {
+ var a *A = &A{0};
+ var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line)
+}
+
+/*
+uetli:~/Source/go1/test/bugs gri$ 6g bug098.go && 6l bug098.6 && 6.out
+bug098.go:10: illegal types for operand: AS
+ (*MAP[<int32>INT32]<int32>INT32)
+ (**MAP[<int32>INT32]<int32>INT32)
+*/
diff --git a/test/fixedbugs/bug099.go b/test/fixedbugs/bug099.go
index 2b1776c..f76f0e8 100644
--- a/test/fixedbugs/bug099.go
+++ b/test/fixedbugs/bug099.go
@@ -18,7 +18,7 @@
// if you take it out (and the 0s below)
// then the bug goes away.
func NewI(i int) I {
- return new(*S)
+ return new(S)
}
// Uses interface method.
diff --git a/test/fixedbugs/bug102.go b/test/fixedbugs/bug102.go
index 314a37f..5848097 100644
--- a/test/fixedbugs/bug102.go
+++ b/test/fixedbugs/bug102.go
@@ -16,7 +16,7 @@
if string(b1) != "hello" {
panic("bad convert 1")
}
- var b2 = new([]byte, 5);
+ var b2 = make([]byte, 5);
for i := 0; i < 5; i++ { b2[i] = b1[i] }
if string(b2) != "hello" {
panic("bad convert 2")
diff --git a/test/fixedbugs/bug111.go b/test/fixedbugs/bug111.go
index ee61cd8..39da9b4 100644
--- a/test/fixedbugs/bug111.go
+++ b/test/fixedbugs/bug111.go
@@ -22,7 +22,7 @@
}
func main() {
- s := new(*Stucky);
+ s := new(Stucky);
i := s.Me();
j := i.Me();
j.Me();