ID:2130609
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
mob
var
A = 0 // set to a number
strict/B = "" // set to a string
Login()
. = 444
A = . // Sets A to "444"
B = . // Produces an error because . is not a string which was B's initial value type.
Pretty sure the compiler would have no way of doing this. Runtime, sure, compile-time? Doubtful.
Think it would be possible to get its value at run-time when it's created and set that to its specific-type if the variable is set to strict?

A run-time error/crash would be okay imo too :)
Probably best to handle those kinds of checks yourself.
To implement this, an additional if() check would be needed during all var writes that would slow all code down across the board. That's a non-starter, at least as far as runtime checks would be concerned.

There is a distant possibility that the compiler could be made to recognize this and simply build in an automatic istype() assertion.