Commit 9a36beb2 authored by Dmitry Vyukov's avatar Dmitry Vyukov

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/3284Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent d9419218
...@@ -98,13 +98,13 @@ typecheckrange(Node *n) ...@@ -98,13 +98,13 @@ typecheckrange(Node *n)
} }
out: out:
typechecklist(n->nbody, Etop);
// second half of dance // second half of dance
n->typecheck = 1; n->typecheck = 1;
for(ll=n->list; ll; ll=ll->next) for(ll=n->list; ll; ll=ll->next)
if(ll->n->typecheck == 0) if(ll->n->typecheck == 0)
typecheck(&ll->n, Erv | Easgn); typecheck(&ll->n, Erv | Easgn);
typechecklist(n->nbody, Etop);
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment