Type Error for dynamic property access on Instance triggers when using a property with the type of keyof<Instance> in New Solver

--!strict

local function get_property(instance: Instance, property: keyof<Instance>): any
-- Type Error: Attempting a dynamic property access on type 'Instance' is unsafe and may cause exceptions at runtime
	return instance[property]
end

Beta Features:

  • New Luau Type Solver

Expected behavior

I would expect it to not trigger if the property is a union of strings that are valid properties.

1 Like

Thank you for the report! This is an, admittedly unsurprising, bug in the new solver. We will try to keep you in the loop as we resolve this.

2 Likes

Any updates regarding this? I’m encountering the same issue and it’s annoying.

Hi! I’m actively working on improving type inference/checking for indexing operations. I’ll post back when I have a fix out.

3 Likes

I am also having this issue… Any updates on this?

any updates on this? this is still an issue

1 Like

any updates?this is stil happening :[

1 Like