luau icon indicating copy to clipboard operation
luau copied to clipboard

Code is too complex to type check error is too eager with class prototypes in new solver

Open gaymeowing opened this issue 2 months ago • 2 comments

type BaseButtonPrototype = {
	set_active: (plugin_button: { read button: PluginToolbarButton }, active: boolean) -> (),
	__index: BaseButtonPrototype
}

type PluginActionButtonPrototype = BaseButtonPrototype & {
	on_trigger: (plugin_action_button: PluginActionButton, f: () -> ()) -> (() -> ()),
 	__index: PluginActionButtonPrototype,
}

export type PluginActionButton = typeof(setmetatable({} :: {
	read button: PluginToolbarButton,
	read action: PluginAction,
	enabled: boolean,
-- type error occurs when the cast happens {} :: PluginActionButtonPrototype
-- the type error wont occur if __index is removed from BaseButtonPrototype
-- TypeError: Code is too complex to typecheck! Consider simplifying the code around this area Luau (1035)
}, {} :: PluginActionButtonPrototype))

gaymeowing avatar Oct 22 '25 12:10 gaymeowing

What do you mean by "too eager?" This error corresponds to hitting internal limitations in certain places, it's certainly fair to say "i feel like it is too restrictive for this code to error," but the phrasing too eager makes me feel like your expectation might be something else?

aatxe avatar Oct 22 '25 16:10 aatxe

What do you mean by "too eager?" This error corresponds to hitting internal limitations in certain places, it's certainly fair to say "i feel like it is too restrictive for this code to error," but the phrasing too eager makes me feel like your expectation might be something else?

The former, I just couldn't think of a better title for the report.

gaymeowing avatar Oct 25 '25 22:10 gaymeowing