diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 5c54f235c..7880a6390 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -1004,6 +1004,17 @@ class Inferencer(algorithm.Visitor): elif keyword.arg in typ_optargs: self._unify(keyword.value.type, typ_optargs[keyword.arg], keyword.value.loc, None) + else: + note = diagnostic.Diagnostic("note", + "extraneous argument", {}, + keyword.loc) + diag = diagnostic.Diagnostic("error", + "this function of type {type} does not accept argument '{name}'", + {"type": types.TypePrinter().name(node.func.type), + "name": keyword.arg}, + node.func.loc, [], [note]) + self.engine.process(diag) + return passed_args[keyword.arg] = keyword.arg_loc for formalname in typ_args: diff --git a/artiq/test/lit/inferencer/error_call.py b/artiq/test/lit/inferencer/error_call.py index 1c3df3a6a..1497c7821 100644 --- a/artiq/test/lit/inferencer/error_call.py +++ b/artiq/test/lit/inferencer/error_call.py @@ -18,3 +18,6 @@ f(1, x=1) # CHECK-L: ${LINE:+1}: error: mandatory argument 'x' is not passed f() + +# CHECK: ${LINE:+1}: error: this function of type .* does not accept argument 'q' +f(1, q=1)