Skip to content

Commit

Permalink
Add Visit Ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
faze-geek committed Jun 25, 2023
1 parent dbee8ff commit 6a9ae81
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ RUN(NAME test_generics_01 LABELS cpython llvm c NOFAST)
RUN(NAME test_cmath LABELS cpython llvm c NOFAST)
RUN(NAME test_complex_01 LABELS cpython llvm c wasm wasm_x64)
RUN(NAME test_complex_02 LABELS cpython llvm c)
RUN(NAME test_ConstantEllipsis LABLES cpython llvm c)
RUN(NAME test_max_min LABELS cpython llvm c)
RUN(NAME test_global LABELS cpython llvm c)
RUN(NAME test_global_decl LABELS cpython llvm c)
Expand Down
13 changes: 13 additions & 0 deletions integration_tests/test_ConstantEllipsis
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from lpython import i32

def test_Ellipsis_Function():
...

def test_Ellipsis_For():
i:i32
for i in range(5):
...

def main0():
test_Ellipsis_Function()
test_Ellipsis_For()
6 changes: 5 additions & 1 deletion src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6236,6 +6236,10 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
}
}

void visit_ConstantEllipsis(const AST::ConstantEllipsis_t &/*x*/) {
tmp = nullptr;
}

void visit_Pass(const AST::Pass_t &/*x*/) {
tmp = nullptr;
}
Expand Down Expand Up @@ -6443,7 +6447,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
// If tmp is a statement and not an expression
// never cast into expression using ASRUtils::EXPR
// Just ignore and exit the function naturally.
if( !ASR::is_a<ASR::stmt_t>(*tmp) ) {
if( tmp && !ASR::is_a<ASR::stmt_t>(*tmp) ) {
LCOMPILERS_ASSERT(ASR::is_a<ASR::expr_t>(*tmp));
tmp = nullptr;
}
Expand Down

0 comments on commit 6a9ae81

Please sign in to comment.