ruby-changes:57575
From: Nobuyoshi <ko1@a...>
Date: Fri, 6 Sep 2019 09:06:13 +0900 (JST)
Subject: [ruby-changes:57575] 3754e15530 (master): Warn local variables which conflict with new numbered parameters
https://git.ruby-lang.org/ruby.git/commit/?id=3754e15530 From 3754e155309ed430250781c616a6e52b54ef511d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 29 Aug 2019 22:07:45 +0900 Subject: Warn local variables which conflict with new numbered parameters diff --git a/defs/id.def b/defs/id.def index 9b3fb00..6bfce29 100644 --- a/defs/id.def +++ b/defs/id.def @@ -57,6 +57,19 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L57 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? diff --git a/parse.y b/parse.y index 63d8f53..602c572 100644 --- a/parse.y +++ b/parse.y @@ -11652,6 +11652,10 @@ arg_var(struct parser_params *p, ID id) https://github.com/ruby/ruby/blob/trunk/parse.y#L11652 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); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/