You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: case wildcard missed after a continuation line at column 0 #241
Applies to the PyCaseWildcardPattern added in #236 (not on main yet).
A wildcard _ is missed when a statement in the previous case body continues onto a line at column 0, either inside brackets or after a \. The pattern finds the enclosing block by indentation, so it reads that continuation line as the enclosing block instead of the match.
Steps to reproduce
useTempest\Highlight\Highlighter;
echo (newHighlighter())->parse("match command:\n case 1:\n y = foo(\n1)\n case _:\n pass", 'python');
Expected
case <span class="hl-keyword">_</span>:. Python's ast parses the second clause as MatchAs(), a wildcard.
Actual
case _:, with no highlighting.
Notes
y = 1 + \ followed by 2 at column 0 fails the same way.
With normal indentation (foo(\n 1)) the wildcard is highlighted.
A possible fix: track bracket depth and \ continuations in the existing lexing pass, and skip lines that start inside them.
Activity