-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Backslashes in %w() and %i() misbehave #12277
Copy link
Copy link
Open
Labels
breaking-changeMay have breaking effect in some edge cases. Mostly negligible, but still noteworthy.May have breaking effect in some edge cases. Mostly negligible, but still noteworthy.kind:bugA bug in the code. Does not apply to documentation, specs, etc.A bug in the code. Does not apply to documentation, specs, etc.topic:compiler:parser
Metadata
Metadata
Assignees
Labels
breaking-changeMay have breaking effect in some edge cases. Mostly negligible, but still noteworthy.May have breaking effect in some edge cases. Mostly negligible, but still noteworthy.kind:bugA bug in the code. Does not apply to documentation, specs, etc.A bug in the code. Does not apply to documentation, specs, etc.topic:compiler:parser
Currently, backslashes inside a
%w()string array literal may escape whitespaces and the literal delimiters: (contrast with #5403 where%q()cannot escape its own delimiters)However, backslashes here also indefinitely extend an escape sequence, and one
\is written for every extra backslash:Consequently, it is not possible to use a backslash at the very end of an array, as any number of
\s followed by the end delimiter merely escapes that delimiter:%w(\) # Error: Unterminated string array literalHere are the same literals in Ruby:
I think we should follow suit and make
\escape only the following character. Like #5403, however, we should decide whether this would constitute a breaking change.