IfExp precidence handling in 2.6...

2.7 still has a bug
This commit is contained in:
rocky
2019-05-05 09:48:20 -04:00
parent 8c611476fe
commit 393e5c9303
3 changed files with 15 additions and 4 deletions

Binary file not shown.

View File

@@ -0,0 +1,9 @@
# From 3.7.3 dataclasses.py
# Bug was handling precedence. Need parenthesis before IfExp.
#
# RUNNABLE!
def _hash_add(fields):
flds = [f for f in fields if (4 if f is None else f)]
return flds
assert _hash_add([None, True, False, 3]) == [None, True, 3]

View File

@@ -95,6 +95,7 @@ PRECEDENCE = {
'conditional_lamdba': 28,
'conditional_not_lamdba': 28,
'conditionalnot': 28,
'conditional_true': 28,
'ret_cond': 28,
'_mklambda': 30,
@@ -257,7 +258,8 @@ TABLE_DIRECT = {
'list_iter': ( '%c', 0 ),
'list_for': ( ' for %c in %c%c', 2, 0, 3 ),
'list_if': ( ' if %c%c', 0, 2 ),
'list_if': ( ' if %p%c',
(0, 'expr', 27), 2 ),
'list_if_not': ( ' if not %p%c',
(0, 'expr', PRECEDENCE['unary_not']),
2 ),