[Typed Luau] Script analyzer doesn't enforce that functions actually return anything

In Typed Luau, the script analyzer doesn’t enforce that functions return something when they say they do, only the type of what they return. This can easily lead to bugs wherein someone forgets to add a return statement.

As an example, paste this code into the script editor and observe that it throws no errors, despite being doomed to error:

--!strict
local function foo(): number

end

local bar = foo()

print(bar + 1)

I almost caused a bug where I returned out of part of a function but not all of it, and it would have been nice to have that caught.

This happens in studio version 0.445.0.410316.

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up here when we have an update for you.

1 Like