Hello matevskial,
Welcome to the forum.
The default settings of Lazarus is to ignore many compile-time (and runtime) checks that avoid programmers to do bad things. It is good for performance. I guess you're coming from other language's IDE, which those settings are on by default.
To enable the checks:
Lazarus main menu > Project > Project Options > Debugging > turn on these things:
- I/O
- Range
- Overflow
- Stack
- Verify method calls
- Include assertion code
Range check is associated with array dimension, which is what you're asking. Turn it on and try to run the code.