static int
nodefmt(Fmt *f, Node *n)
{
+ Type *t;
+
+ t = n->type;
+ if(n->orig != N)
+ n = n->orig;
- if(f->flags&FmtLong && n->type != T) {
- if(n->type->etype == TNIL)
+ if(f->flags&FmtLong && t != T) {
+ if(t->etype == TNIL)
return fmtprint(f, "nil");
else
- return fmtprint(f, "%N (type %T)", n, n->type);
-
+ return fmtprint(f, "%N (type %T)", n, t);
}
// TODO inlining produces expressions with ninits. we can't print these yet.
switch(fmtmode) {
case FErr:
case FExp:
- if(n->orig != N)
- n = n->orig;
r = nodefmt(fp, n);
break;
case FDbg:
_ = sum()
_ = sum(1.0, 2.0)
_ = sum(1.5) // ERROR "integer"
- _ = sum("hello") // ERROR ".hello. .type ideal string. as type int|incompatible"
+ _ = sum("hello") // ERROR ".hello. .type string. as type int|incompatible"
_ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
)
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2011 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 2451, 2452
+package foo
+
+func f() error { return 0 } // ERROR "cannot use 0 .type int."
+
+func g() error { return -1 } // ERROR "cannot use -1 .type int."
\ No newline at end of file
asBool(true)
asBool(*&b)
asBool(Bool(true))
- asBool(1 != 2) // ERROR "cannot use.*type ideal bool.*as type Bool"
+ asBool(1 != 2) // ERROR "cannot use.*type bool.*as type Bool"
asBool(i < j) // ERROR "cannot use.*type bool.*as type Bool"
_, b = m[2] // ERROR "cannot .* bool.*type Bool"