summaryrefslogtreecommitdiff
path: root/tests/basics/async_syntaxerror.py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-03-01 09:40:43 -0600
committerDamien George <damien@micropython.org>2021-05-30 10:38:48 +1000
commitf2dbc9102251f092e93b7c87cd8ffa5e9e5b880b (patch)
treef1f42bde0323d14ada0f8a057ac2956833a500eb /tests/basics/async_syntaxerror.py
parenta60ad3364132b9c4a30b20cd91fd5cd1ac965618 (diff)
py/compile: Raise an error on async with/for outside an async function.
A simple reproducer is: async for x in (): x Before this change, it would cause an assertion error in mpy-cross and micropython-coverage.
Diffstat (limited to 'tests/basics/async_syntaxerror.py')
-rw-r--r--tests/basics/async_syntaxerror.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/basics/async_syntaxerror.py b/tests/basics/async_syntaxerror.py
new file mode 100644
index 000000000..ddd2c4b59
--- /dev/null
+++ b/tests/basics/async_syntaxerror.py
@@ -0,0 +1,19 @@
+# test syntax errors using async
+
+try:
+ exec
+except NameError:
+ print("SKIP")
+ raise SystemExit
+
+
+def test_syntax(code):
+ try:
+ exec(code)
+ print("no SyntaxError")
+ except SyntaxError:
+ print("SyntaxError")
+
+
+test_syntax("async for x in (): x")
+test_syntax("async with x: x")