Commit fc557085 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2304 from ksss/class-new

Class.new do not call `class_eval'
parents ccaf3e35 1f3d7e93
......@@ -1105,7 +1105,7 @@ mrb_class_new_class(mrb_state *mrb, mrb_value cv)
}
new_class = mrb_obj_value(mrb_class_new(mrb, mrb_class_ptr(super)));
if (!mrb_nil_p(blk)) {
mrb_funcall_with_block(mrb, new_class, mrb_intern_lit(mrb, "class_eval"), 0, NULL, blk);
mrb_yield_with_class(mrb, blk, 1, &new_class, new_class, mrb_class_ptr(new_class));
}
mrb_funcall(mrb, super, "inherited", 1, new_class);
return new_class;
......
......@@ -226,8 +226,13 @@ assert('Class Dup 2') do
assert_equal(Module, M.dup.class)
end
assert('Class new') do
assert('Class.new') do
assert_equal(Class, Class.new.class)
a = []
klass = Class.new do |c|
a << c
end
assert_equal([klass], a)
end
assert('class to return the last value') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment