From: "mame (Yusuke Endoh)" Date: 2012-11-04T10:19:59+09:00 Subject: [ruby-core:48833] [ruby-trunk - Bug #6899][Assigned] Flip flop operator broken in IRB (1.9.3, win/osx) Issue #6899 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to nobu (Nobuyoshi Nakada) Target version set to 2.0.0 Confirmed. Good catch! A simplified example: $ ruby -e 'eval("x = 1; " + "if x==1..x==2;end;" * 1000000)' -e:1:in `eval': method `eql?' called on hidden T_STRING object (0x000000210d9488 flags=0x2805 klass=0x0) (NotImplementedError) from -e:1:in `eval' from -e:1:in `
' I guess that this is caused by the "hidden string" for flipflop's internal variable name. The following patch stops the exception, though it makes the string visible for ObjectSpace. Nobu, what do you think? diff --git a/compile.c b/compile.c index 16bfcef..3924948 100644 --- a/compile.c +++ b/compile.c @@ -4965,7 +4965,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) RSTRING_PTR(iseq->location.label), (void *)iseq, iseq->compile_data->flip_cnt++); - hide_obj(key); + rb_obj_freeze(key); iseq_add_mark_object_compile_time(iseq, key); ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0)); ADD_INSNL(ret, nd_line(node), branchif, lend); -- Yusuke Endoh ---------------------------------------- Bug #6899: Flip flop operator broken in IRB (1.9.3, win/osx) https://bugs.ruby-lang.org/issues/6899#change-32322 Author: Schwarze (Matthias Schwarze) Status: Assigned Priority: Normal Assignee: nobu (Nobuyoshi Nakada) Category: Target version: 2.0.0 ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0] IRB *sometimes* fails with "NotImplementedError: method `eql?' called on hidden T_STRING object" When running this code in IRB, you either get the correct bunch of "345..." or you get the error message above: 2000.times do 20.times do |x| print x if x==3..x==5 end end You may have to repeat the command several times to get the error! This does not seem to happen when running this as a script with ruby - just with IRB! Fresh install of ruby 1.9.3p194 (windows 7: OneClickInstaller / OSX: RVM) No gems installed or loaded! Full stack trace: NotImplementedError: method `eql?' called on hidden T_STRING object (0x007f9fd18f2460 flags=0x2805 klass=0x0) from (irb):46:in `block (2 levels) in irb_binding' from (irb):46:in `times' from (irb):46:in `block in irb_binding' from (irb):46:in `times' from (irb):46 from /Users/schwarze/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `
' -- http://bugs.ruby-lang.org/