2 ms·
> It was my understanding that most/all of this unsoundness can be removed by telling the compiler to disallow a bunch of stuff using command line args, is this
by munificent 10y ago
> It was my understanding that most/all of this unsoundness can be removed by telling the compiler to disallow a bunch of stuff using command line args, is this still not the case?
Nope, it's never been the case, even with all the flags on. It's not about implicit casts, it's about soundness in the actual type rules. Here's an example:
function append(array: Array<Object>) {
array.push("not a number");
}
var nums: Array<number> = [];
append(nums);
console.log(nums[0].toFixed());
If you run this, it throws an exception because String does not have a "toFixed()" method.
> If most of the objects are statically known would it give you a large part of the speed up of a totally static system?
Maybe, but it's hard to say. Once you have a single hole, if you can't check it at runtime right at the hole, then values of the wrong type can spread anywhere in the program.
> In Java and C# there's still some intentional holes in the type systems like the dynamic keyword or casting to object
Right. In the above example, Java and C# would throw an exception when you added the string to the array. This check has some runtime cost, but works.
I believe TypeScript is also unsound around function types, which is harder to address because there's no easy place to know where to add the check.