From d23c5b27d56d5c25ba43e4d250b66a2c8b067d6a Mon Sep 17 00:00:00 2001 From: "ajeffrey@roblox.com" Date: Tue, 16 Nov 2021 12:13:18 -0600 Subject: [PATCH] Clarified parsing properties of tables in the presence of singleton types --- rfcs/syntax-singleton-types.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rfcs/syntax-singleton-types.md b/rfcs/syntax-singleton-types.md index 749006c7..26ea3028 100644 --- a/rfcs/syntax-singleton-types.md +++ b/rfcs/syntax-singleton-types.md @@ -48,6 +48,18 @@ type Animals = "Dog" | "Cat" | "Bird" type TrueOrNil = true? ``` +Adding constant strings as type means that it is now legal to write +`{["foo"]:T}` as a table type. This should be parsed as a property, +not an indexer. For example: +```lua + type T = { + ["foo"]: number, + ["$$bar"]: string, + baz: boolean, + } +``` +The table type `T` is a table with three properties and no indexer. + ### Semantics You are allowed to provide a constant value to the generic primitive type.