Created
February 9, 2010 22:28
-
-
Save kronos/299766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e6c56f266af3e0ab6906d9b6ddc4c182f833375f Mon Sep 17 00:00:00 2001 | |
From: Ivan Samsonov <[email protected]> | |
Date: Wed, 10 Feb 2010 01:09:53 +0300 | |
Subject: [PATCH] Fix Block#arity | |
--- | |
kernel/common/block_environment.rb | 2 +- | |
lib/compiler/ast/sends.rb | 4 ++++ | |
2 files changed, 5 insertions(+), 1 deletions(-) | |
diff --git a/kernel/common/block_environment.rb b/kernel/common/block_environment.rb | |
index 03ff90b..09ddc82 100644 | |
--- a/kernel/common/block_environment.rb | |
+++ b/kernel/common/block_environment.rb | |
@@ -53,7 +53,7 @@ module Rubinius | |
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 | |
diff --git a/lib/compiler/ast/sends.rb b/lib/compiler/ast/sends.rb | |
index 3355979..11e4c89 100644 | |
--- a/lib/compiler/ast/sends.rb | |
+++ b/lib/compiler/ast/sends.rb | |
@@ -384,6 +384,7 @@ module Rubinius | |
array = [] | |
case arguments | |
when Fixnum | |
+ @splat_index = nil | |
@arity = 0 | |
@prelude = nil | |
when MAsgn | |
@@ -402,10 +403,12 @@ module Rubinius | |
@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 | |
@@ -423,6 +426,7 @@ module Rubinius | |
@prelude = nil | |
@block = arguments | |
else # Assignment | |
+ @splat_index = nil | |
@arguments = arguments | |
@arity = 1 | |
@required_args = 1 | |
-- | |
1.6.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment