[#24105] [Bug #1711] Marshal Failing to Round-Trip Certain Recurisve Data Structures — Run Paint Run Run <redmine@...>

Bug #1711: Marshal Failing to Round-Trip Certain Recurisve Data Structures

9 messages 2009/07/01

[#24116] [Bug #1715] Numeric#arg for NaN is Inconsistent Across Versions — Run Paint Run Run <redmine@...>

Bug #1715: Numeric#arg for NaN is Inconsistent Across Versions

10 messages 2009/07/02

[#24240] [Bug #1755] IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8 — Run Paint Run Run <redmine@...>

Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8

8 messages 2009/07/09

[#24321] [Bug #1773] Gem path doesn't honor user gem? — Lin Jen-Shin <redmine@...>

Bug #1773: Gem path doesn't honor user gem?

12 messages 2009/07/14

[#24390] [Feature #1784] More encoding (Big5 series) support? — Lin Jen-Shin <redmine@...>

Feature #1784: More encoding (Big5 series) support?

12 messages 2009/07/16

[#24467] Re: [ruby-cvs:31226] Ruby:r24008 (ruby_1_8_6): Removed private on to_date and to_datetime. — Urabe Shyouhei <shyouhei@...>

Hello.

10 messages 2009/07/21

[#24472] [Feature #1800] rubygems can replace system executable files — Kazuhiro NISHIYAMA <redmine@...>

Feature #1800: rubygems can replace system executable files

13 messages 2009/07/21

[#24530] [Feature #1811] Default BasicSocket.do_not_reverse_lookup to true — Roger Pack <redmine@...>

Feature #1811: Default BasicSocket.do_not_reverse_lookup to true

9 messages 2009/07/23

[#24624] [Bug #1844] Immediates Should Not Respond to :dup — Run Paint Run Run <redmine@...>

Bug #1844: Immediates Should Not Respond to :dup

15 messages 2009/07/30

[ruby-core:24225] [Bug #1750] Inconsistent Behavior on 1.8 and 1.9 of String#[]= with Single Fixnum Argument

From: Run Paint Run Run <redmine@...>
Date: 2009-07-09 02:30:58 UTC
List: ruby-core #24225
Bug #1750: Inconsistent Behavior on 1.8 and 1.9 of String#[]= with Single Fixnum Argument
http://redmine.ruby-lang.org/issues/show/1750

Author: Run Paint Run Run
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.2dev (2009-07-08 trunk 23995) [i686-linux]

Brian Ford posted the following to [ruby-core:23706], but it seems to have been passed over, so I'm submitting it as a ticket. Hopefully we can clarify this behaviour, then get the affected RubySpec tests fixed. :-)

####

String[]= behaves differently on 1.8 and 1.9 when given a single
Fixnum argument == to the size of the string. Given the following
code:

$ cat string.rb
s = ""
p s[0]

s[0,0] = "a"
p s

s = ""
s[0] = "a"
p s

s = "x"
s[1] = "a"
p s

these are the results:

$ ruby -vw string.rb
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
nil
"a"
string.rb:8:in `[]=': index 0 out of string (IndexError)
       from string.rb:8

$ ruby1.8 -vw string.rb
ruby 1.8.8dev (2009-06-04 revision 23638) [i386-darwin9.7.0]
nil
"a"
string.rb:8:in `[]=': index 0 out of string (IndexError)
       from string.rb:8

$ ruby1.9 -vw string.rb
ruby 1.9.2dev (2009-05-28 trunk 23601) [i386-darwin9.7.0]
nil
"a"
"a"
"xa"


Given any string s of N characters, s[N] == nil, so I understand that
to mean that N is out of the bounds of the string. The RDoc for
String#[]= states that

 "The forms that take a +Fixnum+ will raise an +IndexError+ if the value
   is out of range; the +Range+ form will raise a +RangeError+, and the
   +Regexp+ and +String+ forms will silently ignore the assignment."

The RDoc does not appear to have changed on 1.9.

So, my questions are:

1. should ""[0] = "a" work on 1.8 the way it does on 1.9?
 OR
2. should ""[0] = "a" raise an IndexError on 1.9?

If the answer to the above is "it should raise an IndexError on 1.9",
then should ""[0,N] = "a" also raise an IndexError?

If the answer is ""[0] = "a" should work as it does on 1.9, can we
please update the RDoc to somehow explain that while s[N] is out of
bounds of the string, you can "replace" that non-existent character
with an arbitrary length string.

Cheers,
Brian


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next