ruby-changes:49648
From: mame <ko1@a...>
Date: Thu, 11 Jan 2018 12:23:56 +0900 (JST)
Subject: [ruby-changes:49648] mame:r61764 (trunk): parse.y (local_push_gen): Rewrite the condition of "unused var" warning
mame 2018-01-11 12:23:50 +0900 (Thu, 11 Jan 2018) New Revision: 61764 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61764 Log: parse.y (local_push_gen): Rewrite the condition of "unused var" warning It was unnecessarily too complex, IMO. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 61763) +++ parse.y (revision 61764) @@ -1094,7 +1094,7 @@ static void token_info_pop_gen(struct pa https://github.com/ruby/ruby/blob/trunk/parse.y#L1094 program : { SET_LEX_STATE(EXPR_BEG); /*%%%*/ - local_push(compile_for_eval || in_main); + local_push(1); /*% local_push(0); %*/ @@ -10641,17 +10641,22 @@ warn_unused_var(struct parser_params *pa https://github.com/ruby/ruby/blob/trunk/parse.y#L10641 } static void -local_push_gen(struct parser_params *parser, int inherit_dvars) +local_push_gen(struct parser_params *parser, int toplevel_scope) { struct local_vars *local; + int inherits_dvars = toplevel_scope && (compile_for_eval || in_main /* is in_main really needed? */); + int warn_unused_vars = RTEST(ruby_verbose); local = ALLOC(struct local_vars); local->prev = lvtbl; local->args = vtable_alloc(0); - local->vars = vtable_alloc(inherit_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE); - local->used = !(inherit_dvars && - (ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) && - RTEST(ruby_verbose) ? vtable_alloc(0) : 0; + local->vars = vtable_alloc(inherits_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE); +#ifndef RIPPER + if (toplevel_scope && compile_for_eval) warn_unused_vars = 0; + if (toplevel_scope && e_option_supplied(parser)) warn_unused_vars = 0; +#endif + local->used = warn_unused_vars ? vtable_alloc(0) : 0; + # if WARN_PAST_SCOPE local->past = 0; # endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/