diff options
author | Li Jin <dragon-fly@qq.com> | 2023-11-02 12:27:27 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-11-02 12:27:27 +0800 |
commit | 5ad0f4daa8171460dc71332669c365bb8e07dab0 (patch) | |
tree | da57ecdabf5fa54c324c023ac22c53041aaff143 /spec | |
parent | 2263cca3687bb5c6b9c51f42d59d2249c18941a0 (diff) | |
download | yuescript-5ad0f4daa8171460dc71332669c365bb8e07dab0.tar.gz yuescript-5ad0f4daa8171460dc71332669c365bb8e07dab0.tar.bz2 yuescript-5ad0f4daa8171460dc71332669c365bb8e07dab0.zip |
fix table matching syntax in switch statement with list table.v0.20.4
Diffstat (limited to 'spec')
-rw-r--r-- | spec/inputs/switch.yue | 6 | ||||
-rw-r--r-- | spec/outputs/switch.lua | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/spec/inputs/switch.yue b/spec/inputs/switch.yue index cb1eb31..49d47f3 100644 --- a/spec/inputs/switch.yue +++ b/spec/inputs/switch.yue | |||
@@ -159,5 +159,11 @@ do | |||
159 | when {x: <>: mt} | 159 | when {x: <>: mt} |
160 | print mt | 160 | print mt |
161 | 161 | ||
162 | do | ||
163 | switch tb | ||
164 | when [ [item,],] | ||
165 | print item | ||
166 | when [a = 1, b = "abc"] | ||
167 | print a, b | ||
162 | nil | 168 | nil |
163 | 169 | ||
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index 1ace1e3..bbdf794 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua | |||
@@ -398,4 +398,39 @@ do | |||
398 | end | 398 | end |
399 | end | 399 | end |
400 | end | 400 | end |
401 | do | ||
402 | do | ||
403 | local _exp_0 = tb | ||
404 | local _type_0 = type(_exp_0) | ||
405 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
406 | local _match_0 = false | ||
407 | if _tab_0 then | ||
408 | local item | ||
409 | do | ||
410 | local _obj_0 = _exp_0[1] | ||
411 | local _type_1 = type(_obj_0) | ||
412 | if "table" == _type_1 or "userdata" == _type_1 then | ||
413 | item = _obj_0[1] | ||
414 | end | ||
415 | end | ||
416 | if item ~= nil then | ||
417 | _match_0 = true | ||
418 | print(item) | ||
419 | end | ||
420 | end | ||
421 | if not _match_0 then | ||
422 | if _tab_0 then | ||
423 | local a = _exp_0[1] | ||
424 | local b = _exp_0[2] | ||
425 | if a == nil then | ||
426 | a = 1 | ||
427 | end | ||
428 | if b == nil then | ||
429 | b = "abc" | ||
430 | end | ||
431 | print(a, b) | ||
432 | end | ||
433 | end | ||
434 | end | ||
435 | end | ||
401 | return nil | 436 | return nil |