Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl syntax highlighting issue - s{foo}{bar} if $baz; #49

Open
alexr00 opened this issue Aug 25, 2021 · 0 comments
Open

Perl syntax highlighting issue - s{foo}{bar} if $baz; #49

alexr00 opened this issue Aug 25, 2021 · 0 comments

Comments

@alexr00
Copy link

alexr00 commented Aug 25, 2021

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).

Screen Shot 2021-08-21 at 12 25 02 PM

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; # OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant