Type**
stotype(NodeList *l, int et, Type **t)
{
- Type *f, *t1;
+ Type *f, *t1, **t0;
Strlit *note;
int lno;
NodeList *init;
Node *n;
+ t0 = t;
init = nil;
lno = lineno;
for(; l; l=l->next) {
f->sym = f->nname->sym;
if(pkgimportname != S && !exportname(f->sym->name))
f->sym = pkglookup(f->sym->name, structpkg);
+ if(f->sym) {
+ for(t1=*t0; t1!=T; t1=t1->down) {
+ if(t1->sym == f->sym) {
+ yyerror("duplicate field %s", t1->sym->name);
+ break;
+ }
+ }
+ }
}
*t = f;
-// ! $G $D/$F.go || echo BUG: compilation succeeds incorrectly
+// errchk $G $D/$F.go
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
package main
type T struct {
- x, x int // this should be a compile-time error
+ x, x int // ERROR "duplicate"
}
/*
/* Condensed e-mail thread:
----------- Russ Cox
+---------- Russ Cox
I don't think this is an error as long as you don't refer to x. I like the fact that you could name
multiple elements in the struct "pad".
== bugs/
-=========== bugs/bug132.go
-BUG: compilation succeeds incorrectly
-
=========== bugs/bug136.go
BUG: errchk: command succeeded unexpectedly