From a6744ed09b49b740dfc2852d655f5ed6dd471cbf Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 8 Feb 2022 16:39:20 +0800 Subject: fix a case combining the use of existential op and metatable op. raise error when use existential op in the left part in an assignment. --- spec/inputs/existential.yue | 7 +++++++ spec/outputs/existential.lua | 28 +++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/inputs/existential.yue b/spec/inputs/existential.yue index 3055705..101e1d8 100644 --- a/spec/inputs/existential.yue +++ b/spec/inputs/existential.yue @@ -49,3 +49,10 @@ with? io.open "test.txt", "w" \write "hello" \close! +tb?.a#? 123 + +with? tb.#?.index# + .a = 1 + +nil + diff --git a/spec/outputs/existential.lua b/spec/outputs/existential.lua index 4a64c49..b594218 100644 --- a/spec/outputs/existential.lua +++ b/spec/outputs/existential.lua @@ -148,9 +148,27 @@ end)() ~= nil) or (function() end return nil end)() -local _with_0 = io.open("test.txt", "w") -if _with_0 ~= nil then - _with_0:write("hello") - _with_0:close() +do + local _with_0 = io.open("test.txt", "w") + if _with_0 ~= nil then + _with_0:write("hello") + _with_0:close() + end +end +if tb ~= nil then + local _obj_1 = getmetatable(tb).__a + if _obj_1 ~= nil then + _obj_1(123) + end +end +do + local _with_0 + local _obj_1 = getmetatable(tb) + if _obj_1 ~= nil then + _with_0 = getmetatable(_obj_1).__index + end + if _with_0 ~= nil then + _with_0.a = 1 + end end -return _with_0 +return nil -- cgit v1.2.3-55-g6feb