Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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