diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index a3bb17a49a..5eb253f8f0 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -592,6 +592,11 @@ class CommonVisitor : public AST::BaseVisitor { return nullptr; } + + void visit_AsyncFunctionDef(const AST::AsyncFunctionDef_t &x){ + throw SemanticError("The `async` keyword is currently not supported", x.base.base.loc); + } + void visit_expr_list(AST::expr_t** exprs, size_t n, Vec& exprs_vec) { LCOMPILERS_ASSERT(exprs_vec.reserve_called); diff --git a/tests/errors/test_async.py b/tests/errors/test_async.py new file mode 100644 index 0000000000..a435c814aa --- /dev/null +++ b/tests/errors/test_async.py @@ -0,0 +1,4 @@ +async def test_async(): + print("done") + +test_async() \ No newline at end of file diff --git a/tests/reference/asr-test_async-361297c.json b/tests/reference/asr-test_async-361297c.json new file mode 100644 index 0000000000..4477cbad49 --- /dev/null +++ b/tests/reference/asr-test_async-361297c.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-test_async-361297c", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/errors/test_async.py", + "infile_hash": "f4d737246effd50f1798a81f07042ad15a045e275448fe0226334f03", + "outfile": null, + "outfile_hash": null, + "stdout": null, + "stdout_hash": null, + "stderr": "asr-test_async-361297c.stderr", + "stderr_hash": "abf614594f89a7a6d93d469d512e31de5adc64feef866957de80cd03", + "returncode": 2 +} \ No newline at end of file diff --git a/tests/reference/asr-test_async-361297c.stderr b/tests/reference/asr-test_async-361297c.stderr new file mode 100644 index 0000000000..c24b2174ae --- /dev/null +++ b/tests/reference/asr-test_async-361297c.stderr @@ -0,0 +1,9 @@ +semantic error: The `async` keyword is currently not supported + --> tests/errors/test_async.py:1:1 - 2:17 + | +1 | async def test_async(): + | ^^^^^^^^^^^^^^^^^^^^^^^... +... + | +2 | print("done") + | ...^^^^^^^^^^^^^^^^^ diff --git a/tests/tests.toml b/tests/tests.toml index 9ed98dd2f7..5f6f56a9cf 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -784,6 +784,10 @@ ast_new = true # tests/errors +[[test]] +filename = "errors/test_async.py" +asr = true + [[test]] filename = "errors/test_str_indexing.py" asr = true