[前][次][番号順一覧][スレッド一覧]

ruby-changes:34648

From: usa <ko1@a...>
Date: Mon, 7 Jul 2014 11:49:21 +0900 (JST)
Subject: [ruby-changes:34648] usa:r46731 (ruby_2_0_0): merge revision(s) 45845, 45847: [Backport #9786]

usa	2014-07-07 11:49:13 +0900 (Mon, 07 Jul 2014)

  New Revision: 46731

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46731

  Log:
    merge revision(s) 45845,45847: [Backport #9786]
    
    * parse.y (local_tbl_gen): remove local variables duplicated with
      arguments.
      [ruby-core:60501] [Bug #9486]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/parse.y
    branches/ruby_2_0_0/test/ruby/test_variable.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46730)
+++ ruby_2_0_0/ChangeLog	(revision 46731)
@@ -1,5 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Jul  7 11:47:51 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (local_tbl_gen): remove local variables duplicated with
+	  arguments.
+
 Thu Jul  3 15:17:22 2014  Koichi Sasada  <ko1@a...>
 
+	  [ruby-core:60501] [Bug #9486]
 	* vm.c (rb_vm_pop_cfunc_frame): added.  It cares c_return event.
 	  The patch base by drkaes (Stefan Kaes).
 	  [Bug #9321]
Index: ruby_2_0_0/parse.y
===================================================================
--- ruby_2_0_0/parse.y	(revision 46730)
+++ ruby_2_0_0/parse.y	(revision 46731)
@@ -9564,30 +9564,25 @@ local_pop_gen(struct parser_params *pars https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/parse.y#L9564
 
 #ifndef RIPPER
 static ID*
-vtable_tblcpy(ID *buf, const struct vtable *src)
-{
-    int i, cnt = vtable_size(src);
-
-    if (cnt > 0) {
-        buf[0] = cnt;
-        for (i = 0; i < cnt; i++) {
-            buf[i] = src->tbl[i];
-        }
-        return buf;
-    }
-    return 0;
-}
-
-static ID*
 local_tbl_gen(struct parser_params *parser)
 {
-    int cnt = vtable_size(lvtbl->args) + vtable_size(lvtbl->vars);
+    int cnt_args = vtable_size(lvtbl->args);
+    int cnt_vars = vtable_size(lvtbl->vars);
+    int cnt = cnt_args + cnt_vars;
+    int i, j;
     ID *buf;
 
     if (cnt <= 0) return 0;
     buf = ALLOC_N(ID, cnt + 1);
-    vtable_tblcpy(buf+1, lvtbl->args);
-    vtable_tblcpy(buf+vtable_size(lvtbl->args)+1, lvtbl->vars);
+    MEMCPY(buf+1, lvtbl->args->tbl, ID, cnt_args);
+    /* remove IDs duplicated to warn shadowing */
+    for (i = 0, j = cnt_args+1; i < cnt_vars; ++i) {
+	ID id = lvtbl->vars->tbl[i];
+	if (!vtable_included(lvtbl->args, id)) {
+	    buf[j++] = id;
+	}
+    }
+    if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1);
     buf[0] = cnt;
     return buf;
 }
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46730)
+++ ruby_2_0_0/version.h	(revision 46731)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-07-04"
-#define RUBY_PATCHLEVEL 515
+#define RUBY_RELEASE_DATE "2014-07-07"
+#define RUBY_PATCHLEVEL 516
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 7
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 7
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/test_variable.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_variable.rb	(revision 46730)
+++ ruby_2_0_0/test/ruby/test_variable.rb	(revision 46731)
@@ -83,6 +83,12 @@ class TestVariable < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_variable.rb#L83
     end.call
   end
 
+  def test_shadowing_local_variables
+    bug9486 = '[ruby-core:60501] [Bug #9486]'
+    x = tap {|x| break local_variables}
+    assert_equal([:x, :bug9486, :x], x)
+  end
+
   def test_global_variable_0
     assert_in_out_err(["-e", "$0='t'*1000;print $0"], "", /\At+\z/, [])
   end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45845,45847


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]