Type check error when indexing members of a type-checked table that could be nil just after the table has been assigned to a non-nil value

Reproduction Steps

Open a script and insert the following code:

local Table: {Member: boolean}? = nil
Table = {Member = true}
print(Table.Member)

Line 3 will display the following type checking error due to the use of Table.Member:

Value of type '{| Member: boolean |}' could be nil

Roblox Studio Version: 0.529.1.5290370 (64bit)

Expected Behavior

Because the member was used right after assigning the table to a value the type-checking error should not be displayed.

Actual Behavior

Line 3 of the reproduction code will display the following type checking error due to the use of Table.Member even though we know that Table is not nil:

Value of type '{| Member: boolean |}' could be nil

Issue Area: Studio
Issue Type: Other
Impact: Low
Frequency: Often
Date Last Experienced: 2022-06-02 11:06:00 (+12:00)

Hello and thank you for the report.

We have people working on a feature that will fix this and similar issues in more complicated cases.
We don’t have a timeline for the release of that feature yet.

4 Likes