cmd/gc: fix range typecheck order

Typecheck for range variables before typechecking for range body.
Body can refer to new vars declared in for range,
so it is preferable to typecheck them before the body.
Makes typecheck order consistent between ORANGE and OFOR.

This come up during another change that computes some predicates
on variables during typechecking.

Change-Id: Ic975db61b1fd5b7f9ee78896d4cc7d93c593c532
Reviewed-on: https://go-review.googlesource.com/3284
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Dmitry Vyukov 2015-01-26 16:43:20 +03:00
parent d94192180f
commit 9a36beb2af
1 changed files with 2 additions and 2 deletions

View File

@ -98,13 +98,13 @@ typecheckrange(Node *n)
}
out:
typechecklist(n->nbody, Etop);
// second half of dance
n->typecheck = 1;
for(ll=n->list; ll; ll=ll->next)
if(ll->n->typecheck == 0)
typecheck(&ll->n, Erv | Easgn);
typechecklist(n->nbody, Etop);
}
void