Skip to content
Browse files

* id.c (Init_id): add underscore name.

* parse.y (warn_unused_var): ignore underscore name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 14a15f8 commit d31350f827b02bbbd5154e8a34cbe55c49240af9 @nobu nobu committed Jun 20, 2010
Showing with 12 additions and 6 deletions.
  1. +5 −1 ChangeLog
  2. +1 −0 id.c
  3. +2 −4 parse.y
  4. +4 −1 template/id.h.tmpl
View
6 ChangeLog
@@ -1,4 +1,8 @@
-Sun Jun 20 15:14:05 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 20 16:17:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * id.c (Init_id): add underscore name.
+
+ * parse.y (warn_unused_var): ignore underscore name.
* parse.y (warn_unused_var): use same format as shadowing local
variable.
View
1 id.c
@@ -47,4 +47,5 @@ Init_id(void)
REGISTER_SYMID(idSend, "send");
REGISTER_SYMID(id__send__, "__send__");
REGISTER_SYMID(idInitialize, "initialize");
+ REGISTER_SYMID(idUScore, "_");
}
View
6 parse.y
@@ -8229,10 +8229,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
static ID
shadowing_lvar_gen(struct parser_params *parser, ID name)
{
- ID uscore;
-
- CONST_ID(uscore, "_");
- if (uscore == name) return name;
+ if (idUScore == name) return name;
if (dyna_in_block()) {
if (dvar_curr(name)) {
yyerror("duplicated argument name");
@@ -8935,6 +8932,7 @@ warn_unused_var(struct parser_params *parser, struct local_vars *local)
}
for (i = 0; i < cnt; ++i) {
if (!v[i] || (u[i] & LVAR_USED)) continue;
+ if (idUScore == v[i]) continue;
rb_compile_warn(ruby_sourcefile, (int)u[i], "assigned but unused variable - %s", rb_id2name(v[i]));
}
}
View
5 template/id.h.tmpl
@@ -100,6 +100,7 @@ enum ruby_method_ids {
tSend,
t__send__,
tInitialize,
+ tUScore,
#if SUPPORT_JOKE
tBitblt,
tAnswer,
@@ -120,7 +121,9 @@ enum ruby_method_ids {
TOKEN2ID(Lambda),
TOKEN2ID(Send),
TOKEN2ID(__send__),
- TOKEN2ID(Initialize)
+ TOKEN2ID(Initialize),
+ TOKEN2ID(UScore),
+ TOKEN2ID(LAST_ID)
};
#ifdef tLAST_TOKEN

0 comments on commit d31350f

Please sign in to comment.
Something went wrong with that request. Please try again.