Typechecking on Functions #1260
-
Taking a look at the following code: --!strict
local TestFunc: (number, string) -> nil = function()
end Is it intentional that I don't see any warnings/errors telling me that the assigned function doesn't have the same signature as the type I declared for the variable? |
Beta Was this translation helpful? Give feedback.
Answered by
alexmccord
May 19, 2024
Replies: 1 comment 3 replies
-
Are you using |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay. I asked because
luau-analyze
was separate fromluau
and it wasn't mentioned in there.So, it is the case that a function of the type
() -> ()
is compatible with(number, string) -> nil
, ignoring the()
vsnil
that we've grown to regret. You are always allowed to pass excess amount of arguments to a function because that function doesn't make use of those excess arguments. Therefore no errors are produced.