Skip to content

Commit

Permalink
Test syntax error on comma-less tuple-style sequence patterns (#115485)
Browse files Browse the repository at this point in the history
Adds a test that length-1 tuple-style sequence patterns must end in a comma, since there isn't currently one.

Spotted while reviewing Cython's proposed implementation of the pattern matching syntax (cython/cython#4897 (comment)) where there was a bug my the reimplementation that wasn't caught against the CPython tests here.
  • Loading branch information
da-woods authored May 1, 2024
1 parent fc7e1aa commit 21c09d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/test/test_patma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,14 @@ def test_invalid_syntax_3(self):
pass
""")

def test_len1_tuple_sequence_pattern_comma(self):
# correct syntax would be `case(*x,):`
self.assert_syntax_error("""
match ...:
case (*x):
pass
""")

def test_mapping_pattern_keys_may_only_match_literals_and_attribute_lookups(self):
self.assert_syntax_error("""
match ...:
Expand Down

0 comments on commit 21c09d9

Please sign in to comment.