From a9d28cb615d2bdc09d2482d5262951f2afc8d6e1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 26 May 2025 15:52:07 +0800 Subject: Added doc for `with?` syntax. --- spec/inputs/with.yue | 5 +++++ spec/outputs/codes_from_doc.lua | 8 ++++++++ spec/outputs/codes_from_doc_zh.lua | 8 ++++++++ spec/outputs/with.lua | 16 ++++++++++++++++ 4 files changed, 37 insertions(+) (limited to 'spec') diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index c1cf3e3..2256833 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue @@ -165,4 +165,9 @@ do break with? tb break 1 +do + a = for i = 1, 100 + with? x := tb[i] + break x if .id := 1 + nil diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index d857dec..55be7df 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua @@ -2147,6 +2147,10 @@ do _with_1["key-name"] = value end _with_0[#_with_0 + 1] = "abc" +local _with_0 = obj +if _with_0 ~= nil then + print(obj.name) +end do local var = "hello" print(var) @@ -4363,6 +4367,10 @@ do _with_1["key-name"] = value end _with_0[#_with_0 + 1] = "abc" +local _with_0 = obj +if _with_0 ~= nil then + print(obj.name) +end do local var = "hello" print(var) diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index ecab077..399f8c1 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua @@ -2141,6 +2141,10 @@ do _with_1["key-name"] = value end _with_0[#_with_0 + 1] = "abc" +local _with_0 = obj +if _with_0 ~= nil then + print(obj.name) +end do local var = "hello" print(var) @@ -4351,6 +4355,10 @@ do _with_1["key-name"] = value end _with_0[#_with_0 + 1] = "abc" +local _with_0 = obj +if _with_0 ~= nil then + print(obj.name) +end do local var = "hello" print(var) diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua index 867d1b5..338d51f 100644 --- a/spec/outputs/with.lua +++ b/spec/outputs/with.lua @@ -234,4 +234,20 @@ do end a = _accum_0 end +do + local a + local _accum_0 + for i = 1, 100 do + local x = tb[i] + if x ~= nil then + local _des_0 = 1 + if _des_0 then + x.id = _des_0 + _accum_0 = x + break + end + end + end + a = _accum_0 +end return nil -- cgit v1.2.3-55-g6feb