@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 I mean that the compiler throws a compiler error so I don't have to find out at runtime my assumptions were wrong
@rq What would you expect the compiler to do in the desired world if it couldn't determine whether the assumption is always held?
@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
@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 forf
(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