From f2dbc9102251f092e93b7c87cd8ffa5e9e5b880b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 1 Mar 2020 09:40:43 -0600 Subject: 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. --- tests/basics/async_syntaxerror.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/basics/async_syntaxerror.py (limited to 'tests/basics/async_syntaxerror.py') 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") -- cgit v1.2.3