tl
tl copied to clipboard
Compiler option to warn when non-boolean values used in if statements
After using teal daily for years, I find that one of the most common mistakes I make is accidentally doing something like
local record Foo
bar: boolean
end
local foo:Foo = {
bar = false
}
if foo then
print("true")
else
print("false")
end
When I meant to do this:
if foo.bar then
print("true")
else
print("false")
end
Teal happily type checks this first code even though foo is a table and not a bool. I suspect most users like this because it's so common to do nil checks, but I would much rather require a strict "if foo == nil then" if I could have teal catch these mistakes instead
Related: https://github.com/teal-language/tl/pull/46
also related: #598