Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new solver has problems with generic typing #1442

Open
idk-i-reportbugs opened this issue Sep 28, 2024 · 1 comment
Open

new solver has problems with generic typing #1442

idk-i-reportbugs opened this issue Sep 28, 2024 · 1 comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@idk-i-reportbugs
Copy link

idk-i-reportbugs commented Sep 28, 2024


this code raises 2 errors:

local function lerp<T>(a: T, b: T, t: number): T
	if type(a) ~= type(b) or (type(a) ~= "number" and type(a) ~= "vector") then
		warn(`Unable to cast {typeof(a)} to number or vector`)
		return a
	end
	return a + (b - a) * t
end

Error 1:
line 2 gives the error: Type function instance union<*blocked-203614*, nil> is uninhabited
entire line was highlighted, except if and then

Error 2:
normally, line 6 should detect that generic type T should either be number, Vector3 or Vector2 (because of the ifs at line 2-5)
however, that doesn't happen. Instead, I get an error at line 6: Type function instance intersect<T, number> is uninhabited


Moreover, it seems like typechecking has problems with for i, v in table do, where pairs, ipairs or next is omitted
Error message: Cannot iterate over a table without indexer
the table:

type RigAnimationAxisTable<T> = {
	RootJoint: T,
	Neck: T,
	["Right Shoulder"]: T,
	["Left Shoulder"]: T,
	["Right Hip"]: T,
	["Left Hip"]: T,
}

local joint_names: RigAnimationAxisTable<true> = {
	RootJoint = true,
	Neck = true,
	["Right Shoulder"] = true,
	["Left Shoulder"] = true,
	["Right Hip"] = true,
	["Left Hip"] = true,
}
  • all of these use strict typechecking
  • after a bit of checking, issue 1 seems to apply anytime i use a generic type in a similar way, and then try to check the type of said parameter
@idk-i-reportbugs idk-i-reportbugs added the bug Something isn't working label Sep 28, 2024
@idk-i-reportbugs idk-i-reportbugs changed the title new typechecking has problems with generic typing new solver has problems with generic typing Sep 28, 2024
@AshleyFlow
Copy link

I've found a similar issue with generics... intersections?...

local function foo<T>(bar: number & T)
	assert(typeof(bar) == "number")

	typeof(bar) -- TypeError: Type function instance intersect<T & number, number> is uninhabited
end

after the assertion bar turns into intersect<T & number, number> which causes the type error

@aatxe aatxe added the new solver This issue is specific to the new solver. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.
Development

No branches or pull requests

3 participants