luau icon indicating copy to clipboard operation
luau copied to clipboard

Type functions can be named "typeof"

Open nothing1649 opened this issue 1 year ago • 1 comments

As of version 0.655, type functions can be named "typeof", which appears to be an oversight as type aliases can't be named typeof and cause a syntax error when attempting to do so. The resulting type function can't be used in a type alias (unless imported from a module).

--!strict
type function typeof(t) --no error
	return t
end

local _:typeof<number> = 1 --invalid, parsed as typeof type

nothing1649 avatar Dec 14 '24 02:12 nothing1649

some of the text in the original post resulted from confusion with typeof(t) not returning 'type' as described in the type function rfc and causing me to think that it couldn't be called from another type function, i'll leave it up in case it isn't actually intended

nothing1649 avatar Dec 14 '24 02:12 nothing1649

fixed in 0.670 by making it an error to define these: https://github.com/luau-lang/luau/pull/1779

nothing1649 avatar Apr 24 '25 21:04 nothing1649