Commit 30dc6b3a authored by Tom Niget's avatar Tom Niget

Add proper display for ICEs

parent d3d9dc40
......@@ -5,8 +5,13 @@ import importlib
import inspect
import os
import traceback
#os.environ["TERM"] = "xterm-256"
import colorama
from transpiler.phases.desugar_compare import DesugarCompare
colorama.init()
from transpiler.consts import MAPPINGS
......@@ -32,6 +37,8 @@ def exception_hook(exc_type, exc_value, tb):
last_node = None
last_file = None
orig_tb = tb
while tb:
local_vars = tb.tb_frame.f_locals
name = tb.tb_frame.f_code.co_name
......@@ -103,12 +110,17 @@ def exception_hook(exc_type, exc_value, tb):
print(disp)
# print(repr(disp))
print()
print(cf.red("Error:"), exc_value)
if isinstance(exc_value, CompileError):
print(cf.red("Error:"), exc_value)
detail = inspect.cleandoc(exc_value.detail(last_node))
if detail:
print()
print(detail)
else:
print(cf.red("Internal Compiler Error:"), exc_value)
print()
print("Please report this error to the Typon maintainers.")
traceback.print_tb(orig_tb, limit=-1)
print()
def find_indices(s, indices: list[int]) -> list[int]:
......@@ -162,8 +174,9 @@ def transpile(source, name="<module>", path=None):
res = ast.parse(source, type_comments=True)
# res = initial_pytype.run(source, res)
res = DesugarWith().visit(res)
IfMainVisitor().visit(res)
res = DesugarWith().visit(res)
res = DesugarCompare().visit(res)
ScoperBlockVisitor().visit(res)
# print(res.scope)
......
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