diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 3d69c73c32..93bfe8bdfb 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -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) diff --git a/integration_tests/test_ConstantEllipsis b/integration_tests/test_ConstantEllipsis new file mode 100644 index 0000000000..58222aa9eb --- /dev/null +++ b/integration_tests/test_ConstantEllipsis @@ -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() \ No newline at end of file diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 506cc52c25..cdcd3badcc 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -6236,6 +6236,10 @@ class BodyVisitor : public CommonVisitor { } } + void visit_ConstantEllipsis(const AST::ConstantEllipsis_t &/*x*/) { + tmp = nullptr; + } + void visit_Pass(const AST::Pass_t &/*x*/) { tmp = nullptr; } @@ -6443,7 +6447,7 @@ class BodyVisitor : public CommonVisitor { // 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(*tmp) ) { + if( tmp && !ASR::is_a(*tmp) ) { LCOMPILERS_ASSERT(ASR::is_a(*tmp)); tmp = nullptr; }