Skip to content

Commit

Permalink
can now apply '#' on enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Jul 26, 2024
1 parent f97625d commit cd378f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/operator/len_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
]]))
Expand Down
1 change: 1 addition & 0 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6293,6 +6293,7 @@ local equality_binop = {

local unop_types = {
["#"] = {
["enum"] = "integer",
["string"] = "integer",
["array"] = "integer",
["tupletable"] = "integer",
Expand Down
1 change: 1 addition & 0 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -6293,6 +6293,7 @@ local equality_binop = {

local unop_types: {string:{TypeName:TypeName}} = {
["#"] = {
["enum"] = "integer",
["string"] = "integer",
["array"] = "integer",
["tupletable"] = "integer",
Expand Down

0 comments on commit cd378f9

Please sign in to comment.