new new & make
R=r
OCL=22166
CL=22166
diff --git a/test/235.go b/test/235.go
index 4ff7c30..9db1017 100644
--- a/test/235.go
+++ b/test/235.go
@@ -9,8 +9,8 @@
type T chan uint64;
func M(f uint64) (in, out T) {
- in = new(T, 100);
- out = new(T, 100);
+ in = make(T, 100);
+ out = make(T, 100);
go func(in, out T, f uint64) {
for {
out <- f * <-in;
@@ -44,9 +44,9 @@
1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 };
x := uint64(1);
- ins := new([]T, n);
- outs := new([]T, n);
- xs := new([]uint64, n);
+ ins := make([]T, n);
+ outs := make([]T, n);
+ xs := make([]uint64, n);
for i := 0; i < n; i++ {
ins[i], outs[i] = M(F[i]);
xs[i] = x;
diff --git a/test/bigalg.go b/test/bigalg.go
index 748ef85..434eecf 100644
--- a/test/bigalg.go
+++ b/test/bigalg.go
@@ -45,8 +45,8 @@
}
var t = T{1.5, 123, "hello", 255}
-var mt = new(map[int]T)
-var ma = new(map[int][]int)
+var mt = make(map[int]T)
+var ma = make(map[int][]int)
func maptest() {
mt[0] = t;
@@ -62,8 +62,8 @@
}
}
-var mt1 = new(map[T]int)
-var ma1 = new(map[[]int] int)
+var mt1 = make(map[T]int)
+var ma1 = make(map[[]int] int)
func maptest2() {
mt1[t] = 123;
@@ -81,8 +81,8 @@
}
}
-var ct = new(chan T)
-var ca = new(chan []int)
+var ct = make(chan T)
+var ca = make(chan []int)
func send() {
ct <- t;
@@ -114,7 +114,7 @@
if !SameArray(a, a1) {
println("interface <-> []int", a, a1);
}
- pa := new(*[]int);
+ pa := new([]int);
*pa = a;
i = pa;
a1 = *i.(*[]int);
diff --git a/test/bugs/bug121.go b/test/bugs/bug121.go
index cea6f1b..cc960e3 100644
--- a/test/bugs/bug121.go
+++ b/test/bugs/bug121.go
@@ -21,5 +21,5 @@
func (s *S) h() {} // here we can't write (s *S) T either
func main() {
- var i I = new(*S);
+ var i I = new(S);
}
diff --git a/test/bugs/bug122.go b/test/bugs/bug122.go
index da58944..775cf73 100644
--- a/test/bugs/bug122.go
+++ b/test/bugs/bug122.go
@@ -7,5 +7,5 @@
package main
func main() {
- a := new([]int, 10, 20, 30, 40); // should allow at most 2 sizes
+ a := make([]int, 10, 20, 30, 40); // should allow at most 2 sizes
}
diff --git a/test/bugs/bug130.go b/test/bugs/bug130.go
index 6e189ca..7122863 100644
--- a/test/bugs/bug130.go
+++ b/test/bugs/bug130.go
@@ -14,7 +14,7 @@
func main() {
s := S{0};
var i I = &s;
- c := new(chan int);
+ c := make(chan int);
go i.send(c);
sys.exit(<-c);
}
diff --git a/test/chan/fifo.go b/test/chan/fifo.go
index eef494d..e190595 100644
--- a/test/chan/fifo.go
+++ b/test/chan/fifo.go
@@ -11,7 +11,7 @@
const N = 10
func AsynchFifo() {
- ch := new(chan int, N);
+ ch := make(chan int, N);
for i := 0; i < N; i++ {
ch <- i
}
@@ -33,11 +33,11 @@
// thread together a daisy chain to read the elements in sequence
func SynchFifo() {
- ch := new(chan int);
- in := new(chan int);
+ ch := make(chan int);
+ in := make(chan int);
start := in;
for i := 0; i < N; i++ {
- out := new(chan int);
+ out := make(chan int);
go Chain(ch, i, in, out);
in = out;
}
diff --git a/test/chan/goroutines.go b/test/chan/goroutines.go
index afc5ead..db76a39 100644
--- a/test/chan/goroutines.go
+++ b/test/chan/goroutines.go
@@ -28,11 +28,11 @@
sys.exit(1);
}
}
- leftmost := new(chan int);
+ leftmost := make(chan int);
right := leftmost;
left := leftmost;
for i := 0; i < n; i++ {
- right = new(chan int);
+ right = make(chan int);
go f(left, right);
left = right;
}
diff --git a/test/chan/nonblock.go b/test/chan/nonblock.go
index 4d36bdb..1c3128d 100644
--- a/test/chan/nonblock.go
+++ b/test/chan/nonblock.go
@@ -53,10 +53,10 @@
var ok bool;
for buffer := 0; buffer < 2; buffer++ {
- c32 := new(chan int32, buffer);
- c64 := new(chan int64, buffer);
- cb := new(chan bool, buffer);
- cs := new(chan string, buffer);
+ c32 := make(chan int32, buffer);
+ c64 := make(chan int64, buffer);
+ cb := make(chan bool, buffer);
+ cs := make(chan string, buffer);
i32, ok = <-c32;
if ok { panic("blocked i32sender") }
diff --git a/test/chan/powser1.go b/test/chan/powser1.go
index a010f69..6e64891 100644
--- a/test/chan/powser1.go
+++ b/test/chan/powser1.go
@@ -46,15 +46,15 @@
func mkdch() *dch {
c := chnameserial % len(chnames);
chnameserial++;
- d := new(*dch);
- d.req = new(chan int);
- d.dat = new(chan item);
+ d := new(dch);
+ d.req = make(chan int);
+ d.dat = make(chan item);
d.nam = c;
return d;
}
func mkdch2() *dch2 {
- d2 := new(*dch2);
+ d2 := new(dch2);
d2[0] = mkdch();
d2[1] = mkdch();
return d2;
@@ -93,7 +93,7 @@
seqno++;
in.req <- seqno;
- release := new(chan int);
+ release := make(chan int);
go dosplit(in, out, release);
dat := <-in.dat;
out[0].dat <- dat;
@@ -106,7 +106,7 @@
}
func split(in *dch, out *dch2){
- release := new(chan int);
+ release := make(chan int);
go dosplit(in, out, release);
release <- 0;
}
@@ -127,9 +127,9 @@
func getn(in []*dch, n int) []item {
// BUG n:=len(in);
if n != 2 { panic("bad n in getn") };
- req := new(*[2] chan int);
- dat := new(*[2] chan item);
- out := new([]item, 2);
+ req := new([2] chan int);
+ dat := new([2] chan item);
+ out := make([]item, 2);
var i int;
var it item;
for i=0; i<n; i++ {
@@ -208,7 +208,7 @@
func i2tor(u, v int64) *rat{
g := gcd(u,v);
- r := new(*rat);
+ r := new(rat);
if v > 0 {
r.num = u/g;
r.den = v/g;
@@ -246,7 +246,7 @@
func mul(u, v *rat) *rat{
g1 := gcd(u.num,v.den);
g2 := gcd(u.den,v.num);
- r := new(*rat);
+ r := new(rat);
r.num =(u.num/g1)*(v.num/g2);
r.den = (u.den/g2)*(v.den/g1);
return r;
@@ -646,7 +646,7 @@
check(Ones, one, 5, "Ones");
check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones"); // 1 1 1 1 1
check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos"); // 3 3 3 3 3
- a := new([] *rat, N);
+ a := make([] *rat, N);
d := Diff(Ones);
// BUG: want array initializer
for i:=0; i < N; i++ {
diff --git a/test/chan/powser2.go b/test/chan/powser2.go
index 5f2d1dc..14364e6 100644
--- a/test/chan/powser2.go
+++ b/test/chan/powser2.go
@@ -51,15 +51,15 @@
func mkdch() *dch {
c := chnameserial % len(chnames);
chnameserial++;
- d := new(*dch);
- d.req = new(chan int);
- d.dat = new(chan item);
+ d := new(dch);
+ d.req = make(chan int);
+ d.dat = make(chan item);
d.nam = c;
return d;
}
func mkdch2() *dch2 {
- d2 := new(*dch2);
+ d2 := new(dch2);
d2[0] = mkdch();
d2[1] = mkdch();
return d2;
@@ -98,7 +98,7 @@
seqno++;
in.req <- seqno;
- release := new(chan int);
+ release := make(chan int);
go dosplit(in, out, release);
dat := <-in.dat;
out[0].dat <- dat;
@@ -111,7 +111,7 @@
}
func split(in *dch, out *dch2){
- release := new(chan int);
+ release := make(chan int);
go dosplit(in, out, release);
release <- 0;
}
@@ -132,9 +132,9 @@
func getn(in []*dch, n int) []item {
// BUG n:=len(in);
if n != 2 { panic("bad n in getn") };
- req := new([] chan int, 2);
- dat := new([] chan item, 2);
- out := new([]item, 2);
+ req := make([] chan int, 2);
+ dat := make([] chan item, 2);
+ out := make([]item, 2);
var i int;
var it item;
for i=0; i<n; i++ {
@@ -213,7 +213,7 @@
func i2tor(u, v int64) *rat{
g := gcd(u,v);
- r := new(*rat);
+ r := new(rat);
if v > 0 {
r.num = u/g;
r.den = v/g;
@@ -251,7 +251,7 @@
func mul(u, v *rat) *rat{
g1 := gcd(u.num,v.den);
g2 := gcd(u.den,v.num);
- r := new(*rat);
+ r := new(rat);
r.num =(u.num/g1)*(v.num/g2);
r.den = (u.den/g2)*(v.den/g1);
return r;
@@ -651,7 +651,7 @@
check(Ones, one, 5, "Ones");
check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones"); // 1 1 1 1 1
check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos"); // 3 3 3 3 3
- a := new([]*rat, N);
+ a := make([]*rat, N);
d := Diff(Ones);
// BUG: want array initializer
for i:=0; i < N; i++ {
diff --git a/test/chan/select.go b/test/chan/select.go
index 3158ee6..d8a4625 100644
--- a/test/chan/select.go
+++ b/test/chan/select.go
@@ -34,8 +34,8 @@
}
func main() {
- a := new(chan uint, 1);
- b := new(chan uint, 1);
+ a := make(chan uint, 1);
+ b := make(chan uint, 1);
if v := Send(a, b); v != 2 {
panicln("Send returned", v, "!= 2");
}
diff --git a/test/chan/sieve.go b/test/chan/sieve.go
index b6bcdb3..0923ab5 100644
--- a/test/chan/sieve.go
+++ b/test/chan/sieve.go
@@ -29,19 +29,19 @@
// The prime sieve: Daisy-chain Filter processes together.
func Sieve(primes chan<- int) {
- ch := new(chan int); // Create a new channel.
+ ch := make(chan int); // Create a new channel.
go Generate(ch); // Start Generate() as a subprocess.
for {
prime := <-ch;
primes <- prime;
- ch1 := new(chan int);
+ ch1 := make(chan int);
go Filter(ch, ch1, prime);
ch = ch1
}
}
func main() {
- primes := new(chan int);
+ primes := make(chan int);
go Sieve(primes);
a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
for i := 0; i < len(a); i++ {
diff --git a/test/complit.go b/test/complit.go
index ca3c8e0..67064fe2 100644
--- a/test/complit.go
+++ b/test/complit.go
@@ -11,7 +11,7 @@
type R struct { num int }
func itor(a int) *R {
- r := new(*R);
+ r := new(R);
r.num = a;
return r;
}
@@ -48,7 +48,7 @@
at := []*T{&t, &t, &t};
if len(at) != 3 { panic("at") }
- c := new(chan int);
+ c := make(chan int);
ac := []chan int{c, c, c};
if len(ac) != 3 { panic("ac") }
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/bugs/bug098.go b/test/fixedbugs/bug098.go
similarity index 100%
rename from test/bugs/bug098.go
rename to test/fixedbugs/bug098.go
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();
diff --git a/test/func.go b/test/func.go
index 7b15f74..ee9414d 100644
--- a/test/func.go
+++ b/test/func.go
@@ -81,7 +81,7 @@
r9, s9 := f9(1);
assertequal(r9, 9, "r9");
assertequal(int(s9), 9, "s9");
- var t *T = new(*T);
+ var t *T = new(T);
t.x = 1;
t.y = 2;
r10 := t.m10(1, 3.0);
diff --git a/test/golden.out b/test/golden.out
index f1a6ad3..8ee55ef 100644
--- a/test/golden.out
+++ b/test/golden.out
@@ -111,12 +111,6 @@
bugs/bug087.go:8: illegal combination of literals LEN 9
BUG: fails incorrectly
-=========== bugs/bug098.go
-bugs/bug098.go:10: illegal types for operand: AS
- *M
- **M
-BUG should compile
-
=========== bugs/bug105.go
bugs/bug105.go:8: P: undefined
bugs/bug105.go:8: illegal types for operand: RETURN
diff --git a/test/hashmap.go b/test/hashmap.go
index d458b8c..6f70f2b 100755
--- a/test/hashmap.go
+++ b/test/hashmap.go
@@ -64,7 +64,7 @@
func (m *HashMap) Initialize (initial_log2_capacity uint32) {
m.log2_capacity_ = initial_log2_capacity;
- m.map_ = new(*[1024] Entry);
+ m.map_ = new([1024] Entry);
m.Clear();
}
@@ -157,7 +157,7 @@
func MakeNumber (x uint32) *Number {
- var n *Number = new(*Number);
+ var n *Number = new(Number);
n.x = x;
return n;
}
@@ -168,7 +168,7 @@
//print "HashMap - gri 2/8/2008\n";
- var hmap *HashMap = new(*HashMap);
+ var hmap *HashMap = new(HashMap);
hmap.Initialize(0);
var x1 *Number = MakeNumber(1001);
diff --git a/test/hilbert.go b/test/hilbert.go
index a807c3c..5410db9 100644
--- a/test/hilbert.go
+++ b/test/hilbert.go
@@ -47,10 +47,10 @@
func NewMatrix(n, m int) *Matrix {
assert(0 <= n && 0 <= m);
- a := new(*Matrix);
+ a := new(Matrix);
a.n = n;
a.m = m;
- a.a = new([]*Big.Rational, n*m);
+ a.a = make([]*Big.Rational, n*m);
return a;
}
diff --git a/test/interface1.go b/test/interface1.go
index a053ed3..649a955 100644
--- a/test/interface1.go
+++ b/test/interface1.go
@@ -28,8 +28,8 @@
}
func main() {
- re := new(*Regexp);
+ re := new(Regexp);
print("call addinst\n");
- var x Inst = AddInst(new(*Start)); // ERROR "illegal|incompatible"
+ var x Inst = AddInst(new(Start)); // ERROR "illegal|incompatible"
print("return from addinst\n");
}
diff --git a/test/ken/array.go b/test/ken/array.go
index 29b456d..2969f36 100644
--- a/test/ken/array.go
+++ b/test/ken/array.go
@@ -66,7 +66,7 @@
func
testpdpd()
{
- a := new([]int, 10, 100);
+ a := make([]int, 10, 100);
if len(a) != 10 && cap(a) != 100 {
panic("len and cap from new: ", len(a), " ", cap(a), "\n");
}
@@ -95,7 +95,7 @@
func
testpdpf1()
{
- a := new(*[40]int);
+ a := new([40]int);
setpd(*a);
res(sumpd(*a), 0, 40);
@@ -117,7 +117,7 @@
func
testpdfault()
{
- a := new([]int, 100);
+ a := make([]int, 100);
print("good\n");
for i:=0; i<100; i++ {
diff --git a/test/ken/chan.go b/test/ken/chan.go
index da08477..ba13375 100644
--- a/test/ken/chan.go
+++ b/test/ken/chan.go
@@ -38,17 +38,17 @@
func
init()
{
- nc = new(*Chan);
+ nc = new(Chan);
}
func
mkchan(c,n int) []*Chan
{
- ca := new([]*Chan, n);
+ ca := make([]*Chan, n);
for i:=0; i<n; i++ {
cval = cval+100;
- ch := new(*Chan);
- ch.sc = new(chan int, c);
+ ch := new(Chan);
+ ch.sc = make(chan int, c);
ch.rc = ch.sc;
ch.sv = cval;
ch.rv = cval;
diff --git a/test/ken/embed.go b/test/ken/embed.go
index 42e83e4..f0c9f4e 100644
--- a/test/ken/embed.go
+++ b/test/ken/embed.go
@@ -166,10 +166,10 @@
var s *S;
// allocate
- s = new(*S);
- s.Subp = new(*Subp);
- s.Sub.SubSubp = new(*SubSubp);
- s.Subp.SubpSubp = new(*SubpSubp);
+ s = new(S);
+ s.Subp = new(Subp);
+ s.Sub.SubSubp = new(SubSubp);
+ s.Subp.SubpSubp = new(SubpSubp);
// explicit assignment
s.a = 1;
diff --git a/test/ken/interfun.go b/test/ken/interfun.go
index 4ab2b8b..97db893 100644
--- a/test/ken/interfun.go
+++ b/test/ken/interfun.go
@@ -40,7 +40,7 @@
var i2 I2;
var g *S;
- s := new(*S);
+ s := new(S);
s.a = 5;
s.b = 6;
diff --git a/test/ken/intervar.go b/test/ken/intervar.go
index 711568b..1c3d650 100644
--- a/test/ken/intervar.go
+++ b/test/ken/intervar.go
@@ -58,9 +58,9 @@
func
main()
{
- p := new(*Print);
- b := new(*Bio);
- f := new(*File);
+ p := new(Print);
+ b := new(Bio);
+ f := new(File);
p.whoami = 1;
p.put = b;
diff --git a/test/ken/ptrfun.go b/test/ken/ptrfun.go
index 949cb82..e7db3a9 100644
--- a/test/ken/ptrfun.go
+++ b/test/ken/ptrfun.go
@@ -27,7 +27,7 @@
var v int;
var c *C;
- c = new(*C);
+ c = new(C);
c.a = 6;
c.x = &g;
diff --git a/test/ken/range.go b/test/ken/range.go
index 5bb6d55..2417580 100644
--- a/test/ken/range.go
+++ b/test/ken/range.go
@@ -21,8 +21,8 @@
func
init()
{
- p = new([]byte, size);
- m = new(map[int]byte);
+ p = make([]byte, size);
+ m = make(map[int]byte);
for k:=0; k<size; k++ {
v := f(k);
a[k] = v;
diff --git a/test/ken/rob1.go b/test/ken/rob1.go
index 35397b3..a75878b 100644
--- a/test/ken/rob1.go
+++ b/test/ken/rob1.go
@@ -31,7 +31,7 @@
func (list *List)
Insert(i Item)
{
- item := new(*ListItem);
+ item := new(ListItem);
item.item = i;
item.next = list.head;
list.head = item;
@@ -69,10 +69,10 @@
func
main()
{
- list := new(*List);
+ list := new(List);
list.Init();
for i := 0; i < 10; i = i + 1 {
- integer := new(*Integer);
+ integer := new(Integer);
integer.Init(i);
list.Insert(integer);
}
diff --git a/test/ken/rob2.go b/test/ken/rob2.go
index 6e14bda..1b4d86e 100644
--- a/test/ken/rob2.go
+++ b/test/ken/rob2.go
@@ -213,7 +213,7 @@
{
var slist, retval *Slist;
- slist = new(*Slist);
+ slist = new(Slist);
slist.list.car = nil;
slist.list.cdr = nil;
slist.isatom = false;
@@ -225,7 +225,7 @@
if token == ')' || token == EOF { // empty cdr
break;
}
- slist.list.cdr = new(*Slist);
+ slist.list.cdr = new(Slist);
slist = slist.list.cdr;
}
return retval;
@@ -236,7 +236,7 @@
var h, length int;
var slist, tail *Slist;
- slist = new(*Slist);
+ slist = new(Slist);
if token == '0' {
slist.atom.integer = i;
slist.isstring = false;
diff --git a/test/ken/robfunc.go b/test/ken/robfunc.go
index 947016f..12b4b6d7 100644
--- a/test/ken/robfunc.go
+++ b/test/ken/robfunc.go
@@ -86,7 +86,7 @@
r9, s9 = f9(1);
assertequal(r9, 9, "r9");
assertequal(int(s9), 9, "s9");
- var t *T = new(*T);
+ var t *T = new(T);
t.x = 1;
t.y = 2;
r10 := t.m10(1, 3.0);
diff --git a/test/ken/simparray.go b/test/ken/simparray.go
index f68ff14..90331e5 100644
--- a/test/ken/simparray.go
+++ b/test/ken/simparray.go
@@ -35,7 +35,7 @@
if s2 != 35 { panic(s2); }
- b := new(*[100]int);
+ b := new([100]int);
for i:=0; i<100; i=i+1 {
b[i] = i;
}
diff --git a/test/ken/simpbool.go b/test/ken/simpbool.go
index 28ddafe..aad111d 100644
--- a/test/ken/simpbool.go
+++ b/test/ken/simpbool.go
@@ -30,7 +30,7 @@
if !!!a { panic(6); }
var x *s;
- x = new(*s);
+ x = new(s);
x.a = true;
x.b = false;
diff --git a/test/ken/string.go b/test/ken/string.go
index 7bd402e..850ddcc 100644
--- a/test/ken/string.go
+++ b/test/ken/string.go
@@ -92,7 +92,7 @@
}
/* create string with byte array pointer */
- z2 := new(*[3]byte);
+ z2 := new([3]byte);
z2[0] = 'a';
z2[1] = 'b';
z2[2] = 'c';
diff --git a/test/mallocrep1.go b/test/mallocrep1.go
index ae54ab8..f048647 100644
--- a/test/mallocrep1.go
+++ b/test/mallocrep1.go
@@ -96,7 +96,7 @@
func main() {
flag.Parse();
- b = new([]*byte, 10000);
+ b = make([]*byte, 10000);
if flag.NArg() > 0 {
AllocAndFree(atoi(flag.Arg(0)), atoi(flag.Arg(1)));
return;
diff --git a/test/map.go b/test/map.go
index bc31bf8..caa764d 100644
--- a/test/map.go
+++ b/test/map.go
@@ -35,27 +35,27 @@
}
}
- mib := new(map[int] bool);
- mii := new(map[int] int);
- mfi := new(map[float] int);
- mif := new(map[int] float);
- msi := new(map[string] int);
- mis := new(map[int] string);
- mss := new(map[string] string);
- mspa := new(map[string] []string);
+ mib := make(map[int] bool);
+ mii := make(map[int] int);
+ mfi := make(map[float] int);
+ mif := make(map[int] float);
+ msi := make(map[string] int);
+ mis := make(map[int] string);
+ mss := make(map[string] string);
+ mspa := make(map[string] []string);
// BUG need an interface map both ways too
type T struct {
i int64; // can't use string here; struct values are only compared at the top level
f float;
};
- mipT := new(map[int] *T);
- mpTi := new(map[*T] int);
- mit := new(map[int] T);
- mti := new(map[T] int);
+ mipT := make(map[int] *T);
+ mpTi := make(map[*T] int);
+ mit := make(map[int] T);
+ mti := make(map[T] int);
type M map[int] int;
- mipM := new(map[int] M);
+ mipM := make(map[int] M);
const count = 1000;
var apT [2*count]*T;
@@ -65,14 +65,13 @@
s10 := strconv.itoa(i*10);
f := float(i);
t := T{int64(i),f};
- apT[i] = new(*T);
+ apT[i] = new(T);
apT[i].i = int64(i);
apT[i].f = f;
- apT[2*i] = new(*T); // need twice as many entries as we use, for the nonexistence check
+ apT[2*i] = new(T); // need twice as many entries as we use, for the nonexistence check
apT[2*i].i = int64(i);
apT[2*i].f = f;
- // BUG m := M{i, i+1};
- m := new(M); m[i] = i+1;
+ m := M{i: i+1};
mib[i] = (i != 0);
mii[i] = 10*i;
mfi[float(i)] = 10*i;
@@ -81,7 +80,7 @@
msi[s] = i;
mss[s] = s10;
mss[s] = s10;
- as := new([]string, arraylen);
+ as := make([]string, arraylen);
as[0] = s10;
as[1] = s10;
mspa[s] = as;
@@ -123,6 +122,9 @@
if len(mpTi) != count {
fmt.printf("len(mpTi) = %d\n", len(mpTi));
}
+ if len(mti) != count {
+ fmt.printf("len(mti) = %d\n", len(mti));
+ }
if len(mipM) != count {
fmt.printf("len(mipM) = %d\n", len(mipM));
}
@@ -172,6 +174,9 @@
if(mpTi[apT[i]] != i) {
fmt.printf("mpTi[apT[%d]] = %d\n", i, mpTi[apT[i]]);
}
+ if(mti[t] != i) {
+ fmt.printf("mti[%s] = %s\n", s, mti[t]);
+ }
if (mipM[i][i] != i + 1) {
fmt.printf("mipM[%d][%d] = %d\n", i, i, mipM[i][i]);
}
diff --git a/test/newfn.go b/test/newfn.go
index 8aacd84..fbbf942 100644
--- a/test/newfn.go
+++ b/test/newfn.go
@@ -10,5 +10,5 @@
{
f := new(()); // ERROR "new"
g := new((x int, f float) string); // ERROR "new"
- h := new(*()); // ok
+ h := new(()); // ok
}
diff --git a/test/nil.go b/test/nil.go
index 8cd8e57..1aef54b 100644
--- a/test/nil.go
+++ b/test/nil.go
@@ -30,6 +30,6 @@
c = nil;
t = nil;
i = nil;
- ta = new([]IN, 1);
+ ta = make([]IN, 1);
ta[0] = nil;
}
diff --git a/test/peano.go b/test/peano.go
index e290905..07e5f0e 100644
--- a/test/peano.go
+++ b/test/peano.go
@@ -25,7 +25,7 @@
func add1(x *Number) *Number {
- e := new(*Number);
+ e := new(Number);
e.next = x;
return e;
}
diff --git a/test/sieve.go b/test/sieve.go
index 91fa6e5..e163456 100644
--- a/test/sieve.go
+++ b/test/sieve.go
@@ -26,12 +26,12 @@
// The prime sieve: Daisy-chain Filter processes together.
func Sieve() {
- ch := new(chan int); // Create a new channel.
+ ch := make(chan int); // Create a new channel.
go Generate(ch); // Start Generate() as a subprocess.
for {
prime := <-ch;
print(prime, "\n");
- ch1 := new(chan int);
+ ch1 := make(chan int);
go Filter(ch, ch1, prime);
ch = ch1
}
diff --git a/test/test0.go b/test/test0.go
index 0a11e1d..95d2254 100644
--- a/test/test0.go
+++ b/test/test0.go
@@ -55,7 +55,7 @@
}
func control_structs() {
- var p *Point = new(*Point).Initialize(2, 3);
+ var p *Point = new(Point).Initialize(2, 3);
i := p.Distance();
var f float = 0.3;
for {}
diff --git a/test/utf.go b/test/utf.go
index 7880b5a..5905152 100644
--- a/test/utf.go
+++ b/test/utf.go
@@ -29,7 +29,7 @@
// encoded as bytes: 'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
const L = 12;
if L != l { panic("wrong length constructing array") }
- a := new(*[L]byte);
+ a := new([L]byte);
a[0] = 'a';
a[1] = 'b';
a[2] = 'c';
diff --git a/test/vectors.go b/test/vectors.go
index 921bc28..e5cbde2 100644
--- a/test/vectors.go
+++ b/test/vectors.go
@@ -31,7 +31,7 @@
func test1() {
var a [1000] *S;
for i := 0; i < len(a); i++ {
- a[i] = new(*S).Init(i);
+ a[i] = new(S).Init(i);
}
v := array.New(0);