Commit e7f89fcb authored by Luuk van Dijk's avatar Luuk van Dijk

cmd/gc: fix strict tree property for AST for OAS2RECV nodes.

in typecheck and walk, conversion from OAS2RECV to OAS2
and to OSELRECV2 duplicated the ->rlist->n to ->right
thereby destroying the strict tree-ness of the AST (up to
ONAMES) of course.  Several recursions in esc.c and inl.c
and probably elsewhere assume nodes of the tree aren't duplicated.
rather than defensively code around this, i'd rather assert
these cases away and fix their cause.

(this was tripped in 6741044)

R=rsc
CC=golang-dev
https://golang.org/cl/6750043
parent 9714691a
...@@ -62,7 +62,7 @@ typecheckselect(Node *sel) ...@@ -62,7 +62,7 @@ typecheckselect(Node *sel)
case OAS2RECV: case OAS2RECV:
// convert x, ok = <-c into OSELRECV2(x, <-c) with ntest=ok // convert x, ok = <-c into OSELRECV2(x, <-c) with ntest=ok
if(n->right->op != ORECV) { if(n->rlist->n->op != ORECV) {
yyerror("select assignment must have receive on right hand side"); yyerror("select assignment must have receive on right hand side");
break; break;
} }
...@@ -70,6 +70,7 @@ typecheckselect(Node *sel) ...@@ -70,6 +70,7 @@ typecheckselect(Node *sel)
n->left = n->list->n; n->left = n->list->n;
n->ntest = n->list->next->n; n->ntest = n->list->next->n;
n->right = n->rlist->n; n->right = n->rlist->n;
n->rlist = nil;
break; break;
case ORECV: case ORECV:
...@@ -146,7 +147,7 @@ walkselect(Node *sel) ...@@ -146,7 +147,7 @@ walkselect(Node *sel)
a = nod(OAS2, N, N); a = nod(OAS2, N, N);
a->list = n->list; a->list = n->list;
a->rlist = n->rlist; a->rlist = list1(n->right);
n = a; n = a;
typecheck(&n, Etop); typecheck(&n, Etop);
break; break;
......
...@@ -2574,7 +2574,6 @@ typecheckas2(Node *n) ...@@ -2574,7 +2574,6 @@ typecheckas2(Node *n)
goto common; goto common;
case ORECV: case ORECV:
n->op = OAS2RECV; n->op = OAS2RECV;
n->right = n->rlist->n;
goto common; goto common;
case ODOTTYPE: case ODOTTYPE:
n->op = OAS2DOTTYPE; n->op = OAS2DOTTYPE;
......
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