aboutsummaryrefslogtreecommitdiff
path: root/tests/basics/syntaxerror_return.py
blob: a32bfbd33cdf5be2d4829401724457c0eb705e3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# With MICROPY_CPYTHON_COMPAT, the "return" statement can only appear in a
# function.
# Otherwise (in minimal builds), it ends execution of a module/class.

try:
    exec
except NameError:
    print("SKIP")
    raise SystemExit

try:
    exec('return; print("this should not be executed.")')
    # if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
    # should be skipped.
    print("SKIP")
    raise SystemExit
except SyntaxError:
    print('SyntaxError')