Skip to content

Commit

Permalink
Fix some cases for method#arity and proc#arity
Browse files Browse the repository at this point in the history
  • Loading branch information
kronos committed Feb 11, 2010
1 parent 0b35b16 commit b1f731d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/common/block_environment.rb
Expand Up @@ -53,7 +53,7 @@ def call_on_instance(obj, *args)
end

def arity
if method.splat >= 0 or method.splat == -2
if method.splat and (method.splat >= 0 or method.splat == -2)
-(method.required_args + 1)
else
method.required_args
Expand Down
4 changes: 4 additions & 0 deletions lib/compiler/ast/sends.rb
Expand Up @@ -384,6 +384,7 @@ def initialize(line, arguments)
array = []
case arguments
when Fixnum
@splat_index = nil
@arity = 0
@prelude = nil
when MAsgn
Expand All @@ -402,10 +403,12 @@ def initialize(line, arguments)
@arity = -1
end
elsif arguments.left
@splat_index = nil
@prelude = :multi
@arity = arguments.left.body.size
@required_args = arguments.left.body.size
else
@splat_index = 0
@prelude = :multi
@arity = -1
end
Expand All @@ -423,6 +426,7 @@ def initialize(line, arguments)
@prelude = nil
@block = arguments
else # Assignment
@splat_index = nil
@arguments = arguments
@arity = 1
@required_args = 1
Expand Down

0 comments on commit b1f731d

Please sign in to comment.