news-2022-11-01-luau-recap-september-october-2022.md
November 1, 2022
One of the most important goals for Luau is to avoid false positives, that is cases where Script Analysis reports a type error, but in fact the code is correct. This is very frustrating, especially for beginners. Spending time chasing down a gnarly type error only to discover that it was the type system that’s wrong is nobody’s idea of fun!
We are pleased to announce that a major component of minimizing false positives has landed, semantic subtyping, which removes a class of false positives caused by failures of subtyping. For example, in the program
an error is reported, even though there is no problem at runtime. This is because CFrame’s multiplication has two overloads:
The current syntax-driven algorithm for subtyping is not sophisticated enough to realize that this is a subtype of the desired type:
Our new algorithm is driven by the semantics of subtyping, not the syntax of types, and eliminates this class of false positives.
If you want to know more about semantic subtyping in Luau, check out our technical blog post on the subject.
{ ... }.() -> (number...).getmetatable and setmetatable.Thanks for all the contributions!