← Back to context

Comment by delian66

3 years ago

> Bounds checking

    fn main() {
        x := []&int { len: 10, cap: 0 }
        println(x[4])
    }

Again, a bug caused by the auto generated string conversion method for arrays of pointers, that does not check for nil pointers. Once https://github.com/vlang/v/issues/14786 is fixed, that will work too.

It has nothing to do with bounds checking, as you can see if you just use `x := []int { len: 10, cap: 0 }` instead.

> Allowing the user to control the len property is a really bad idea.

Can you clarify what you mean by that?