diff options
author | Li Jin <dragon-fly@qq.com> | 2024-09-29 16:45:06 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2024-09-29 16:46:51 +0800 |
commit | 6af288657f5a7c43570ffbe91e1b727a4af5362d (patch) | |
tree | 72f0cb77d3fec4e6d6ab413c112278887ed44d3f /spec | |
parent | d6d29a4288b96d42c7cabf424beb286bfbd24456 (diff) | |
download | yuescript-6af288657f5a7c43570ffbe91e1b727a4af5362d.tar.gz yuescript-6af288657f5a7c43570ffbe91e1b727a4af5362d.tar.bz2 yuescript-6af288657f5a7c43570ffbe91e1b727a4af5362d.zip |
Disallowed some semantically incorrect syntax to improve code consistency.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/inputs/upvalue_func.yue | 13 | ||||
-rw-r--r-- | spec/outputs/5.1/attrib.lua | 144 |
2 files changed, 68 insertions, 89 deletions
diff --git a/spec/inputs/upvalue_func.yue b/spec/inputs/upvalue_func.yue index d4b3273..378bf60 100644 --- a/spec/inputs/upvalue_func.yue +++ b/spec/inputs/upvalue_func.yue | |||
@@ -208,20 +208,21 @@ GameEngine\schedule (deltaTime) -> -- closure 1 | |||
208 | -- test cases from issue | 208 | -- test cases from issue |
209 | do | 209 | do |
210 | buff_strength = (char, item) -> | 210 | buff_strength = (char, item) -> |
211 | item.buffer.strength? char.stats.strength?::ref() | 211 | item.buffer.strength? char.stats.strength?::ref! |
212 | 212 | ||
213 | local debug_env_before, debug_env_after | 213 | local debug_env_before, debug_env_after |
214 | 214 | ||
215 | exe_func = (func, env) -> | 215 | exe_func = (func, env) -> |
216 | ok, ... = try | 216 | ok, ... = try |
217 | debug_env_before(env) | 217 | debug_env_before env |
218 | func(env) | 218 | func env |
219 | debug_env_after(env) | 219 | debug_env_after env |
220 | catch ex | 220 | catch ex |
221 | -- accessing ex and error | 221 | -- accessing ex and error |
222 | error ex | 222 | error ex |
223 | return ex | 223 | -- implicit return |
224 | ex | ||
224 | if ok | 225 | if ok |
225 | return ... | 226 | return ... |
226 | else | 227 | else |
227 | os.exit(1) | 228 | os.exit 1 |
diff --git a/spec/outputs/5.1/attrib.lua b/spec/outputs/5.1/attrib.lua index c48c72c..dc1285c 100644 --- a/spec/outputs/5.1/attrib.lua +++ b/spec/outputs/5.1/attrib.lua | |||
@@ -44,18 +44,6 @@ do | |||
44 | } | 44 | } |
45 | a, b = _obj_0[1], _obj_0[2] | 45 | a, b = _obj_0[1], _obj_0[2] |
46 | end | 46 | end |
47 | local _anon_func_0 = function(_close_1, error, f, _arg_0, ...) | ||
48 | do | ||
49 | local _ok_0 = _arg_0 | ||
50 | _close_1(f) | ||
51 | if _ok_0 then | ||
52 | return ... | ||
53 | else | ||
54 | return error(...) | ||
55 | end | ||
56 | end | ||
57 | end | ||
58 | local _anon_func_1 = function() end | ||
59 | do | 47 | do |
60 | local v | 48 | local v |
61 | if flag then | 49 | if flag then |
@@ -82,28 +70,17 @@ do | |||
82 | f = _with_0 | 70 | f = _with_0 |
83 | end | 71 | end |
84 | local _close_1 = assert(getmetatable(f).__close) | 72 | local _close_1 = assert(getmetatable(f).__close) |
85 | return _anon_func_0(_close_1, error, f, pcall(_anon_func_1)) | 73 | return (function(_arg_0, ...) |
74 | local _ok_0 = _arg_0 | ||
75 | _close_1(f) | ||
76 | if _ok_0 then | ||
77 | return ... | ||
78 | else | ||
79 | return error(...) | ||
80 | end | ||
81 | end)(pcall(function() end)) | ||
86 | end)) | 82 | end)) |
87 | end | 83 | end |
88 | local _anon_func_2 = function(_close_1, d, error, _arg_0, ...) | ||
89 | do | ||
90 | local _ok_0 = _arg_0 | ||
91 | _close_1(d) | ||
92 | if _ok_0 then | ||
93 | return ... | ||
94 | else | ||
95 | return error(...) | ||
96 | end | ||
97 | end | ||
98 | end | ||
99 | local _anon_func_3 = function(a, b) | ||
100 | if a ~= nil then | ||
101 | return a | ||
102 | else | ||
103 | return b | ||
104 | end | ||
105 | end | ||
106 | local _anon_func_4 = function() end | ||
107 | do | 84 | do |
108 | local a | 85 | local a |
109 | if true then | 86 | if true then |
@@ -133,37 +110,29 @@ do | |||
133 | end | 110 | end |
134 | end | 111 | end |
135 | local d | 112 | local d |
136 | if _anon_func_3(a, b) then | 113 | if (function() |
114 | if a ~= nil then | ||
115 | return a | ||
116 | else | ||
117 | return b | ||
118 | end | ||
119 | end)() then | ||
137 | d = { | 120 | d = { |
138 | value = value | 121 | value = value |
139 | } | 122 | } |
140 | end | 123 | end |
141 | local _close_1 = assert(getmetatable(d).__close) | 124 | local _close_1 = assert(getmetatable(d).__close) |
142 | return _anon_func_2(_close_1, d, error, pcall(_anon_func_4)) | 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)) | ||
143 | end)) | 134 | end)) |
144 | end | 135 | end |
145 | local _anon_func_5 = function(_, _close_1, error, _arg_0, ...) | ||
146 | do | ||
147 | local _ok_0 = _arg_0 | ||
148 | _close_1(_) | ||
149 | if _ok_0 then | ||
150 | return ... | ||
151 | else | ||
152 | return error(...) | ||
153 | end | ||
154 | end | ||
155 | end | ||
156 | local _anon_func_6 = function(_, _close_2, error, _arg_0, ...) | ||
157 | do | ||
158 | local _ok_0 = _arg_0 | ||
159 | _close_2(_) | ||
160 | if _ok_0 then | ||
161 | return ... | ||
162 | else | ||
163 | return error(...) | ||
164 | end | ||
165 | end | ||
166 | end | ||
167 | do | 136 | do |
168 | local _ | 137 | local _ |
169 | do | 138 | do |
@@ -187,14 +156,30 @@ do | |||
187 | end | 156 | end |
188 | }) | 157 | }) |
189 | local _close_1 = assert(getmetatable(_).__close) | 158 | local _close_1 = assert(getmetatable(_).__close) |
190 | return _anon_func_5(_, _close_1, error, pcall(function() | 159 | return (function(_arg_0, ...) |
160 | local _ok_0 = _arg_0 | ||
161 | _close_1(_) | ||
162 | if _ok_0 then | ||
163 | return ... | ||
164 | else | ||
165 | return error(...) | ||
166 | end | ||
167 | end)(pcall(function() | ||
191 | local _ = setmetatable({ }, { | 168 | local _ = setmetatable({ }, { |
192 | __close = function() | 169 | __close = function() |
193 | return print("first") | 170 | return print("first") |
194 | end | 171 | end |
195 | }) | 172 | }) |
196 | local _close_2 = assert(getmetatable(_).__close) | 173 | local _close_2 = assert(getmetatable(_).__close) |
197 | return _anon_func_6(_, _close_2, error, pcall(function() | 174 | return (function(_arg_0, ...) |
175 | local _ok_0 = _arg_0 | ||
176 | _close_2(_) | ||
177 | if _ok_0 then | ||
178 | return ... | ||
179 | else | ||
180 | return error(...) | ||
181 | end | ||
182 | end)(pcall(function() | ||
198 | return print("third") | 183 | return print("third") |
199 | end)) | 184 | end)) |
200 | end)) | 185 | end)) |
@@ -211,29 +196,6 @@ def = function(item) | |||
211 | _defers[#_defers + 1] = item | 196 | _defers[#_defers + 1] = item |
212 | return _defers | 197 | return _defers |
213 | end | 198 | end |
214 | local _anon_func_7 = function(_, _close_1, error, _arg_0, ...) | ||
215 | do | ||
216 | local _ok_0 = _arg_0 | ||
217 | _close_1(_) | ||
218 | if _ok_0 then | ||
219 | return ... | ||
220 | else | ||
221 | return error(...) | ||
222 | end | ||
223 | end | ||
224 | end | ||
225 | local _anon_func_8 = function(_, _close_2, error, _arg_0, ...) | ||
226 | do | ||
227 | local _ok_0 = _arg_0 | ||
228 | _close_2(_) | ||
229 | if _ok_0 then | ||
230 | return ... | ||
231 | else | ||
232 | return error(...) | ||
233 | end | ||
234 | end | ||
235 | end | ||
236 | local _anon_func_9 = function() end | ||
237 | do | 199 | do |
238 | local _ = def(function() | 200 | local _ = def(function() |
239 | return print(3) | 201 | return print(3) |
@@ -252,12 +214,28 @@ do | |||
252 | return print(2) | 214 | return print(2) |
253 | end) | 215 | end) |
254 | local _close_1 = assert(getmetatable(_).__close) | 216 | local _close_1 = assert(getmetatable(_).__close) |
255 | return _anon_func_7(_, _close_1, error, pcall(function() | 217 | return (function(_arg_0, ...) |
218 | local _ok_0 = _arg_0 | ||
219 | _close_1(_) | ||
220 | if _ok_0 then | ||
221 | return ... | ||
222 | else | ||
223 | return error(...) | ||
224 | end | ||
225 | end)(pcall(function() | ||
256 | local _ = def(function() | 226 | local _ = def(function() |
257 | return print(1) | 227 | return print(1) |
258 | end) | 228 | end) |
259 | local _close_2 = assert(getmetatable(_).__close) | 229 | local _close_2 = assert(getmetatable(_).__close) |
260 | return _anon_func_8(_, _close_2, error, pcall(_anon_func_9)) | 230 | return (function(_arg_0, ...) |
231 | local _ok_0 = _arg_0 | ||
232 | _close_2(_) | ||
233 | if _ok_0 then | ||
234 | return ... | ||
235 | else | ||
236 | return error(...) | ||
237 | end | ||
238 | end)(pcall(function() end)) | ||
261 | end)) | 239 | end)) |
262 | end)) | 240 | end)) |
263 | end | 241 | end |