diff --git a/src/graph/validator/SequentialValidator.cpp b/src/graph/validator/SequentialValidator.cpp index c054a6ef965..ff8743fbf64 100644 --- a/src/graph/validator/SequentialValidator.cpp +++ b/src/graph/validator/SequentialValidator.cpp @@ -43,6 +43,16 @@ Status SequentialValidator::validateImpl() { break; } + for (const auto& sentence : sentences) { + switch (sentence->kind()) { + case Sentence::Kind::kLimit: + return Status::SemanticError("Don't allowed dangle Limit sentence."); + default: + // nothing + break; + } + } + seqAstCtx_->startNode = StartNode::make(seqAstCtx_->qctx); for (auto* sentence : sentences) { auto validator = makeValidator(sentence, qctx_); diff --git a/tests/tck/features/bugfix/DangleLimit.feature b/tests/tck/features/bugfix/DangleLimit.feature new file mode 100644 index 00000000000..13d443230d2 --- /dev/null +++ b/tests/tck/features/bugfix/DangleLimit.feature @@ -0,0 +1,13 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. +Feature: Dangle limit + + # issue #2548 + Scenario: Dangle limit + When executing query: + """ + YIELD 1; LIMIT 1; + """ + Then a SemanticError should be raised at runtime: Don't allowed dangle Limit sentence.