Project

General

Profile

Bug #5966 ยป 0001-Bug-5966-lambda-in-BasicObject.patch

nobu (Nobuyoshi Nakada), 02/11/2012 06:56 AM

View differences:

compile.c
ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(0))
#define ADD_CALL_RECEIVER(seq, line) \
ADD_INSN((seq), (line), putnil)
ADD_INSN((seq), (line), putself)
#define ADD_CALL(seq, line, id, argc) \
ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
......
/* compile same as lambda{...} */
VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node));
VALUE argc = INT2FIX(0);
ADD_CALL_RECEIVER(ret, nd_line(node));
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
if (poped) {
insns.def
ID id = op_id;
/* get receiver */
recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
recv = TOPN(num);
klass = CLASS_OF(recv);
me = vm_method_search(id, klass, ic);
CALL_METHOD(num, blockptr, flag, id, me, recv);
test/ruby/test_lambda.rb
def foo
assert_equal(nil, ->(&b){ b }.call)
end
def test_in_basic_object
bug5966 = '[ruby-core:42349]'
called = false
BasicObject.new.instance_eval {->() {called = true}.()}
assert_equal(true, called, bug5966)
end
end
    (1-1/1)