-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Originally from @NorthboundTrain in microsoft/vscode#131322
Issue Type: Bug
Perl's regex operators can use any pair of matching characters as delimiters (see https://perldoc.perl.org/perlop#Regexp-Quote-Like-Operators). When using a bracketing character as the delimiter, e.g. ({[, then the matching closing bracket can be used to close the operator, e.g. m<foo> or s{foo}{bar}. The bug only occurs when using the substitution operator (s///), and only when using bracketing delimiters, and only with a statement modifier (a trailing if, while, etc).
s/foo/bar/; # OK
s/foo/bar/ unless $baz; # OK
s/foo/bar/ if $baz; # OK
s{foo}{bar}; # OK
s{foo}{bar} if $baz; # BROKEN
# lasts until a scalar variable is given; neither an @array nor a %hash works,
# but the $scalar does (but the remainder of the line is still FUBAR)
# next line is OK, though
s(foo)(bar) if $baz; # BROKEN - $clear;
s[foo][bar] if $baz; # BROKEN - $clear;
s<foo><bar> if $baz; # BROKEN - $clear;
s:foo:bar: if $baz; # OK
s#foo#bar# if $baz; # OK
# other statement modifiers
s(foo)(bar) for $baz; # BROKEN differently
s(foo)(bar) foreach $baz; # BROKEN - $clear
s(foo)(bar) unless $baz; # OK
s(foo)(bar) until $baz; # BROKEN differently
s(foo)(bar) when $baz; # BROKEN differently
s(foo)(bar) while $baz; # BROKEN differently
# other regex/quote-like operators are OK:
m/foo/ if $baz; # OK
m{foo} if $baz; # OK
q/foo/ if $baz; # OK
q{foo} if $baz; # OK
qq/foo/ if $baz; # OK
qq{foo} if $baz; # OK
qw/foo/ if $baz; # OK
qw{foo} if $baz; # OKReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
