Closed
Description
I imitated some code in integration_tests/array_expr02.py
. Here is a snippet:
def modify(array_a: f32[:], n: i32) -> f32[n]:
return sqrt(array_a)
In my context, this pattern generated an unhandled exception.
import numpy
from numpy import array, empty, int16
from lpython import (i16, i32, ccallback, c_p_pointer, Pointer, u64, CPtr, i64,
ccall, sizeof, Array, Allocatable, TypeVar, Const)
@ccall
def _lfortran_malloc(size : i32) -> CPtr:
"""Borrow from bindc_07.py in integration_tests."""
pass
rows = TypeVar("rows")
cols = TypeVar("cols")
def load_lpython_array_from_c_fortran_array(b: CPtr, rows: i32, cols: i32) -> i16[rows, cols]:
"""Load an LPython array from a C / Fortran array."""
B: Pointer[i16[:]] = c_p_pointer(b, i16[:], array([rows * cols]))
D: i16[rows, cols] = empty((rows, cols), dtype=int16)
i: i32
j: i32
for i in range(rows):
for j in range(cols):
D[i, j] = B[(i * cols) + j]
return D
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ATTENTION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def spot_print_lpython_array(a: i16[:], rows: i32, cols: i32) -> None:
pass
def main() -> i32:
# "Const" lets these appear in type declarations such as i16[n, m]
n : Const[i32] = 15
m : Const[i32] = 3
Anm_l4 : CPtr = _lfortran_malloc((n * m) * i32(sizeof(i16)))
Anm: i16[n, m] = load_lpython_array_from_c_fortran_array(Anm_l4, n, m)
spot_print_lpython_array(Anm, n, m)
return 0
if __name__ == "__main__":
main()
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)──────────────────────────────────────────────────────────────────────────────(brian@MacBook-Pro:s001)─┐
└─(19:42:08 on vector-backend ✹ ✭)──> PYTHONPATH=".:../src/runtime/lpython:.." LPYTHON_PY_MOD_NAME="" LPYTHON_PY_MOD_PATH="_lpython-tmp-test-cpython" python ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2497.py
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)──────────────────────────────────────────────────────────────────────────────(brian@MacBook-Pro:s001)─┐
└─(19:43:02 on vector-backend ✹ ✭)──> lpython ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2497.py ──(Tue,Feb06)─┘
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 824
res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/lpython/python_evaluator.cpp", line 71
run_fn, infile);
File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 9276
pass_manager.apply_passes(al, &asr, co.po, diagnostics);
File "/Users/brian/Documents/GitHub/lpython/src/libasr/pass/pass_manager.h", line 299
apply_passes(al, asr, _passes, pass_options, diagnostics);
File "/Users/brian/Documents/GitHub/lpython/src/libasr/pass/pass_manager.h", line 160
_passes_db[passes[i]](al, *asr, pass_options);
File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/libasr/pass/pass_array_by_data.cpp", line 651
u.visit_TranslationUnit(unit);
File "../libasr/asr.h", line 39627
File "../libasr/asr.h", line 5060
File "../libasr/asr.h", line 4774
File "../libasr/asr.h", line 39645
File "../libasr/asr.h", line 5060
File "../libasr/asr.h", line 4775
File "../libasr/asr.h", line 39661
File "../libasr/asr.h", line 39621
File "../libasr/asr.h", line 5077
File "../libasr/asr.h", line 4825
File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/libasr/pass/pass_array_by_data.cpp", line 573
visit_Call(x);
File "/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/libasr/pass/pass_array_by_data.cpp", line 540
throw LCompilersException("Number of arguments in the new "
LCompilersException: Number of arguments in the new function call doesn't satisfy min_args <= new_args.size() <= max_args, 5 <= 7 <= 5