From 26e154b4dd1ea3436613cf3749f831b0159f570c Mon Sep 17 00:00:00 2001 From: CPWstatic <13495049+CPWstatic@users.noreply.github.com> Date: Tue, 7 Jun 2022 12:00:42 +0800 Subject: [PATCH 1/2] More readable error msg for operator and/or. --- src/graph/visitor/DeduceTypeVisitor.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/graph/visitor/DeduceTypeVisitor.cpp b/src/graph/visitor/DeduceTypeVisitor.cpp index 73f947d266a..16fccff4e78 100644 --- a/src/graph/visitor/DeduceTypeVisitor.cpp +++ b/src/graph/visitor/DeduceTypeVisitor.cpp @@ -105,8 +105,19 @@ static const std::unordered_map kConstantValues = { auto detectValue = prevOp->second OP currentOp->second; \ if (detectValue.isBadNull()) { \ std::stringstream ss; \ - ss << "`" << expr->toString() << "' is not a valid expression, " \ - << "can not apply `" << #OP << "' to `" << prev << "' and `" << current << "'."; \ + if (strcmp(#OP, "&&") == 0 || strcmp(#OP, "AND") == 0) { \ + ss << "`" << expr->toString() << "' is not a valid expression, " \ + << "can not apply `&&' or `AND' operator to `" << prev << "' and `" << current \ + << "'."; \ + } else if (strcmp(#OP, "||") == 0 || strcmp(#OP, "OR") == 0) { \ + ss << "`" << expr->toString() << "' is not a valid expression, " \ + << "can not apply `||' or `OR' operator to `" << prev << "' and `" << current \ + << "'."; \ + } else { \ + ss << "`" << expr->toString() << "' is not a valid expression, " \ + << "can not apply `" << #OP << "' operator to `" << prev << "' and `" << current \ + << "'."; \ + } \ status_ = Status::SemanticError(ss.str()); \ return; \ } \ From 9ab5c181670b0e9873850977552c40b4903e7400 Mon Sep 17 00:00:00 2001 From: CPWstatic <13495049+CPWstatic@users.noreply.github.com> Date: Tue, 7 Jun 2022 15:28:47 +0800 Subject: [PATCH 2/2] Add test. --- tests/tck/features/yield/yield.feature | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/tck/features/yield/yield.feature b/tests/tck/features/yield/yield.feature index 9eb6d8c962b..71afde05e15 100644 --- a/tests/tck/features/yield/yield.feature +++ b/tests/tck/features/yield/yield.feature @@ -554,3 +554,10 @@ Feature: Yield Sentence Then the result should be, in any order, with relax comparison: | counT(*) | aVg(3) | bit_Or(1) | | 1 | 3.0 | 1 | + + Scenario: Error message for and/or + When executing query: + """ + YIELD -1 AND TRUE; + """ + Then a SemanticError should be raised at runtime: `(-(1) AND true)' is not a valid expression, can not apply `&&' or `AND' operator to `INT' and `BOOL'.