[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30964: python-mode failing "overlapping strings" assertion lately

From: Philipp Stephani
Subject: bug#30964: python-mode failing "overlapping strings" assertion lately
Date: Sat, 2 Jun 2018 21:03:10 +0200

Noam Postavsky <address@hidden> schrieb am Mi., 30. Mai 2018 um 02:29 Uhr:
Clément Pit-Claudel <address@hidden> writes:

> Here's a reliable repro:
> def f():
>     "
> def g():
>     """That's a docstring"""
>     return ''

It can be reduced a bit:

Debugger entered--Lisp error: (cl-assertion-failed ((> string-start last-string-end) "Overlapping strings detected" 13 13))
  cl--assertion-failed((> string-start last-string-end) "Overlapping strings detected" (13 13) nil)
  python-nav--forward-sexp(-1 nil nil)
  python-nav-forward-sexp(-1 nil nil)
  python-info-docstring-p((0 nil nil t nil nil 0 nil 1 nil nil))
  python-font-lock-syntactic-face-function((0 nil nil t nil nil 0 nil 1 nil nil))
  font-lock-fontify-syntactically-region(1 15 nil)
  font-lock-default-fontify-region(1 15 nil)
  font-lock-fontify-region(1 15)
  funcall-interactively(font-lock-fontify-block nil)
  call-interactively(font-lock-fontify-block nil nil)

I think the problem is that the assertion is off by 1, it currently
asserts that there is at least one space between strings (because the
end position goes *after* the string, while the start position is part
of the string).

I see the assertion was added in [1: 4fbd330fae].  Phillip, does my
proposed change make sense to you?

Maybe :-)
Off-by-one errors are always a bit subtle, so it might definitely be the case that there is one. If so, the problem could be further reduced to
' '' '
or similar. Could you add a unit test using such input and make sure that it breaks without your patch?

  ('make -C test python-tests' still

--- i/lisp/progmodes/python.el
+++ w/lisp/progmodes/python.el
@@ -1506,7 +1506,7 @@ python-nav-end-of-statement
                        ;; are somehow out of whack.  This has been
                        ;; observed when using `syntax-ppss' during
                        ;; narrowing.
-                       (cl-assert (> string-start last-string-end)
+                       (cl-assert (>= string-start last-string-end)
                                   "Overlapping strings detected")
                        (goto-char string-start)

[1: 4fbd330fae]: 2017-03-23 23:05:19 +0100
  Protect against an infloop in python-mode

reply via email to

[Prev in Thread] Current Thread [Next in Thread]