Why doesn't checking if it's in the range at the beginning and blowing up if not do what you want?
@robryk@qoto.org String patterns. Let's say function f processes a string and expects certain patterns and length. I wrote it half a year ago. It cannot fail on valid input.
Now, I put f somewhere else, but I forgot to put code that validates it's valid input for f (because at the original calling site, the input was always valid, so I had nothing to check).
The alternative is that every calling site has to error check or I have an unhandled return value or, worse, I have to do multi-return in a language that only has one return
@rq What did you mean by blow up? I thought you meant safely crashing. If so, you can add the verification at the beginning of the function itself and crash there.
@robryk@qoto.org Yell at me to add code to ensure the assumption is always held or to add a compiler hint if I know it'll always be held