TheRealMichaelWang/cish

Type Safety Issue with Down-casting Type Arguments for Reference-Types

Closed this issue · 2 comments

I hadn't considered the possibility until now that one couldn't downcast safely because of mutability. See this SO thread for details.

One potential fix I am considering is to allow down-casting for arrays, and type-check each assignment during runtime. See the upcasting branch, which will add run-time type information for runtime-typechecking and runtime-typecasting, for more information. Array assignment will leverage this new feature for safety.

However that still leaves out regular types. I think the only soloution at this point would be to disallow implicit down-casting for record type arguments during compile time, like Java.

After some further analysis, it is impossible to implement such a feature that saves silent params for type arguments whilst also including some for type signature comparisons is impossible because it is impossible to determine such information purely at compile time from the procedure calling perspective.

The temporary solution for now is to be able to detect this unsaftey and panic.