From 7bfa002f3d4dcb62e6a301141be6d17889a94f55 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 27 Oct 2023 16:58:43 +0800 Subject: fix a missing case for list destructuring. --- spec/inputs/destructure.yue | 8 ++++++++ spec/outputs/destructure.lua | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'spec') diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index d161fd8..73e4d33 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue @@ -80,6 +80,8 @@ do for {x,y} in *thing print x,y + for [x,y] in *thing + print x,y -- @@ -178,9 +180,15 @@ do for {left = "null", right = false} in *tuples print left, right + for [left = "null", right = false] in *tuples + print left, right + do {_, a, _, b} = tb -- list placeholder +do + [a, _, b, _] = tb -- list placeholder + do {x: a.b = 1, y: a.c = 2} = x.x.x diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua index 25e0529..38f21ff 100644 --- a/spec/outputs/destructure.lua +++ b/spec/outputs/destructure.lua @@ -124,6 +124,11 @@ do local x, y = _des_0[1], _des_0[2] print(x, y) end + for _index_0 = 1, #thing do + local _des_0 = thing[_index_0] + local x, y = _des_0[1], _des_0[2] + print(x, y) + end end do do @@ -370,6 +375,18 @@ do end print(left, right) end + local _list_1 = tuples + for _index_0 = 1, #_list_1 do + local _des_0 = _list_1[_index_0] + local left, right = _des_0[1], _des_0[2] + if left == nil then + left = "null" + end + if right == nil then + right = false + end + print(left, right) + end end do local a, b @@ -378,6 +395,13 @@ do a, b = _obj_0[2], _obj_0[4] end end +do + local a, b + do + local _obj_0 = tb + a, b = _obj_0[1], _obj_0[3] + end +end do do local _obj_0 = x.x.x -- cgit v1.2.3-55-g6feb