1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:57:57 -07:00

gc: Switch related errors should use plain format.

Fixes #2422.

R=rsc
CC=golang-dev
https://golang.org/cl/5353046
This commit is contained in:
Luuk van Dijk 2011-11-06 22:13:54 +01:00
parent c171633780
commit 0d6f857c3f
2 changed files with 4 additions and 4 deletions

View File

@ -825,7 +825,7 @@ typecheckswitch(Node *n)
typecheck(&n->ntest->right, Erv); typecheck(&n->ntest->right, Erv);
t = n->ntest->right->type; t = n->ntest->right->type;
if(t != T && t->etype != TINTER) if(t != T && t->etype != TINTER)
yyerror("cannot type switch on non-interface value %+N", n->ntest->right); yyerror("cannot type switch on non-interface value %lN", n->ntest->right);
} else { } else {
// value switch // value switch
top = Erv; top = Erv;
@ -860,13 +860,13 @@ typecheckswitch(Node *n)
if(ll->n->op == OTYPE) if(ll->n->op == OTYPE)
yyerror("type %T is not an expression", ll->n->type); yyerror("type %T is not an expression", ll->n->type);
else if(ll->n->type != T && !eqtype(ll->n->type, t)) else if(ll->n->type != T && !eqtype(ll->n->type, t))
yyerror("case %+N in %T switch", ll->n, t); yyerror("case %lN in %T switch", ll->n, t);
break; break;
case Etype: // type switch case Etype: // type switch
if(ll->n->op == OLITERAL && istype(ll->n->type, TNIL)) { if(ll->n->op == OLITERAL && istype(ll->n->type, TNIL)) {
; ;
} else if(ll->n->op != OTYPE && ll->n->type != T) { } else if(ll->n->op != OTYPE && ll->n->type != T) {
yyerror("%#N is not a type", ll->n); yyerror("%lN is not a type", ll->n);
// reset to original type // reset to original type
ll->n = n->ntest->right; ll->n = n->ntest->right;
} }

View File

@ -10,7 +10,7 @@ package main
func main() { func main() {
var x interface{} var x interface{}
switch t := x.(type) { // GC_ERROR "0 is not a type" switch t := x.(type) { // GC_ERROR "is not a type"
case 0: // GCCGO_ERROR "expected type" case 0: // GCCGO_ERROR "expected type"
t.x = 1 // ERROR "type interface \{\}|reference to undefined field or method" t.x = 1 // ERROR "type interface \{\}|reference to undefined field or method"
} }