From 07a64933f8d956a8bba401db2200e6f7d8244dc9 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 9 Feb 2022 10:14:25 +0800 Subject: fix the way update assignment is implemented. --- spec/inputs/syntax.yue | 5 +++++ spec/outputs/syntax.lua | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index aed4144..cb947e1 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue @@ -183,6 +183,11 @@ a["hello"] += 10 a["hello#{tostring ff}"] += 10 a[four].x += 10 +a.b += 1 +a.b[1].c[2+3] += 1 +with tb + .a.c += 1 + x = 0 _ = (if ntype(v) == "fndef" then x += 1) for v in *values diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 3187898..ed8ed39 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua @@ -184,7 +184,17 @@ local _update_0 = "hello" a[_update_0] = a[_update_0] + 10 local _update_1 = "hello" .. tostring(tostring(ff)) a[_update_1] = a[_update_1] + 10 -a[four].x = a[four].x + 10 +local _obj_0 = a[four] +_obj_0.x = _obj_0.x + 10 +a.b = a.b + 1 +local _obj_1 = a.b[1].c +local _update_2 = 2 + 3 +_obj_1[_update_2] = _obj_1[_update_2] + 1 +do + local _with_0 = tb + local _obj_2 = _with_0.a + _obj_2.c = _obj_2.c + 1 +end x = 0 local _list_0 = values for _index_0 = 1, #_list_0 do -- cgit v1.2.3-55-g6feb