fix: NOT not correctly executed

This commit is contained in:
Eatswap 2022-12-13 15:22:35 +08:00
parent 266273963c
commit 3547e58f2c
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
1 changed files with 1 additions and 1 deletions

View File

@ -179,7 +179,7 @@ std::shared_ptr<Value> UnaryAST::eval(Context* parent) {
auto valS = std::dynamic_pointer_cast<SingleValue>(val); auto valS = std::dynamic_pointer_cast<SingleValue>(val);
switch (this->op) { switch (this->op) {
case NOT: case NOT:
return std::make_shared<SingleValue>(val->isArray() || (valS && !valS->isNil())); return std::make_shared<SingleValue>(!val->isArray() && valS && valS->isNil());
case MAKE_ARRAY: case MAKE_ARRAY:
if (val->isArray() || (valS && !valS->isInt())) if (val->isArray() || (valS && !valS->isInt()))
throw std::runtime_error("Array size must be an integer"); throw std::runtime_error("Array size must be an integer");