aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-06-29 14:23:44 +0800
committerLi Jin <dragon-fly@qq.com>2023-06-29 14:24:40 +0800
commitdce38caac22a024026d19f556aefe0669f97403c (patch)
tree8b90a10585139dec76b596d714e213fc9393603b /src
parent3edfe65c36d716ca0d1a4d15e78c84c94cb144d0 (diff)
downloadyuescript-dce38caac22a024026d19f556aefe0669f97403c.tar.gz
yuescript-dce38caac22a024026d19f556aefe0669f97403c.tar.bz2
yuescript-dce38caac22a024026d19f556aefe0669f97403c.zip
fix assignment to in-expression with discrete values issue from #140v0.17.3
Diffstat (limited to 'src')
-rw-r--r--src/yuescript/yue_ast.h2
-rw-r--r--src/yuescript/yue_compiler.cpp10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h
index c47ba8a..85a1e52 100644
--- a/src/yuescript/yue_ast.h
+++ b/src/yuescript/yue_ast.h
@@ -910,7 +910,7 @@ struct YueFormat {
910 int tabSpaces = 4; 910 int tabSpaces = 4;
911 std::string toString(ast_node* node); 911 std::string toString(ast_node* node);
912 912
913 Converter converter; 913 Converter converter{};
914 void pushScope(); 914 void pushScope();
915 void popScope(); 915 void popScope();
916 std::string convert(const ast_node* node); 916 std::string convert(const ast_node* node);
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index c1426f9..efd0aed 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -72,7 +72,7 @@ static std::unordered_set<std::string> Metamethods = {
72 "close"s // Lua 5.4 72 "close"s // Lua 5.4
73}; 73};
74 74
75const std::string_view version = "0.17.2"sv; 75const std::string_view version = "0.17.3"sv;
76const std::string_view extension = "yue"sv; 76const std::string_view extension = "yue"sv;
77 77
78class CompileError : public std::logic_error { 78class CompileError : public std::logic_error {
@@ -5429,7 +5429,13 @@ private:
5429 for (auto exp : discrete->values.objects()) { 5429 for (auto exp : discrete->values.objects()) {
5430 transformExp(static_cast<Exp_t*>(exp), tmp, ExpUsage::Closure); 5430 transformExp(static_cast<Exp_t*>(exp), tmp, ExpUsage::Closure);
5431 } 5431 }
5432 _buf << indent() << "return "sv; 5432 if (usage == ExpUsage::Assignment) {
5433 str_list tmpList;
5434 transformExp(static_cast<Exp_t*>(assignList->exprs.front()), tmpList, ExpUsage::Closure);
5435 _buf << indent() << tmpList.back() << " = "sv;
5436 } else {
5437 _buf << indent() << "return "sv;
5438 }
5433 if (unary_exp->inExp->not_) { 5439 if (unary_exp->inExp->not_) {
5434 _buf << "not ("sv; 5440 _buf << "not ("sv;
5435 } 5441 }