Skip to content

Commit 2afa365

Browse files
authored
Implemented visit_AsyncFunctionDef in the AST->ASR visitor (#2442)
1 parent c2ae7ac commit 2afa365

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
592592
return nullptr;
593593
}
594594

595+
596+
void visit_AsyncFunctionDef(const AST::AsyncFunctionDef_t &x){
597+
throw SemanticError("The `async` keyword is currently not supported", x.base.base.loc);
598+
}
599+
595600
void visit_expr_list(AST::expr_t** exprs, size_t n,
596601
Vec<ASR::expr_t*>& exprs_vec) {
597602
LCOMPILERS_ASSERT(exprs_vec.reserve_called);

tests/errors/test_async.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
async def test_async():
2+
print("done")
3+
4+
test_async()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_async-361297c",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_async.py",
5+
"infile_hash": "f4d737246effd50f1798a81f07042ad15a045e275448fe0226334f03",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_async-361297c.stderr",
11+
"stderr_hash": "abf614594f89a7a6d93d469d512e31de5adc64feef866957de80cd03",
12+
"returncode": 2
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
semantic error: The `async` keyword is currently not supported
2+
--> tests/errors/test_async.py:1:1 - 2:17
3+
|
4+
1 | async def test_async():
5+
| ^^^^^^^^^^^^^^^^^^^^^^^...
6+
...
7+
|
8+
2 | print("done")
9+
| ...^^^^^^^^^^^^^^^^^

tests/tests.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ ast_new = true
784784

785785
# tests/errors
786786

787+
[[test]]
788+
filename = "errors/test_async.py"
789+
asr = true
790+
787791
[[test]]
788792
filename = "errors/test_str_indexing.py"
789793
asr = true

0 commit comments

Comments
 (0)