From 05da3cbfa3689e6c229c41156d0dd08ab554cd77 Mon Sep 17 00:00:00 2001 From: Li Jin <dragon-fly@qq.com> Date: Tue, 8 Oct 2024 17:58:49 +0800 Subject: Fixed a miss indent and removed an unnecessary do block. --- spec/inputs/with.yue | 5 +++++ spec/outputs/unicode/with.lua | 4 +--- spec/outputs/with.lua | 11 ++++++++--- src/yuescript/yue_compiler.cpp | 5 ++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index 5da0980..19b7be1 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue @@ -147,4 +147,9 @@ do .touchEnabled = true .swallowTouches = true +do + f = -> + return with {} + return [123] + nil diff --git a/spec/outputs/unicode/with.lua b/spec/outputs/unicode/with.lua index cfad264..7a5ba00 100644 --- a/spec/outputs/unicode/with.lua +++ b/spec/outputs/unicode/with.lua @@ -123,9 +123,7 @@ do local _ _ = function() local _with_0 = _u55e8 - do - return _with_0.a, _with_0.b - end + return _with_0.a, _with_0.b end end do diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua index d880d1e..5d33bdb 100644 --- a/spec/outputs/with.lua +++ b/spec/outputs/with.lua @@ -121,9 +121,7 @@ do local _ _ = function() local _with_0 = hi - do - return _with_0.a, _with_0.b - end + return _with_0.a, _with_0.b end end do @@ -184,4 +182,11 @@ do mask.swallowTouches = true end end +do + local f + f = function() + local _with_0 = { } + return _with_0[123] + end +end return nil diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index b7e09d3..c29513e 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -75,7 +75,7 @@ static std::unordered_set<std::string> Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.25.4"sv; +const std::string_view version = "0.25.5"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -9174,7 +9174,7 @@ private: transformIf(ifNode, temp, ExpUsage::Common); } else { bool transformed = false; - if (assignList || returnValue) { + if (!extraScope && assignList) { if (auto block = with->body.as<Block_t>()) { if (!block->statements.empty()) { Statement_t* stmt = static_cast<Statement_t*>(block->statements.back()); @@ -9199,7 +9199,6 @@ private: auto doNode = stmt->new_ptr<Do_t>(); doNode->body.set(newBody); transformDo(doNode, temp, ExpUsage::Common); - temp.back().insert(0, indent()); transformed = true; } } -- cgit v1.2.3-55-g6feb