Nick Coghlan <ncogh...@gmail.com> added the comment:

To get the "0+0" matching case rejected again I had to flesh out a bit more of 
the AST validator. This initial piece of the validator replaces the previously 
pattern-matching-specific AST optimisation code that refused to fold BinOp 
expressions that weren't complex numbers, allowing the compiler to reject them.

I also added two new tests (240b and 241b) to ensure that 0+0 & f"" were also 
rejected as mapping keys. 241b passes with the current PR, as f"" gets rejected 
by both the check in the AST validator *and* by the "constant or attribute 
lookup" restriction in the compiler, so the latter check covers for the leaky 
validator.

240b is disabled for now, as it won't pass until the AST validator checks all 
the subexpressions being used as keys in a mapping pattern (because it gets 
constant folded to "0", the check in the compiler accepts it).

That leaves fixing the unparser tests as the key thing to do before I create 
the main PR.

Before that, though, I'll look at potentially simplifying the MatchMapping code 
by changing the signature as Brandt suggested.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43892>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to