diff options
-rw-r--r-- | spec/inputs/in_expression.yue | 4 | ||||
-rw-r--r-- | spec/outputs/in_expression.lua | 6 | ||||
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 26 |
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 {} | ||
76 | nil | 78 | nil |
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)) | ||
209 | end | 215 | end |
210 | return nil | 216 | return 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 | ||
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 << ')'; |