Better error reporting for List.

This commit is contained in:
whitequark 2015-06-11 04:22:31 +03:00
parent 4b7d4c2425
commit e18ea0daae
2 changed files with 4 additions and 4 deletions

View File

@ -268,9 +268,9 @@ class Inferencer(algorithm.Transformer):
def makenotes(printer, typea, typeb, loca, locb):
return [
diagnostic.Diagnostic("note",
"a list of type {typea}",
{"typea": printer.name(node.type)},
loca),
"a list element of type {typea}",
{"typea": printer.name(node.elts[0].type)},
node.elts[0].loc),
diagnostic.Diagnostic("note",
"a list element of type {typeb}",
{"typeb": printer.name(typeb)},

View File

@ -9,7 +9,7 @@ a = b
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with list(elt='b)
[1, []]
# CHECK-L: note: a list of type list(elt=int(width='a))
# CHECK-L: note: a list element of type int(width='a)
# CHECK-L: note: a list element of type list(elt='b)
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool