Commit d84f8bc7 authored by Tom Niget's avatar Tom Niget

Fix dict typing

parent 637bee47
......@@ -147,10 +147,10 @@ class ScoperExprVisitor(ScoperVisitor):
raise IncompatibleTypesError(f"{e} in `{ast.unparse(node)}`")
def visit_Attribute(self, node: ast.Attribute) -> BaseType:
ltype = self.visit(node.value)
try:
ltype = self.visit(node.value)
return self.visit_getattr(ltype, node.attr)
except IncompatibleTypesError as e:
except Exception as e:
raise IncompatibleTypesError(f"{e} in `{ast.unparse(node)}`")
def visit_getattr(self, ltype: BaseType, name: str):
......@@ -191,11 +191,11 @@ class ScoperExprVisitor(ScoperVisitor):
def visit_Dict(self, node: ast.Dict) -> BaseType:
if not node.keys:
return PyDict(TypeVariable())
return PyDict(TypeVariable(), TypeVariable())
keys = [self.visit(e) for e in node.keys]
values = [self.visit(e) for e in node.values]
if len(set(keys)) != 1 or len(set(values)) != 1:
raise NotImplementedError("Dict with different types not handled yet")
raise NotImplementedError(f"Dict with different types not handled yet in `{ast.unparse(node)}`")
return PyDict(keys[0], values[0])
def visit_Subscript(self, node: ast.Subscript) -> BaseType:
......
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