Skip to content

Commit

Permalink
tests: add regression test for #749
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Aug 7, 2024
1 parent 181d2a5 commit 8edaa26
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions spec/declaration/local_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,29 @@ describe("local", function()
local b <total>: A = { v = 10 }
]]))

it("localizing a record does not make the new local a type (#759)", util.check([[
local record k
it("does not consider a metamethod to be a missing field (regression test for #749", util.check([[
local interface Op
op: string
end
local kk: k = {}
local interface Binary
is Op
left: number
right: number
end
local k = k
local record Add
is Binary
where self.op == '+' -- removing the comment triggers an error
end
k = {}
local sum <total>: Add = {
op = '+',
left = 10,
right = 20
}
kk = {}
print(sum.op, sum.left, sum.right)
]]))
end)

Expand Down Expand Up @@ -515,4 +527,17 @@ describe("local", function()
]]))
end)
end)

it("localizing a record does not make the new local a type (#759)", util.check([[
local record k
end
local kk: k = {}
local k = k
k = {}
kk = {}
]]))
end)

0 comments on commit 8edaa26

Please sign in to comment.