From 585ce6ba37581a242d61a790dd86049f4d3b4325 Mon Sep 17 00:00:00 2001 From: ffrostfall <80861876+ffrostfall@users.noreply.github.com> Date: Tue, 4 Feb 2025 00:52:01 -0500 Subject: [PATCH] Specify behavior for getmetatable --- docs/metatable-type-functions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/metatable-type-functions.md b/docs/metatable-type-functions.md index 14f7a4b..767b4f8 100644 --- a/docs/metatable-type-functions.md +++ b/docs/metatable-type-functions.md @@ -41,6 +41,9 @@ type Identity = setmetatable<{ }> ``` +When a non-table type (number, boolean) is passed into the type function, it should result in an error. This includes classes. +If the type is an intersection/union of tables, then the metatable should be applied to every + ### `getmetatable` Type Function In the following code example, `ReversedIdentity` should evaluate to `{ __index: typeof(animal) }`: @@ -66,6 +69,9 @@ type metatable = { type MetatableType = getmetatable> ``` +If the type passed into the type function doesn't have a metatable and it *could* have a metatable (so primitives, singletons, classes, and tables), then it will return nil. +If the type passed in is an intersection/union, then it will return an interesction/union respectively. + ## Drawbacks Introducing a large library of "global" type functions can clutter naming space for users.