diff options
author | Li Jin <dragon-fly@qq.com> | 2023-08-07 09:57:27 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-08-07 09:57:27 +0800 |
commit | c9b70274787ed8a77e7b47c4628197f0c6c1ba30 (patch) | |
tree | fae88047d312962aebfd97a0183c2f9f19e2cc76 /spec/outputs/5.1 | |
parent | aff8e69bf589d2ee5f4a7b72b7e2f643d55b87fa (diff) | |
download | yuescript-c9b70274787ed8a77e7b47c4628197f0c6c1ba30.tar.gz yuescript-c9b70274787ed8a77e7b47c4628197f0c6c1ba30.tar.bz2 yuescript-c9b70274787ed8a77e7b47c4628197f0c6c1ba30.zip |
fixing issue #143 and #144.
Diffstat (limited to 'spec/outputs/5.1')
-rw-r--r-- | spec/outputs/5.1/attrib.lua | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/spec/outputs/5.1/attrib.lua b/spec/outputs/5.1/attrib.lua new file mode 100644 index 0000000..f782b45 --- /dev/null +++ b/spec/outputs/5.1/attrib.lua | |||
@@ -0,0 +1,238 @@ | |||
1 | local a, b, c, d = 1, 2, 3, 4 | ||
2 | do | ||
3 | local a, b = setmetatable({ }, { | ||
4 | __close = function(self) | ||
5 | return print("closed") | ||
6 | end | ||
7 | }) | ||
8 | local _close_0 = assert(getmetatable(a).__close) | ||
9 | local _close_1 = assert(getmetatable(b).__close); | ||
10 | (function(_arg_0, ...) | ||
11 | local _ok_0 = _arg_0 | ||
12 | _close_1(b) | ||
13 | _close_0(a) | ||
14 | if _ok_0 then | ||
15 | return ... | ||
16 | else | ||
17 | return error(...) | ||
18 | end | ||
19 | end)(pcall(function(...) | ||
20 | local c, d = 123, 'abc' | ||
21 | close(a, b) | ||
22 | return const(c, d) | ||
23 | end, ...)) | ||
24 | end | ||
25 | do | ||
26 | local a = f() | ||
27 | local b, c, d | ||
28 | do | ||
29 | local _obj_0, _obj_1 = f1() | ||
30 | b, c = _obj_0[1], _obj_0[2] | ||
31 | d = _obj_1[1] | ||
32 | end | ||
33 | end | ||
34 | do | ||
35 | local a, b, c, d | ||
36 | do | ||
37 | local _obj_0, _obj_1, _obj_2 = f() | ||
38 | a = _obj_0 | ||
39 | b, c = _obj_1[1], _obj_1[2] | ||
40 | d = _obj_2[1] | ||
41 | end | ||
42 | end | ||
43 | do | ||
44 | local v = (function() | ||
45 | if flag then | ||
46 | return func() | ||
47 | else | ||
48 | return setmetatable({ }, { | ||
49 | __close = function(self) end | ||
50 | }) | ||
51 | end | ||
52 | end)() | ||
53 | local _close_0 = assert(getmetatable(v).__close); | ||
54 | (function(_arg_0, ...) | ||
55 | local _ok_0 = _arg_0 | ||
56 | _close_0(v) | ||
57 | if _ok_0 then | ||
58 | return ... | ||
59 | else | ||
60 | return error(...) | ||
61 | end | ||
62 | end)(pcall(function(...) | ||
63 | local f = (function() | ||
64 | local _with_0 = io.open("file.txt") | ||
65 | _with_0:write("Hello") | ||
66 | return _with_0 | ||
67 | end)() | ||
68 | local _close_1 = assert(getmetatable(f).__close) | ||
69 | return (function(_arg_0, ...) | ||
70 | local _ok_0 = _arg_0 | ||
71 | _close_1(f) | ||
72 | if _ok_0 then | ||
73 | return ... | ||
74 | else | ||
75 | return error(...) | ||
76 | end | ||
77 | end)(pcall(function(...) end, ...)) | ||
78 | end, ...)) | ||
79 | end | ||
80 | do | ||
81 | local a = (function() | ||
82 | if true then | ||
83 | return 1 | ||
84 | end | ||
85 | end)() | ||
86 | local b = (function() | ||
87 | if not false then | ||
88 | if x then | ||
89 | return 1 | ||
90 | end | ||
91 | end | ||
92 | end)() | ||
93 | local _close_0 = assert(getmetatable(b).__close); | ||
94 | (function(_arg_0, ...) | ||
95 | local _ok_0 = _arg_0 | ||
96 | _close_0(b) | ||
97 | if _ok_0 then | ||
98 | return ... | ||
99 | else | ||
100 | return error(...) | ||
101 | end | ||
102 | end)(pcall(function(...) | ||
103 | local c = (function() | ||
104 | if true then | ||
105 | local _exp_0 = x | ||
106 | if "abc" == _exp_0 then | ||
107 | return 998 | ||
108 | end | ||
109 | end | ||
110 | end)() | ||
111 | local d = (function() | ||
112 | if (function() | ||
113 | if a ~= nil then | ||
114 | return a | ||
115 | else | ||
116 | return b | ||
117 | end | ||
118 | end)() then | ||
119 | return { | ||
120 | value = value | ||
121 | } | ||
122 | end | ||
123 | end)() | ||
124 | local _close_1 = assert(getmetatable(d).__close) | ||
125 | return (function(_arg_0, ...) | ||
126 | local _ok_0 = _arg_0 | ||
127 | _close_1(d) | ||
128 | if _ok_0 then | ||
129 | return ... | ||
130 | else | ||
131 | return error(...) | ||
132 | end | ||
133 | end)(pcall(function(...) end, ...)) | ||
134 | end, ...)) | ||
135 | end | ||
136 | do | ||
137 | local _ = (function() | ||
138 | local _with_0 = io.open("file.txt") | ||
139 | _with_0:write("Hello") | ||
140 | return _with_0 | ||
141 | end)() | ||
142 | local _close_0 = assert(getmetatable(_).__close); | ||
143 | (function(_arg_0, ...) | ||
144 | local _ok_0 = _arg_0 | ||
145 | _close_0(_) | ||
146 | if _ok_0 then | ||
147 | return ... | ||
148 | else | ||
149 | return error(...) | ||
150 | end | ||
151 | end)(pcall(function(...) | ||
152 | local _ = setmetatable({ }, { | ||
153 | __close = function() | ||
154 | return print("second") | ||
155 | end | ||
156 | }) | ||
157 | local _close_1 = assert(getmetatable(_).__close) | ||
158 | return (function(_arg_0, ...) | ||
159 | local _ok_0 = _arg_0 | ||
160 | _close_1(_) | ||
161 | if _ok_0 then | ||
162 | return ... | ||
163 | else | ||
164 | return error(...) | ||
165 | end | ||
166 | end)(pcall(function(...) | ||
167 | local _ = setmetatable({ }, { | ||
168 | __close = function() | ||
169 | return print("first") | ||
170 | end | ||
171 | }) | ||
172 | local _close_2 = assert(getmetatable(_).__close) | ||
173 | return (function(_arg_0, ...) | ||
174 | local _ok_0 = _arg_0 | ||
175 | _close_2(_) | ||
176 | if _ok_0 then | ||
177 | return ... | ||
178 | else | ||
179 | return error(...) | ||
180 | end | ||
181 | end)(pcall(function(...) end, ...)) | ||
182 | end, ...)) | ||
183 | end, ...)) | ||
184 | end | ||
185 | local _defers = setmetatable({ }, { | ||
186 | __close = function(self) | ||
187 | self[#self]() | ||
188 | self[#self] = nil | ||
189 | end | ||
190 | }) | ||
191 | local def | ||
192 | def = function(item) | ||
193 | _defers[#_defers + 1] = item | ||
194 | return _defers | ||
195 | end | ||
196 | do | ||
197 | local _ = def(function() | ||
198 | return print(3) | ||
199 | end) | ||
200 | local _close_0 = assert(getmetatable(_).__close) | ||
201 | return (function(_arg_0, ...) | ||
202 | local _ok_0 = _arg_0 | ||
203 | _close_0(_) | ||
204 | if _ok_0 then | ||
205 | return ... | ||
206 | else | ||
207 | return error(...) | ||
208 | end | ||
209 | end)(pcall(function(...) | ||
210 | local _ = def(function() | ||
211 | return print(2) | ||
212 | end) | ||
213 | local _close_1 = assert(getmetatable(_).__close) | ||
214 | return (function(_arg_0, ...) | ||
215 | local _ok_0 = _arg_0 | ||
216 | _close_1(_) | ||
217 | if _ok_0 then | ||
218 | return ... | ||
219 | else | ||
220 | return error(...) | ||
221 | end | ||
222 | end)(pcall(function(...) | ||
223 | local _ = def(function() | ||
224 | return print(1) | ||
225 | end) | ||
226 | local _close_2 = assert(getmetatable(_).__close) | ||
227 | return (function(_arg_0, ...) | ||
228 | local _ok_0 = _arg_0 | ||
229 | _close_2(_) | ||
230 | if _ok_0 then | ||
231 | return ... | ||
232 | else | ||
233 | return error(...) | ||
234 | end | ||
235 | end)(pcall(function(...) end, ...)) | ||
236 | end, ...)) | ||
237 | end, ...)) | ||
238 | end | ||