Commit 968bedc0 authored by Tom Niget's avatar Tom Niget

Fix some Python unification problems

parent 551ba3cc
......@@ -76,8 +76,8 @@ class ModuleVisitor(BlockVisitor):
yield ""
elif node.module_obj.is_python:
for alias in node.names:
fty = alias.item_obj
assert isinstance(fty, FunctionType)
fty = alias.item_obj.resolve()
#assert isinstance(fty, FunctionType)
yield from self.emit_python_func(node.module, alias.name, alias.asname or alias.name, fty)
else:
......
......@@ -131,14 +131,18 @@ class ScoperExprVisitor(ScoperVisitor):
init: FunctionType = self.visit_getattr(ftype, "__init__").remove_self()
init.return_type = ftype.type_object
return self.visit_function_call(init, arguments)
if not isinstance(ftype, FunctionType):
if isinstance(ftype, FunctionType):
ret = ftype.return_type
elif isinstance(ftype, TypeVariable):
ret = TypeVariable()
else:
from transpiler.phases.typing.exceptions import NotCallableError
raise NotCallableError(ftype)
#is_generic = any(isinstance(arg, TypeVariable) for arg in ftype.to_list())
equivalent = FunctionType(arguments, ftype.return_type)
equivalent = FunctionType(arguments, ret)
equivalent.is_intermediary = True
ftype.unify(equivalent)
return ftype.return_type
return equivalent.return_type
def visit_Lambda(self, node: ast.Lambda) -> BaseType:
argtypes = [TypeVariable() for _ in node.args.args]
......
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