From 56d1a9bc57f436720ae210e5baa008aabb040da4 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 29 May 2015 10:01:22 +0300 Subject: [PATCH] Shorten the unification error message when too redundant. --- artiq/py2llvm/typing.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/artiq/py2llvm/typing.py b/artiq/py2llvm/typing.py index effbca78f..bc14dfa25 100644 --- a/artiq/py2llvm/typing.py +++ b/artiq/py2llvm/typing.py @@ -129,13 +129,20 @@ class Inferencer(algorithm.Transformer): "expression of type {typeb}", {"typeb": types.TypePrinter().name(typeb)}, locb) - diag = diagnostic.Diagnostic('fatal', - "cannot unify {typea} with {typeb}: {fraga} is incompatible with {fragb}", - {"typea": types.TypePrinter().name(typea), - "typeb": types.TypePrinter().name(typeb), - "fraga": types.TypePrinter().name(e.typea), - "fragb": types.TypePrinter().name(e.typeb),}, - loca, [locb], notes=[note1, note2]) + if e.typea.find() == typea.find() and e.typeb.find() == typeb.find(): + diag = diagnostic.Diagnostic('fatal', + "cannot unify {typea} with {typeb}", + {"typea": types.TypePrinter().name(typea), + "typeb": types.TypePrinter().name(typeb)}, + loca, [locb], notes=[note1, note2]) + else: # give more detail + diag = diagnostic.Diagnostic('fatal', + "cannot unify {typea} with {typeb}: {fraga} is incompatible with {fragb}", + {"typea": types.TypePrinter().name(typea), + "typeb": types.TypePrinter().name(typeb), + "fraga": types.TypePrinter().name(e.typea), + "fragb": types.TypePrinter().name(e.typeb),}, + loca, [locb], notes=[note1, note2]) self.engine.process(diag) def visit_FunctionDef(self, node):