diff options
author | Li Jin <dragon-fly@qq.com> | 2022-07-26 11:34:34 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-07-26 11:34:34 +0800 |
commit | f7150a004e26f446fbf7a47bae368f209248fa67 (patch) | |
tree | 28cbfc756cfef955a6a40f62d3395920938256db /spec/outputs | |
parent | 13c7eb4252e8c4228fabf1ade13b7b9bcbd80656 (diff) | |
download | yuescript-f7150a004e26f446fbf7a47bae368f209248fa67.tar.gz yuescript-f7150a004e26f446fbf7a47bae368f209248fa67.tar.bz2 yuescript-f7150a004e26f446fbf7a47bae368f209248fa67.zip |
make destructuring work on function multiple returned values, fix `a, b[] = 1` crashing issue, no longer support implicit declaring variable to be nil.
Diffstat (limited to 'spec/outputs')
-rw-r--r-- | spec/outputs/destructure.lua | 21 | ||||
-rw-r--r-- | spec/outputs/local.lua | 2 | ||||
-rw-r--r-- | spec/outputs/syntax.lua | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua index 59ee358..dfac42c 100644 --- a/spec/outputs/destructure.lua +++ b/spec/outputs/destructure.lua | |||
@@ -407,3 +407,24 @@ do | |||
407 | end | 407 | end |
408 | end | 408 | end |
409 | end | 409 | end |
410 | do | ||
411 | local x1, x2, x3, d, e | ||
412 | local b | ||
413 | do | ||
414 | local _obj_0, _obj_1, _obj_2, _obj_3, _obj_4 = f() | ||
415 | do | ||
416 | local _obj_5 = a | ||
417 | _obj_5[#_obj_5 + 1] = _obj_0 | ||
418 | end | ||
419 | setmetatable(c, _obj_4) | ||
420 | x1, x2, x3, d, e = 1, 2, 3, _obj_1, _obj_3 | ||
421 | b = _obj_2[1] | ||
422 | end | ||
423 | local y1, y4 | ||
424 | local y2, y3 | ||
425 | do | ||
426 | local _obj_0, _obj_1 = f2() | ||
427 | y1, y4 = f1(), _obj_1 | ||
428 | y2, y3 = _obj_0.y2, _obj_0.y3 | ||
429 | end | ||
430 | end | ||
diff --git a/spec/outputs/local.lua b/spec/outputs/local.lua index 524d9ef..5004e75 100644 --- a/spec/outputs/local.lua +++ b/spec/outputs/local.lua | |||
@@ -2,7 +2,7 @@ do | |||
2 | local a | 2 | local a |
3 | local a, b, c | 3 | local a, b, c |
4 | local g | 4 | local g |
5 | b, g = 23232 | 5 | b, g = 23232, nil |
6 | end | 6 | end |
7 | do | 7 | do |
8 | local x = 1212 | 8 | local x = 1212 |
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index a4cb8e2..22b6b80 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
@@ -1,6 +1,6 @@ | |||
1 | local a = 1 + 2 * 3 / 6 | 1 | local a = 1 + 2 * 3 / 6 |
2 | local bunch, go, here | 2 | local bunch, go, here |
3 | a, bunch, go, here = another, world | 3 | a, bunch, go, here = another, world, nil, nil |
4 | func(arg1, arg2, another, arg3) | 4 | func(arg1, arg2, another, arg3) |
5 | local we | 5 | local we |
6 | here, we = function() end, yeah | 6 | here, we = function() end, yeah |