Forum: Ruby-core [ruby-trunk - Bug #6899][Open] Flip flop operator broken in IRB (1.9.3, win/osx)

5df4fb8df70a66b6568863ee6ee10cc9?d=identicon&s=25 Schwarze (Matthias Schwarze) (Guest)
on 2012-08-20 20:53
(Received via mailing list)
Issue #6899 has been reported by Schwarze (Matthias Schwarze).

----------------------------------------
Bug #6899: Flip flop operator broken in IRB (1.9.3, win/osx)
https://bugs.ruby-lang.org/issues/6899

Author: Schwarze (Matthias Schwarze)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
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
`<main>'
F24ff61beb80aa5f13371aa22a35619c?d=identicon&s=25 mame (Yusuke Endoh) (Guest)
on 2012-11-04 02:20
(Received via mailing list)
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 `<main>'

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 <mame@tsg.ne.jp>
----------------------------------------
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
`<main>'
60d06f7560160f3ce7aa3877596da63f?d=identicon&s=25 bkabrda (Bohuslav Kabrda) (Guest)
on 2012-11-30 14:03
(Received via mailing list)
Issue #6899 has been updated by bkabrda (Bohuslav Kabrda).


I'm experiencing this issue on ruby-1.9.3p327 during test suite run on
armv7:

31) Failure:
test_literal_in_conditional(TestParse)
[/builddir/build/BUILD/ruby-1.9.3-p327/test/ruby/test_parse.rb:787]:
Exception raised:
<#<NotImplementedError: method `eql?' called on hidden T_STRING object
(0x4d72e38 flags=0x2805 klass=0x0)>>.

The above patch fixes the issue.
----------------------------------------
Bug #6899: Flip flop operator broken in IRB (1.9.3, win/osx)
https://bugs.ruby-lang.org/issues/6899#change-34219

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
`<main>'
This topic is locked and can not be replied to.