}
ret = AMEM;
for(t1=t->type; t1!=T; t1=t1->down) {
+ if(isblanksym(t1->sym))
+ continue;
a = algtype1(t1->type, bad);
if(a == ANOEQ)
return ANOEQ; // not comparable
int
isblank(Node *n)
+{
+ if(n == N)
+ return 0;
+ return isblanksym(n->sym);
+}
+
+int
+isblanksym(Sym *s)
{
char *p;
- if(n == N || n->sym == S)
+ if(s == S)
return 0;
- p = n->sym->name;
+ p = s->name;
if(p == nil)
return 0;
return p[0] == '_' && p[1] == '\0';
// and calling specific hash functions for the others.
first = T;
for(t1=t->type;; t1=t1->down) {
- if(t1 != T && algtype1(t1->type, nil) == AMEM) {
+ if(t1 != T && (isblanksym(t1->sym) || algtype1(t1->type, nil) == AMEM)) {
if(first == T)
first = t1;
continue;
}
// Run memhash for fields up to this one.
+ while(first != T && isblanksym(first->sym))
+ first = first->down;
if(first != T) {
if(first->down == t1)
size = first->type->width;
// and calling specific equality tests for the others.
first = T;
for(t1=t->type;; t1=t1->down) {
- if(t1 != T && algtype1(t1->type, nil) == AMEM) {
+ if(t1 != T && (isblanksym(t1->sym) || algtype1(t1->type, nil) == AMEM)) {
if(first == T)
first = t1;
continue;
// Run memequal for fields up to this one.
// TODO(rsc): All the calls to newname are wrong for
// cross-package unexported fields.
+ while(first != T && isblanksym(first->sym))
+ first = first->down;
if(first != T) {
if(first->down == t1) {
fn->nbody = list(fn->nbody, eqfield(np, nq, newname(first->sym), neq));
} else if(first->down->down == t1) {
fn->nbody = list(fn->nbody, eqfield(np, nq, newname(first->sym), neq));
first = first->down;
- fn->nbody = list(fn->nbody, eqfield(np, nq, newname(first->sym), neq));
+ if(!isblanksym(first->sym))
+ fn->nbody = list(fn->nbody, eqfield(np, nq, newname(first->sym), neq));
} else {
// More than two fields: use memequal.
if(t1 == T)
var t3 T3
+type T4 struct { _ []int; a float64 }
+
+var t4 T4
+
func main() {
// Arguments to comparison must be
// assignable one to the other (or vice versa)
// Comparison of structs should have a good message
use(t3 == t3) // ERROR "struct|expected"
+ use(t4 == t4) // ok; the []int is a blank field
// Slices, functions, and maps too.
var x []int