mirror of https://github.com/m-labs/artiq.git
Add check for duplicate parameter names.
This commit is contained in:
parent
d27bb3168d
commit
dbfdbc3c22
|
@ -71,6 +71,12 @@ class LocalExtractor(algorithm.Visitor):
|
||||||
self.typing_env[name] = types.TVar()
|
self.typing_env[name] = types.TVar()
|
||||||
|
|
||||||
def visit_arg(self, node):
|
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._assignable(node.arg)
|
||||||
self.params.add(node.arg)
|
self.params.add(node.arg)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,10 @@ def d(x):
|
||||||
# CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and global simultaneously
|
# CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and global simultaneously
|
||||||
global x
|
global x
|
||||||
|
|
||||||
def d(x):
|
def e(x):
|
||||||
# CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and nonlocal simultaneously
|
# CHECK-L: ${LINE:+1}: error: name 'x' cannot be a parameter and nonlocal simultaneously
|
||||||
nonlocal x
|
nonlocal x
|
||||||
|
|
||||||
|
# CHECK-L: ${LINE:+1}: error: duplicate parameter 'x'
|
||||||
|
def f(x, x):
|
||||||
|
pass
|
Loading…
Reference in New Issue