Skip to content

Unhandled Exception for simple array allocation #2491

Open
@rebcabin

Description

@rebcabin

passes CPython but not lpython

import numpy
from numpy import empty

from lpython import (i16)


def main():
    A_nm: i16[15, 3] = empty((15, 3), dtype=numpy.int16)
    print ("hello, world!")


if __name__ == "__main__":
    main()
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)────(brian@MacBook-Pro:s001)─┐
└─(11:58:11 on vector-backend ✹ ✭)──> lpython ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2491.py

Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/bin/lpython.cpp", line 1872
    err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/bin/lpython.cpp", line 786
    r1 = LCompilers::LPython::python_ast_to_asr(al, lm, nullptr, *ast, diagnostics, compiler_options,
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7996
    auto res2 = body_visitor(al, lm, *ast_m, diagnostics, unit, main_module, module_name,
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7932
    BodyVisitor b(al, lm, unit, diagnostics, main_module, module_name, ast_overload, allow_implicit_casting);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4713
    visit_stmt(*x.m_body[i]);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1883
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1751
    case stmtType::FunctionDef: { v.visit_FunctionDef((const FunctionDef_t &)x); return; }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4814
    handle_fn(x, *f);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4790
    transform_stmts(body, x.n_body, x.m_body);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4667
    this->visit_stmt(*m_body[i]);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1883
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1757
    case stmtType::AugAssign: { v.visit_AugAssign((const AugAssign_t &)x); return; }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4885
    visit_AnnAssignUtil(x, var_name, init_expr);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 2812
    this->visit_expr(*x.m_value);
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1910
    void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_ast.h", line 1799
    case exprType::Compare: { v.visit_Compare((const Compare_t &)x); return; }
  File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7577
    LCOMPILERS_ASSERT(false);
AssertFailed: false
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)────(brian@MacBook-Pro:s001)─┐
└─(11:59:37 on vector-backend ✹ ✭)──> PYTHONPATH=".:../src/runtime/lpython:.." LPYTHON_PY_MOD_NAME="" LPYTHON_PY_MOD_PATH="_lpython-tmp-test-cpython" python ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2491.py

hello, world!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions