[ruby-core:114193] [Ruby master Bug#19769] Range of size 1 in String#tr causes unexpected behavior

Issue #19769 has been reported by alexandre (alexandre borderes). ---------------------------------------- Bug #19769: Range of size 1 in String#tr causes unexpected behavior https://bugs.ruby-lang.org/issues/19769 * Author: alexandre (alexandre borderes) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Hi, I noticed a possible unexpected behavior in String#tr. Is that intentional? ``` ruby 'ABC'.tr 'A-AB', 'XY' # => "YYC" ``` I would expect the same result as: ``` ruby 'ABC'.tr 'AB', 'XY' # => "XYC" ``` The tr utility does exactly that: ``` shell echo ABC | tr A-AB XY # => "XYC" ``` The letter 'A' is interpreted 2 times in that case, shifting by 1 all the replacement string. -- https://bugs.ruby-lang.org/

Issue #19769 has been updated by alexandre (alexandre borderes). Description updated I created a PR https://github.com/ruby/ruby/pull/8080 ---------------------------------------- Bug #19769: Range of size 1 in String#tr causes unexpected behavior https://bugs.ruby-lang.org/issues/19769#change-103880 * Author: alexandre (alexandre borderes) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Hi, I noticed a possible unexpected behavior in String#tr. Is that intentional? ``` ruby 'ABC'.tr 'A-AB', 'XY' # => "YYC" ``` I would expect the same result as: ``` ruby 'ABC'.tr 'AB', 'XY' # => "XYC" ``` The tr utility does exactly that: ``` shell echo ABC | tr A-AB XY # => "XYC" ``` The letter 'A' is interpreted 2 times in that case, shifting by 1 all the replacement string. (I found this related https://bugs.ruby-lang.org/issues/1953) -- https://bugs.ruby-lang.org/
participants (1)
-
alexandre (alexandre borderes)