fix bug198.
R=ken
OCL=35504
CL=35507
if(n->right != N) {
typecheck(&n->right, Etype);
n->type = n->right->type;
+ if(n->type == T) {
+ *t0 = T;
+ return t0;
+ }
if(n->left != N)
n->left->type = n->type;
n->right = N;
t = typ(et);
t->funarg = funarg;
stotype(l, et, &t->type);
+ if(t->type == T && l != nil) {
+ t->broke = 1;
+ return t;
+ }
if(!funarg)
checkwidth(t);
return t;
uchar copyany;
uchar local; // created in this file
uchar deferwidth;
+ uchar broke;
Node* nod; // canonical OTYPE node
int lineno;
n->typecheck = 2;
redo:
- if(n->sym)
- walkdef(n);
-
lno = setlineno(n);
+ if(n->sym) {
+ walkdef(n);
+ if(n->op == ONONAME)
+ goto error;
+ }
reswitch:
ok = 0;
ok |= Erv;
if(t->outtuple == 1) {
t = getoutargx(l->type)->type;
+ if(t == T)
+ goto error;
if(t->etype == TFIELD)
t = t->type;
n->type = t;
lno = lineno;
+ if(tstruct->broke)
+ goto out;
+
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
if(n->type->etype == TSTRUCT && n->type->funarg) {
setlineno(n);
memset(hash, 0, sizeof hash);
- // TODO: dup detection
l = typecheck(&n->right /* sic */, Etype /* TODO | Edotarray */);
if((t = l->type) == T)
goto error;
typecheck(&l->right, Erv);
continue;
}
+ l->left = newname(l->left->sym);
l->left->typecheck = 1;
f = lookdot1(l->left->sym, t, t->type);
typecheck(&l->right, Erv);
// license that can be found in the LICENSE file.
package main
-func f(a T) T { return a } // ERROR "T"
+func f(a T) T { return a } // ERROR "undefined"
func main() {
x := f(0);
+ _ = x;
}
--- /dev/null
+// 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
+
+type T struct
+{
+ f int;
+}
+
+var _ = T{f: 1}
+
+// 6g used to get confused by the f:1 above
+// and allow uses of f that would be silently
+// dropped during the compilation.
+var _ = f; // ERROR "undefined"
+
too many calls: 5
panic PC=xxx
BUG: bug196
-
-=========== bugs/bug198.go
-bugs/bug198.go:8: undefined: T
-bugs/bug198.go:8: T is not a type
-bugs/bug198.go:8: too many arguments to return
-bugs/bug198.go:10: too many arguments to CALL
-BUG: errchk: compiler crashed