From 127e8f58185dd436b293c58a31f9264355233b40 Mon Sep 17 00:00:00 2001 From: dutor <440396+dutor@users.noreply.github.com> Date: Wed, 5 Aug 2020 15:06:41 +0800 Subject: [PATCH] Fix build error due to new type of expression (#184) --- src/util/ExpressionUtils.h | 18 ++++++++++++++++-- src/validator/GoValidator.cpp | 14 ++++++++++++-- src/validator/MutateValidator.cpp | 7 ++++++- src/validator/Validator.cpp | 31 +++++++++++++++++++++++++++---- 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/util/ExpressionUtils.h b/src/util/ExpressionUtils.h index ede22afb..bfc2f9e5 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 aee047db..d5de495e 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 23644220..5bf1931a 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 c47bf21a..c9482411 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; } } -- GitLab