Permalink
Browse files

Merge pull request #2169 from tsion/proc-argument-error

Use CompiledCode name in Proc/BlockEnvironment ArgumentErrors
  • Loading branch information...
2 parents baef812 + 1079afa commit 0589507d22c7d61ef333f6071eda693388fdad99 @dbussink dbussink committed Feb 23, 2013
Showing with 15 additions and 14 deletions.
  1. +2 −2 vm/builtin/block_environment.cpp
  2. +13 −12 vm/builtin/proc.cpp
@@ -380,7 +380,7 @@ namespace rubinius {
if(args.total() < 1) {
Exception* exc =
Exception::make_argument_error(state, 1, args.total(),
- state->symbol("__block__"));
+ compiled_code_->name());
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
return NULL;
@@ -399,7 +399,7 @@ namespace rubinius {
if(args.total() < 2) {
Exception* exc =
Exception::make_argument_error(state, 2, args.total(),
- state->symbol("__block__"));
+ compiled_code_->name());
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
return NULL;
View
@@ -116,7 +116,7 @@ namespace rubinius {
if(!arity_ok) {
Exception* exc =
Exception::make_argument_error(state, required, args.total(),
- state->symbol("__block__"));
+ block_->compiled_code()->name());
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
return NULL;
@@ -174,30 +174,31 @@ namespace rubinius {
bool lambda_style = !lambda_->nil_p();
int flags = 0;
+ // Since we allow Proc's to be created without setting block_, we need to check
+ // it.
+ if(block_->nil_p()) {
+ Exception* exc =
+ Exception::make_type_error(state, BlockEnvironment::type, block_, "Invalid proc style");
+ exc->locations(state, Location::from_call_stack(state, call_frame));
+ state->raise_exception(exc);
+ return NULL;
+ }
+
// Check the arity in lambda mode
if(lambda_style) {
flags = CallFrame::cIsLambda;
int required = block_->compiled_code()->required_args()->to_native();
if(args.total() < 1 || (required >= 0 && (size_t)required != args.total() - 1)) {
Exception* exc =
- Exception::make_argument_error(state, required, args.total(), state->symbol("__block__"));
+ Exception::make_argument_error(state, required, args.total(),
+ block_->compiled_code()->name());
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
return NULL;
}
}
- // Since we allow Proc's to be created without setting block_, we need to check
- // it.
- if(block_->nil_p()) {
- Exception* exc =
- Exception::make_type_error(state, BlockEnvironment::type, block_, "Invalid proc style");
- exc->locations(state, Location::from_call_stack(state, call_frame));
- state->raise_exception(exc);
- return NULL;
- }
-
return block_->call_on_object(state, call_frame, args, flags);
}
}

0 comments on commit 0589507

Please sign in to comment.