aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-02-05 14:52:29 +0800
committerLi Jin <dragon-fly@qq.com>2024-02-05 14:52:29 +0800
commit5ef5cff3efd030eb440133b5e4b2925bb9fe8ead (patch)
treea563ad80b12777dfcb920c21e2a00b201252b7aa
parent018b9408f167067c596fc23781bc945edb9f4d89 (diff)
downloadyuescript-0.21.8.tar.gz
yuescript-0.21.8.tar.bz2
yuescript-0.21.8.zip
fix an empty check case.v0.21.8
-rw-r--r--spec/inputs/in_expression.yue4
-rw-r--r--spec/outputs/in_expression.lua6
-rw-r--r--src/yuescript/yue_compiler.cpp26
3 files changed, 26 insertions, 10 deletions
diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue
index 0b2a87a..e854083 100644
--- a/spec/inputs/in_expression.yue
+++ b/spec/inputs/in_expression.yue
@@ -72,6 +72,8 @@ do
72 2 72 2
73 x: 3 73 x: 3
74 } 74 }
75 75 print a in []
76 a = 1
77 print a in {}
76nil 78nil
77 79
diff --git a/spec/outputs/in_expression.lua b/spec/outputs/in_expression.lua
index b99be8a..3ccab0c 100644
--- a/spec/outputs/in_expression.lua
+++ b/spec/outputs/in_expression.lua
@@ -206,5 +206,11 @@ do
206 b = not _find_0 206 b = not _find_0
207 end 207 end
208 end 208 end
209 print((function()
210 local _val_0 = a
211 return false
212 end)())
213 local a = 1
214 print((false))
209end 215end
210return nil 216return nil
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
78const std::string_view version = "0.21.7"sv; 78const std::string_view version = "0.21.8"sv;
79const std::string_view extension = "yue"sv; 79const std::string_view extension = "yue"sv;
80 80
81class CompileError : public std::logic_error { 81class 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 << ')';