diff --git a/artiq/py2llvm/typing.py b/artiq/py2llvm/typing.py index 5d2b140a9..29981389a 100644 --- a/artiq/py2llvm/typing.py +++ b/artiq/py2llvm/typing.py @@ -71,6 +71,12 @@ class LocalExtractor(algorithm.Visitor): self.typing_env[name] = types.TVar() def visit_arg(self, node): + if node.arg in self.params: + diag = diagnostic.Diagnostic("error", + "duplicate parameter '{name}'", {"name": node.arg}, + node.loc) + self.engine.process(diag) + return self._assignable(node.arg) self.params.add(node.arg) diff --git a/lit-test/py2llvm/typing/error_nonlocal_global.py b/lit-test/py2llvm/typing/error_locals.py similarity index 89% rename from lit-test/py2llvm/typing/error_nonlocal_global.py rename to lit-test/py2llvm/typing/error_locals.py index 1242f56db..7d07d699b 100644 --- a/lit-test/py2llvm/typing/error_nonlocal_global.py +++ b/lit-test/py2llvm/typing/error_locals.py @@ -20,6 +20,10 @@ def d(x): # CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and global simultaneously global x -def d(x): +def e(x): # CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and nonlocal simultaneously nonlocal x + +# CHECK-L: ${LINE:+1}: error: duplicate parameter 'x' +def f(x, x): + pass