allow range on nil maps

R=ken
OCL=26663
CL=26663
This commit is contained in:
Russ Cox 2009-03-23 18:32:37 -07:00
parent 8d44052b6d
commit 86145611b0
2 changed files with 10 additions and 0 deletions

View file

@ -870,6 +870,10 @@ sys·mapassign2(Hmap *h, ...)
void
sys·mapiterinit(Hmap *h, struct hash_iter *it)
{
if(h == nil) {
it->data = nil;
return;
}
hash_iter_init(h, it);
it->data = hash_next(it);
if(debug) {

View file

@ -487,4 +487,10 @@ func main() {
fmt.Printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i]);
}
}
// test range on nil map
var mnil map[string] int;
for x, y := range mnil {
panic("range mnil");
}
}