diff options
Diffstat (limited to 'src/cmd/gc/range.c')
-rw-r--r-- | src/cmd/gc/range.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/gc/range.c b/src/cmd/gc/range.c index d301e4e4f..50c4617c0 100644 --- a/src/cmd/gc/range.c +++ b/src/cmd/gc/range.c @@ -72,6 +72,15 @@ typecheckrange(Node *n) if(n->list->next) v2 = n->list->next->n; + // this is not only a optimization but also a requirement in the spec. + // "if the second iteration variable is the blank identifier, the range + // clause is equivalent to the same clause with only the first variable + // present." + if(isblank(v2)) { + n->list = list1(v1); + v2 = N; + } + if(v1->defn == n) v1->type = t1; else if(v1->type != T && assignop(t1, v1->type, &why) == 0) @@ -145,7 +154,7 @@ walkrange(Node *n) if(v2) { hp = temp(ptrto(n->type->type)); tmp = nod(OINDEX, ha, nodintconst(0)); - tmp->etype = 1; // no bounds check + tmp->bounded = 1; init = list(init, nod(OAS, hp, nod(OADDR, tmp, N))); } |