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

export type destroys free table state type syntax declaration #1189

Closed
karl-police opened this issue Mar 11, 2024 · 3 comments
Closed

export type destroys free table state type syntax declaration #1189

karl-police opened this issue Mar 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@karl-police
Copy link
Contributor

karl-police commented Mar 11, 2024

export type test = typeof(table.clone())

This is supposed to give you a Free Table {- -}, as shown here:

image

But it doesn't

Testing Script

local module = {}

export type test = typeof(table.clone())

return module
local typeTest = require(script.ModuleScript)

local test = {} :: typeTest.test

test.e = "e"
test.

image

@karl-police karl-police added the bug Something isn't working label Mar 11, 2024
@karl-police karl-police changed the title export type destroys free table type syntax declaration export type destroys free table state type syntax declaration Mar 11, 2024
@vegorov-rbx
Copy link
Collaborator

Modules exports are immutable and all free tables are sealed on that boundary.

@vegorov-rbx vegorov-rbx closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
@vegorov-rbx vegorov-rbx self-assigned this Mar 11, 2024
@vegorov-rbx vegorov-rbx added the invalid This doesn't seem right label Mar 11, 2024
@karl-police
Copy link
Contributor Author

karl-police commented Mar 11, 2024

Modules exports are immutable and all free tables are sealed on that boundary.

Even happens with unsealed tables turning into sealed tables, not only free tables.

Removing the possibility to declare that there's a table which's content is not yet completly fully known.

For a table like

local module = {}

module.Data = {}

return module

if you say Data is unsealed and access to that can be modified, but the type export won't allow it, where I start to not understand if this is intended to be like that or if that can be something that can be changed on Luau.

@AmaranthineCodices
Copy link
Contributor

To explain further: both free and unsealed tables are implementation details of the type solver. They are intended to go away when solving is "finished" for a module, which explains the behavior you're seeing here. You should not rely on them being exported through module interfaces, and we have no plans to support that. That you see the free table in Roblox Studio's hover type view is the result of an optimization - we don't sanitize interior types for performance reasons.

Luau generally treats each module as an independent unit, require calls excepted. This means that Luau isn't going to think about the possibility of module.Data being changed after the module is required. Supporting this in a way that's up to Luau's standards would require making judgements about the order in which each line of code in the program runs, which is generally impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Development

No branches or pull requests

3 participants