diff options
author | Li Jin <dragon-fly@qq.com> | 2025-01-30 13:46:12 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2025-01-30 13:46:12 +0800 |
commit | cf91f61990babdd8a80774809e9e860a155e4201 (patch) | |
tree | f163ca2a655f614c844ae786c5c0fe73a9422ef2 | |
parent | 56287718ddbb85b66a011e014f01a844580caf16 (diff) | |
download | yuescript-cf91f61990babdd8a80774809e9e860a155e4201.tar.gz yuescript-cf91f61990babdd8a80774809e9e860a155e4201.tar.bz2 yuescript-cf91f61990babdd8a80774809e9e860a155e4201.zip |
Fixed one more case for issue #185.
-rw-r--r-- | spec/inputs/in_expression.yue | 4 | ||||
-rw-r--r-- | spec/outputs/in_expression.lua | 10 | ||||
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue index 0393881..f34a4ad 100644 --- a/spec/inputs/in_expression.yue +++ b/spec/inputs/in_expression.yue | |||
@@ -89,5 +89,9 @@ do | |||
89 | b = 1 | 89 | b = 1 |
90 | print a in [b, 10, b] | 90 | print a in [b, 10, b] |
91 | 91 | ||
92 | do | ||
93 | print x in ["", ""] | ||
94 | print 1 in [1, 2, 1] | ||
95 | |||
92 | nil | 96 | nil |
93 | 97 | ||
diff --git a/spec/outputs/in_expression.lua b/spec/outputs/in_expression.lua index 6fbbf91..0778c8e 100644 --- a/spec/outputs/in_expression.lua +++ b/spec/outputs/in_expression.lua | |||
@@ -226,4 +226,14 @@ do | |||
226 | local b = 1 | 226 | local b = 1 |
227 | print((b == a or 10 == a or b == a)) | 227 | print((b == a or 10 == a or b == a)) |
228 | end | 228 | end |
229 | do | ||
230 | print((function() | ||
231 | local _val_0 = x | ||
232 | return "" == _val_0 or "" == _val_0 | ||
233 | end)()) | ||
234 | print((function() | ||
235 | local _val_0 = 1 | ||
236 | return 1 == _val_0 or 2 == _val_0 or 1 == _val_0 | ||
237 | end)()) | ||
238 | end | ||
229 | return nil | 239 | return nil |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index eb12b3f..369f7e8 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.26.2"sv; | 78 | const std::string_view version = "0.26.3"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 { |
@@ -7031,7 +7031,7 @@ private: | |||
7031 | } else { | 7031 | } else { |
7032 | for (const auto& exp : tmp) { | 7032 | for (const auto& exp : tmp) { |
7033 | _buf << exp << " == "sv << newVar; | 7033 | _buf << exp << " == "sv << newVar; |
7034 | if (exp != tmp.back()) { | 7034 | if (&exp != &tmp.back()) { |
7035 | _buf << " or "sv; | 7035 | _buf << " or "sv; |
7036 | } | 7036 | } |
7037 | } | 7037 | } |