From 65115e8d0e2d3ad63aaee00228c6d8d3064d6cf2 Mon Sep 17 00:00:00 2001 From: "ajeffrey@roblox.com" Date: Mon, 11 Jul 2022 15:08:39 -0500 Subject: [PATCH] Added note on string types --- rfcs/shape-types.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rfcs/shape-types.md b/rfcs/shape-types.md index 8d1bf969..2f8bd3ab 100644 --- a/rfcs/shape-types.md +++ b/rfcs/shape-types.md @@ -52,6 +52,20 @@ will, with bounded generics and this RFC, have type: getP : (t) -> a ``` +### String types + +In Luau, the string type has a metatable, so is a supertype of +any appropriate shape type, for example `{ lower: (string) -> string }`. + +This is necessary to support string parameters to appropriate bounded generics, for example +```lua + function getLower(x) return x:lower() end +``` +which has type +``` + getLower : a}> (t) -> a +``` + ### Related work This design is essentially the same as