Skip to content

Commit

Permalink
Implemented visit_AsyncFunctionDef in the AST->ASR visitor (#2442)
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwaltwitx authored Dec 14, 2023
1 parent c2ae7ac commit 2afa365
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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<ASR::expr_t*>& exprs_vec) {
LCOMPILERS_ASSERT(exprs_vec.reserve_called);
Expand Down
4 changes: 4 additions & 0 deletions tests/errors/test_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
async def test_async():
print("done")

test_async()
13 changes: 13 additions & 0 deletions tests/reference/asr-test_async-361297c.json
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 9 additions & 0 deletions tests/reference/asr-test_async-361297c.stderr
Original file line number Diff line number Diff line change
@@ -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")
| ...^^^^^^^^^^^^^^^^^
4 changes: 4 additions & 0 deletions tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2afa365

Please sign in to comment.