Skip to content

Bug: Assert failure in logical operation #2597

Closed
@ubaidsk

Description

@ubaidsk
% cat examples/expr2.py 
print(2.0 > 0.0 and 2.0**0.5)
% python examples/expr2.py                
1.4142135623730951
% lpython examples/expr2.py --backend llvm
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/bin/lpython.cpp", line 1929
    err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/bin/lpython.cpp", line 837
    r1 = LCompilers::LPython::python_ast_to_asr(al, lm, nullptr, *ast, diagnostics, compiler_options,
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 8149
    auto res2 = body_visitor(al, lm, *ast_m, diagnostics, unit, main_module, module_name,
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 8085
    BodyVisitor b(al, lm, unit, diagnostics, main_module, module_name, ast_overload, allow_implicit_casting);
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4732
    visit_stmt(*x.m_body[i]);
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/python_ast.h", line 1883
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/python_ast.h", line 1772
    case stmtType::Nonlocal: { v.visit_Nonlocal((const Nonlocal_t &)x); return; }
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 6524
    AST::Call_t *c = AST::down_cast<AST::Call_t>(x.m_value);
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7618
    visit_expr_list(x.m_args, x.n_args, args);
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 613
    this->visit_expr(*exprs[i]);
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/python_ast.h", line 1910
    void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/python_ast.h", line 1784
    case exprType::BoolOp: { v.visit_BoolOp((const BoolOp_t &)x); return; }
  File "/Users/ubaid/Desktop/OpenSource/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 3329
    LCOMPILERS_ASSERT(
AssertFailed: ASRUtils::check_equal_type(ASRUtils::expr_type(lhs), ASRUtils::expr_type(rhs))

We should rather be printing a semantic error that the types to the logical operation are not equal and also are not of type logical.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions