[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev-en:127

From: John Turner <xennocide yahoo.com>
Date: Wed, 21 Jun 2006 00:28:31 -0700 (PDT)
Subject: [yarv-dev-en:127] open> Range bug.

There's a fairly small bug in range.c that means that a Float step size
of between 0 and 1 raises an erroneous exception:

irb(main):007:0> RUBY_VERSION
=> "2.0.0"
irb(main):008:0> (0.0..1.0).step(0.1){|i| puts i}
ArgumentError: step can't be 0
        from (irb):8:in `step'
        from (irb):8
        from /usr/local/lib/ruby/2.0/irb.rb:150:in `block (2 levels) in
eval_input'
        from /usr/local/lib/ruby/2.0/irb.rb:259:in `signal_status'
        from /usr/local/lib/ruby/2.0/irb.rb:147:in `block in
eval_input'
        from /usr/local/lib/ruby/2.0/irb.rb:146:in `eval_input'
        from /usr/local/lib/ruby/2.0/irb.rb:70:in `block in start'
        from /usr/local/lib/ruby/2.0/irb.rb:69:in `catch'
        from /usr/local/lib/ruby/2.0/irb.rb:69:in `start'
        from /usr/local/bin/irb:13:in `<main>'

vs:

irb(main):005:0> RUBY_VERSION
=> "1.8.4"
irb(main):006:0> (0.0..1.0).step(0.1){|i| puts i}
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
=> 0.0..1.0

This is caused by checking:

306    unit = NUM2LONG(step);
...
310    if (unit == 0)
311	rb_raise(rb_eArgError, "step can't be 0");

too early.

Easiest fix for this would be to just put it back like it is in 1.8,
where the check was done for each type of range rather than
universally, with the different check for Numeric types other than
Fixnum, which still exists in yarv, but is now redundant.

Hope this is the right format for a bug report, not made any to the
list before.

---
John Turner

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
ML: yarv-dev-en quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

->     127 2006-06-21 16:28 [xennocide yahoo.com ] open> Range bug.                        
       128 2006-06-21 16:33 ┗[ko1 atdot.net       ]                                       
       144 2006-07-14 20:49  ┗[xennocide yahoo.com ]