odin-lang / odin-lang.org

http://odin-lang.org
22 stars 81 forks source link

Compile-time array access bound checking statement should be corrected/updated #147

Closed mahSource closed 8 months ago

mahSource commented 11 months ago

In the Odin Overview in this section: https://odin-lang.org/docs/overview/#fixed-arrays It states:

Array access is always bounds checked (at compile-time and at runtime). 

This is not true, it is not always checked. For example the code below does not throw a compilation warning or compilation error; but thankfully does panic (error) during runtime.

myarray3 := [?]int{1, 2, 3, 4, 5, 6}
    for i in 0 ..= 6 {
        fmt.print(myarray3[i], "")
    }

Suggest to change Overview sentence to this or something similar:

Array access is bounds checked by default, both at compile-time (with constant indices) and at runtime.

Thanks to Sentient Coffee for the suggested wording tweak!

Skytrias commented 8 months ago

next time feel free to create a PR with all fixes combined 😄