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
208 208
  ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(0))
209 209

  
210 210
#define ADD_CALL_RECEIVER(seq, line) \
211
  ADD_INSN((seq), (line), putnil)
211
  ADD_INSN((seq), (line), putself)
212 212

  
213 213
#define ADD_CALL(seq, line, id, argc) \
214 214
  ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
......
5068 5068
	/* compile same as lambda{...} */
5069 5069
	VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node));
5070 5070
	VALUE argc = INT2FIX(0);
5071
	ADD_CALL_RECEIVER(ret, nd_line(node));
5071
	ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
5072 5072
	ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
5073 5073

  
5074 5074
	if (poped) {
insns.def
1009 1009
    ID id = op_id;
1010 1010

  
1011 1011
    /* get receiver */
1012
    recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
1012
    recv = TOPN(num);
1013 1013
    klass = CLASS_OF(recv);
1014 1014
    me = vm_method_search(id, klass, ic);
1015 1015
    CALL_METHOD(num, blockptr, flag, id, me, recv);
test/ruby/test_lambda.rb
63 63
  def foo
64 64
    assert_equal(nil, ->(&b){ b }.call)
65 65
  end
66

  
67
  def test_in_basic_object
68
    bug5966 = '[ruby-core:42349]'
69
    called = false
70
    BasicObject.new.instance_eval {->() {called = true}.()}
71
    assert_equal(true, called, bug5966)
72
  end
66 73
end
67
-