Commit 5f568116 authored by Tom Niget's avatar Tom Niget

Store type origin info for traceback display

parent 175ae7bf
...@@ -42,6 +42,8 @@ class ScoperExprVisitor(ScoperVisitor): ...@@ -42,6 +42,8 @@ class ScoperExprVisitor(ScoperVisitor):
TB_SKIP = False TB_SKIP = False
raise NotImplementedError(f"`{ast.unparse(node)}` {type(node)}") raise NotImplementedError(f"`{ast.unparse(node)}` {type(node)}")
res = res.resolve() res = res.resolve()
if True or not hasattr(res, "from_node"):
res.from_node = node
node.type = res node.type = res
return res return res
......
...@@ -174,6 +174,8 @@ class TypeOperator(BaseType, ABC): ...@@ -174,6 +174,8 @@ class TypeOperator(BaseType, ABC):
def unify_internal(self, other: BaseType): def unify_internal(self, other: BaseType):
from transpiler.phases.typing.exceptions import TypeMismatchError, TypeMismatchKind from transpiler.phases.typing.exceptions import TypeMismatchError, TypeMismatchKind
if from_node := next(filter(None, (getattr(x, "from_node", None) for x in (other, self))), None):
TB_NODE = from_node
if not isinstance(other, TypeOperator): if not isinstance(other, TypeOperator):
raise TypeMismatchError(self, other, TypeMismatchKind.DIFFERENT_TYPE) raise TypeMismatchError(self, other, TypeMismatchKind.DIFFERENT_TYPE)
if other.is_protocol and not self.is_protocol: if other.is_protocol and not self.is_protocol:
......
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