summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-07 15:34:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-07 15:34:31 +0000
commit9481face427a93e1a557ecd980ec82f5d04da8d5 (patch)
tree62cdfef0f5cf342039ea74934348a4de34d77007 /eval.c
parenta4c37a4b7fb14c1eb81cbd3226761c522f3a49bc (diff)
* parse.y (value_expr0): class and module statements should not be
warned for "void value expression". [ruby-talk:72989] * gc.c (add_final): should determine type by respond_to? * gc.c (define_final): ditto. * io.c (rb_io_ctl): should not depend on respond_to? * range.c (range_step): rb_check_string_type(). * process.c (proc_setgroups): new functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/eval.c b/eval.c
index 11e470a..101a271 100644
--- a/eval.c
+++ b/eval.c
@@ -6838,14 +6838,15 @@ block_alloc(klass, proc)
struct RVarmap *vars;
if (!rb_block_given_p() && !rb_f_block_given_p()) {
- rb_raise(rb_eArgError, "tried to create Block object without a block");
+ rb_raise(rb_eArgError, "tried to create %s object without a block",
+ proc ? "Proc" : "Block");
+ }
+ if (proc && !rb_block_given_p()) {
+ rb_warn("tried to create Proc object without a block");
}
- if (ruby_block->block_obj) {
- if ((proc && (ruby_block->flags & BLOCK_PROC)) ||
- (!proc && !(ruby_block->flags & BLOCK_PROC)))
- return ruby_block->block_obj;
- ruby_block->flags &= ~BLOCK_PROC;
+ if (!proc && ruby_block->block_obj) {
+ return ruby_block->block_obj;
}
block = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
*data = *ruby_block;
@@ -6873,9 +6874,10 @@ block_alloc(klass, proc)
block_save_safe_level(block);
if (proc) {
data->flags |= BLOCK_PROC;
- ruby_block->flags |= BLOCK_PROC;
}
- ruby_block->block_obj = block;
+ else {
+ ruby_block->block_obj = block;
+ }
return block;
}
@@ -6895,12 +6897,7 @@ block_s_new(argc, argv, klass)
VALUE
rb_block_new()
{
- if (ruby_block->flags & BLOCK_PROC) {
- return block_alloc(rb_cProc, Qtrue);
- }
- else {
- return block_alloc(rb_cBlock, Qfalse);
- }
+ return block_alloc(rb_cBlock, Qfalse);
}
static VALUE