GNU bug report logs -
#62092
30.0.50; "case" does not work as dedenter in Python
Previous Next
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
Message #17 received at 62092 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov wrote:
> I type the colon after 'case 2', see it indented correctly, but also a
> message in the echo area:
>
> Closes case 1:
>
> I type the next case with colon and see:
>
> Closes case 2:
>
> and so on. They don't do much harm, but they still seem semantically
> incorrect.
Thank you for testing my patch. I don't think this is a incorrect
message. Let's discuss with the following code:
#+begin_src python
match a:
case 1:
print("a = 1")
match b:
case 2:
print("b = 2")
case 3
#+end_src
When I type ":" at the last line after "case 3", it will be indented
as follows:
#+begin_src python
match a:
case 1:
print("a = 1")
match b:
case 2:
print("b = 2")
case 3:
#+end_src
The message "Closes case 2:" is shown. It means that the "case 3:"
corresponds to the "case 2:" in the inner "match" statement, not the
"case 1:" in the outer "match" statement.
When I type TAB twice, the line will be indented as follows:
#+begin_src python
match a:
case 1:
print("a = 1")
match b:
case 2:
print("b = 2")
case 3:
#+end_src
The message "Closes case 1:" is shown. It is shown to help
distinguishing nested blocks, although it will not be useful if the
case statements are same.
This is the same behavior as "if" blocks, etc. The term "Closes" may
not be the most appropriate for "case," but I don't think it is wrong.
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.