From ee3f35c608d4ab9ef09203ac875720dc7dfa71de Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 8 Aug 2015 21:06:13 +0300 Subject: [PATCH] Improve error message on passing an argument twice. --- artiq/compiler/transforms/inferencer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 6df5d3eec..47145b9a9 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -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