Improve error message on passing an argument twice.

This commit is contained in:
whitequark 2015-08-08 21:06:13 +03:00
parent bdcf7f100b
commit ee3f35c608
1 changed files with 4 additions and 4 deletions

View File

@ -696,7 +696,7 @@ class Inferencer(algorithm.Visitor):
return
typ = node.func.type.find()
passed_args = set()
passed_args = dict()
if len(node.args) > typ.arity():
note = diagnostic.Diagnostic("note",
@ -714,14 +714,14 @@ class Inferencer(algorithm.Visitor):
zip(node.args, list(typ.args.items()) + list(typ.optargs.items())):
self._unify(actualarg.type, formaltyp,
actualarg.loc, None)
passed_args.add(formalname)
passed_args[formalname] = actualarg.loc
for keyword in node.keywords:
if keyword.arg in passed_args:
diag = diagnostic.Diagnostic("error",
"the argument '{name}' is already passed",
"the argument '{name}' has been passed earlier as positional",
{"name": keyword.arg},
keyword.arg_loc)
keyword.arg_loc, [passed_args[keyword.arg]])
self.engine.process(diag)
return