From 1d2423bff4ecc4396d65c387982d6667b33bd796 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 13 Jul 2023 09:09:47 +0800 Subject: fix a missing case for in expression. --- spec/inputs/in_expression.yue | 2 +- spec/outputs/in_expression.lua | 2 +- src/yuescript/yue_compiler.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/inputs/in_expression.yue b/spec/inputs/in_expression.yue index 66a8215..4080016 100644 --- a/spec/inputs/in_expression.yue +++ b/spec/inputs/in_expression.yue @@ -36,7 +36,7 @@ do do item = get! list = {1, 2, 3} - exist = item in list + not_exist = item not in list check item in list check item in {1, 2, 3} check item in {[1]: 1, [2]: 2, [3]: 3} diff --git a/spec/outputs/in_expression.lua b/spec/outputs/in_expression.lua index 41ae87e..ccc5fd0 100644 --- a/spec/outputs/in_expression.lua +++ b/spec/outputs/in_expression.lua @@ -92,7 +92,7 @@ do 2, 3 } - local exist = (#list > 0 and (function() + local not_exist = not (#list > 0 and (function() for _index_0 = 1, #list do if list[_index_0] == item then return true diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 3353a2a..c6cc4ba 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -72,7 +72,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.17.5"sv; +const std::string_view version = "0.17.6"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -5483,6 +5483,9 @@ private: } popAnonVarArg(); popFunctionScope(); + if (unary_exp->inExp->not_) { + temp.front().insert(0, "not "s); + } out.push_back(join(temp)); return; } -- cgit v1.2.3-55-g6feb