Safe array operations

Description

We need an new compiler flag `*unchecked-array-access*`.

We should add a `safe-aget`, `safe-aget` runtime functions. These functions should make three assertions before bottoming out to `unsafe-get`:

  • first argument `array?`

  • second argument must be `number?`

  • second argument must be in array bounds

If `:invalid-array-access` is true, compilation mode is not `:advanced` and `*unchecked-array-access*` is not true, then `aget/aset` macro should not generate inlined JS array access but should instead call `safe-aget` and `safe-aset`.

We also need to update `aset/aget` runtime fns to also do these assertions under the same compiler option configuration specified above.

Finally `*unchecked-array-access*` needs to be be set to true for the standard library. It's important that this flag is file local and we should provide a simple test that setting it in one file will not affect a dependent namespace.

Environment

None

Assignee

David Nolen

Reporter

David Nolen

Labels

Approval

Vetted

Patch

Code and Test

Fix versions

Affects versions

Priority

Critical
Configure