diff options
author | Li Jin <dragon-fly@qq.com> | 2024-02-05 14:52:29 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2024-02-05 14:52:29 +0800 |
commit | 5ef5cff3efd030eb440133b5e4b2925bb9fe8ead (patch) | |
tree | a563ad80b12777dfcb920c21e2a00b201252b7aa /src | |
parent | 018b9408f167067c596fc23781bc945edb9f4d89 (diff) | |
download | yuescript-5ef5cff3efd030eb440133b5e4b2925bb9fe8ead.tar.gz yuescript-5ef5cff3efd030eb440133b5e4b2925bb9fe8ead.tar.bz2 yuescript-5ef5cff3efd030eb440133b5e4b2925bb9fe8ead.zip |
fix an empty check case.v0.21.8
Diffstat (limited to 'src')
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 5cdbfda..30800e6 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.21.7"sv; | 78 | const std::string_view version = "0.21.8"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 { |
@@ -6162,10 +6162,14 @@ private: | |||
6162 | if (unary_exp->inExp->not_) { | 6162 | if (unary_exp->inExp->not_) { |
6163 | _buf << "not ("sv; | 6163 | _buf << "not ("sv; |
6164 | } | 6164 | } |
6165 | for (const auto& exp : tmp) { | 6165 | if (tmp.empty()) { |
6166 | _buf << exp << " == "sv << newVar; | 6166 | _buf << "false"sv; |
6167 | if (exp != tmp.back()) { | 6167 | } else { |
6168 | _buf << " or "sv; | 6168 | for (const auto& exp : tmp) { |
6169 | _buf << exp << " == "sv << newVar; | ||
6170 | if (exp != tmp.back()) { | ||
6171 | _buf << " or "sv; | ||
6172 | } | ||
6169 | } | 6173 | } |
6170 | } | 6174 | } |
6171 | if (unary_exp->inExp->not_) { | 6175 | if (unary_exp->inExp->not_) { |
@@ -6203,10 +6207,14 @@ private: | |||
6203 | _buf << "not "sv; | 6207 | _buf << "not "sv; |
6204 | } | 6208 | } |
6205 | _buf << '('; | 6209 | _buf << '('; |
6206 | for (const auto& exp : tmp) { | 6210 | if (tmp.empty()) { |
6207 | _buf << exp << " == "sv << varName; | 6211 | _buf << "false"sv; |
6208 | if (exp != tmp.back()) { | 6212 | } else { |
6209 | _buf << " or "sv; | 6213 | for (const auto& exp : tmp) { |
6214 | _buf << exp << " == "sv << varName; | ||
6215 | if (exp != tmp.back()) { | ||
6216 | _buf << " or "sv; | ||
6217 | } | ||
6210 | } | 6218 | } |
6211 | } | 6219 | } |
6212 | _buf << ')'; | 6220 | _buf << ')'; |