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 | |
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')
-rw-r--r-- | spec/inputs/destructure.yue | 8 | ||||
-rw-r--r-- | spec/inputs/local.yue | 2 | ||||
-rw-r--r-- | spec/inputs/syntax.yue | 2 | ||||
-rw-r--r-- | spec/outputs/destructure.lua | 21 | ||||
-rw-r--r-- | spec/outputs/local.lua | 2 | ||||
-rw-r--r-- | spec/outputs/syntax.lua | 2 |
6 files changed, 31 insertions, 6 deletions
diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index 24282c0..53f9ea3 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue | |||
@@ -12,7 +12,7 @@ do | |||
12 | {:a,:b,:c,:d} = yeah | 12 | {:a,:b,:c,:d} = yeah |
13 | 13 | ||
14 | {a}, b = one, two | 14 | {a}, b = one, two |
15 | {b}, c = one | 15 | {b}, c = one, nil |
16 | {d}, e = one, two | 16 | {d}, e = one, two |
17 | 17 | ||
18 | x, {y} = one, two | 18 | x, {y} = one, two |
@@ -22,7 +22,7 @@ do | |||
22 | 22 | ||
23 | {a, :b, c, :d, e, :f, g} = tbl | 23 | {a, :b, c, :d, e, :f, g} = tbl |
24 | 24 | ||
25 | do :a, :b, c = tbl | 25 | do :a, :b, c = tbl, nil |
26 | 26 | ||
27 | do a, :b, :c = tbl, _ | 27 | do a, :b, :c = tbl, _ |
28 | 28 | ||
@@ -187,3 +187,7 @@ do | |||
187 | do | 187 | do |
188 | const :width, :height = View.size | 188 | const :width, :height = View.size |
189 | const {:x = 0.0, :y = 0.0} = point | 189 | const {:x = 0.0, :y = 0.0} = point |
190 | |||
191 | do | ||
192 | x1, x2, x3, a[], d, {b}, e, c.# = 1, 2, 3, f! | ||
193 | y1, :y2, :y3, y4 = f1!, f2! | ||
diff --git a/spec/inputs/local.yue b/spec/inputs/local.yue index 8e04742..a801fb7 100644 --- a/spec/inputs/local.yue +++ b/spec/inputs/local.yue | |||
@@ -3,7 +3,7 @@ do | |||
3 | local a | 3 | local a |
4 | local a,b,c | 4 | local a,b,c |
5 | 5 | ||
6 | b,g = 23232 | 6 | b,g = 23232,nil |
7 | 7 | ||
8 | 8 | ||
9 | do | 9 | do |
diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index d18bd0e..e274f1a 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | a = 1 + 2* 3 / 6 | 3 | a = 1 + 2* 3 / 6 |
4 | 4 | ||
5 | a, bunch, go, here = another, world | 5 | a, bunch, go, here = another, world, nil, nil |
6 | 6 | ||
7 | func arg1, arg2, another, arg3 | 7 | func arg1, arg2, another, arg3 |
8 | 8 | ||
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 |