diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index be3f0b9cb72..047ae099288 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -338,7 +338,7 @@ walkexpr(Node *n, int top, NodeList **init) NodeList *ll, *lr; Type *t; Sym *s; - int et, cl, cr, typeok; + int et, cl, cr, typeok, op; int32 lno; if(n == N) @@ -1252,7 +1252,10 @@ reswitch: * ======== second switch ======== */ - switch(n->op) { + op = n->op; + if(op == OASOP) + op = n->etype; + switch(op) { default: fatal("walkexpr: switch 2 unknown op %N", n, init); goto ret; @@ -1423,7 +1426,10 @@ badt: badtype(n->op, n->left->type, T); goto ret; } - badtype(n->op, n->left->type, n->right->type); + op = n->op; + if(op == OASOP) + op = n->etype; + badtype(op, n->left->type, n->right->type); goto ret; ret: diff --git a/test/fixedbugs/bug172.go b/test/fixedbugs/bug172.go new file mode 100644 index 00000000000..2ee26148f1c --- /dev/null +++ b/test/fixedbugs/bug172.go @@ -0,0 +1,12 @@ +// errchk $G $D/$F.go + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func f() { + a := true; + a |= a; // ERROR "illegal.*OR" +}