FAQ
Reviewers: ken2,

Message:
Hello ken2 (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go/


Description:
cmd/gc: fix imported and not used error for import .

Fixes issues 6420.

Please review this at https://codereview.appspot.com/13703044/

Affected files (+4, -3 lines):
    M src/cmd/gc/lex.c
    M test/import1.go


Index: src/cmd/gc/lex.c
===================================================================
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -2296,7 +2296,7 @@
     elem++;
    else
     elem = path->s;
- if(strcmp(elem, name) == 0)
+ if(name == nil || strcmp(elem, name) == 0)
     yyerrorl(lineno, "imported and not used: \"%Z\"", path);
    else
     yyerrorl(lineno, "imported and not used: \"%Z\" as %s", path, name);
@@ -2335,7 +2335,7 @@
        // throw away top-level name left over
        // from previous import . "x"
        if(s->def->pack != N && !s->def->pack->used && !nsyntaxerrors) {
- pkgnotused(s->def->pack->lineno, s->def->pack->pkg->path, s->name);
+ pkgnotused(s->def->pack->lineno, s->def->pack->pkg->path, nil);
         s->def->pack->used = 1;
        }
        s->def = N;
Index: test/import1.go
===================================================================
--- a/test/import1.go
+++ b/test/import1.go
@@ -14,5 +14,6 @@

   import (
    "fmt" // GCCGO_ERROR "previous|not used"
- fmt "math" // ERROR "redeclared|redefinition|incompatible" "imported and
not used"
+ fmt "math" // ERROR "redeclared|redefinition|incompatible" "imported and
not used: \x22math\x22 as fmt"
+ . "math" // ERROR "imported and not used: \x22math\x22$"
   )


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rsc at Sep 20, 2013 at 7:25 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=d7f09de722b6 ***

    cmd/gc: fix imported and not used error for import .

    Fixes issues 6420.

    R=ken2
    CC=golang-dev
    https://codereview.appspot.com/13703044


    https://codereview.appspot.com/13703044/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ken at Sep 20, 2013 at 10:42 pm

    On 2013/09/20 19:25:48, rsc wrote:
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=d7f09de722b6 ***
    cmd/gc: fix imported and not used error for import .
    Fixes issues 6420.
    R=ken2
    CC=golang-dev
    https://codereview.appspot.com/13703044
    lgtm


    https://codereview.appspot.com/13703044/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 20, '13 at 7:25p
activeSep 20, '13 at 10:42p
posts3
users2
websitegolang.org

2 users in discussion

Rsc: 2 posts Ken: 1 post

People

Translate

site design / logo © 2022 Grokbase