Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More readable error msg for operator and/or. #4304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/graph/visitor/DeduceTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,19 @@ static const std::unordered_map<Value::Type, Value> 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; \
} \
Expand Down
7 changes: 7 additions & 0 deletions tests/tck/features/yield/yield.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'.