Commit 73735bc8 authored by Tom Niget's avatar Tom Niget

Fix precedence issue

parent ad38a7ab
......@@ -137,7 +137,7 @@ class NodeVisitor:
class ExpressionVisitor(NodeVisitor):
def __init__(self, precedence: int = 0):
def __init__(self, precedence: Optional[int] = None):
self._precedence = precedence
def visit_Tuple(self, node: ast.Tuple) -> Iterable[str]:
......@@ -199,7 +199,7 @@ class ExpressionVisitor(NodeVisitor):
# TODO: precedence
op = SYMBOLS[type(op)]
inner = ExpressionVisitor(PRECEDENCE_LEVELS[op])
prio = inner._precedence > self._precedence != 0
prio = self._precedence is not None and inner._precedence > self._precedence
if prio:
yield "("
yield from inner.visit(left)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment