2015-06-30 01:12:09 +08:00
|
|
|
# RUN: %python -m artiq.compiler.typing +diag %s >%t
|
2015-06-06 23:05:06 +08:00
|
|
|
# RUN: OutputCheck %s --file-to-check=%t
|
|
|
|
|
2015-06-15 16:30:50 +08:00
|
|
|
x = 1
|
2015-06-06 23:05:06 +08:00
|
|
|
def a():
|
2015-06-11 08:55:06 +08:00
|
|
|
# CHECK-L: ${LINE:+1}: error: cannot declare name 'x' as nonlocal: it is not bound in any outer scope
|
2015-06-06 23:05:06 +08:00
|
|
|
nonlocal x
|
|
|
|
|
2015-06-15 16:30:50 +08:00
|
|
|
def f():
|
|
|
|
y = 1
|
|
|
|
def b():
|
|
|
|
nonlocal y
|
|
|
|
# CHECK-L: ${LINE:+1}: error: name 'y' cannot be nonlocal and global simultaneously
|
|
|
|
global y
|
2015-06-06 23:05:06 +08:00
|
|
|
|
2015-06-15 16:30:50 +08:00
|
|
|
def c():
|
|
|
|
global y
|
|
|
|
# CHECK-L: ${LINE:+1}: error: name 'y' cannot be global and nonlocal simultaneously
|
|
|
|
nonlocal y
|
2015-06-06 23:05:06 +08:00
|
|
|
|
2015-06-15 16:30:50 +08:00
|
|
|
def d(y):
|
|
|
|
# CHECK-L: ${LINE:+1}: error: name 'y' cannot be a parameter and global simultaneously
|
|
|
|
global y
|
2015-06-06 23:05:06 +08:00
|
|
|
|
2015-06-15 16:30:50 +08:00
|
|
|
def e(y):
|
|
|
|
# CHECK-L: ${LINE:+1}: error: name 'y' cannot be a parameter and nonlocal simultaneously
|
|
|
|
nonlocal y
|
2015-06-15 14:05:24 +08:00
|
|
|
|
|
|
|
# CHECK-L: ${LINE:+1}: error: duplicate parameter 'x'
|
|
|
|
def f(x, x):
|
|
|
|
pass
|
2015-06-15 16:30:50 +08:00
|
|
|
|
|
|
|
# CHECK-L: ${LINE:+1}: error: variadic arguments are not supported
|
|
|
|
def g(*x):
|
|
|
|
pass
|