Skip to content

Commit

Permalink
* eval.c (proc_eq): avoid false positive by using scope and
Browse files Browse the repository at this point in the history
  dyna_vars.  no longer use frame.uniq.

* eval.c (proc_arity): arity is now defined as number of
  parameters that would not be ignored. i.e. Proc.new{}.arity
  returns zero.  update test suites too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 18, 2004
1 parent 311fdfd commit c223709
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ Thu Mar 18 17:46:35 2004 Masatoshi SEKI <[email protected]>

* lib/drb/drb.rb: do not undef :to_a.

Thu Mar 18 16:22:38 2004 Yukihiro Matsumoto <[email protected]>

* eval.c (proc_eq): avoid false positive by using scope and
dyna_vars. no longer use frame.uniq.

* eval.c (proc_arity): arity is now defined as number of
parameters that would not be ignored. i.e. Proc.new{}.arity
returns zero. update test suites too.

Thu Mar 18 15:27:25 2004 Yukihiro Matsumoto <[email protected]>

* eval.c: remove specialized version of rb_Array(). use simple
Expand Down
6 changes: 3 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -8160,9 +8160,8 @@ proc_arity(proc)
data->body->nd_cfnc == bmcall) {
return method_arity(data->body->nd_tval);
}
return INT2FIX(-1);
return INT2FIX(0);
}
if (!(data->flags & BLOCK_LAMBDA)) return INT2FIX(-1);
if (data->var == (NODE*)1) return INT2FIX(0);
if (data->var == (NODE*)2) return INT2FIX(0);
switch (nd_type(data->var)) {
Expand Down Expand Up @@ -8202,7 +8201,8 @@ proc_eq(self, other)
Data_Get_Struct(other, struct BLOCK, data2);
if (data->body != data2->body) return Qfalse;
if (data->var != data2->var) return Qfalse;
if (data->frame.uniq != data2->frame.uniq) return Qfalse;
if (data->scope != data2->scope) return Qfalse;
if (data->dyna_vars != data2->dyna_vars) return Qfalse;
if (data->flags != data2->flags) return Qfalse;

return Qtrue;
Expand Down
2 changes: 1 addition & 1 deletion lib/drb/drb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def __drbref
end

undef :to_s
undef :to_a if respond_to?(:respond_to)
undef :to_a if respond_to?(:to_a)
undef :respond_to?

# Routes method calls to the referenced object.
Expand Down
2 changes: 1 addition & 1 deletion lib/yaml/rubytypes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def is_complex_yaml?
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
out << "!ruby/range "
self.to_s.to_yaml( :Emitter => out )
self.to_s.to_yaml(:Emitter => out)
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_iterator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def test_ljump

block = get_block{11}
lambda = lambda{44}
assert_equal(-1, block.arity)
assert_equal(-1, lambda.arity)
assert_equal(0, block.arity)
assert_equal(0, lambda.arity)
assert_equal(0, lambda{||}.arity)
assert_equal(1, lambda{|a|}.arity)
assert_equal(1, lambda{|a,|}.arity)
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def assert_arity(n)
end

def test_arity
assert_equal(-1, proc{}.arity)
assert_equal(0, proc{}.arity)
assert_equal(0, proc{||}.arity)
assert_equal(1, proc{|x|}.arity)
assert_equal(2, proc{|x, y|}.arity)
assert_equal(-2, proc{|x, *y|}.arity)
assert_equal(-1, proc{|*x|}.arity)
assert_equal(-1, proc{|*|}.arity)

assert_arity(-1) {}
assert_arity(0) {}
assert_arity(0) {||}
assert_arity(1) {|x|}
assert_arity(2) {|x, y|}
Expand Down

0 comments on commit c223709

Please sign in to comment.