Skip to content

Unimplemented ... should print error, not throw #2001

Closed

Description

@rebcabin

repro:

def match_symbol() -> None:
    ...

passes CPython, but LPython throws:

/Users/brian/CLionProjects/lpython/src/bin/python /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_lexer.py 
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  File "/Users/brian/CLionProjects/lpython/src/bin/lpython.cpp", line 1844
    err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
  File "/Users/brian/CLionProjects/lpython/src/bin/lpython.cpp", line 783
    r1 = LCompilers::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options,
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7532
    auto res2 = body_visitor(al, lm, *ast_m, diagnostics, unit, main_module,
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7485
    b.visit_Module(ast);
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4620
    visit_stmt(*x.m_body[i]);
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1883
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1751
    case stmtType::FunctionDef: { v.visit_FunctionDef((const FunctionDef_t &)x); return; }
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4727
    handle_fn(x, *f);
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4709
    transform_stmts(body, x.n_body, x.m_body);
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4580
    this->visit_stmt(*m_body[i]);
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1883
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1772
    case stmtType::Nonlocal: { v.visit_Nonlocal((const Nonlocal_t &)x); return; }
  File "/Users/brian/CLionProjects/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 6441
    this->visit_expr(*x.m_value);
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1910
    void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1807
    case exprType::ConstantComplex: { v.visit_ConstantComplex((const ConstantComplex_t &)x); return; }
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_ast.h", line 1935
    void visit_ConstantEllipsis(const ConstantEllipsis_t & /* x */) { throw LCompilersException("visit_ConstantEllipsis() not implemented"); }
LCompilersException: visit_ConstantEllipsis() not implemented

Activity

  1. rebcabin commented on Jun 22, 2023

    @rebcabin
    ContributorAuthor

    Also consider making ... a synonym for pass, which is, I believe, what CPython does (though I am not 100% sure).

  2. faze-geek commented on Jun 24, 2023

    @faze-geek
    Contributor

    @Thirumalai-Shaktivel I see the grammar for ... is already added here -

    #define ELLIPSIS(l) make_ConstantEllipsis_t(p.m_a, l, nullptr)

    A diff like this will do the job here.

    +++ b/src/lpython/semantics/python_ast_to_asr.cpp
    @@ -6240,6 +6240,10 @@ public:
    
    +    void visit_ConstantEllipsis(const AST::ConstantEllipsis_t &/*x*/) {
    +        tmp = nullptr;
    +    }
    +
    

    Kindly check it out once. I'll make a pr for it then.

  3. certik commented on Jun 24, 2023

    @certik
    Contributor

    @faze-geek go ahead and make a PR with a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions