Minimal example:
local hello : string = "world"
if hello == "" then
return
end
string.find(hello, "bye")
-- Type Error: the function 'string.find' expects to get a string as its 1st argument, but is being given a string & ~""
The same behavior applies to some other methods such as sub, match, split, etc.
Expected behavior
I believe this error is incorrect because the indicated type is a subtype of string (every non-empty string is still of type string).
The following counterexample does not produce an error.
local function foo(bar : string)
return bar
end
local hello : string = "world"
if hello == "" then
return
end
foo(hello)