[#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:109027] [Ruby master Feature#18838] Avoid swallowing regexp escapes in the lexer
From:
"mame (Yusuke Endoh)" <noreply@...>
Date:
2022-06-21 02:10:21 UTC
List:
ruby-core #109027
Issue #18838 has been updated by mame (Yusuke Endoh).
Agreed with Jeremy. There is the same "inconsistency" in a string literal, but this is clearly by design.
```
puts 'foo\'bar' #=> foo'bar
puts %q'foo\'bar' #=> foo'bar
puts %q{foo\'bar} #=> foo\\'bar
```
----------------------------------------
Feature #18838: Avoid swallowing regexp escapes in the lexer
https://bugs.ruby-lang.org/issues/18838#change-98142
* Author: andrykonchin (Andrew Konchin)
* Status: Closed
* Priority: Normal
----------------------------------------
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>