Brandt Bucher <brandtbuc...@gmail.com> added the comment:
Nice find! In my opinion, we should do two things here: - Update PEP 638 to specify that a SyntaxError is raised "if *any duplicate* key patterns are literal patterns". This was absolutely our original intention... I think the nuances were just lost in the final phrasing. I can take care of that PR. - Update the compiler to raise SyntaxErrors for duplicate literal keys. It should be as simple as updating the first loop in compiler_pattern_mapping to build a set containing the values of any literal keys and raise on duplicates (and adding/updating tests, of course). We'll want to make sure we have test coverage of edge cases like {0: _, False: _}, {0: _, 0.0: _}, {0: _, -0: _}, {0: _, 0j: _}, etc. Since you found this, you get first dibs on a PR. Otherwise, I have a few first-time contributors who would probably be interested. ---------- nosy: +gvanrossum type: -> behavior versions: +Python 3.11 -Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44589> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com