Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free Table State autocompletes "properties that were only read and not written to" outside of the function argument scope in New Solver #1389

Open
karl-police opened this issue Sep 10, 2024 · 0 comments
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@karl-police
Copy link
Contributor

karl-police commented Sep 10, 2024

image

image

TEST_CASE_FIXTURE(ACBuiltinsFixture, "test")
{
    ScopedFastFlag sff[]{
        {FFlag::LuauSolverV2, true},
        //{FFlag::DebugLuauLogSolver, false},
    };

    CheckResult check1 = check(R"(
local tbl_A = {entry1 = nil}

local tbl_Test = {} :: typeof(tbl_A) & tabletype<"free">

tbl_Test.entry2 = "hello"

print(tbl_Test.doesntExist)

tbl_Test.doesExist@1
)");

Description

This is based on #1309 but finally I can state what is wrong.

I don't believe Free Types should be used "free". I know that Free Types are used however, they're controlled. When someone manages to define a free type out of nowhere, weird things happen. At least that's the case with Free Tables.

tabletype<"free"> is a test of mine.

TableType newTbl = TableType(TableState::Free, TypeLevel{}, ctx->constraint->scope.get());

I lack the knowledge about type constraints yet. Otherwise I could have made a unit test that defines a local variable that would have a Free Table Type. While I think there are some examples, I had trouble with this type function and table being properly assigned as a constraint.

Obviously I don't know a lot but. Usually the autocomplete would tell you about properties that the function itself is reading from.

As example, if you'd have

function test(a)
    if (a.entry) then

    end
end

If you'd do

test({@1}) I think the autocomplete would tell you about entry.

But if you're outside a function argument scope, it doesn't really make sense, I am not sure. At least for the autocomplete.

It doesn't make sense that the autocomplete shows properties that are only being read from. 🤷 You'd only need that if you're in the function argument.

Reproduction Steps

You can use the unit test, the only thing you need to replace or change is that tabletype returns a TableType with the "Free" State.

Expected Result

If not in a function body argument, the autocomplete should maybe not autocomplete things that are only being read from.

Especially when I did

tbl_Test.doesExist@1 even that part is being taken in as read and with it being a free type, it will add it into the autocomplete as well.

Actual Result

The autocomplete puts EVERYTHING that is being Read or Written.

For instance, the sole print(tbl_Test.doesntExist) causes the autocomplete to put doesntExist into the entryMap

See the screenshot above where it says read to see what was only read from.

@karl-police karl-police added the bug Something isn't working label Sep 10, 2024
@karl-police karl-police changed the title Free Tables and Types autocomplete "Read" outside of function bodies Free Tables and Types autocomplete "Read" outside of the function argument scope Sep 10, 2024
@karl-police karl-police changed the title Free Tables and Types autocomplete "Read" outside of the function argument scope Free Tables and Types autocomplete "Read" outside of the function argument scope in New Solver Sep 10, 2024
@karl-police karl-police changed the title Free Tables and Types autocomplete "Read" outside of the function argument scope in New Solver Free Tables and Types autocomplete "properties that were read only and not written to" outside of the function argument scope in New Solver Sep 10, 2024
@karl-police karl-police changed the title Free Tables and Types autocomplete "properties that were read only and not written to" outside of the function argument scope in New Solver Free Tables and Types autocomplete "properties that were only read and not written to" outside of the function argument scope in New Solver Sep 10, 2024
@karl-police karl-police changed the title Free Tables and Types autocomplete "properties that were only read and not written to" outside of the function argument scope in New Solver Free Table State autocompletes "properties that were only read and not written to" outside of the function argument scope in New Solver Sep 10, 2024
@aatxe aatxe added the new solver This issue is specific to the new solver. label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.
Development

No branches or pull requests

2 participants