* 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
This commit is contained in:
parent
14a15f8b7f
commit
d31350f827
@ -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
|
* parse.y (warn_unused_var): use same format as shadowing local
|
||||||
variable.
|
variable.
|
||||||
|
1
id.c
1
id.c
@ -47,4 +47,5 @@ Init_id(void)
|
|||||||
REGISTER_SYMID(idSend, "send");
|
REGISTER_SYMID(idSend, "send");
|
||||||
REGISTER_SYMID(id__send__, "__send__");
|
REGISTER_SYMID(id__send__, "__send__");
|
||||||
REGISTER_SYMID(idInitialize, "initialize");
|
REGISTER_SYMID(idInitialize, "initialize");
|
||||||
|
REGISTER_SYMID(idUScore, "_");
|
||||||
}
|
}
|
||||||
|
6
parse.y
6
parse.y
@ -8229,10 +8229,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
|
|||||||
static ID
|
static ID
|
||||||
shadowing_lvar_gen(struct parser_params *parser, ID name)
|
shadowing_lvar_gen(struct parser_params *parser, ID name)
|
||||||
{
|
{
|
||||||
ID uscore;
|
if (idUScore == name) return name;
|
||||||
|
|
||||||
CONST_ID(uscore, "_");
|
|
||||||
if (uscore == name) return name;
|
|
||||||
if (dyna_in_block()) {
|
if (dyna_in_block()) {
|
||||||
if (dvar_curr(name)) {
|
if (dvar_curr(name)) {
|
||||||
yyerror("duplicated argument 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) {
|
for (i = 0; i < cnt; ++i) {
|
||||||
if (!v[i] || (u[i] & LVAR_USED)) continue;
|
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]));
|
rb_compile_warn(ruby_sourcefile, (int)u[i], "assigned but unused variable - %s", rb_id2name(v[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ enum ruby_method_ids {
|
|||||||
tSend,
|
tSend,
|
||||||
t__send__,
|
t__send__,
|
||||||
tInitialize,
|
tInitialize,
|
||||||
|
tUScore,
|
||||||
#if SUPPORT_JOKE
|
#if SUPPORT_JOKE
|
||||||
tBitblt,
|
tBitblt,
|
||||||
tAnswer,
|
tAnswer,
|
||||||
@ -120,7 +121,9 @@ enum ruby_method_ids {
|
|||||||
TOKEN2ID(Lambda),
|
TOKEN2ID(Lambda),
|
||||||
TOKEN2ID(Send),
|
TOKEN2ID(Send),
|
||||||
TOKEN2ID(__send__),
|
TOKEN2ID(__send__),
|
||||||
TOKEN2ID(Initialize)
|
TOKEN2ID(Initialize),
|
||||||
|
TOKEN2ID(UScore),
|
||||||
|
TOKEN2ID(LAST_ID)
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef tLAST_TOKEN
|
#ifdef tLAST_TOKEN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user