Dynamic property access on enums and the Enum global fail to typecheck in strict mode, despite being constant

When performing a dynamic property access on an enum or the global Enum object, a type error is thrown, warning about a potentially unsafe operation where the indexed enum may not exist at runtime. However due to the fact that enums are constants this case can never occur as they are immutable and always loaded.

--!strict
local str, otherStr = 'KeyCode', 'H'
local _ = Enum[str] --Attempting a dynamic property access on type 'Enums' is unsafe and may cause exceptions at runtime
local _ = Enum.KeyCode[otherStr] --Attempting a dynamic property access on type 'typeof(Enum.KeyCode)' is unsafe and may cause exceptions at runtime

This did not occur previously and may be related to the fix here:

Expected behavior

No type error is reported, matching the original behavior.

3 Likes

Bumping, encountering the same problem still.

Thanks for bringing this to our attention! We’re taking a look at this.

1 Like

We’ve just rolled out a fix for this issue! Take a moment to check and confirm if everything is working as expected on your end.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.