Add protection from calling `typeStr` with an invalid type
This checks before calling typeStr with the places that I could generate a crash, and adds a check for non-debug modes so that they'll return an obvious error instead of illegal behavior.
Closes #585
There are no tests because you need lots of errors in the first place to generate these crashes and I don't think the messages themselves would be very useful. I tested manually by making a builtin with a return type of .invalid and doing various operations on the returned value.
Sorry to make you check all potential places where this could happen but seeing the change now I agree that it'd be better to just check the type in typeStr and return an error.