Skip to content

Misleading error message #2492

Open
Open
@rebcabin

Description

@rebcabin
from numpy import empty, int16

from lpython import (i16, i32, CPtr, ccall, sizeof)


@ccall
def _lfortran_malloc(size : i32) -> CPtr:
    """borrowed from bindc_07.py in integration_tests"""
    pass


def main():
    n  : i32 = 15  # <~~~~~~~~~~~ LOOKS LIKE COMPILE-TIME CONSTANT ??? ~~~~~~~~~~
    m  : i32 = 3

    # Emulate getting stuff from the C side.
    Anm_l4 : CPtr = _lfortran_malloc( (n * m) * i32(sizeof(i16)) )
    A_nm: i16[n, m] = empty((n, m), dtype=int16)


if __name__ == "__main__":
    main()
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)────(brian@MacBook-Pro:s001)─┐
└─(12:16:55 on vector-backend ✹ ✭)──> lpython ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2492.py                                              2 ↵ ──(Tue,Feb06)─┘
semantic error: Only those local variables which can be reduced to compile time constant should be used in dimensions of an array.
  --> ../ISSUES/UNHANDLED-EXCEPTIONS/Issue2492.py:18:15
   |
18 |     A_nm: i16[n, m] = empty((n, m), dtype=int16)
   |               ^ 

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