diff --git a/src/util/ExpressionUtils.h b/src/util/ExpressionUtils.h index ede22afbc4621f9e04121286c4b99944fbc57ffb..bfc2f9e50d64b1ef5e122059a5c5b7e97995db55 100644 --- a/src/util/ExpressionUtils.h +++ b/src/util/ExpressionUtils.h @@ -63,6 +63,8 @@ public: case Expression::Kind::kRelLE: case Expression::Kind::kRelGT: case Expression::Kind::kRelGE: + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: case Expression::Kind::kLogicalAnd: case Expression::Kind::kLogicalOr: case Expression::Kind::kLogicalXor: { @@ -73,7 +75,6 @@ public: } return traverse(biExpr->right(), visitor); } - case Expression::Kind::kRelIn: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: case Expression::Kind::kUnaryPlus: @@ -98,6 +99,12 @@ public: } return true; } + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: { + return false; + } } DLOG(FATAL) << "Impossible expression kind " << static_cast<int>(expr->kind()); return false; @@ -262,6 +269,8 @@ public: case Expression::Kind::kRelLE: case Expression::Kind::kRelGT: case Expression::Kind::kRelGE: + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: case Expression::Kind::kLogicalAnd: case Expression::Kind::kLogicalOr: case Expression::Kind::kLogicalXor: { @@ -276,7 +285,6 @@ public: } return true; } - case Expression::Kind::kRelIn: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: case Expression::Kind::kUnaryPlus: @@ -309,6 +317,12 @@ public: } return true; } + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: { + return false; + } } // switch DLOG(FATAL) << "Impossible expression kind " << static_cast<int>(current->kind()); return false; diff --git a/src/validator/GoValidator.cpp b/src/validator/GoValidator.cpp index aee047db0b7523520e50117ae93e6bd8216db743..d5de495e3a105705dc95ef001dde8081c3179029 100644 --- a/src/validator/GoValidator.cpp +++ b/src/validator/GoValidator.cpp @@ -848,7 +848,12 @@ void GoValidator::extractPropExprs(const Expression* expr) { case Expression::Kind::kSymProperty: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: - case Expression::Kind::kRelIn: { + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: { LOG(FATAL) << "Not support " << expr->kind(); break; } @@ -941,7 +946,12 @@ std::unique_ptr<Expression> GoValidator::rewriteToInputProp(Expression* expr) { case Expression::Kind::kSymProperty: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: - case Expression::Kind::kRelIn: { + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: { LOG(FATAL) << "Not support " << expr->kind(); break; } diff --git a/src/validator/MutateValidator.cpp b/src/validator/MutateValidator.cpp index 236442200183b6c667745297835be4d40289da4e..5bf1931ae744b2d736462f760101dc1946ca32bf 100644 --- a/src/validator/MutateValidator.cpp +++ b/src/validator/MutateValidator.cpp @@ -644,6 +644,7 @@ std::unique_ptr<Expression> UpdateValidator::rewriteSymExpr(Expression* expr, case Expression::Kind::kRelGT: case Expression::Kind::kRelGE: case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: case Expression::Kind::kLogicalAnd: case Expression::Kind::kLogicalOr: case Expression::Kind::kLogicalXor: { @@ -727,7 +728,11 @@ std::unique_ptr<Expression> UpdateValidator::rewriteSymExpr(Expression* expr, case Expression::Kind::kVarProperty: case Expression::Kind::kInputProperty: case Expression::Kind::kUnaryIncr: - case Expression::Kind::kUnaryDecr: { + case Expression::Kind::kUnaryDecr: + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: { hasWrongType = true; break; } diff --git a/src/validator/Validator.cpp b/src/validator/Validator.cpp index c47bf21a50371767594b27b28ad41bdcfef782d8..c94824115a1377ac6fe704ec8cc170b85fb0fc30 100644 --- a/src/validator/Validator.cpp +++ b/src/validator/Validator.cpp @@ -312,13 +312,14 @@ StatusOr<Value::Type> Validator::deduceExprType(const Expression* expr) const { case Expression::Kind::kLogicalOr: { DETECT_BIEXPR_TYPE(||) } - case Expression::Kind::kRelIn: { + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: { auto biExpr = static_cast<const BinaryExpression*>(expr); NG_RETURN_IF_ERROR(deduceExprType(biExpr->left())); auto right = deduceExprType(biExpr->right()); NG_RETURN_IF_ERROR(right); - if (right.value() != Value::Type::LIST) { + if (right.value() != Value::Type::LIST) { // FIXME(dutor) std::stringstream ss; ss << "`" << expr->toString() << "' is not a valid expression, " << "expected `LIST' but `" << right.value() << "' was given."; @@ -508,6 +509,18 @@ StatusOr<Value::Type> Validator::deduceExprType(const Expression* expr) const { // TODO: not only dataset return Value::Type::DATASET; } + case Expression::Kind::kList: { + return Value::Type::LIST; + } + case Expression::Kind::kSet: { + return Value::Type::SET; + } + case Expression::Kind::kMap: { + return Value::Type::MAP; + } + case Expression::Kind::kSubscript: { + return Value::Type::LIST; // FIXME(dutor) + } } return Status::SemanticError("Unknown expression kind: %ld", static_cast<int64_t>(expr->kind())); @@ -612,7 +625,12 @@ Status Validator::deduceProps(const Expression* expr) { case Expression::Kind::kSymProperty: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: - case Expression::Kind::kRelIn: { + case Expression::Kind::kList: + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: + case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: { // TODO: std::stringstream ss; ss << "Not supported expression kind for type deduction: " << expr->toString(); @@ -639,6 +657,7 @@ bool Validator::evaluableExpr(const Expression* expr) const { case Expression::Kind::kRelGT: case Expression::Kind::kRelGE: case Expression::Kind::kRelIn: + case Expression::Kind::kRelNotIn: case Expression::Kind::kLogicalAnd: case Expression::Kind::kLogicalOr: case Expression::Kind::kLogicalXor: { @@ -679,7 +698,11 @@ bool Validator::evaluableExpr(const Expression* expr) const { case Expression::Kind::kInputProperty: case Expression::Kind::kSymProperty: case Expression::Kind::kUnaryIncr: - case Expression::Kind::kUnaryDecr: { + case Expression::Kind::kUnaryDecr: + case Expression::Kind::kList: // FIXME(dutor) + case Expression::Kind::kSet: + case Expression::Kind::kMap: + case Expression::Kind::kSubscript: { return false; } }