diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-29 22:07:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-06 09:02:12 +0900 |
commit | 3754e155309ed430250781c616a6e52b54ef511d (patch) | |
tree | 6bd60f672da679421968e7577363b11b48e58795 | |
parent | 092f31e7e23c0ee04df987f0c0f979d036971804 (diff) | |
download | ruby-3754e155309ed430250781c616a6e52b54ef511d.tar.gz |
Warn local variables which conflict with new numbered parameters
-rw-r--r-- | defs/id.def | 13 | ||||
-rw-r--r-- | parse.y | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/defs/id.def b/defs/id.def index 9b3fb00ce8..6bfce29a9d 100644 --- a/defs/id.def +++ b/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? @@ -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); |