From a66ec0d18eba6b38fad25cc88c82f7532d689670 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 9 Feb 2022 10:52:49 +0800 Subject: fix a case nil coalesing used as update assignment. --- spec/inputs/nil_coalesing.yue | 5 +++++ spec/outputs/nil_coalesing.lua | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'spec') diff --git a/spec/inputs/nil_coalesing.yue b/spec/inputs/nil_coalesing.yue index facd64c..76915c7 100644 --- a/spec/inputs/nil_coalesing.yue +++ b/spec/inputs/nil_coalesing.yue @@ -39,5 +39,10 @@ do do a = 1 ?? 2 ?? 3 +do + a.b.c ??= 1 + a = b.x ?? c.x ?? d.x + a.c ??= 1 + nil diff --git a/spec/outputs/nil_coalesing.lua b/spec/outputs/nil_coalesing.lua index b434671..e1547df 100644 --- a/spec/outputs/nil_coalesing.lua +++ b/spec/outputs/nil_coalesing.lua @@ -153,4 +153,29 @@ do end end end +do + local _obj_0 = a.b + if _obj_0.c == nil then + _obj_0.c = 1 + end + local a + do + local _exp_0 = b.x + if _exp_0 ~= nil then + a = _exp_0 + else + do + local _exp_1 = c.x + if _exp_1 ~= nil then + a = _exp_1 + else + a = d.x + end + end + end + end + if a.c == nil then + a.c = 1 + end +end return nil -- cgit v1.2.3-55-g6feb