diff --git a/.gitignore b/.gitignore index b67eda3..2fb7a59 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ bin tup/*.lua tup/t/*.lua Yuescript.vcxproj.user -spec/generated \ No newline at end of file +spec/generated +.release_time \ No newline at end of file diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index c346891..b44b697 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -75,7 +75,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.25.2"sv; +const std::string_view version = "0.25.3"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -9154,33 +9154,35 @@ class YueCompilerImpl { transformIf(ifNode, temp, ExpUsage::Common); } else { bool transformed = false; - if (auto block = with->body.as()) { - if (!block->statements.empty()) { - Statement_t* stmt = static_cast(block->statements.back()); + if (assignList || returnValue) { + if (auto block = with->body.as()) { + if (!block->statements.empty()) { + Statement_t* stmt = static_cast(block->statements.back()); + if (stmt->content.is()) { + auto newBlock = with->body->new_ptr(); + newBlock->statements.dup(block->statements); + newBlock->statements.pop_back(); + transform_plain_body(newBlock, temp, ExpUsage::Common); + auto newBody = stmt->new_ptr(); + newBody->content.set(stmt); + auto doNode = stmt->new_ptr(); + doNode->body.set(newBody); + transformDo(doNode, temp, ExpUsage::Common); + transformed = true; + } + } + } else { + auto stmt = with->body.to(); if (stmt->content.is()) { - auto newBlock = with->body->new_ptr(); - newBlock->statements.dup(block->statements); - newBlock->statements.pop_back(); - transform_plain_body(newBlock, temp, ExpUsage::Common); auto newBody = stmt->new_ptr(); newBody->content.set(stmt); auto doNode = stmt->new_ptr(); doNode->body.set(newBody); transformDo(doNode, temp, ExpUsage::Common); + temp.back().insert(0, indent()); transformed = true; } } - } else { - auto stmt = with->body.to(); - if (stmt->content.is()) { - auto newBody = stmt->new_ptr(); - newBody->content.set(stmt); - auto doNode = stmt->new_ptr(); - doNode->body.set(newBody); - transformDo(doNode, temp, ExpUsage::Common); - temp.back().insert(0, indent()); - transformed = true; - } } if (!transformed) { transform_plain_body(with->body, temp, ExpUsage::Common);