]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: more detail in import conflict error message
authorRuss Cox <rsc@golang.org>
Mon, 9 Sep 2013 16:30:53 +0000 (12:30 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 9 Sep 2013 16:30:53 +0000 (12:30 -0400)
Cannot happen when using the go command, but help
people running commands by hand or with other tools.

Fixes #5888.

R=ken2
CC=golang-dev
https://golang.org/cl/13324048

src/cmd/gc/export.c
src/cmd/gc/go.h

index ece02bc3bd02ff2df6a4cca3afde26fc02216ca2..31bcdf8e779b1db4e0e6b43da3e8383e9dc71956 100644 (file)
@@ -481,9 +481,10 @@ importvar(Sym *s, Type *t)
        if(s->def != N && s->def->op == ONAME) {
                if(eqtype(t, s->def->type))
                        return;
-               yyerror("inconsistent definition for var %S during import\n\t%T\n\t%T", s, s->def->type, t);
+               yyerror("inconsistent definition for var %S during import\n\t%T (in \"%Z\")\n\t%T (in \"%Z\")", s, s->def->type, s->importdef->path, t, importpkg->path);
        }
        n = newname(s);
+       s->importdef = importpkg;
        n->type = t;
        declare(n, PEXTERN);
 
@@ -509,11 +510,12 @@ importtype(Type *pt, Type *t)
                n = pt->nod;
                copytype(pt->nod, t);
                pt->nod = n;            // unzero nod
+               pt->sym->importdef = importpkg;
                pt->sym->lastlineno = parserline();
                declare(n, PEXTERN);
                checkwidth(pt);
        } else if(!eqtype(pt->orig, t))
-               yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt, t);
+               yyerror("inconsistent definition for type %S during import\n\t%lT (in \"%Z\")\n\t%lT (in \"%Z\")", pt->sym, pt, pt->sym->importdef->path, t, importpkg->path);
 
        if(debug['E'])
                print("import type %T %lT\n", pt, t);
index 8f0c2dfcf938c4c87aa59dfd94956d2504abc044..51f8fe67f8629d609a2907cf20c00e91da5db5a3 100644 (file)
@@ -380,6 +380,7 @@ struct      Sym
        Sym*    link;
        int32   npkg;   // number of imported packages with this name
        uint32  uniqgen;
+       Pkg*    importdef;      // where imported definition was found
 
        // saved and restored by dcopy
        Pkg*    pkg;