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

Allow Instance.new("Model") :: (Model & {kid: BasePart}) #1456

Open
0x13479 opened this issue Oct 4, 2024 · 1 comment
Open

Allow Instance.new("Model") :: (Model & {kid: BasePart}) #1456

0x13479 opened this issue Oct 4, 2024 · 1 comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@0x13479
Copy link

0x13479 commented Oct 4, 2024

--!strict
local a = Instance.new("Model") :: (Model & {kid: BasePart})
--Type Error: (68,11) Cannot cast 'Model' into 'Model & { kid: BasePart }'
--because the types are unrelated

It would be sensible to allow such casts. they are allowed in the old solver but not in the new one

@0x13479 0x13479 added the bug Something isn't working label Oct 4, 2024
@vegorov-rbx vegorov-rbx added the new solver This issue is specific to the new solver. label Oct 4, 2024
@0x13479
Copy link
Author

0x13479 commented Oct 4, 2024

From the looks of it, instances are not considered tables... here is a very similar warning:

type Widget =
	ButtonWidget |
	InputWidget

type ButtonWidget = {
	type: {
		Value: "Button",
	},
}

type InputWidget = {
	type: {
		Value: "Input",
	}
}

-- "Button" | "Input"
type WidgetClass = index<index<Widget, "type">, "Value">

A warning appears when i add roblox types:

type Widget =
	ButtonWidget |
	InputWidget

type ButtonWidget = {
	type: StringValue & {
		Value: "Button",
	},
}

type InputWidget = {
	type: StringValue & {
		Value: "Input",
	}
}

--Type Error: (57,20) Property '"Value"' does not exist on type
--'(StringValue & { Value: "Button" }) | (StringValue & { Value: "Input" })'
type WidgetClass = index<index<Widget, "type">, "Value">

AND it does not appear if:

type ButtonWidget = {
	type: StringValue & {
		Value: "Button",
	},
}

type InputWidget = {
	-- 'StringValue &' is missing
	type: {
		Value: "Input",
	}
}

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

2 participants