mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Warn local variables which conflict with new numbered parameters
This commit is contained in:
parent
092f31e7e2
commit
3754e15530
2 changed files with 17 additions and 0 deletions
13
defs/id.def
13
defs/id.def
|
@ -57,6 +57,19 @@ firstline, predefined = __LINE__+1, %[\
|
|||
nil
|
||||
|
||||
_ UScore
|
||||
|
||||
# MUST be successive
|
||||
_0 NUMPARAM_0
|
||||
_1 NUMPARAM_1
|
||||
_2 NUMPARAM_2
|
||||
_3 NUMPARAM_3
|
||||
_4 NUMPARAM_4
|
||||
_5 NUMPARAM_5
|
||||
_6 NUMPARAM_6
|
||||
_7 NUMPARAM_7
|
||||
_8 NUMPARAM_8
|
||||
_9 NUMPARAM_9
|
||||
|
||||
"/*NULL*/" NULL
|
||||
empty?
|
||||
eql?
|
||||
|
|
4
parse.y
4
parse.y
|
@ -11652,6 +11652,10 @@ arg_var(struct parser_params *p, ID id)
|
|||
static void
|
||||
local_var(struct parser_params *p, ID id)
|
||||
{
|
||||
if (id >= idNUMPARAM_0 && id <= idNUMPARAM_9) {
|
||||
rb_warn1("`_%d' is used as numbered parameter",
|
||||
WARN_I((int)(id - idNUMPARAM_0)));
|
||||
}
|
||||
vtable_add(p->lvtbl->vars, id);
|
||||
if (p->lvtbl->used) {
|
||||
vtable_add(p->lvtbl->used, (ID)p->ruby_sourceline);
|
||||
|
|
Loading…
Add table
Reference in a new issue