summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-02-08 16:39:20 +0800
committerLi Jin <dragon-fly@qq.com>2022-02-08 16:39:20 +0800
commita6744ed09b49b740dfc2852d655f5ed6dd471cbf (patch)
tree4209b5f16c67f79259ad4c6bf116a8428b589ad3 /spec
parentd22ae154b57ac80107020e98f04f76fffaa9cd90 (diff)
downloadyuescript-a6744ed09b49b740dfc2852d655f5ed6dd471cbf.tar.gz
yuescript-a6744ed09b49b740dfc2852d655f5ed6dd471cbf.tar.bz2
yuescript-a6744ed09b49b740dfc2852d655f5ed6dd471cbf.zip
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.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/existential.yue7
-rw-r--r--spec/outputs/existential.lua28
2 files changed, 30 insertions, 5 deletions
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"
49 \write "hello" 49 \write "hello"
50 \close! 50 \close!
51 51
52tb?.a#? 123
53
54with? tb.#?.index#
55 .a = 1
56
57nil
58
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()
148 end 148 end
149 return nil 149 return nil
150end)() 150end)()
151local _with_0 = io.open("test.txt", "w") 151do
152if _with_0 ~= nil then 152 local _with_0 = io.open("test.txt", "w")
153 _with_0:write("hello") 153 if _with_0 ~= nil then
154 _with_0:close() 154 _with_0:write("hello")
155 _with_0:close()
156 end
157end
158if tb ~= nil then
159 local _obj_1 = getmetatable(tb).__a
160 if _obj_1 ~= nil then
161 _obj_1(123)
162 end
163end
164do
165 local _with_0
166 local _obj_1 = getmetatable(tb)
167 if _obj_1 ~= nil then
168 _with_0 = getmetatable(_obj_1).__index
169 end
170 if _with_0 ~= nil then
171 _with_0.a = 1
172 end
155end 173end
156return _with_0 174return nil