Commit 9b8da153 authored by Tom Niget's avatar Tom Niget

Fix sync function generation

parent 29793d0f
def f[T](x: T): def f[T](x: T):
return x return x
def g[X](a: X, b: X):
return a + b
if __name__ == "__main__": if __name__ == "__main__":
#a = 5 #a = 5
print(f("abc")) print(f("abc"))
print(f(6)) print(f(6))
print(g(6, 8))
print(g("abc", "def"))
...@@ -222,13 +222,17 @@ class ExpressionVisitor(NodeVisitor): ...@@ -222,13 +222,17 @@ class ExpressionVisitor(NodeVisitor):
yield from self.visit_binary_operation(node.ops[0], node.left, node.comparators[0], linenodata(node)) yield from self.visit_binary_operation(node.ops[0], node.left, node.comparators[0], linenodata(node))
def visit_binary_operation(self, op, left: ast.AST, right: ast.AST, lnd: dict) -> Iterable[str]: def visit_binary_operation(self, op, left: ast.AST, right: ast.AST, lnd: dict) -> Iterable[str]:
yield "(co_await (" if self.generator != CoroutineMode.SYNC:
yield "(co_await"
yield "("
yield from self.visit(left) yield from self.visit(left)
yield " " yield " "
yield SYMBOLS[type(op)] yield SYMBOLS[type(op)]
yield " " yield " "
yield from self.visit(right) yield from self.visit(right)
yield "))" yield ")"
if self.generator != CoroutineMode.SYNC:
yield ")"
return return
raise NotImplementedError() raise NotImplementedError()
# if type(op) == ast.In: # if type(op) == ast.In:
......
...@@ -75,6 +75,7 @@ class NodeVisitor(UniversalVisitor): ...@@ -75,6 +75,7 @@ class NodeVisitor(UniversalVisitor):
if em: if em:
yield name yield name
else: else:
raise UnresolvedTypeVariableError(node)
yield f"$VAR__{name}" yield f"$VAR__{name}"
#raise UnresolvedTypeVariableError(node) #raise UnresolvedTypeVariableError(node)
......
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