From 0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 26 Jul 2022 18:05:23 +0800 Subject: fix missing checks and issues related to destrucuring in if branches. --- spec/inputs/assign.yue | 50 ++++++++++++++++++++++++++++++++++++++++++++--- spec/inputs/cond.yue | 2 +- spec/inputs/global.yue | 4 ++-- spec/inputs/metatable.yue | 2 +- spec/inputs/using.yue | 7 +++++++ 5 files changed, 58 insertions(+), 7 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/assign.yue b/spec/inputs/assign.yue index dac2ba3..d04bcb8 100644 --- a/spec/inputs/assign.yue +++ b/spec/inputs/assign.yue @@ -8,20 +8,20 @@ _ = -> a,b,c,d = 1,2,3,4 - hello[232], (5+5)[121], hello, x[99] = 100, 200, 300 + hello[232], (5+5)[121], hello, x[99] = 100, 200, 300, 400 joop = 12 joop = 2345 a, b = if hello - "hello" + "hello", nil else "nothing", "yeah" a, b = if hello - if yeah then "one", "two" else "mmhh" + if yeah then "one", "two" else "mmhh", nil else print "the other" "nothing", "yeah" @@ -31,3 +31,47 @@ c, d = 1, 2 if true x = (do f! 123) if f = getHandler! + +(using nil) <- _ + +a.# = do + print 123 + {} + +do + {a, b} = switch c + when "a" + tb + when "b" + f! + +a[] = if x + 1 +else + 2 + +do + a, b[] = if x + switch y + when 1 + f! + +do + a, {b} = if x + f! + else + 123, tb + +do + a, b[], c, d.add# = if x + switch y + when 1 + f! + elseif x2 + if y2 + f1! + else + print "hello" + do + print 123 + 1, f2! diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue index 773ef91..9981e93 100644 --- a/spec/inputs/cond.yue +++ b/spec/inputs/cond.yue @@ -158,7 +158,7 @@ do ---------------- a = 12 -a,c,b = "cool" if something +a,c,b = "cool", nil, nil if something diff --git a/spec/inputs/global.yue b/spec/inputs/global.yue index 7d6cfde..59cf764 100644 --- a/spec/inputs/global.yue +++ b/spec/inputs/global.yue @@ -1,6 +1,6 @@ do - global a,b,c = 223, 343 + global a,b,c = 223, 343, nil global cool = "dad" do @@ -9,7 +9,7 @@ do do global a,b,c - a,b,c,d = "hello" + a,b,c,d = "hello", nil, nil, nil do diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue index 7e9b4f2..86991c2 100644 --- a/spec/inputs/metatable.yue +++ b/spec/inputs/metatable.yue @@ -24,7 +24,7 @@ do x.abc, a.b.# = 123, {} func!.# = mt --, extra -a, b.c.#, d, e = 1, mt, "abc" +a, b.c.#, d, e = 1, mt, "abc", nil is_same = a.#.__index == a.index# diff --git a/spec/inputs/using.yue b/spec/inputs/using.yue index 9944b60..31afaab 100644 --- a/spec/inputs/using.yue +++ b/spec/inputs/using.yue @@ -20,3 +20,10 @@ _ = (a,e,f using a,b,c, hello) -> _ = (using nil) -> hello or= 2 + +do + a = {} + (using nil) <- _ + {x, y} = a + +nil -- cgit v1.2.3-55-g6feb