From 8edaa26e7c2ac015ece216a05d86a7b29474c8c3 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 7 Aug 2024 17:37:11 -0300 Subject: [PATCH] tests: add regression test for #749 --- spec/declaration/local_spec.lua | 37 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/spec/declaration/local_spec.lua b/spec/declaration/local_spec.lua index 044d7a47a..b56b7556e 100644 --- a/spec/declaration/local_spec.lua +++ b/spec/declaration/local_spec.lua @@ -461,17 +461,29 @@ describe("local", function() local b : 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 : Add = { + op = '+', + left = 10, + right = 20 + } - kk = {} + print(sum.op, sum.left, sum.right) ]])) end) @@ -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)