diff --git a/defs/id.def b/defs/id.def index f0e1db90dc..a35b5d55f9 100644 --- a/defs/id.def +++ b/defs/id.def @@ -60,7 +60,6 @@ firstline, predefined = __LINE__+1, %[\ _ UScore # MUST be successive - _0 NUMPARAM_0 _1 NUMPARAM_1 _2 NUMPARAM_2 _3 NUMPARAM_3 diff --git a/parse.y b/parse.y index 48dd44a197..14568d98c3 100644 --- a/parse.y +++ b/parse.y @@ -173,9 +173,16 @@ enum { NUMPARAM_MAX = 9, }; -#define NUMPARAM_ID_P(id) (is_local_id(id) && NUMPARAM_ID_TO_IDX(id) <= NUMPARAM_MAX) -#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_0) -#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_0 + (idx))) +#define NUMPARAM_ID_P(id) numparam_id_p(id) +#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_1 + 1) +#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 + (idx) - 1)) +static int +numparam_id_p(ID id) +{ + if (!is_local_id(id)) return 0; + unsigned int idx = NUMPARAM_ID_TO_IDX(id); + return idx > 0 && idx <= NUMPARAM_MAX; +} #define DVARS_INHERIT ((void*)1) #define DVARS_TOPSCOPE NULL diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 662ab3d7fe..4cb56f66f0 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -60,7 +60,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal '[ref(true)]', parse('true') assert_equal '[vcall(_0)]', parse('_0') assert_equal '[vcall(_1)]', parse('_1') - assert_include parse('proc{_0}'), '[ref(_0)]' assert_include parse('proc{_1}'), '[ref(_1)]' end