diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-10-08 17:58:49 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-10-08 17:58:49 +0800 |
| commit | 05da3cbfa3689e6c229c41156d0dd08ab554cd77 (patch) | |
| tree | 97eb63ae37ac36a41bbf8a6a02f3a838d089d600 | |
| parent | 91ca3bfacc2b3f5516a519c939814d7462f73141 (diff) | |
| download | yuescript-0.25.5.tar.gz yuescript-0.25.5.tar.bz2 yuescript-0.25.5.zip | |
Fixed a miss indent and removed an unnecessary do block.v0.25.5
| -rw-r--r-- | spec/inputs/with.yue | 5 | ||||
| -rw-r--r-- | spec/outputs/unicode/with.lua | 4 | ||||
| -rw-r--r-- | spec/outputs/with.lua | 11 | ||||
| -rw-r--r-- | 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 | |||
| 147 | .touchEnabled = true | 147 | .touchEnabled = true |
| 148 | .swallowTouches = true | 148 | .swallowTouches = true |
| 149 | 149 | ||
| 150 | do | ||
| 151 | f = -> | ||
| 152 | return with {} | ||
| 153 | return [123] | ||
| 154 | |||
| 150 | nil | 155 | 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 | |||
| 123 | local _ | 123 | local _ |
| 124 | _ = function() | 124 | _ = function() |
| 125 | local _with_0 = _u55e8 | 125 | local _with_0 = _u55e8 |
| 126 | do | 126 | return _with_0.a, _with_0.b |
| 127 | return _with_0.a, _with_0.b | ||
| 128 | end | ||
| 129 | end | 127 | end |
| 130 | end | 128 | end |
| 131 | do | 129 | 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 | |||
| 121 | local _ | 121 | local _ |
| 122 | _ = function() | 122 | _ = function() |
| 123 | local _with_0 = hi | 123 | local _with_0 = hi |
| 124 | do | 124 | return _with_0.a, _with_0.b |
| 125 | return _with_0.a, _with_0.b | ||
| 126 | end | ||
| 127 | end | 125 | end |
| 128 | end | 126 | end |
| 129 | do | 127 | do |
| @@ -184,4 +182,11 @@ do | |||
| 184 | mask.swallowTouches = true | 182 | mask.swallowTouches = true |
| 185 | end | 183 | end |
| 186 | end | 184 | end |
| 185 | do | ||
| 186 | local f | ||
| 187 | f = function() | ||
| 188 | local _with_0 = { } | ||
| 189 | return _with_0[123] | ||
| 190 | end | ||
| 191 | end | ||
| 187 | return nil | 192 | 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 = { | |||
| 75 | "close"s // Lua 5.4 | 75 | "close"s // Lua 5.4 |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | const std::string_view version = "0.25.4"sv; | 78 | const std::string_view version = "0.25.5"sv; |
| 79 | const std::string_view extension = "yue"sv; | 79 | const std::string_view extension = "yue"sv; |
| 80 | 80 | ||
| 81 | class CompileError : public std::logic_error { | 81 | class CompileError : public std::logic_error { |
| @@ -9174,7 +9174,7 @@ private: | |||
| 9174 | transformIf(ifNode, temp, ExpUsage::Common); | 9174 | transformIf(ifNode, temp, ExpUsage::Common); |
| 9175 | } else { | 9175 | } else { |
| 9176 | bool transformed = false; | 9176 | bool transformed = false; |
| 9177 | if (assignList || returnValue) { | 9177 | if (!extraScope && assignList) { |
| 9178 | if (auto block = with->body.as<Block_t>()) { | 9178 | if (auto block = with->body.as<Block_t>()) { |
| 9179 | if (!block->statements.empty()) { | 9179 | if (!block->statements.empty()) { |
| 9180 | Statement_t* stmt = static_cast<Statement_t*>(block->statements.back()); | 9180 | Statement_t* stmt = static_cast<Statement_t*>(block->statements.back()); |
| @@ -9199,7 +9199,6 @@ private: | |||
| 9199 | auto doNode = stmt->new_ptr<Do_t>(); | 9199 | auto doNode = stmt->new_ptr<Do_t>(); |
| 9200 | doNode->body.set(newBody); | 9200 | doNode->body.set(newBody); |
| 9201 | transformDo(doNode, temp, ExpUsage::Common); | 9201 | transformDo(doNode, temp, ExpUsage::Common); |
| 9202 | temp.back().insert(0, indent()); | ||
| 9203 | transformed = true; | 9202 | transformed = true; |
| 9204 | } | 9203 | } |
| 9205 | } | 9204 | } |
