forked from M-Labs/artiq
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()
|
||||
|
||||
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)
|
||||
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user