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 in map as function parameter fails to compile #914

Open
BLKTower opened this issue Jan 16, 2025 · 5 comments
Open

Bug: using interface in map as function parameter fails to compile #914

BLKTower opened this issue Jan 16, 2025 · 5 comments

Comments

@BLKTower
Copy link

BLKTower commented Jan 16, 2025

Seems using interface in map just causes compiler error:

local interface A
end

local record B is A
end

local c: B
local d: {string: B}

local function Test_1(a: A)
end

local function Test_2(a: {string: A})
end

Test_1(c) -- Compiles fine
Test_2(d) -- Error: argument 1: in map value: B is not a A

If changed map to array, both compile fine:

local interface A
end

local record B is A
end

local c: B
local d: {B}

local function Test_1(a: A)
end

local function Test_2(a: {A})
end

Test_1(c) -- Compiles fine
Test_2(d) -- Compiles fine

Desired behavior: Test_2 compiles without error.

@BLKTower
Copy link
Author

BLKTower commented Jan 16, 2025

local interface A
end

local record B is A
end

local c: B
local d: {B}

local function Test_1(a: A)
end

local function Test_2(a: {A})
end

Test_1(c) -- Compiles fine
Test_2(d) -- Compiles fine

And it seems not bugged for all types. For example, if nested in array, both compile without error.

@BLKTower
Copy link
Author

BLKTower commented Jan 16, 2025

local interface A
end

local record C is A
end

local c: C

local function Test(a: {string: A})
end

Test(c) --- Compiles fine. Why?

And as I kept testing, more weird stuff happened... I have no idea why this is valid.

@hishamhm
Copy link
Member

Can you test it with the branch from PR #911 ? thank you!

@BLKTower
Copy link
Author

Can you test it with the branch from PR #911 ? thank you!

Hi, @hishamhm , thanks for the rapid replay. I just tested with both #911 commit and generics-regressions branch latest commit. Unfortunately, both issues I reported above persist.

@BLKTower
Copy link
Author

Can you test it with the branch from PR #911 ? thank you!

Sorry, the test case I presented above is misleading, this is actually nothing to do with generic. Seems using interface in map just causes problem.

local interface A
end

local record B is A
end

local c: B
local d: {string: B}

local function Test_1(a: A)
end

local function Test_2(a: {string: A})
end

Test_1(c) -- Compiles fine
Test_2(d) -- Error: argument 1: in map value: B is not a A

@BLKTower BLKTower changed the title Bug: interface with generic nested in other type fails to compile Bug: using interface in map as function parameter fails to compile Jan 17, 2025
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

2 participants