mirror of
https://github.com/golang/go
synced 2024-11-11 23:20:24 -07:00
fix one bug involving [...] constructors.
added iant's bug202 (in main code) and ken's bug203 (in init function). bug187 remains at large. R=ken OCL=34293 CL=34293
This commit is contained in:
parent
5db1d3867f
commit
a1391c2d13
@ -199,9 +199,12 @@ dowidth(Type *t)
|
||||
if(t->type == T)
|
||||
break;
|
||||
dowidth(t->type);
|
||||
w = sizeof_Array;
|
||||
if(t->bound >= 0)
|
||||
w = t->bound * t->type->width;
|
||||
else if(t->bound == -1)
|
||||
w = sizeof_Array;
|
||||
else
|
||||
fatal("dowidth %T", t); // probably [...]T
|
||||
break;
|
||||
|
||||
case TSTRUCT:
|
||||
|
@ -1061,6 +1061,8 @@ Tpretty(Fmt *fp, Type *t)
|
||||
case TARRAY:
|
||||
if(t->bound >= 0)
|
||||
return fmtprint(fp, "[%d]%T", (int)t->bound, t->type);
|
||||
if(t->bound == -100)
|
||||
return fmtprint(fp, "[...]%T", t->type);
|
||||
return fmtprint(fp, "[]%T", t->type);
|
||||
|
||||
case TINTER:
|
||||
|
@ -159,7 +159,8 @@ reswitch:
|
||||
n->type = t;
|
||||
n->left = N;
|
||||
n->right = N;
|
||||
checkwidth(t);
|
||||
if(t->bound != -100)
|
||||
checkwidth(t);
|
||||
break;
|
||||
|
||||
case OTMAP:
|
||||
|
16
test/fixedbugs/bug202.go
Normal file
16
test/fixedbugs/bug202.go
Normal file
@ -0,0 +1,16 @@
|
||||
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should run
|
||||
|
||||
// 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 f() {
|
||||
v := [...]string{"a", "b"};
|
||||
}
|
||||
func main() {
|
||||
f();
|
||||
}
|
||||
|
||||
|
||||
|
20
test/fixedbugs/bug203.go
Normal file
20
test/fixedbugs/bug203.go
Normal file
@ -0,0 +1,20 @@
|
||||
// $G $D/$F.go && $L $F.$A && ./$A.out
|
||||
|
||||
// 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
|
||||
|
||||
var s [8]string
|
||||
|
||||
func
|
||||
init()
|
||||
{
|
||||
s = [...]string{ "now", "is", "the", "time", "to", "fix", "this", "bug"}
|
||||
}
|
||||
|
||||
func
|
||||
main()
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user