You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
localmodule= {}
module.Data= {}
returnmodule
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.
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.
export type test = typeof(table.clone())
This is supposed to give you a Free Table
{- -}
, as shown here:But it doesn't
Testing Script
The text was updated successfully, but these errors were encountered: