Yes, if all operands are comptime-known (or comptime-length-known), bounds checks happen eagerly at compile time.
> Could I use variables as the indices and, if so, could I get a seg fault at runtime or are there some sort of guards on there?
Yes you can use variables. If they're out of range, behavior depends on the build mode:
- In Debug and ReleaseSafe, you get a guaranteed panic (which aborts the app with a stack trace)
- In ReleaseSmall and ReleaseFast, you get undefined behavior
On their discord I suggested a version of slicing that bounds checks in all modes (something like `slice?[1..5]`, syntax doesn't matter) and returns an optional slice, which is null if the bounds are out of range. But they didn't seem too keen on it. So I've been using a little wrapper function instead.