FAQ
Thank you for posting that.

I spent the last 2 minutes reading this thread going, wtf, if you're that
convinced it shouldn't be an error, just patch the source.

I'm glad to see someone here is actually willing to do more than just
complain about the things that bug them.

(No, I'm not endorsing using a fragmented version of go, I'm just saying,
its refreshing to see someone actually pickup the challenge of trying to
fix something that irritates them, rather than just complain. I wonder if
anyone will implement generics... :)

~
Doug.
On Saturday, March 16, 2013 12:55:50 AM UTC+8, Nicolas Sebrecht wrote:
On Thu, Mar 14, 2013 at 09:35:32PM +0100, Nicolas Sebrecht wrote:
On Thu, Mar 14, 2013 at 05:55:50PM +0000, Sam Harwell wrote:

1. Go's compiler is open source and the license permits such
alteration
2. If not already done by someone else, I plan personally create
the fork (perhaps for internal use only) the next time we get a contract
working with a Go project. Naturally our deliverables would compile without
warnings, but we are highly productive during rapid prototyping and the Go
compiler proved extremely cumbersome in practice last time we were working
with it.
If such initiative is made public I would be one of the users. Honestly,
I would even be very happy with only floating patches to apply on my
own. ;-)
Here is a starting point. The current patch turns compiler errors for
unused
stuff into warnings. It looks to work fine for me. Not widely tested, yet.

Also, the patch definetly turns errors into warnings. No option is exposed
to
the user.

Now, I'll be happy to hack with go. ,-)

Applies fine on top of go1.0.3 (changeset 16127:70d1d0a4bcab to be exact).


diff -r d5666bad617d src/cmd/gc/lex.c
--- a/src/cmd/gc/lex.c Thu Sep 27 15:36:22 2012 -0700
+++ b/src/cmd/gc/lex.c Fri Mar 15 18:47:10 2013 +0100
@@ -2200,7 +2200,7 @@
// errors if a conflicting
top-level name is
// introduced by a different file.
if(!s->def->used &&
!nsyntaxerrors)
- yyerrorl(s->def->lineno,
"imported and not used: \"%Z\"", s->def->pkg->path);
+ warnl(s->def->lineno,
"imported and not used: \"%Z\"", s->def->pkg->path);
s->def = N;
continue;
}
@@ -2208,7 +2208,7 @@
// throw away top-level name left
over
// from previous import . "x"
if(s->def->pack != N &&
!s->def->pack->used && !nsyntaxerrors) {
-
yyerrorl(s->def->pack->lineno, "imported and not used: \"%Z\"",
s->def->pack->pkg->path);
+
warnl(s->def->pack->lineno, "imported and not used: \"%Z\"",
s->def->pack->pkg->path);
s->def->pack->used = 1;
}
s->def = N;
diff -r d5666bad617d src/cmd/gc/subr.c
--- a/src/cmd/gc/subr.c Thu Sep 27 15:36:22 2012 -0700
+++ b/src/cmd/gc/subr.c Fri Mar 15 18:47:10 2013 +0100
@@ -400,7 +400,7 @@
}
if(n == 0) {
// can't possibly be used - there were no symbols
- yyerrorl(pack->lineno, "imported and not used: \"%Z\"",
opkg->path);
+ warnl(pack->lineno, "imported and not used: \"%Z\"",
opkg->path);
}
}

diff -r d5666bad617d src/cmd/gc/walk.c
--- a/src/cmd/gc/walk.c Thu Sep 27 15:36:22 2012 -0700
+++ b/src/cmd/gc/walk.c Fri Mar 15 18:47:10 2013 +0100
@@ -94,11 +94,11 @@
if(l->n->defn->left->used)
continue;
lineno = l->n->defn->left->lineno;
- yyerror("%S declared and not used", l->n->sym);
+ warn("%S declared and not used", l->n->sym);
l->n->defn->left->used = 1; // suppress repeats
} else {
lineno = l->n->lineno;
- yyerror("%S declared and not used", l->n->sym);
+ warn("%S declared and not used", l->n->sym);
}
}

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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase