Skip to content

Commit

Permalink
Merge pull request #1358 from krekoten/core_module_define_method_19
Browse files Browse the repository at this point in the history
Check for args number in methods created by Module#define_method
  • Loading branch information
rue committed Oct 25, 2011
2 parents db32bc2 + edf6f1d commit 80e8429
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 0 additions & 3 deletions spec/tags/19/ruby/core/module/define_method_tags.txt

This file was deleted.

9 changes: 6 additions & 3 deletions vm/builtin/block_as_method.cpp
Expand Up @@ -10,6 +10,8 @@

#include "object_utils.hpp"

#include "configuration.hpp"

namespace rubinius {
BlockAsMethod* BlockAsMethod::create(STATE, Object* self, BlockEnvironment* be) {
BlockAsMethod* pe = state->new_object<BlockAsMethod>(as<Class>(self));
Expand All @@ -35,7 +37,7 @@ namespace rubinius {
* -------------|---------------|-------|-------
* { || } | 0 | nil | ==
* { } | 0 | -2 | none
* { |a| } | 1 | nil | none
* { |a| } | 1 | nil | none (1.8), == (>= 1.9)
* { |*a| } | 0 | 0 | none
* { |a, b| } | 2 | nil | ==
* { |a, *b| } | 1 | 1 | >=
Expand All @@ -45,8 +47,9 @@ namespace rubinius {
* no arguments are passed). This is handled by the bytecode prologue
* of the block.
*/
if((splat->nil_p() && (required == 0 || required > 1)
&& (size_t)required != args.total())
if((splat->nil_p()
&& ((LANGUAGE_18_ENABLED(state) && (required == 0 || required > 1)) || !LANGUAGE_18_ENABLED(state))
&& (size_t)required != args.total())
|| (!splat->nil_p() && required > 0 && (size_t)required > args.total())) {
Exception* exc =
Exception::make_argument_error(state, required, args.total(), args.name());
Expand Down

0 comments on commit 80e8429

Please sign in to comment.