diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-16 10:16:14 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-16 10:16:14 +0900 |
| commit | 1685eff2a5e672173d67916a1c96648df92b7271 (patch) | |
| tree | 75c7f5484456bdd4f524d1fa6654810858b78498 /mrblib/string.rb | |
| parent | 1f554ff8540d61e30d0e649bf80c0ecd27b40ad6 (diff) | |
| download | mruby-1685eff2a5e672173d67916a1c96648df92b7271.tar.gz mruby-1685eff2a5e672173d67916a1c96648df92b7271.zip | |
Fixed off-by-one error in String#[]= with Ranges
Diffstat (limited to 'mrblib/string.rb')
| -rw-r--r-- | mrblib/string.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/mrblib/string.rb b/mrblib/string.rb index f22071b36..aa2ca9973 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -173,11 +173,8 @@ class String head = pos.begin tail = pos.end tail += self.length if tail < 0 - if pos.exclude_end? - tail -= 1 - end - if tail < 0 || tail > self.length - raise IndexError, "index #{args[0]} out of string" + unless pos.exclude_end? + tail += 1 end return self[head, tail-head]=value else |
