typecheckrange(n);
goto ret;
- case OTYPECASE:
- ok |= Etop | Erv;
- typecheck(&n->left, Erv);
- goto ret;
-
case OTYPESW:
yyerror("use of .(type) outside type switch");
goto error;
expandmeth(f2->sym, f2);
f2 = lookdot1(s, f2, f2->xmethod, dostrcmp);
+ if(f2 == T)
+ return 0;
// disallow T.m if m requires *T receiver
if(isptr[getthisx(f2->type)->type->type->etype]
tn = n->type->type;
for(tl=tstruct->type; tl; tl=tl->down) {
if(tl->isddd) {
- for(; tn; tn=tn->down)
+ for(; tn; tn=tn->down) {
+ exportassignok(tn->type, desc);
if(assignop(tn->type, tl->type->type, &why) == 0)
yyerror("cannot use %T as type %T in %s%s", tn->type, tl->type->type, desc, why);
+ }
goto out;
}
if(tn == T)
goto notenough;
+ exportassignok(tn->type, desc);
if(assignop(tn->type, tl->type, &why) == 0)
yyerror("cannot use %T as type %T in %s%s", tn->type, tl->type, desc, why);
tn = tn->down;
goto notenough;
if(nl->next != nil)
goto toomany;
- if(assignop(nl->n->type, t, &why) == 0)
- yyerror("ddd cannot use %+N as type %T in %s%s", nl->n, t, desc, why);
+ n = nl->n;
+ setlineno(n);
+ if(n->type != T)
+ nl->n = assignconv(n, t, desc);
goto out;
}
for(; nl; nl=nl->next) {
+ n = nl->n;
setlineno(nl->n);
- defaultlit(&nl->n, t->type);
- if(assignop(nl->n->type, t->type, &why) == 0)
- yyerror("cannot use %+N as type %T in %s%s", nl->n, t->type, desc, why);
+ if(n->type != T)
+ nl->n = assignconv(n, t->type, desc);
}
goto out;
}
--- /dev/null
+// $G $D/$F.go
+
+// Copyright 2010 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.
+
+// issue 1016
+
+package main
+
+func foo(t interface{}, c chan int) {
+ switch v := t.(type) {
+ case int:
+ select {
+ case <-c:
+ // bug was: internal compiler error: var without type, init: v
+ }
+ }
+}