From cd378f92d0610f11a06cbb2e00907767d623fe22 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 23 Jul 2024 20:18:48 -0300 Subject: [PATCH] can now apply '#' on enum values --- spec/operator/len_spec.lua | 14 ++++++++++++++ tl.lua | 1 + tl.tl | 1 + 3 files changed, 16 insertions(+) diff --git a/spec/operator/len_spec.lua b/spec/operator/len_spec.lua index f4779bf5c..8ae53e2d0 100644 --- a/spec/operator/len_spec.lua +++ b/spec/operator/len_spec.lua @@ -5,6 +5,20 @@ describe("#", function() local x: integer = #({1, 2, 3}) ]])) + it("can run on a string", util.check([[ + local s = "hello" + local len = #s + ]])) + + it("can run on an enum value", util.check([[ + local enum Enum + "hello" + end + + local s: Enum = "hello" + local len = #s + ]])) + it("returns an integer when used on tuple", util.check([[ local x: integer = #({1, "hi"}) ]])) diff --git a/tl.lua b/tl.lua index be3186b8d..b85344f75 100644 --- a/tl.lua +++ b/tl.lua @@ -6293,6 +6293,7 @@ local equality_binop = { local unop_types = { ["#"] = { + ["enum"] = "integer", ["string"] = "integer", ["array"] = "integer", ["tupletable"] = "integer", diff --git a/tl.tl b/tl.tl index 788835fff..582d3282d 100644 --- a/tl.tl +++ b/tl.tl @@ -6293,6 +6293,7 @@ local equality_binop = { local unop_types: {string:{TypeName:TypeName}} = { ["#"] = { + ["enum"] = "integer", ["string"] = "integer", ["array"] = "integer", ["tupletable"] = "integer",