You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Main function that will be called twice, and the second time it gets called it will print 64. However the type solver throws unclear type error.
typeFunc= () ->numberlocalFuncThatReturnsNumber:Func?=nillocalfunctionGetFuncThatReturnsNumber(): Funcreturnfunction()
return64endendlocalfunctionMain()
ifFuncThatReturnsNumberthenlocalposition=FuncThatReturnsNumber() -- TypeError: Cannot call a value of type ((() -> number)?) & (buffer | class | function | number | string | table | thread | true) Luau(1020)-- local position: 'aprint(position)
elseFuncThatReturnsNumber=GetFuncThatReturnsNumber()
endendMain() -- Prints nothingMain() -- Prints 64
This does not happen when the if statement is not wrapped inside a function.
typeFunc= () ->numberlocalFuncThatReturnsNumber:Func?=nillocalfunctionGetFuncThatReturnsNumber(): Funcreturnfunction()
return64endendifFuncThatReturnsNumberthenlocalposition=FuncThatReturnsNumber() -- numberprint(position)
elseFuncThatReturnsNumber=GetFuncThatReturnsNumber()
end
The text was updated successfully, but these errors were encountered:
Daw588
changed the title
New type solver throws weird type error when code is wrapped inside a function.
New type solver throws weird type error when code is wrapped inside a function
Sep 12, 2024
Daw588
changed the title
New type solver throws weird type error when code is wrapped inside a function
New type solver throws unclear type error when code is wrapped inside a function
Sep 13, 2024
The problem here is that intersections of the function type (or unions including it) with individual specific function types do not correctly simplify. So, (() -> number) | nil intersected with ~(false | nil) (which is what the refinement for a truthy test does) doesn't correctly simplify to () -> number. We might be able to fix this sooner, but this will definitely be addressed by the upcoming work on integrated e-graphs (#1285, but there's follow-up integration work that is under way).
aatxe
changed the title
New type solver throws unclear type error when code is wrapped inside a function
Intersections of specific function types and the top function type do not normalize correctly
Sep 13, 2024
I have a
Main
function that will be called twice, and the second time it gets called it will print64
. However the type solver throws unclear type error.This does not happen when the if statement is not wrapped inside a function.
The text was updated successfully, but these errors were encountered: