diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-18 08:06:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-18 08:06:09 +0000 |
commit | 35d7953c8d8954ab18ec5a0f7c14983e1095c1a3 (patch) | |
tree | 418d0474a05ef29bba0c8c7b6c0fed18488c5ff6 | |
parent | 6dbd9680c233f6b373150ba9ddc992a19886bdef (diff) | |
download | ruby-35d7953c8d8954ab18ec5a0f7c14983e1095c1a3.tar.gz ruby-35d7953c8d8954ab18ec5a0f7c14983e1095c1a3.tar.xz ruby-35d7953c8d8954ab18ec5a0f7c14983e1095c1a3.zip |
* parse.y (f_rest_arg): store rest args into invisible local variabe
in order to get rid of SEGV at ZSUPER. [ruby-dev:24913]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 68 |
3 files changed, 74 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Thu Nov 18 17:05:01 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (f_rest_arg): store rest args into invisible local variabe + in order to get rid of SEGV at ZSUPER. [ruby-dev:24913] + Thu Nov 18 14:58:42 2004 Shugo Maeda <shugo@ruby-lang.org> * ext/readline/readline.c: check $SAFE. @@ -3973,7 +3973,7 @@ f_rest_arg : restarg_mark tIDENTIFIER | restarg_mark { /*%%%*/ - $$ = -2; + $$ = local_append((ID)0); /*% $$ = dispatch1(restparam, Qnil); %*/ diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb new file mode 100644 index 000000000..ec0f8b608 --- /dev/null +++ b/test/ruby/test_super.rb @@ -0,0 +1,68 @@ +require 'test/unit' + +class TestSuper < Test::Unit::TestCase + class Base + def single(a) a end + def double(a, b) [a,b] end + def array(*a) a end + end + class Single1 < Base + def single(*) super end + end + class Single2 < Base + def single(a,*) super end + end + class Double1 < Base + def double(*) super end + end + class Double2 < Base + def double(a,*) super end + end + class Double3 < Base + def double(a,b,*) super end + end + class Array1 < Base + def array(*) super end + end + class Array2 < Base + def array(a,*) super end + end + class Array3 < Base + def array(a,b,*) super end + end + class Array4 < Base + def array(a,b,c,*) super end + end + + def test_single1 + assert_equal(1, Single1.new.single(1)) + end + def test_single2 + assert_equal(1, Single2.new.single(1)) + end + def test_double1 + assert_equal([1, 2], Double1.new.double(1, 2)) + end + def test_double2 + assert_equal([1, 2], Double2.new.double(1, 2)) + end + def test_double3 + assert_equal([1, 2], Double3.new.double(1, 2)) + end + def test_array1 + assert_equal([], Array1.new.array()) + assert_equal([1], Array1.new.array(1)) + end + def test_array2 + assert_equal([1], Array2.new.array(1)) + assert_equal([1,2], Array2.new.array(1, 2)) + end + def test_array3 + assert_equal([1,2], Array3.new.array(1, 2)) + assert_equal([1,2,3], Array3.new.array(1, 2, 3)) + end + def test_array4 + assert_equal([1,2,3], Array4.new.array(1, 2, 3)) + assert_equal([1,2,3,4], Array4.new.array(1, 2, 3, 4)) + end +end |