GNU bug report logs - #62092
30.0.50; "case" does not work as dedenter in Python

Previous Next

Package: emacs;

Reported by: kobarity <kobarity <at> gmail.com>

Date: Fri, 10 Mar 2023 05:34:01 UTC

Severity: normal

Found in version 30.0.50

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: kobarity <kobarity <at> gmail.com>
Cc: Lele Gaifax <lele <at> metapensiero.it>, 62092 <at> debbugs.gnu.org
Subject: bug#62092: 30.0.50; "case" does not work as dedenter in Python
Date: Sun, 26 Mar 2023 05:04:12 +0300
On 25/03/2023 16:13, kobarity wrote:
> 
> Dmitry Gutov wrote:
>> Pushed your change to emacs-29, and closing. Thanks!
> 
> Thank you for applying the patch.  However, I overlooked one problem.
> 
> #+begin_src python
> match a:
>      case 1:
>          match b:
>              case 2
> #+end_src
> 
> When I type ":" at the last line after "case 2", the message "Closes
> case 1:" is shown.  This is wrong because it cannot be the "case"
> block of the outer "match" block (match a:).  I'm sorry if you were
> mentioning this case.

Not really, I wasn't thinking about this one in particular.

> Similar message can be shown with "elif":
> 
> #+begin_src python
> for c in (1, 2):
>      if a == 1:
>          for d in (3, 4):
>              elif b == 1:
> #+end_src
> 
> However, this is not a correct Python code because "elif" cannot be
> the first sentence in a block.
> 
> Dedenters other than "case" can never be the first sentence of a
> block, whereas "case" can be the first sentence of a block.
> 
> So I think it is appropriate that the first "case" in the block should
> not be considered a dedenter.  Attached is a patch to add a condition
> in `python-info-dedenter-statement-p'.

Thanks! I've pushed it to emacs-29 as well.




This bug report was last modified 1 year and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.