Skip to content

Numpy arrays should not allow out of bounds access in case of IndexError #2531

Open
@faze-geek

Description

@faze-geek
from numpy import int32
from enum import Enum

class ArraySizes(Enum):
    SIZE_3: i32 = 3
    SIZE_10: i32 = 10

def f(xi32: i32[:]) -> i32:
    xi32[0] = 1
    xi32[1] = 2
    xi32[2] = 3
    xi32[3] = 4
    print(xi32)
    print(xi32[3])

def d():
    ai32: i32[ArraySizes.SIZE_3] = empty(ArraySizes.SIZE_3.value, dtype=int32)
    f(ai32)

d()

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
1 2 3
4

Metadata

Metadata

Assignees

No one assigned

    Labels

    numpyBugs and feature requests regarding NumPy support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions