mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
iseq.c: fix parameter of unnamed rest keywords argument
* iseq.c (rb_iseq_parameters): push argument type symbol only for unnamed rest keywords argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7fd58845d9
commit
4398093755
4 changed files with 50 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Dec 25 20:30:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* iseq.c (rb_iseq_parameters): push argument type symbol only for
|
||||
unnamed rest keywords argument.
|
||||
|
||||
Wed Dec 25 20:28:48 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if
|
||||
|
|
6
iseq.c
6
iseq.c
|
@ -2015,10 +2015,8 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
|
|||
}
|
||||
rb_ary_push(args, a);
|
||||
}
|
||||
if (rb_id2str(iseq->local_table[iseq->arg_keyword])) {
|
||||
CONST_ID(keyrest, "keyrest");
|
||||
rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest));
|
||||
}
|
||||
CONST_ID(keyrest, "keyrest");
|
||||
rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest));
|
||||
}
|
||||
if (iseq->arg_block != -1) {
|
||||
CONST_ID(block, "block");
|
||||
|
|
|
@ -491,6 +491,13 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters)
|
||||
assert_equal([[:req], [:block, :b]], method(:ma1).parameters)
|
||||
assert_equal([[:keyrest]], method(:mk1).parameters)
|
||||
assert_equal([[:keyrest, :o]], method(:mk2).parameters)
|
||||
assert_equal([[:req, :a], [:keyrest, :o]], method(:mk3).parameters)
|
||||
assert_equal([[:opt, :a], [:keyrest, :o]], method(:mk4).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:mk5).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:mk6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters)
|
||||
end
|
||||
|
||||
def test_unbound_parameters
|
||||
|
@ -505,6 +512,13 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters)
|
||||
assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters)
|
||||
assert_equal([[:keyrest]], self.class.instance_method(:mk1).parameters)
|
||||
assert_equal([[:keyrest, :o]], self.class.instance_method(:mk2).parameters)
|
||||
assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:mk3).parameters)
|
||||
assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:mk4).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:mk5).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:mk6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters)
|
||||
end
|
||||
|
||||
def test_bmethod_bound_parameters
|
||||
|
@ -519,6 +533,13 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters)
|
||||
assert_equal([[:req], [:block, :b]], method(:pma1).parameters)
|
||||
assert_equal([[:keyrest]], method(:pmk1).parameters)
|
||||
assert_equal([[:keyrest, :o]], method(:pmk2).parameters)
|
||||
assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).parameters)
|
||||
assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).parameters)
|
||||
end
|
||||
|
||||
def test_bmethod_unbound_parameters
|
||||
|
@ -533,6 +554,14 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters)
|
||||
assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
|
||||
assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
|
||||
assert_equal([[:keyrest]], self.class.instance_method(:pmk1).parameters)
|
||||
assert_equal([[:keyrest, :o]], self.class.instance_method(:pmk2).parameters)
|
||||
assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:pmk3).parameters)
|
||||
assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:pmk4).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:pmk5).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:pmk6).parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:pmk7).parameters)
|
||||
end
|
||||
|
||||
def test_public_method_with_zsuper_method
|
||||
|
|
|
@ -1104,6 +1104,13 @@ class TestProc < Test::Unit::TestCase
|
|||
def pmo6(a, *b, c, &d) end
|
||||
def pmo7(a, b = :b, *c, d, &e) end
|
||||
def pma1((a), &b) a; end
|
||||
def pmk1(**) end
|
||||
def pmk2(**o) nil && o end
|
||||
def pmk3(a, **o) nil && o end
|
||||
def pmk4(a = nil, **o) nil && o end
|
||||
def pmk5(a, b = nil, **o) nil && o end
|
||||
def pmk6(a, b = nil, c, **o) nil && o end
|
||||
def pmk7(a, b = nil, *c, d, **o) nil && o end
|
||||
|
||||
|
||||
def test_bound_parameters
|
||||
|
@ -1118,6 +1125,13 @@ class TestProc < Test::Unit::TestCase
|
|||
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters)
|
||||
assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters)
|
||||
assert_equal([[:keyrest]], method(:pmk1).to_proc.parameters)
|
||||
assert_equal([[:keyrest, :o]], method(:pmk2).to_proc.parameters)
|
||||
assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).to_proc.parameters)
|
||||
assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).to_proc.parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).to_proc.parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).to_proc.parameters)
|
||||
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).to_proc.parameters)
|
||||
|
||||
assert_equal([], "".method(:upcase).to_proc.parameters)
|
||||
assert_equal([[:rest]], "".method(:gsub).to_proc.parameters)
|
||||
|
|
Loading…
Reference in a new issue