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

Bug: using interface with generic cause type resolve incorrectly #931

Open
BLKTower opened this issue Feb 28, 2025 · 1 comment
Open

Bug: using interface with generic cause type resolve incorrectly #931

BLKTower opened this issue Feb 28, 2025 · 1 comment

Comments

@BLKTower
Copy link

local interface I<L>
    _: L
end
local record A end
local record IA is I<A> end
local record B end
local record IB is I<B> end

local function Create<L, C is I<L>>(l: L, c:C): C
    return {}
end

local function Test(a: A, b: B)
    -- Test 1
    Create(a, IA)
    Create(b, IB) -- Error: argument 2: given type IB does not satisfy I<L> constraint in type variable C
    Create(b, IA) -- No error, but it should.
    -- Test 2 -- No error if separate 2 function calls in different scope
    -- do
    --     Create(a, IA)
    -- end
    -- do
    --     Create(b, IB)
    -- end    
end

It seems after Create first gets called, all the following function calls in the same scope will use the same type resolve results.
Desired behavior: the teal compiler can resolve the type correctly.

@BLKTower
Copy link
Author

Hi @hishamhm , I reported the same issue a while back and ran into this annoying issue again today. Could you take a look when you get time? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant