Commit dd9385b4 authored by Harald Jörg's avatar Harald Jörg
Browse files

; perl-mode.el: Detect quote-like operator immediately after =>

* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Detect a quotelike operator immediately after a fat comma "=>"
(Bug#25098)

* test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-25098):
Test case for the bug with code from the bug report.

* test/lisp/progmodes/cperl-mode-resources/cperl-bug-25098.pl:
Resource file for the test.
parent ff65ea93
Pipeline #11039 failed with stages
in 168 minutes and 52 seconds
......@@ -285,7 +285,7 @@
(put-text-property (match-beginning 2) (match-end 2)
'syntax-table (string-to-syntax "\""))
(perl-syntax-propertize-special-constructs end)))))
("\\(^\\|[?:.,;=|&!~({[ \t]\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\(?:\\([^])}>= \n\t]\\)\\|\\(?3:=\\)[^>]\\)"
("\\(^\\|[?:.,;=|&!~({[ \t]\\|=>\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\(?:\\([^])}>= \n\t]\\)\\|\\(?3:=\\)[^>]\\)"
;; Nasty cases:
;; /foo/m $a->m $#m $m @m %m
;; \s (appears often in regexps).
......
# Code from the bug report Bug#25098
my $good = XML::LibXML->load_xml( string => q{<div class="clearfix">});
my $bad = XML::LibXML->load_xml( string =>q{<div class="clearfix">});
# Related: Method calls are no quotelike operators. That's why you
# can't just add '>' to the character class.
my $method_call = $object->q(argument);
# Also related, still not fontified correctly:
#
# my $method_call = $object -> q (argument);
#
# perl-mode interprets the method call as a quotelike op (because it
# is preceded by a space).
# cperl-mode gets the argument right, but marks q as a quotelike op.
#
# my $greater = 2>q/1/;
#
# perl-mode doesn't identify this as a quotelike op.
......@@ -397,6 +397,24 @@ Regular expressions are strings in both perl-mode and cperl-mode."
(search-forward "RIGHT")
(should (nth 3 (syntax-ppss)))))
(ert-deftest cperl-test-bug-25098 ()
"Verify that a quotelike operator is recognized after a fat comma \"=>\".
Related, check that calling a method named q is not mistaken as a
quotelike operator."
(with-temp-buffer
(insert-file-contents (ert-resource-file "cperl-bug-25098.pl"))
(funcall cperl-test-mode)
(goto-char (point-min))
;; good example from the bug report, with a space
(search-forward "q{")
(should (nth 3 (syntax-ppss)))
;; bad (but now fixed) example from the bug report, without space
(search-forward "q{")
(should (nth 3 (syntax-ppss)))
;; calling a method "q" (parens instead of braces to make it valid)
(search-forward "q(")
(should-not (nth 3 (syntax-ppss)))))
(ert-deftest cperl-test-bug-28650 ()
"Verify that regular expressions are recognized after 'return'.
The test uses the syntax property \"inside a string\" for the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment