Better Python Error Messages Idea

That proposal would also work. I was intentionally trying to avoid making this a something individual IRs would have to carry around, but this would still be ok. Just to make this concrete though, you’d be worried about an ArrayExpression.__getItem__(i) implementation that looked roughly like:

def __getitem__(self, i):
    return ArrayRef(self._ir, hl.cases().when(hl.len(self) < i, i).or_error("Array index out of bounds")

You think that would be significantly slower than handwriting Code that does that check? I guess we don’t want to do it twice, and maybe we still want to do the check on IRs we generate during simplifications, so maybe it’s not ok to only check in Python. Some of my NDArray stuff only has checks in python at this time.