Autocomplete - Prevent TableState:Free properties with no writeTy to show up when requesting properties from an AST Index #1392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1309
#1389
There is a Unit Test, I hope it explains it.
Now the thing is,
writeTy
is nullopt only in the New Type Solver.When a property is only read from in the old type solver for some reason it also gets a
writeTy
assigned, hence why this fix only works for the new type solver 🤷And when a property is written to
writeTy
is empty in the old solver no clue how.I do know that this fix doesn't work if the FreeType is getting intersected with anything else, but... you'd loop through the intersection type I guess.
I didn't fix it because I ran into a bug that wasn't caused by this change. Which can be found here: #1391
Summary
If you have a TableType with
TableState:Free
doing an autocomplete is actually going to fill up the propeties that were never written to, into the entryMap as well.And this should prevent that from happening. This shouldn't ruin function table based autocompletes.
The purpose of Free Table types is to have unsealed tables work anywhere. You can't actually create a Free Table type with Luau syntax I think. At least yet.