aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-02-09 10:52:49 +0800
committerLi Jin <dragon-fly@qq.com>2022-02-09 10:52:49 +0800
commita66ec0d18eba6b38fad25cc88c82f7532d689670 (patch)
treed125105f8cde4e7a37ca407e7bccedea783a1127 /spec
parent07a64933f8d956a8bba401db2200e6f7d8244dc9 (diff)
downloadyuescript-a66ec0d18eba6b38fad25cc88c82f7532d689670.tar.gz
yuescript-a66ec0d18eba6b38fad25cc88c82f7532d689670.tar.bz2
yuescript-a66ec0d18eba6b38fad25cc88c82f7532d689670.zip
fix a case nil coalesing used as update assignment.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/nil_coalesing.yue5
-rw-r--r--spec/outputs/nil_coalesing.lua25
2 files changed, 30 insertions, 0 deletions
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
39do 39do
40 a = 1 ?? 2 ?? 3 40 a = 1 ?? 2 ?? 3
41 41
42do
43 a.b.c ??= 1
44 a = b.x ?? c.x ?? d.x
45 a.c ??= 1
46
42nil 47nil
43 48
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
153 end 153 end
154 end 154 end
155end 155end
156do
157 local _obj_0 = a.b
158 if _obj_0.c == nil then
159 _obj_0.c = 1
160 end
161 local a
162 do
163 local _exp_0 = b.x
164 if _exp_0 ~= nil then
165 a = _exp_0
166 else
167 do
168 local _exp_1 = c.x
169 if _exp_1 ~= nil then
170 a = _exp_1
171 else
172 a = d.x
173 end
174 end
175 end
176 end
177 if a.c == nil then
178 a.c = 1
179 end
180end
156return nil 181return nil