soul-lang / SOUL

The SOUL programming language and API
Other
1.71k stars 96 forks source link

Bracketed array access wraps index #30

Closed ellapollack closed 4 years ago

ellapollack commented 4 years ago

The Syntax Guide says that array access like arr[index] should raise an error if index is out of range. But the current behavior (as of 0.9.16) is that arr[index] wraps index before accessing elements.

Bug or feature?

julianstorer commented 4 years ago

I can't find anything like that in the docs, where did you read it? I need to change it if that's true, because it's not how it works.

There are no runtime errors for out-of-bound access, it always wraps the index unless it can predict at compile time that the value is guaranteed to be in range, and it emits a performance warning if it needs to add a runtime wrap step to the operation.

julianstorer commented 4 years ago

oh, I see what you mean now - some of the examples say they cause an error. It's just poorly explained, I'll try to do a better job of describing it!

ellapollack commented 4 years ago

Ah, I see. Thanks for clearing that up :)