Skip to content

Commit

Permalink
make simplify_expr_annotations not resolve ambiguities on the right s…
Browse files Browse the repository at this point in the history
…ide of multiplicative binops
  • Loading branch information
zhudotexe committed Feb 24, 2020
1 parent ceab4a8 commit 40be9f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions d20/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ def do_simplify(node):
for child in node.children:
child.annotation = None
# if there are ambiguous types, resolve children by ambiguity rules
# unless it would change the right side of a multiplicative binop
elif len(possible_types) and ambig_inherit is not None:
for child in node.children:
if child_possibilities[child]:
for i, child in enumerate(node.children):
if child_possibilities[child]: # if the child already provides an annotation or ambiguity
continue
elif isinstance(node, expression.BinOp) \
and node.op in {'*', '/', '//', '%'} \
and i: # if the child is the right side of a multiplicative binop
continue
elif ambig_inherit == 'left':
child.annotation = possible_types[0]
Expand Down

0 comments on commit 40be9f9

Please sign in to comment.