[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108989] [Ruby master Bug#18838] Regexp#source behaves inconsistently with /
From:
"andrykonchin (Andrew Konchin)" <noreply@...>
Date:
2022-06-17 16:52:52 UTC
List:
ruby-core #108989
Issue #18838 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Bug #18838: Regexp#source behaves inconsistently with /
https://bugs.ruby-lang.org/issues/18838
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
According to `Regexp#source` documentation:
```
Returns the original string of the pattern.
/ab+c/ix.source #=> "ab+c"
Note that escape sequences are retained as is.
/\x20\+/.source #=> "\\x20\\+"
```
It works well but backslash (/) is processed in different way by different regexp literal forms.
Examples:
```ruby
/\//.source # => "/"
%r/\//.source # => "/"
%r{\/}.source # => "\\/"
```
Expected result - in all the cases result is the same.
Moreover as documentation states - `escape sequences are retained as is`. So I would say that only `%r{}` works properly.
The issue was reported here https://github.com/oracle/truffleruby/issues/2569.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>