From 60f8f00a022ac08701792b2897b72d8c99b50f52 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 11 Nov 2022 17:19:24 +0800 Subject: fix default value issue when doing metatable destructuring. --- spec/inputs/destructure.yue | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/inputs/destructure.yue') diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index 403923a..d161fd8 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue @@ -214,5 +214,15 @@ do tb = {} <[a + b]>: v1, [c!]: v2 = tb +do + {a: {: = addFunc}, b: {<[fieldName]>: field = 123}} = tb + {<"abc">: meta_field = "def", <[[any string]]>: abc = 123, <'str'>: def = {}} = tb + + switch tb + when {a: {: = addFunc}, b: {<[fieldName]>: field = 123}} + print add, field + switch tb + when {c: {<"abc">: meta_field = "def"}, <[[any string]]>: {d: abc = 123}, <'str'>: {e: def = {}}} + print meta_field, abc, def nil -- cgit v1.2.3-55-g6feb