diff --git a/src/arkreactor/Compiler/AST/Parser.cpp b/src/arkreactor/Compiler/AST/Parser.cpp index d829e5202..d1702431a 100644 --- a/src/arkreactor/Compiler/AST/Parser.cpp +++ b/src/arkreactor/Compiler/AST/Parser.cpp @@ -209,7 +209,7 @@ namespace Ark::internal if (auto condition = nodeOrValue(); condition.has_value()) leaf->push_back(condition.value().attachNearestCommentBefore(comment)); else - errorWithNextToken("If need a valid condition"); + errorWithNextToken("`if' needs a valid condition"); comment.clear(); newlineOrComment(&comment); @@ -217,7 +217,7 @@ namespace Ark::internal if (auto value_if_true = nodeOrValue(); value_if_true.has_value()) leaf->push_back(value_if_true.value().attachNearestCommentBefore(comment)); else - errorWithNextToken("Expected a value"); + errorWithNextToken("Expected a node or value after condition"); comment.clear(); newlineOrComment(&comment); @@ -252,7 +252,7 @@ namespace Ark::internal if (auto condition = nodeOrValue(); condition.has_value()) leaf->push_back(condition.value().attachNearestCommentBefore(comment)); else - errorWithNextToken("While need a valid condition"); + errorWithNextToken("`while' needs a valid condition"); comment.clear(); newlineOrComment(&comment); @@ -260,7 +260,7 @@ namespace Ark::internal if (auto body = nodeOrValue(); body.has_value()) leaf->push_back(body.value().attachNearestCommentBefore(comment)); else - errorWithNextToken("Expected a value"); + errorWithNextToken("Expected a node or value after loop condition"); setNodePosAndFilename(leaf->list().back()); return leaf; diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.ark new file mode 100644 index 000000000..cf41848d7 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.ark @@ -0,0 +1 @@ +(while 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.expected new file mode 100644 index 000000000..7bc74ac52 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_body_while.expected @@ -0,0 +1,5 @@ +At ) @ 1:9 + 1 | (while 1) + | ^ + 2 | + Expected a node or value after loop condition diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.ark new file mode 100644 index 000000000..1bc9c9262 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.ark @@ -0,0 +1 @@ +(if) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.expected new file mode 100644 index 000000000..64ddac115 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_if.expected @@ -0,0 +1,5 @@ +At ) @ 1:4 + 1 | (if) + | ^ + 2 | + `if' needs a valid condition diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.ark new file mode 100644 index 000000000..b151c2fd3 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.ark @@ -0,0 +1 @@ +(while) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.expected new file mode 100644 index 000000000..ef701ec61 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_cond_while.expected @@ -0,0 +1,5 @@ +At ) @ 1:7 + 1 | (while) + | ^ + 2 | + `while' needs a valid condition diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.ark new file mode 100644 index 000000000..14aef1aaa --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.ark @@ -0,0 +1 @@ +(if 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.expected new file mode 100644 index 000000000..7c9d854ba --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/missing_then_if.expected @@ -0,0 +1,5 @@ +At ) @ 1:6 + 1 | (if 1) + | ^ + 2 | + Expected a node or value after condition