icicle-lang / icicle-ambiata

A streaming query language.
BSD 3-Clause "New" or "Revised" License
57 stars 11 forks source link

Safe array indexing #637

Closed amosr closed 6 years ago

amosr commented 7 years ago

586

New exception tags: NotANumber and IndexOutOfBounds.

Make index return Possibly in Source. This is converted to a straightforward safe indexing in Core, which returns Sum Error t. Having safe indexing in Core means we can generate random programs using that. Then when we flatten, it introduces explicit bounds checks before converting to unsafe indexing.

The array and map primitives in Flatten are using unsafe indexing, so this won't affect them.

! @jystic @tranma /jury approved @jystic

tranma commented 7 years ago

very good, it's long overdue 😁

amosr commented 7 years ago

I'm going to hold off merging this one until we've updated payload to master. Have tested on one production dictionary but would prefer to test everywhere, since it does affect the front-end language.

jacobstanley commented 7 years ago

👍

amosr commented 6 years ago

I don't entirely remember why I said above I would wait until merging, but I think it was so this change didn't get confused with other changes, in the unlikely case it breaks an existing dictionary. this is no longer relevant, so I'll just merge