luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau-lang.org
MIT License
3.79k stars 349 forks source link

Unassigned Generic Types break types unification in new type solver #1308

Open karl-police opened 6 days ago

karl-police commented 6 days ago

Description

This is the test thing.

There's a abc<free> where free is unassigned. Because of that, the type a breaks.

Removing it, fixes the issue, and assigning it to a fixes the issue as well. But this did not happen for the old typesolver.

TEST_CASE_FIXTURE(ACBuiltinsFixture, "idk3")
{
    ScopedFastFlag sff[]{
        {FFlag::DebugLuauDeferredConstraintResolution, true},
        {FFlag::DebugLuauLogSolver, true},
    };

    auto check1 = check(R"(
function abc<free>(a)
    local b = a :: typeof({})
    b.abc = "hi"

    return b :: typeof(b) & typeof(a)
end

local test = {}
test.idk = "hi"

local e = abc(test)
e.lo="e"
e.@1
)");

    auto ac1 = autocomplete('1');
    CHECK(ac1.entryMap.count("idk"));
}

Expected

image

Actual Result

image

This did not happen for the old type solver.