From 68f4c0176f93e0108b57593921c6bac5d6fef743 Mon Sep 17 00:00:00 2001 From: Gergo Csizi Date: Fri, 28 Feb 2025 07:31:20 +0100 Subject: [PATCH] Remove LogSyntaxError method Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBK1E8 Testing: pass all current test suites Signed-off-by: Gergo Csizi --- .../ets/constantExpressionLowering.cpp | 22 +- .../lowering/ets/constantExpressionLowering.h | 3 +- ...defaultParametersInConstructorLowering.cpp | 15 +- .../compiler/lowering/ets/enumLowering.cpp | 14 +- .../compiler/lowering/ets/enumLowering.h | 3 +- .../ets/topLevelStmts/importExportDecls.cpp | 59 +-- .../ets/topLevelStmts/importExportDecls.h | 5 +- ets2panda/lexer/ETSLexer.cpp | 10 +- ets2panda/lexer/ETSLexer.h | 4 +- ets2panda/lexer/keywordsUtil.cpp | 4 +- ets2panda/lexer/keywordsUtil.h | 7 +- ets2panda/lexer/lexer.cpp | 69 +-- ets2panda/lexer/lexer.h | 21 +- ets2panda/parser/ETSNolintParser.cpp | 15 +- ets2panda/parser/ETSparser.cpp | 2 +- ets2panda/parser/ThrowingTypedParser.cpp | 2 + ets2panda/parser/parserImpl.cpp | 32 +- ets2panda/parser/parserImpl.h | 9 +- .../enum_import_constant.sts | 4 +- .../default_export/export_default_bad2.sts | 2 +- .../compiler/ets/enum_not_constant_var.sts | 4 +- .../ast/compiler/ets/export_type_enum.sts | 4 +- .../ast/compiler/ets/export_type_function.sts | 4 +- .../ast/compiler/ets/export_type_variable.sts | 4 +- .../export_type_variable_at_definition.sts | 2 +- .../package_test_5/package_module_2_neg.sts | 4 + .../ets/import_tests/export_multi_error.sts | 12 +- .../selective_export_clashing_exports_1.sts | 4 +- .../selective_export_clashing_exports_2.sts | 4 +- .../selective_export_clashing_exports_3.sts | 4 +- .../selective_export_clashing_exports_4.sts | 4 +- .../lambda_infer_type_param1.sts | 12 +- .../ets/namespace_export_invalid01.sts | 2 +- .../ets/variable_declaretion_neg_1.sts | 1 + .../test/ast/parser/ets/AllowSequence.sts | 3 +- .../ast/parser/ets/InvalidExpressions1.sts | 2 +- .../ast/parser/ets/InvalidStatements1.sts | 4 +- .../test/ast/parser/ets/InvalidTyped.sts | 2 +- .../ets/Multiline_string_escape_char.sts | 6 +- .../annotationUsage_parser_bad_token04.sts | 4 +- .../annotationUsage_parser_bad_token05.sts | 1 + .../annotation_export_type.sts | 2 +- .../ets/constant_expression_divide_zero.sts | 6 +- ets2panda/test/ast/parser/ets/enum15.sts | 8 +- ets2panda/test/ast/parser/ets/enum17.sts | 6 +- ets2panda/test/ast/parser/ets/enum18.sts | 6 +- ets2panda/test/ast/parser/ets/enum24.sts | 4 +- ets2panda/test/ast/parser/ets/enum27.sts | 4 +- ets2panda/test/ast/parser/ets/enum28.sts | 4 +- .../ets/enum_default_invalid_value_type.sts | 8 +- .../ast/parser/ets/enum_default_negative.sts | 11 +- .../ast/parser/ets/enum_default_negative1.sts | 10 +- .../extension_function_not_in_toplevel.sts | 6 +- .../default_export_invalid_syntax_3.sts | 2 +- .../default_export_invalid_syntax_4.sts | 2 +- .../parser/ets/import_tests/type/type_3.sts | 6 +- .../test/ast/parser/ets/invalidEnums.sts | 10 +- .../test/ast/parser/ets/invalidEnums1.sts | 10 +- .../test/ast/parser/ets/invalidTypes.sts | 2 + .../ast/parser/ets/namespace_badtoken04.sts | 2 + .../parser/ets/non_constant_expression.sts | 4 +- .../selective_export/selective_export_bad.sts | 4 +- .../ets/single_export/single_export_as_n.sts | 1 + .../single_export/single_export_from_n.sts | 2 +- .../ets/single_export/single_export_n.sts | 4 +- .../test/ast/parser/ets/string_literal_01.sts | 8 +- .../test/ast/parser/ets/trailing_comma_1.sts | 4 +- .../test/ast/parser/ets/tuple_type_3_neg.sts | 4 +- .../test/ast/parser/ets/type_references.sts | 8 +- .../ast/parser/ets/unexpected_token_14.sts | 2 + .../ast/parser/ets/unexpected_token_25.sts | 2 + .../ast/parser/ets/unexpected_token_31.sts | 2 + .../ast/parser/ets/unexpected_token_35.sts | 2 + .../ast/parser/ets/unexpected_token_38.sts | 1 + .../ast/parser/ets/unexpected_token_40.sts | 3 +- .../ast/parser/ets/unexpected_token_48.sts | 3 +- .../ast/parser/ets/unexpected_token_53.sts | 5 + .../ast/parser/ets/unexpected_token_55.sts | 5 + .../ast/parser/ets/unexpected_token_56.sts | 2 + .../test/ast/parser/js/InvalidParserImpl.js | 4 +- .../parser/js/module/unexpected_token_10.js | 4 +- .../ast/parser/js/test-class-static-block6.js | 4 +- .../ast/parser/js/test-escaped-keyword.js | 4 +- ets2panda/test/ast/parser/js/test-for-1.js | 1 + .../ast/parser/js/test-member-expression-1.js | 4 +- .../ast/parser/js/test-multi-line-string.js | 8 +- .../ast/parser/js/test-numeric-separator1.js | 6 +- .../ast/parser/js/test-numeric-separator2.js | 4 +- .../test/ast/parser/js/test-private-field4.js | 6 +- .../test/ast/parser/js/test-private-field5.js | 6 +- .../test/ast/parser/js/test-private-field9.js | 4 +- .../ast/parser/js/test-template-literal-1.js | 9 +- .../test/ast/parser/js/test-use-strict-1.js | 4 +- .../test/ast/parser/js/unexpected_token_3.js | 8 +- .../test/ast/parser/js/unexpected_token_5.js | 6 +- .../test/ast/parser/ts/InvalidExpressions.ts | 5 + .../test/ast/parser/ts/catch_or_finally_1.ts | 7 +- .../test/ast/parser/ts/trailing_comma_4.ts | 2 +- .../test/ast/parser/ts/unexpected_token_7.ts | 2 +- ets2panda/util/diagnostic/syntax.yaml | 484 ++++++++++++------ 100 files changed, 688 insertions(+), 458 deletions(-) diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 10c53cd049..0263d2ce9e 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -23,9 +23,11 @@ namespace ark::es2panda::compiler { using AstNodePtr = ir::AstNode *; -void ConstantExpressionLowering::LogSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) const +void ConstantExpressionLowering::LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams, + const lexer::SourcePosition &pos) const { - context_->diagnosticEngine->LogSyntaxError(program_, errorMessage, pos); + context_->diagnosticEngine->LogDiagnostic(diagnostic, std::move(diagnosticParams), program_, pos); } static bool IsSupportedLiteralForNumeric(ir::Literal *const node) @@ -442,7 +444,7 @@ TargetType ConstantExpressionLowering::HandleArithmeticOperation(TargetType left } case lexer::TokenType::PUNCTUATOR_DIVIDE: { if (isForbiddenZeroDivision()) { - LogSyntaxError("Division by zero are not allowed in Enum or Annotation", expr->Start()); + LogError(diagnostic::DIVISION_BY_ZERO, {}, expr->Start()); return rightNum; } return leftNum / rightNum; @@ -452,7 +454,7 @@ TargetType ConstantExpressionLowering::HandleArithmeticOperation(TargetType left } case lexer::TokenType::PUNCTUATOR_MOD: { if (isForbiddenZeroDivision()) { - LogSyntaxError("Division by zero are not allowed in Enum or Annotation", expr->Start()); + LogError(diagnostic::DIVISION_BY_ZERO, {}, expr->Start()); return rightNum; } if constexpr (std::is_integral_v) { @@ -540,7 +542,7 @@ ir::AstNode *ConstantExpressionLowering::FoldBinaryNumericConstant(ir::BinaryExp ir::AstNode *ConstantExpressionLowering::FoldBinaryStringConstant(ir::BinaryExpression *const expr) { if (expr->OperatorType() != lexer::TokenType::PUNCTUATOR_PLUS) { - LogSyntaxError("Unsupported operator for String", expr->Left()->Start()); + LogError(diagnostic::UNSUPPORTED_OPERATOR_FOR_STRING, {}, expr->Left()->Start()); return expr; } @@ -805,35 +807,35 @@ ir::AstNode *ConstantExpressionLowering::FoldConstant(ir::AstNode *constantNode) if (tmpLiteral->Expressions().empty()) { return FoldMultilineString(tmpLiteral); } - LogSyntaxError("String Interpolation Expression is not constant expression", node->Start()); + LogError(diagnostic::STRING_INTERPOLATION_NOT_CONSTANT, {}, node->Start()); } if (node->IsTSAsExpression()) { auto tsAsExpr = node->AsTSAsExpression(); if (IsSupportedLiteral(tsAsExpr->Expr())) { return FoldTSAsExpression(tsAsExpr); } - LogSyntaxError("Only constant expression is expected in the field", node->Start()); + LogError(diagnostic::ONLY_CONSTANT_EXPRESSION, {}, node->Start()); } if (node->IsUnaryExpression()) { auto unaryOp = node->AsUnaryExpression(); if (IsSupportedLiteral(unaryOp->Argument())) { return FoldUnaryConstant(unaryOp); } - LogSyntaxError("Only constant expression is expected in the field", node->Start()); + LogError(diagnostic::ONLY_CONSTANT_EXPRESSION, {}, node->Start()); } if (node->IsBinaryExpression()) { auto binop = node->AsBinaryExpression(); if (IsSupportedLiteral(binop->Left()) && IsSupportedLiteral(binop->Right())) { return FoldBinaryConstant(binop); } - LogSyntaxError("Only constant expression is expected in the field", node->Start()); + LogError(diagnostic::ONLY_CONSTANT_EXPRESSION, {}, node->Start()); } if (node->IsConditionalExpression()) { auto condExp = node->AsConditionalExpression(); if (IsSupportedLiteral(condExp->Test())) { return FoldTernaryConstant(condExp); } - LogSyntaxError("Only constant expression is expected in the field", node->Start()); + LogError(diagnostic::ONLY_CONSTANT_EXPRESSION, {}, node->Start()); } return node; }; diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h index 269e7a877e..e313da19a7 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h @@ -39,7 +39,8 @@ public: bool PerformForModule(public_lib::Context *ctx, parser::Program *program) override; private: - void LogSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) const; + void LogError(const diagnostic::DiagnosticKind &diagnostic, const util::DiagnosticMessageParams &diagnosticParams, + const lexer::SourcePosition &pos) const; ir::AstNode *FoldTernaryConstant(ir::ConditionalExpression *cond); diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index 011cd103d1..396c8217a3 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -35,7 +35,9 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, parser::Pro } if (hasRestParameter) { - diagnosticEngine.LogSyntaxError(program, "Rest parameter should be the last one.", param->Start()); + util::DiagnosticMessageParams diagnosticParams = {}; + diagnosticEngine.LogDiagnostic(diagnostic::REST_PARAM_LAST, std::move(diagnosticParams), program, + param->Start()); } if (param->IsOptional()) { @@ -44,15 +46,16 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, parser::Pro } if (hasDefaultParameter) { - diagnosticEngine.LogSyntaxError(program, "Required parameter follows default parameter(s).", - param->Start()); + util::DiagnosticMessageParams diagnosticParams = {}; + diagnosticEngine.LogDiagnostic(diagnostic::REQUIRED_PARAM_AFTER_DEFAULT, std::move(diagnosticParams), + program, param->Start()); } } if (hasDefaultParameter && hasRestParameter) { - diagnosticEngine.LogSyntaxError( - program, "Both optional and rest parameters are not allowed in function's parameter list.", - function->Start()); + util::DiagnosticMessageParams diagnosticParams = {}; + diagnosticEngine.LogDiagnostic(diagnostic::REST_AND_DEFAULT_SAME_TIME, std::move(diagnosticParams), program, + function->Start()); } return hasDefaultParameter; diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index 8e4d5464c5..781c801cce 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -67,9 +67,11 @@ ir::MethodDefinition *MakeMethodDef(checker::ETSChecker *const checker, ir::Clas } // namespace -void EnumLoweringPhase::LogSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) const +void EnumLoweringPhase::LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams, + const lexer::SourcePosition &pos) { - context_->diagnosticEngine->LogSyntaxError(program_, errorMessage, pos); + context_->diagnosticEngine->LogDiagnostic(diagnostic, std::move(diagnosticParams), program_, pos); } template @@ -79,16 +81,16 @@ bool EnumLoweringPhase::CheckEnumMemberType(const ArenaVector &en auto *init = member->AsTSEnumMember()->Init(); if constexpr (std::is_same_v) { if (!init->IsNumberLiteral() || !init->AsNumberLiteral()->Number().IsInt()) { - LogSyntaxError("Invalid enum initialization value", init->Start()); + LogError(diagnostic::INVALID_ENUM_VALUE, {}, init->Start()); hasLoggedError = true; } } else if constexpr (std::is_same_v) { if (!init->IsStringLiteral()) { - LogSyntaxError("Invalid enum initialization value", init->Start()); + LogError(diagnostic::INVALID_ENUM_VALUE, {}, init->Start()); hasLoggedError = true; } if (member->AsTSEnumMember()->IsGenerated()) { - LogSyntaxError("All items of string-type enumeration should be explicitly initialized.", init->Start()); + LogError(diagnostic::ENUM_STRING_TYPE_ALL_ITEMS_INIT, {}, init->Start()); hasLoggedError = true; } } else { @@ -416,7 +418,7 @@ bool EnumLoweringPhase::PerformForModule(public_lib::Context *ctx, parser::Progr CheckEnumMemberType(enumDecl->Members(), hasLoggedError)) { CreateEnumStringClassFromEnumDeclaration(enumDecl, flags); } else if (!hasLoggedError) { - LogSyntaxError("Invalid enum initialization value", itemInit->Start()); + LogError(diagnostic::INVALID_ENUM_VALUE, {}, itemInit->Start()); isPerformedSuccess = false; } else { isPerformedSuccess = false; diff --git a/ets2panda/compiler/lowering/ets/enumLowering.h b/ets2panda/compiler/lowering/ets/enumLowering.h index 9d5ef2259f..7f94db9f8d 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.h +++ b/ets2panda/compiler/lowering/ets/enumLowering.h @@ -61,7 +61,8 @@ private: ir::ModifierFlags flags; }; - void LogSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) const; + void LogError(const diagnostic::DiagnosticKind &diagnostic, const util::DiagnosticMessageParams &diagnosticParams, + const lexer::SourcePosition &pos); template bool CheckEnumMemberType(const ArenaVector &enumMembers, bool &hasLoggedError); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp index b46a27d6cb..0a921d8193 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp @@ -69,14 +69,10 @@ GlobalClassHandler::ModuleDependencies ImportExportDecls::HandleGlobalStmts(Aren originNameIt != importedSpecifiersForExportCheck_.end() ? originNameIt->second : middleName; auto result = fieldMap_.find(originalName); if (result == fieldMap_.end() && !isType && originNameIt == importedSpecifiersForExportCheck_.end()) { - parser_->DiagnosticEngine().LogSyntaxError( - varbinder_->Program(), "Cannot find name '" + originalName.Mutf8() + "' to export", startLoc); + parser_->LogError(diagnostic::CAN_NOT_FIND_NAME_TO_EXPORT, {originalName.Mutf8()}, startLoc); } if (result != fieldMap_.end() && result->second->IsAnnotationDeclaration() && exportName != originalName) { - parser_->DiagnosticEngine().LogSyntaxError(varbinder_->Program(), - "Can not rename annotation '" + originalName.Mutf8() + - "' in export or import statements.", - startLoc); + parser_->LogError(diagnostic::CAN_NOT_RENAME_ANNOTATION, {originalName.Mutf8()}, startLoc); } if (!isType) { HandleSelectiveExportWithAlias(originalName, exportName, startLoc); @@ -90,10 +86,7 @@ void ImportExportDecls::PopulateAliasMap(const ir::ExportNamedDeclaration *decl, { for (auto spec : decl->Specifiers()) { if (!varbinder_->AddSelectiveExportAlias(path, spec->Local()->Name(), spec->Exported()->Name(), decl)) { - parser_->DiagnosticEngine().LogSyntaxError(varbinder_->Program(), - "The given name '" + spec->Local()->Name().Mutf8() + - "' is already used in another export", - lastExportErrorPos_); + parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {spec->Local()->Name().Mutf8()}, lastExportErrorPos_); lastExportErrorPos_ = lexer::SourcePosition(); } } @@ -105,9 +98,7 @@ void ImportExportDecls::AddExportFlags(ir::AstNode *node, util::StringView origi if ((node->Modifiers() & ir::ModifierFlags::EXPORTED) != 0) { // Note (oeotvos) Needs to be discussed, whether we would like to allow exporting the same program // element using its original name and also an alias, like: export {test_func, test_func as foo}. - parser_->DiagnosticEngine().LogSyntaxError( - varbinder_->Program(), "Cannot export '" + originalFieldName.Mutf8() + "', it was already exported", - startLoc); + parser_->LogError(diagnostic::ALREADY_EXPORTED, {originalFieldName.Mutf8()}, startLoc); } if (originalFieldName == exportDefaultName_) { node->AddModifier(ir::ModifierFlags::DEFAULT_EXPORT); @@ -122,10 +113,8 @@ void ImportExportDecls::PopulateAliasMap(const ir::TSTypeAliasDeclaration *decl, { if (!varbinder_->AddSelectiveExportAlias(path, decl->Id()->AsIdentifier()->Name(), decl->Id()->AsIdentifier()->Name(), decl)) { - parser_->DiagnosticEngine().LogSyntaxError(varbinder_->Program(), - "The given name '" + decl->Id()->AsIdentifier()->Name().Mutf8() + - "' is already used in another export", - lastExportErrorPos_); + parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {decl->Id()->AsIdentifier()->Name().Mutf8()}, + lastExportErrorPos_); lastExportErrorPos_ = lexer::SourcePosition(); } } @@ -163,9 +152,7 @@ void ImportExportDecls::HandleSelectiveExportWithAlias(util::StringView original ((declarator->Modifiers() & ir::ModifierFlags::EXPORTED) != 0) && !declarator->HasExportAlias(); } if (alreadyExported) { - parser_->DiagnosticEngine().LogSyntaxError( - varbinder_->Program(), - "The given name '" + exportName.Mutf8() + "' is already used in another export", startLoc); + parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {exportName.Mutf8()}, startLoc); } } } @@ -233,9 +220,7 @@ void ImportExportDecls::VisitExportNamedDeclaration(ir::ExportNamedDeclaration * } if (!exportNameMap_.emplace(local->Name(), local->Start()).second) { lastExportErrorPos_ = local->Start(); - parser_->DiagnosticEngine().LogSyntaxError( - varbinder_->Program(), - "The given name '" + local->Name().Mutf8() + "' is already used in another export", local->Start()); + parser_->LogError(diagnostic::DUPLICATE_EXPORT_NAME, {local->Name().Mutf8()}, lastExportErrorPos_); } } } @@ -256,7 +241,7 @@ void ImportExportDecls::VisitETSImportDeclaration(ir::ETSImportDeclaration *impo void ImportExportDecls::HandleSimpleType(std::set &exportedTypes, std::set &exportedStatements, ir::Statement *stmt, - util::StringView name, parser::Program *program, lexer::SourcePosition pos) + util::StringView name, lexer::SourcePosition pos) { if (stmt->IsExported()) { exportedStatements.insert(name); @@ -267,13 +252,11 @@ void ImportExportDecls::HandleSimpleType(std::set &exportedTyp } if (exportedStatements.find(name) != exportedStatements.end()) { - parser_->DiagnosticEngine().LogSyntaxError( - program, "Name '" + name.Mutf8() + "' cannot be exported and type exported at the same time.", pos); + parser_->LogError(diagnostic::NAME_CANNOT_BE_EXPORTED_AND_TYPE_EXPORTED, {name.Mutf8()}, pos); } if (exportedTypes.find(name) != exportedTypes.end()) { - parser_->DiagnosticEngine().LogSyntaxError(program, "Cannot export the same '" + name.Mutf8() + "' type twice.", - pos); + parser_->LogError(diagnostic::CANNOT_EXPORT_SAME_TYPE_TWICE, {name.Mutf8()}, pos); } else { exportedTypes.insert(name); } @@ -287,32 +270,31 @@ void ImportExportDecls::VerifyTypeExports(const ArenaVector & for (const auto &program : programs) { for (auto stmt : program->Ast()->Statements()) { - VerifyType(stmt, program, exportedTypes, exportedStatements, typesMap); + VerifyType(stmt, exportedTypes, exportedStatements, typesMap); } } } -void ImportExportDecls::VerifyType(ir::Statement *stmt, parser::Program *program, - std::set &exportedTypes, +void ImportExportDecls::VerifyType(ir::Statement *stmt, std::set &exportedTypes, std::set &exportedStatements, std::map &typesMap) { if (stmt->IsClassDeclaration()) { typesMap.insert({stmt->AsClassDeclaration()->Definition()->Ident()->Name(), stmt}); return HandleSimpleType(exportedTypes, exportedStatements, stmt, - stmt->AsClassDeclaration()->Definition()->Ident()->Name(), program, stmt->Start()); + stmt->AsClassDeclaration()->Definition()->Ident()->Name(), stmt->Start()); } if (stmt->IsTSInterfaceDeclaration()) { typesMap.insert({stmt->AsTSInterfaceDeclaration()->Id()->Name(), stmt}); return HandleSimpleType(exportedTypes, exportedStatements, stmt, stmt->AsTSInterfaceDeclaration()->Id()->Name(), - program, stmt->Start()); + stmt->Start()); } if (stmt->IsTSTypeAliasDeclaration()) { typesMap.insert({stmt->AsTSTypeAliasDeclaration()->Id()->Name(), stmt}); return HandleSimpleType(exportedTypes, exportedStatements, stmt, stmt->AsTSTypeAliasDeclaration()->Id()->Name(), - program, stmt->Start()); + stmt->Start()); } if (!stmt->IsExportedType()) { @@ -320,7 +302,7 @@ void ImportExportDecls::VerifyType(ir::Statement *stmt, parser::Program *program } if (!stmt->IsExportNamedDeclaration()) { - parser_->DiagnosticEngine().LogSyntaxError(program, "Can only type export class or interface!", stmt->Start()); + parser_->LogError(diagnostic::ONLY_EXPORT_CLASS_OR_INTERFACE, {}, stmt->Start()); return; } @@ -330,17 +312,16 @@ void ImportExportDecls::VerifyType(ir::Statement *stmt, parser::Program *program auto element = typesMap.find(nameFind); if (element == typesMap.end()) { - parser_->DiagnosticEngine().LogSyntaxError(program, "Can only type export class or interface!", - spec->Local()->Start()); + parser_->LogError(diagnostic::ONLY_EXPORT_CLASS_OR_INTERFACE, {}, spec->Local()->Start()); continue; } if (!element->second->IsExportedType()) { element->second->AddModifier(ir::ModifierFlags::EXPORT_TYPE); } - HandleSimpleType(exportedTypes, exportedStatements, stmt, name, program, spec->Local()->Start()); + HandleSimpleType(exportedTypes, exportedStatements, stmt, name, spec->Local()->Start()); if (!name.Is(nameFind.Mutf8())) { element->second->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); - HandleSimpleType(exportedTypes, exportedStatements, stmt, nameFind, program, spec->Local()->Start()); + HandleSimpleType(exportedTypes, exportedStatements, stmt, nameFind, spec->Local()->Start()); } } } diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h index 48091543fa..5e078e6df4 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h @@ -58,12 +58,11 @@ public: void ProcessProgramStatements(parser::Program *program, const ArenaVector &statements, GlobalClassHandler::ModuleDependencies &moduleDependencies); void VerifyTypeExports(const ArenaVector &programs); - void VerifyType(ir::Statement *stmt, parser::Program *program, std::set &exportedTypes, + void VerifyType(ir::Statement *stmt, std::set &exportedTypes, std::set &exportedStatements, std::map &typesMap); void HandleSimpleType(std::set &exportedTypes, std::set &exportedStatements, - ir::Statement *stmt, util::StringView name, parser::Program *program, - lexer::SourcePosition pos); + ir::Statement *stmt, util::StringView name, lexer::SourcePosition pos); void VerifySingleExportDefault(const ArenaVector &programs); void AddExportFlags(ir::AstNode *node, util::StringView originalFieldName, lexer::SourcePosition startLoc, diff --git a/ets2panda/lexer/ETSLexer.cpp b/ets2panda/lexer/ETSLexer.cpp index e2719cb3fb..931e233a9b 100644 --- a/ets2panda/lexer/ETSLexer.cpp +++ b/ets2panda/lexer/ETSLexer.cpp @@ -47,7 +47,7 @@ bool ETSLexer::ScanCharLiteral() switch (cp) { case LEX_CHAR_SINGLE_QUOTE: case util::StringView::Iterator::INVALID_CP: { - LogSyntaxError("Invalid character literal"); + LogError(diagnostic::INVALID_CHAR); status = false; break; } @@ -69,7 +69,7 @@ bool ETSLexer::ScanCharLiteral() } if (Iterator().Peek() != LEX_CHAR_SINGLE_QUOTE) { - LogSyntaxError("Unterminated character literal"); + LogError(diagnostic::UNSUPPORTED_CHAR_LIT); return false; } @@ -85,7 +85,7 @@ void ETSLexer::CheckNumberLiteralEnd() Iterator().Forward(1); const auto nextCp = Iterator().PeekCp(); if (KeywordsUtil::IsIdentifierStart(nextCp) || IsDecimalDigit(nextCp)) { - LogSyntaxError("Invalid numeric literal"); + LogError(diagnostic::INVALID_NUMERIC_LIT); Iterator().Forward(1); // Error processing } } else { @@ -97,7 +97,7 @@ bool ETSLexer::CheckUtf16Compatible(char32_t cp) const { if (cp >= util::StringView::Constants::CELESTIAL_OFFSET) { // lexer_invalid_characters.sts - LogSyntaxError("Unsupported character literal"); + LogError(diagnostic::UNSUPPORTED_CHAR_LIT); return false; } return true; @@ -123,7 +123,7 @@ void ETSLexer::ConvertNumber(NumberFlags const flags) { GetToken().number_ = lexer::Number(GetToken().src_, flags); if (GetToken().number_.ConversionError()) { - LogSyntaxError("Invalid number"); + LogError(diagnostic::INVALID_NUM); } } diff --git a/ets2panda/lexer/ETSLexer.h b/ets2panda/lexer/ETSLexer.h index a4a40d6a17..7f55bd66ac 100644 --- a/ets2panda/lexer/ETSLexer.h +++ b/ets2panda/lexer/ETSLexer.h @@ -51,13 +51,13 @@ public: if (!ScanNumberLeadingZeroImpl(leadingMinus)) { Rewind(savedLexerPosition); if (!ScanNumberLeadingZeroImpl(leadingMinus)) { - LogSyntaxError("Number is too large"); + LogError(diagnostic::TOO_LARGE_NUM); } } if ((GetToken().flags_ & TokenFlags::NUMBER_BIGINT) != 0) { if (!allowBigint) { - LogSyntaxError("Invalid BigInt number"); + LogError(diagnostic::INVALID_BIGINT); } } } diff --git a/ets2panda/lexer/keywordsUtil.cpp b/ets2panda/lexer/keywordsUtil.cpp index 3eaa7fe05f..f3bdff0a97 100644 --- a/ets2panda/lexer/keywordsUtil.cpp +++ b/ets2panda/lexer/keywordsUtil.cpp @@ -195,7 +195,7 @@ bool KeywordsUtil::IsIdentifierPart(char32_t cp) void KeywordsUtil::ScanIdentifierStart(const Keywords *kws, char32_t cp) { if (!KeywordsUtil::IsIdentifierStart(cp)) { - lexer_->LogSyntaxError("Expected an identifier"); + lexer_->LogError(diagnostic::UNEXPECTED_TOKEN_ID); } cp_ = cp; @@ -221,7 +221,7 @@ void KeywordsUtil::ScanIdContinue() auto cp = ScanUnicodeEscapeSequence(); if (!IsIdentifierPart(cp)) { - lexer_->LogSyntaxError("Invalid identifier part"); + lexer_->LogError(diagnostic::INVALID_IDENTIFIER_PART); } escapeEnd = Iterator().Index(); diff --git a/ets2panda/lexer/keywordsUtil.h b/ets2panda/lexer/keywordsUtil.h index fd61b9e3c8..333168992f 100644 --- a/ets2panda/lexer/keywordsUtil.h +++ b/ets2panda/lexer/keywordsUtil.h @@ -49,9 +49,10 @@ public: return lexer_->parserContext_; } - void LogSyntaxError(std::string_view msg) const + void LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams = {}) const { - lexer_->LogSyntaxError(msg); + lexer_->LogError(diagnostic, diagnosticParams); } void LogUnexpectedStrictModeReservedKeyword() const @@ -78,7 +79,7 @@ public: inline void LogEscapedKeyword() const { - LogSyntaxError("Escape sequences are not allowed in keywords"); + LogError(diagnostic::ESCAPE_SEQUENCES_IN_KEYWORD); } inline void SetKeyword(KeywordString kws) const diff --git a/ets2panda/lexer/lexer.cpp b/ets2panda/lexer/lexer.cpp index d6f08ab2e2..1d9ea41808 100644 --- a/ets2panda/lexer/lexer.cpp +++ b/ets2panda/lexer/lexer.cpp @@ -57,7 +57,7 @@ char32_t Lexer::ScanUnicodeCodePointEscape() char32_t code = 0; char32_t cp = Iterator().Peek(); if (!IsHexDigit(cp)) { - LogSyntaxError("Hexadecimal digit expected."); + LogError(diagnostic::HEXADECIMAL_EXPECTED); code = UNICODE_INVALID_CP; } @@ -67,7 +67,7 @@ char32_t Lexer::ScanUnicodeCodePointEscape() constexpr auto MULTIPLIER = 16; code = code * MULTIPLIER + HexValue(cp); if (code > UNICODE_CODE_POINT_MAX) { - LogSyntaxError("Invalid unicode escape sequence"); + LogError(diagnostic::INVALID_UNICODE_ESCAPE); code = UNICODE_INVALID_CP; break; } @@ -79,7 +79,7 @@ char32_t Lexer::ScanUnicodeCodePointEscape() } if (cp != LEX_CHAR_RIGHT_BRACE) { - LogSyntaxError("Invalid unicode escape sequence"); + LogError(diagnostic::INVALID_UNICODE_ESCAPE); code = UNICODE_INVALID_CP; } @@ -156,7 +156,7 @@ void Lexer::SkipMultiLineComment() while (true) { switch (Iterator().Next()) { case util::StringView::Iterator::INVALID_CP: { - LogSyntaxError("Unterminated multi-line comment"); + LogError(diagnostic::UNTERMINATED_MULTI_LINE_COMMENT); return; } case LEX_CHAR_CR: { @@ -212,16 +212,23 @@ void Lexer::SkipSingleLineComment() } } -void Lexer::LogSyntaxError(std::string_view const errorMessage) const +void Lexer::LogUnexpectedToken(lexer::TokenType const tokenType) const { - diagnosticEngine_.LogSyntaxError(parserContext_->GetProgram(), errorMessage, - SourcePosition(Iterator().Index(), pos_.line_)); + LogError(diagnostic::UNEXPECTED_TOKEN_PARAM, {TokenToString(tokenType)}); } -void Lexer::LogUnexpectedToken(lexer::TokenType const tokenType) const +void Lexer::LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams, const lexer::SourcePosition &pos) const +{ + auto loc = pos.ToLocation(parserContext_->GetProgram()); + diagnosticEngine_.LogDiagnostic(diagnostic, std::move(diagnosticParams), + parserContext_->GetProgram()->SourceFilePath().Utf8(), loc.line, loc.col); +} + +void Lexer::LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams) const { - auto const str = std::string {parser::UNEXPECTED_TOKEN}.append(TokenToString(tokenType)).append("'."); - LogSyntaxError(str); + LogError(diagnostic, std::move(diagnosticParams), GetToken().Start()); } void Lexer::CheckNumberLiteralEnd() @@ -236,7 +243,7 @@ void Lexer::CheckNumberLiteralEnd() const auto nextCp = Iterator().PeekCp(); if (IsDecimalDigit(nextCp)) { - LogSyntaxError("Invalid numeric literal"); + LogError(diagnostic::INVALID_NUMERIC_LIT); return; } CheckNumberLiteralEndForIdentifier(); @@ -247,7 +254,7 @@ void Lexer::CheckNumberLiteralEndForIdentifier() // This check is needed only in Ecmascript const auto nextCp = Iterator().PeekCp(); if (KeywordsUtil::IsIdentifierStart(nextCp)) { - LogSyntaxError("Invalid numeric literal"); + LogError(diagnostic::INVALID_NUMERIC_LIT); } } @@ -276,7 +283,7 @@ void Lexer::ScanDecimalNumbers() if (Iterator().Peek() == LEX_CHAR_DOT || !allowNumericOnNext) { Iterator().Forward(1); - LogSyntaxError("Invalid numeric separator"); + LogError(diagnostic::INVALID_NUMERIC_SEP); } GetToken().flags_ |= TokenFlags::NUMBER_HAS_UNDERSCORE; @@ -286,7 +293,7 @@ void Lexer::ScanDecimalNumbers() } default: { if (!allowNumericOnNext) { - LogSyntaxError("Numeric separators are not allowed at the end of numeric literals"); + LogError(diagnostic::INVALID_NUMERIC_SEP_AT_END_OF_NUM); } return; } @@ -301,7 +308,7 @@ void Lexer::ConvertNumber([[maybe_unused]] NumberFlags flags) if (res == ConversionResult::SUCCESS) { GetToken().number_ = Number(GetToken().src_, static_cast(temp)); } else if (res == ConversionResult::INVALID_ARGUMENT) { - LogSyntaxError("Invalid number"); + LogError(diagnostic::INVALID_NUM); } else if (res == ConversionResult::OUT_OF_RANGE) { GetToken().number_ = Number(GetToken().src_, std::numeric_limits::infinity()); } @@ -341,7 +348,7 @@ void Lexer::ScanNumber(bool const leadingMinus, bool allowBigInt) if ((GetToken().flags_ & TokenFlags::NUMBER_BIGINT) != 0) { if (!allowBigInt) { - LogSyntaxError("Invalid BigInt number"); + LogError(diagnostic::INVALID_BIGINT); } return; @@ -381,7 +388,7 @@ std::optional Lexer::ScanCharLex(bool const parseExponent, bool &al rc = ScanSignOfNumber(); if (!IsDecimalDigit(Iterator().Peek())) { - LogSyntaxError("Invalid numeric literal"); + LogError(diagnostic::INVALID_NUMERIC_LIT); } ScanDecimalNumbers(); } @@ -420,7 +427,7 @@ void Lexer::ScanTemplateStringEnd() SetTokenEnd(); SkipWhiteSpaces(); } else { - LogSyntaxError("Unexpected token, expected '`'"); + LogError(diagnostic::UNEXPECTED_TOKEN_EXPECTED_PARAM, {TokenToString(TokenType::PUNCTUATOR_BACK_TICK)}); } } @@ -430,7 +437,7 @@ bool Lexer::CheckOctalDigit(char32_t const nextCp) Iterator().Forward(1); if (Iterator().Peek() != LEX_CHAR_BACK_TICK) { - LogSyntaxError("Octal escape sequences are not allowed in template strings"); + LogError(diagnostic::OCTAL_ESCAPE_IN_TEMPLATE_STRINGS); return false; } @@ -444,7 +451,7 @@ std::tuple Lexer::ScanTemplateStringCpHelper(ch { switch (cp) { case util::StringView::Iterator::INVALID_CP: - LogSyntaxError("Unexpected token, expected '${' or '`'"); + LogError(diagnostic::UNEXPECTED_TOKEN_EXPECTED_BACKTICK_OR_DOLLAR_LBRACE); return {true, false, templateStr}; case LEX_CHAR_BACK_TICK: templateStr.end = Iterator().Index(); @@ -534,7 +541,7 @@ util::StringView Lexer::ScanMultilineString() char32_t cp = Iterator().PeekCp(&cpSize); switch (cp) { case util::StringView::Iterator::INVALID_CP: - LogSyntaxError("Unexpected token, expected '`'"); + LogError(diagnostic::UNEXPECTED_TOKEN_EXPECTED_PARAM, {TokenToString(TokenType::PUNCTUATOR_BACK_TICK)}); [[fallthrough]]; case LEX_CHAR_BACK_TICK: isreturn = true; @@ -612,7 +619,7 @@ char32_t Lexer::ScanUnicodeCharacter() switch (cp) { case util::StringView::Iterator::INVALID_CP: - LogSyntaxError("Unterminated string"); + LogError(diagnostic::UNTERMINATED_STRING); break; case LEX_CHAR_CR: Iterator().Forward(1); @@ -656,7 +663,7 @@ char32_t Lexer::ScanUnicodeCharacter() } default: if (IsDecimalDigit(Iterator().Peek())) { - LogSyntaxError("Invalid character escape sequence"); + LogError(diagnostic::INVALID_CHAR_ESCAPE); cp = UNICODE_INVALID_CP; } break; @@ -1082,7 +1089,7 @@ bool Lexer::ScanRegExpPattern() case LEX_CHAR_CR: case LEX_CHAR_LS: case LEX_CHAR_PS: { - LogSyntaxError("Unterminated RegExp"); + LogError(diagnostic::UNTERMINATED_REGEX); return false; } case LEX_CHAR_SLASH: { @@ -1164,13 +1171,13 @@ RegExpFlags Lexer::ScanRegExpFlags() return resultFlags; } default: { - LogSyntaxError("Invalid RegExp flag"); + LogError(diagnostic::INVALID_REGEX_FLAG); return resultFlags; } } if (flag == RegExpFlags::EMPTY || (resultFlags & flag) != 0) { - LogSyntaxError("Invalid RegExp flag"); + LogError(diagnostic::INVALID_REGEX_FLAG); } resultFlags = resultFlags | flag; @@ -1184,7 +1191,7 @@ void Lexer::CheckOctal() switch (Iterator().Peek()) { case LEX_CHAR_8: case LEX_CHAR_9: { - LogSyntaxError("Invalid octal digit"); + LogError(diagnostic::INVALID_OCTAL_DIGIT); break; } default: { @@ -1512,7 +1519,7 @@ void Lexer::NextToken(Keywords *kws) GetToken().flags_ |= TokenFlags::HAS_ESCAPE; if (Iterator().Peek() != LEX_CHAR_LOWERCASE_U) { - LogSyntaxError("Invalid character"); + LogError(diagnostic::INVALID_CHAR); break; } @@ -1621,16 +1628,16 @@ void Lexer::ScanNumberLeadingZeroImplNonAllowedCases() case LEX_CHAR_5: case LEX_CHAR_6: case LEX_CHAR_7: { - LogSyntaxError("Implicit octal literal not allowed"); + LogError(diagnostic::IMPLICIT_OCTAL_NOT_ALLOWED); break; } case LEX_CHAR_8: case LEX_CHAR_9: { - LogSyntaxError("NonOctalDecimalIntegerLiteral is not enabled in strict mode code"); + LogError(diagnostic::NON_OCTAL_DECIAML_INTEGER_LIT_IN_STRICT_MODE); break; } case LEX_CHAR_UNDERSCORE: { - LogSyntaxError("Numeric separator '_' is not allowed in numbers that start with '0'."); + LogError(diagnostic::NUMERIC_SEP_UNDERSCORE_IN_NUMBER); break; } default: { diff --git a/ets2panda/lexer/lexer.h b/ets2panda/lexer/lexer.h index 6dff8d576c..737ca59716 100644 --- a/ets2panda/lexer/lexer.h +++ b/ets2panda/lexer/lexer.h @@ -184,7 +184,7 @@ public: void PushTemplateContext(TemplateLiteralParserContext *ctx); void LogUnexpectedStrictModeReservedKeyword() const { - LogSyntaxError("Unexpected strict mode reserved keyword"); + LogError(diagnostic::UNEXPECTED_STRICT_MODE_RESERVED_KEYWORD); } enum class ConversionResult : uint8_t { @@ -251,10 +251,13 @@ protected: bool ScanRegExpPattern(); RegExpFlags ScanRegExpFlags(); - void LogSyntaxError(std::string_view const errorMessage) const; - void LogSyntaxError(std::string_view const errorMessage, const lexer::SourcePosition &pos) const; void LogUnexpectedToken(lexer::TokenType const tokenType) const; + void LogError(const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams = {}) const; + void LogError(const diagnostic::DiagnosticKind &diagnostic, const util::DiagnosticMessageParams &diagnosticParams, + const lexer::SourcePosition &pos) const; + void SetTokenStart(); void SetTokenEnd(); @@ -399,13 +402,13 @@ void Lexer::ScanString() const char32_t cp = Iterator().Peek(); switch (cp) { case util::StringView::Iterator::INVALID_CP: { - LogSyntaxError("Unterminated string"); + LogError(diagnostic::UNTERMINATED_STRING); break; } case LEX_CHAR_CR: case LEX_CHAR_LF: { if constexpr (END != LEX_CHAR_BACK_TICK) { - LogSyntaxError("Newline is not allowed in strings"); + LogError(diagnostic::NEWLINE_NOT_ALLOWED_IN_STRING); break; } HandleNewlineHelper(&str, &escapeEnd); @@ -459,7 +462,7 @@ char32_t Lexer::ScanHexEscape() Iterator().Forward(1); if (!IsHexDigit(cp)) { - LogSyntaxError("Invalid unicode escape sequence"); + LogError(diagnostic::INVALID_UNICODE_ESCAPE); return UNICODE_INVALID_CP; } @@ -538,7 +541,7 @@ bool Lexer::ScanNumberRadix(bool leadingMinus, bool allowNumericSeparator) auto cp = Iterator().Peek(); if (!RANGE_CHECK(cp)) { - LogSyntaxError("Invalid digit"); + LogError(diagnostic::INVALID_DIGIT); } bool allowNumericOnNext = true; @@ -559,7 +562,7 @@ bool Lexer::ScanNumberRadix(bool leadingMinus, bool allowNumericSeparator) if (cp == LEX_CHAR_UNDERSCORE) { if (!allowNumericSeparator || !allowNumericOnNext) { - LogSyntaxError("Invalid numeric separator"); + LogError(diagnostic::INVALID_NUMERIC_SEP); } GetToken().flags_ |= TokenFlags::NUMBER_HAS_UNDERSCORE; @@ -570,7 +573,7 @@ bool Lexer::ScanNumberRadix(bool leadingMinus, bool allowNumericSeparator) if (!allowNumericOnNext) { Iterator().Backward(1); - LogSyntaxError("Numeric separators are not allowed at the end of numeric literals"); + LogError(diagnostic::INVALID_NUMERIC_SEP_AT_END_OF_NUM); } break; diff --git a/ets2panda/parser/ETSNolintParser.cpp b/ets2panda/parser/ETSNolintParser.cpp index efd187eb2c..e3450cd0ed 100644 --- a/ets2panda/parser/ETSNolintParser.cpp +++ b/ets2panda/parser/ETSNolintParser.cpp @@ -228,13 +228,18 @@ std::set ETSNolintParser::ParseETSNolintArgs() cp = PeekSymbol(); if (cp != lexer::LEX_CHAR_MINUS && cp != lexer::LEX_CHAR_COMMA && cp != lexer::LEX_CHAR_RIGHT_PAREN && (cp < lexer::LEX_CHAR_LOWERCASE_A || cp > lexer::LEX_CHAR_LOWERCASE_Z)) { - parser_->DiagnosticEngine().LogSyntaxError( - parser_->GetProgram(), "Unexpected character for ETSNOLINT argument! [VALID ONLY: a-z, '-'].", - lexer::SourceLocation {line_ + 1, 0}); + auto loc = lexer::SourceLocation {line_ + 1, 0}; + util::DiagnosticMessageParams diagnosticParams = {}; + parser_->DiagnosticEngine().LogDiagnostic( + diagnostic::UNEXPECTED_CHAR_ETSNOLINT, std::move(diagnosticParams), + parser_->GetProgram()->SourceFilePath().Utf8(), loc.line, loc.col); } if ((cp == lexer::LEX_CHAR_COMMA || cp == lexer::LEX_CHAR_RIGHT_PAREN) && !ValidETSNolintArg(warningName)) { - parser_->DiagnosticEngine().LogSyntaxError(parser_->GetProgram(), "Invalid argument for ETSNOLINT!", - lexer::SourceLocation {line_ + 1, 0}); + auto loc = lexer::SourceLocation {line_ + 1, 0}; + util::DiagnosticMessageParams diagnosticParams = {}; + parser_->DiagnosticEngine().LogDiagnostic( + diagnostic::INVALID_ARGUMENT_ETSNOLINT, std::move(diagnosticParams), + parser_->GetProgram()->SourceFilePath().Utf8(), loc.line, loc.col); } if ((cp == lexer::LEX_CHAR_COMMA || cp == lexer::LEX_CHAR_RIGHT_PAREN) && ValidETSNolintArg(warningName)) { warningsCollection.insert(MapETSNolintArg(warningName)); diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 0e7f067ca1..7f5bad7c79 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -979,7 +979,7 @@ ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::Modifi return ParseSingleExport(modifiers); } if ((modifiers & ir::ModifierFlags::DEFAULT_EXPORT) != 0) { - LogSyntaxError("Cannot use 'export default' in re-export context"); + LogError(diagnostic::EXPORT_DEFAULT_IN_REEXPORT); } // re-export directive ir::ImportSource *reExportSource = ParseSourceFromClause(true); diff --git a/ets2panda/parser/ThrowingTypedParser.cpp b/ets2panda/parser/ThrowingTypedParser.cpp index ee962297bd..9cc639f14a 100644 --- a/ets2panda/parser/ThrowingTypedParser.cpp +++ b/ets2panda/parser/ThrowingTypedParser.cpp @@ -18,6 +18,8 @@ namespace ark::es2panda::parser { +inline constexpr char const UNEXPECTED_TOKEN[] = "Unexpected token '"; + void ThrowingTypedParser::ThrowUnexpectedToken(lexer::TokenType tokenType) const { ThrowSyntaxError({UNEXPECTED_TOKEN, lexer::TokenToString(tokenType), "'."}); diff --git a/ets2panda/parser/parserImpl.cpp b/ets2panda/parser/parserImpl.cpp index b5755a6692..f34af0208d 100644 --- a/ets2panda/parser/parserImpl.cpp +++ b/ets2panda/parser/parserImpl.cpp @@ -258,7 +258,7 @@ void ParserImpl::ParseClassAccessor(ClassElementDescriptor *desc, char32_t *next return; } - LogIfPrivateIdent(desc, "Unexpected identifier"); + LogIfPrivateIdent(desc, diagnostic::UNEXPECTED_ID); if ((lexer_->GetToken().Flags() & lexer::TokenFlags::HAS_ESCAPE) != 0) { LogError(diagnostic::KEYWORD_CONTAINS_ESCAPED_CHARS); @@ -272,10 +272,11 @@ void ParserImpl::ParseClassAccessor(ClassElementDescriptor *desc, char32_t *next ConsumeClassPrivateIdentifier(desc, nextCp); } -void ParserImpl::LogIfPrivateIdent(ClassElementDescriptor *desc, const char *msg) +void ParserImpl::LogIfPrivateIdent(ClassElementDescriptor *desc, const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams) { if (desc->isPrivateIdent) { - LogSyntaxError(msg); + LogError(diagnostic, diagnosticParams); } } @@ -296,7 +297,7 @@ void ParserImpl::ValidateClassKey(ClassElementDescriptor *desc) LogError(diagnostic::CLASS_FIELD_CONSTRUCTOR); } - LogIfPrivateIdent(desc, "Private identifier can not be constructor"); + LogIfPrivateIdent(desc, diagnostic::PRIVATE_IDENTIFIER_NOT_CONSTRUCTOR); if ((desc->modifiers & ir::ModifierFlags::STATIC) == 0) { if ((desc->modifiers & ir::ModifierFlags::ASYNC) != 0 || @@ -351,14 +352,14 @@ ir::Expression *ParserImpl::ParseClassKey(ClassElementDescriptor *desc) break; } case lexer::TokenType::LITERAL_STRING: { - LogIfPrivateIdent(desc, "Private identifier name can not be string"); + LogIfPrivateIdent(desc, diagnostic::PRIVATE_IDENTIFIER_STRING); if (lexer_->GetToken().Ident().Is("constructor")) { LogError(diagnostic::CLASS_FIELD_CONSTRUCTOR); } if (lexer_->GetToken().Ident().Is("prototype") && (desc->modifiers & ir::ModifierFlags::STATIC) != 0) { - LogError(diagnostic::STATIC_PROPERTY_PROTOTYPE_REMOOOVE); + LogError(diagnostic::STATIC_PROPERTY_PROTOTYPE); } propName = AllocNode(lexer_->GetToken().String()); @@ -366,7 +367,7 @@ ir::Expression *ParserImpl::ParseClassKey(ClassElementDescriptor *desc) break; } case lexer::TokenType::LITERAL_NUMBER: { - LogIfPrivateIdent(desc, "Private identifier name can not be number"); + LogIfPrivateIdent(desc, diagnostic::PRIVATE_IDENTIFIER_NUMBER); if ((lexer_->GetToken().Flags() & lexer::TokenFlags::NUMBER_BIGINT) != 0) { propName = AllocNode(lexer_->GetToken().BigInt()); @@ -378,7 +379,7 @@ ir::Expression *ParserImpl::ParseClassKey(ClassElementDescriptor *desc) break; } case lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET: { - LogIfPrivateIdent(desc, "Unexpected character in private identifier"); + LogIfPrivateIdent(desc, diagnostic::UNEXPECTED_CHAR_PRIVATE_IDENTIFIER); std::tie(desc->isComputed, desc->invalidComputedProperty, desc->isIndexSignature) = ParseComputedClassFieldOrIndexSignature(&propName); break; @@ -1304,21 +1305,6 @@ void ParserImpl::LogSyntaxError(std::string_view errorMessage, const lexer::Sour diagnosticEngine_.LogSyntaxError(program_, errorMessage, pos); } -void ParserImpl::LogSyntaxError(std::string_view const errorMessage) -{ - diagnosticEngine_.LogSyntaxError(program_, errorMessage, lexer_->GetToken().Start()); -} - -void ParserImpl::LogSyntaxError(const util::DiagnosticMessageParams &list) -{ - diagnosticEngine_.LogSyntaxError(program_, list, lexer_->GetToken().Start()); -} - -void ParserImpl::LogSyntaxError(const util::DiagnosticMessageParams &list, const lexer::SourcePosition &pos) -{ - diagnosticEngine_.LogSyntaxError(program_, list, pos); -} - void ParserImpl::LogError(const diagnostic::DiagnosticKind &diagnostic, const util::DiagnosticMessageParams &diagnosticParams, const lexer::SourcePosition &pos) { diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index c9f4563533..6cf9403940 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -62,9 +62,6 @@ enum class TypeAnnotationParsingOptions : uint32_t { ANNOTATION_NOT_ALLOW = 1U << 17U }; -// NOLINTNEXTLINE(modernize-avoid-c-arrays) -inline constexpr char const UNEXPECTED_TOKEN[] = "Unexpected token '"; - class ParserImpl { public: explicit ParserImpl(Program *program, const util::Options *options, util::DiagnosticEngine &diagnosticEngine, @@ -111,7 +108,8 @@ protected: static ExpressionParseFlags CarryExpressionParserFlag(ExpressionParseFlags origin, ExpressionParseFlags carry); static ExpressionParseFlags CarryPatternFlags(ExpressionParseFlags flags); - void LogIfPrivateIdent(ClassElementDescriptor *desc, const char *msg); + void LogIfPrivateIdent(ClassElementDescriptor *desc, const diagnostic::DiagnosticKind &diagnostic, + const util::DiagnosticMessageParams &diagnosticParams = {}); void ValidateClassKey(ClassElementDescriptor *desc); bool ValidatePrivateIdentifier(); @@ -192,10 +190,7 @@ public: const util::DiagnosticMessageParams &diagnosticParams = {}); void LogError(const diagnostic::DiagnosticKind &diagnostic, const util::DiagnosticMessageParams &diagnosticParams, const lexer::SourcePosition &pos); - void LogSyntaxError(std::string_view errorMessage); - void LogSyntaxError(const util::DiagnosticMessageParams &list); void LogSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos); - void LogSyntaxError(const util::DiagnosticMessageParams &list, const lexer::SourcePosition &pos); protected: void LogParameterModifierError(ir::ModifierFlags status); diff --git a/ets2panda/test/ast/compiler/ets/constant_variable_import_tests/enum_import_constant.sts b/ets2panda/test/ast/compiler/ets/constant_variable_import_tests/enum_import_constant.sts index ea8c3e6fc0..d2ad230843 100644 --- a/ets2panda/test/ast/compiler/ets/constant_variable_import_tests/enum_import_constant.sts +++ b/ets2panda/test/ast/compiler/ets/constant_variable_import_tests/enum_import_constant.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,4 +20,4 @@ enum Color { C = /* @@ label */constVar } -/* @@@ label Error SyntaxError: Invalid enum initialization value */ \ No newline at end of file +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/default_export/export_default_bad2.sts b/ets2panda/test/ast/compiler/ets/default_export/export_default_bad2.sts index 40f32e7f6a..c478b6a1d6 100644 --- a/ets2panda/test/ast/compiler/ets/default_export/export_default_bad2.sts +++ b/ets2panda/test/ast/compiler/ets/default_export/export_default_bad2.sts @@ -15,4 +15,4 @@ export default * from './export_default1' -/* @@? 16:18 Error SyntaxError: Cannot use 'export default' in re-export context */ +/* @@? 16:18 Error SyntaxError: Cannot use 'export default' in re-export context. */ diff --git a/ets2panda/test/ast/compiler/ets/enum_not_constant_var.sts b/ets2panda/test/ast/compiler/ets/enum_not_constant_var.sts index be0b7d0362..85e363612b 100644 --- a/ets2panda/test/ast/compiler/ets/enum_not_constant_var.sts +++ b/ets2panda/test/ast/compiler/ets/enum_not_constant_var.sts @@ -20,5 +20,5 @@ enum Color { Red = /* @@ label */b, } -/* @@@ label Error SyntaxError: Only constant expression is expected in the field */ -/* @@@ label Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: Only constant expression is expected in the field. */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_enum.sts b/ets2panda/test/ast/compiler/ets/export_type_enum.sts index c5ee4cc9f3..2c8cef647f 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_enum.sts +++ b/ets2panda/test/ast/compiler/ets/export_type_enum.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,4 +17,4 @@ enum E { A = 5, B = 5 } export type {/* @@ label */E} -/* @@@ label Error SyntaxError: Can only type export class or interface! */ +/* @@@ label Error SyntaxError: Can only type export class or interface. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_function.sts b/ets2panda/test/ast/compiler/ets/export_type_function.sts index 29f781ed7b..08b0bf57bd 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_function.sts +++ b/ets2panda/test/ast/compiler/ets/export_type_function.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function f(){ export type {/* @@ label */f} -/* @@@ label Error SyntaxError: Can only type export class or interface! */ +/* @@@ label Error SyntaxError: Can only type export class or interface. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_variable.sts b/ets2panda/test/ast/compiler/ets/export_type_variable.sts index b58f9b11b1..118db2c2b4 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_variable.sts +++ b/ets2panda/test/ast/compiler/ets/export_type_variable.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,4 +17,4 @@ let a = 5; export type {/* @@ label */a} -/* @@@ label Error SyntaxError: Can only type export class or interface! */ +/* @@@ label Error SyntaxError: Can only type export class or interface. */ diff --git a/ets2panda/test/ast/compiler/ets/export_type_variable_at_definition.sts b/ets2panda/test/ast/compiler/ets/export_type_variable_at_definition.sts index c4163577a7..757726185e 100644 --- a/ets2panda/test/ast/compiler/ets/export_type_variable_at_definition.sts +++ b/ets2panda/test/ast/compiler/ets/export_type_variable_at_definition.sts @@ -16,4 +16,4 @@ export type /* @@ label */let a = 5; /* @@@ label Error SyntaxError: Can only type export class or interface. */ -/* @@@ label Error SyntaxError: Can only type export class or interface! */ +/* @@@ label Error SyntaxError: Can only type export class or interface. */ diff --git a/ets2panda/test/ast/compiler/ets/implicit_package_import/package_test_5/package_module_2_neg.sts b/ets2panda/test/ast/compiler/ets/implicit_package_import/package_test_5/package_module_2_neg.sts index 52f554a712..85e26b0383 100644 --- a/ets2panda/test/ast/compiler/ets/implicit_package_import/package_test_5/package_module_2_neg.sts +++ b/ets2panda/test/ast/compiler/ets/implicit_package_import/package_test_5/package_module_2_neg.sts @@ -31,6 +31,8 @@ this file will contain parse error, but compilation of 'package_module_1' is not /* @@? 20:30 Error SyntaxError: Unexpected token 'error'. */ /* @@? 20:30 Error TypeError: Unresolved reference error */ /* @@? 20:35 Error SyntaxError: Unexpected token ','. */ +/* @@? 20:35 Error SyntaxError: Unexpected token ','. */ +/* @@? 20:35 Error SyntaxError: Unexpected token ','. */ /* @@? 20:37 Error TypeError: Unresolved reference but */ /* @@? 20:41 Error SyntaxError: Unexpected token 'compilation'. */ /* @@? 20:41 Error TypeError: Unresolved reference compilation */ @@ -44,6 +46,8 @@ this file will contain parse error, but compilation of 'package_module_1' is not /* @@? 20:82 Error SyntaxError: Unexpected token 'aborted'. */ /* @@? 20:82 Error TypeError: Unresolved reference aborted */ /* @@? 20:89 Error SyntaxError: Unexpected token ','. */ +/* @@? 20:89 Error SyntaxError: Unexpected token ','. */ +/* @@? 20:89 Error SyntaxError: Unexpected token ','. */ /* @@? 20:91 Error TypeError: Unresolved reference file */ /* @@? 20:96 Error SyntaxError: Unexpected token 'is'. */ /* @@? 20:96 Error TypeError: Unresolved reference is */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.sts b/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.sts index ca121d25b0..dbb941239a 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.sts +++ b/ets2panda/test/ast/compiler/ets/import_tests/export_multi_error.sts @@ -59,10 +59,10 @@ export default /* @@ label7 */function TestFuncToo(): void {} /*-----------------*/ /* @@@ label6 Error TypeError: Only one default export is allowed in a module */ /* @@@ label7 Error TypeError: Only one default export is allowed in a module */ -/* @@@ label3 Error SyntaxError: Name 'A' cannot be exported and type exported at the same time. */ +/* @@@ label3 Error SyntaxError: Name 'A' cannot be exported and type exported at the same time. */ /* @@@ label4 Error SyntaxError: Cannot export the same 'MyI' type twice. */ -/* @@@ label5 Error SyntaxError: Can only type export class or interface! */ -/* @@@ label1 Error SyntaxError: The given name 'foo2' is already used in another export */ -/* @@@ label1 Error SyntaxError: The given name 'foo2' is already used in another export */ -/* @@@ label2 Error SyntaxError: Cannot export 'foo3', it was already exported */ -/* @@@ label Error SyntaxError: Cannot find name 'foo' to export */ +/* @@@ label5 Error SyntaxError: Can only type export class or interface. */ +/* @@@ label1 Error SyntaxError: The given name 'foo2' is already used in another export. */ +/* @@@ label1 Error SyntaxError: The given name 'foo2' is already used in another export. */ +/* @@@ label2 Error SyntaxError: Cannot export 'foo3', it was already exported. */ +/* @@@ label Error SyntaxError: Cannot find name 'foo' to export. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts index 08b16e5e65..453e606be3 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ export { foo as /* @@ label */bar } -/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported */ +/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts index 70fcdd369d..b5eeab80f6 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ export { foo as /* @@ label */bar } -/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported */ +/* @@@ label Error SyntaxError: Cannot export 'foo', it was already exported. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts index 3b9ee6d055..cdc798c64d 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,4 +21,4 @@ export { msg as /* @@ label */foo } -/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export */ +/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export. */ diff --git a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts index 966bd48224..123d063b09 100644 --- a/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts +++ b/ets2panda/test/ast/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,4 +21,4 @@ export { msg as /* @@ label */foo } -/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export */ +/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export. */ diff --git a/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_infer_type_param1.sts b/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_infer_type_param1.sts index a2da325275..c0dfadae0b 100644 --- a/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_infer_type_param1.sts +++ b/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_infer_type_param1.sts @@ -17,9 +17,9 @@ function main() { let x: (value: float) => float = value => 3 as float // CTE } -/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ -/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ -/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ -/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ -/* @@? 17:44 Error SyntaxError: Unexpected token '=>'. */ -/* @@? 17:44 Error SyntaxError: Unexpected token '=>'. */ +/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ +/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ +/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ +/* @@? 17:38 Error SyntaxError: Unexpected token 'value'. */ +/* @@? 17:44 Error SyntaxError: Unexpected token '=>'. */ +/* @@? 17:44 Error SyntaxError: Unexpected token '=>'. */ diff --git a/ets2panda/test/ast/compiler/ets/namespace_export_invalid01.sts b/ets2panda/test/ast/compiler/ets/namespace_export_invalid01.sts index 91992b05e1..5b5f4986f7 100644 --- a/ets2panda/test/ast/compiler/ets/namespace_export_invalid01.sts +++ b/ets2panda/test/ast/compiler/ets/namespace_export_invalid01.sts @@ -21,5 +21,5 @@ NS.baz(); /* @@? 17:12 Error SyntaxError: Export declarations are not permitted in a namespace. */ -/* @@? 17:14 Error SyntaxError: Cannot find name 'baz' to export */ +/* @@? 17:14 Error SyntaxError: Cannot find name 'baz' to export. */ /* @@? 20:4 Error TypeError: Property 'baz' does not exist on type 'NS' */ diff --git a/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts b/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts index fafd6e4202..7e3e9315ce 100644 --- a/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts +++ b/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts @@ -18,5 +18,6 @@ let negative%%_ = 1 /* @@? 16:13 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 16:13 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 16:13 Error SyntaxError: Unexpected token '%'. */ +/* @@? 16:13 Error SyntaxError: Unexpected token '%'. */ /* @@? 16:14 Error SyntaxError: Unexpected token '%'. */ /* @@? 16:15 Error TypeError: Unresolved reference _ */ diff --git a/ets2panda/test/ast/parser/ets/AllowSequence.sts b/ets2panda/test/ast/parser/ets/AllowSequence.sts index cfaffd8ec9..3e72a4ceec 100644 --- a/ets2panda/test/ast/parser/ets/AllowSequence.sts +++ b/ets2panda/test/ast/parser/ets/AllowSequence.sts @@ -21,7 +21,8 @@ function main(): void { } } -/* @@? 19:17 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 19:17 Error SyntaxError: Unexpected token, expected ')'. */ /* @@? 19:19 Error SyntaxError: Unexpected token 'x'. */ /* @@? 19:22 Error SyntaxError: Unexpected token ')'. */ /* @@? 19:22 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:22 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/parser/ets/InvalidExpressions1.sts b/ets2panda/test/ast/parser/ets/InvalidExpressions1.sts index 8362478abf..df4bb3cf90 100644 --- a/ets2panda/test/ast/parser/ets/InvalidExpressions1.sts +++ b/ets2panda/test/ast/parser/ets/InvalidExpressions1.sts @@ -100,4 +100,4 @@ let a = [1, 2, 3); /* @@? 38:17 Error SyntaxError: Unexpected token ')'. */ /* @@? 38:17 Error SyntaxError: Unexpected token ')'. */ /* @@? 38:17 Error SyntaxError: Unexpected token ')'. */ -/* @@? 38:17 Error SyntaxError: Unexpected token, expected ',' or ']'. */ \ No newline at end of file +/* @@? 38:17 Error SyntaxError: Unexpected token, expected ',' or ']'. */ diff --git a/ets2panda/test/ast/parser/ets/InvalidStatements1.sts b/ets2panda/test/ast/parser/ets/InvalidStatements1.sts index 0c668353d7..d1736c1bb8 100644 --- a/ets2panda/test/ast/parser/ets/InvalidStatements1.sts +++ b/ets2panda/test/ast/parser/ets/InvalidStatements1.sts @@ -52,9 +52,9 @@ throw "abc" // there were more errors /* @@? 16:13 Error SyntaxError: Can only type export class or interface. */ -/* @@? 16:13 Error SyntaxError: Can only type export class or interface! */ +/* @@? 16:13 Error SyntaxError: Can only type export class or interface. */ +/* @@? 19:13 Error SyntaxError: Can only type export class or interface. */ /* @@? 19:13 Error SyntaxError: Can only type export class or interface. */ -/* @@? 19:13 Error SyntaxError: Can only type export class or interface! */ /* @@? 22:1 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 22:5 Error TypeError: Variable 'x' has already been declared. */ /* @@? 25:5 Error SyntaxError: Unexpected token 'let'. */ diff --git a/ets2panda/test/ast/parser/ets/InvalidTyped.sts b/ets2panda/test/ast/parser/ets/InvalidTyped.sts index c66d6e7cbc..2f734bc55f 100644 --- a/ets2panda/test/ast/parser/ets/InvalidTyped.sts +++ b/ets2panda/test/ast/parser/ets/InvalidTyped.sts @@ -33,8 +33,8 @@ interface I { /* @@? 16:21 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 16:21 Error SyntaxError: Identifier expected. */ /* @@? 16:21 Error TypeError: Interface expected here. */ -/* @@? 16:23 Error TypeError: Interface expected here. */ /* @@? 16:23 Error SyntaxError: Identifier expected. */ +/* @@? 16:23 Error TypeError: Interface expected here. */ /* @@? 18:1 Error TypeError: Variable 'C' has already been declared. */ /* @@? 18:23 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 18:25 Error SyntaxError: Identifier expected. */ diff --git a/ets2panda/test/ast/parser/ets/Multiline_string_escape_char.sts b/ets2panda/test/ast/parser/ets/Multiline_string_escape_char.sts index 7befdee5bd..675fb903ce 100644 --- a/ets2panda/test/ast/parser/ets/Multiline_string_escape_char.sts +++ b/ets2panda/test/ast/parser/ets/Multiline_string_escape_char.sts @@ -18,6 +18,6 @@ function main(){ Test escape characters` | "X"; } -/* @@? 17:40 Error SyntaxError: Invalid character escape sequence */ -/* @@? 17:43 Error SyntaxError: Invalid character escape sequence */ -/* @@? 17:47 Error SyntaxError: Invalid unicode escape sequence */ +/* @@? 17:15 Error SyntaxError: Invalid character escape sequence. */ +/* @@? 17:15 Error SyntaxError: Invalid character escape sequence. */ +/* @@? 17:15 Error SyntaxError: Invalid Unicode escape. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.sts b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.sts index fe6e06f5e8..3ae3ffab28 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.sts +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token04.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,3 +21,5 @@ const invalidUsage1 = @Log("value")) ()=>{} /* @@? 19:36 Error SyntaxError: Unexpected token ')'. */ /* @@? 19:36 Error SyntaxError: Annotations are not allowed on this type of declaration. */ /* @@? 19:36 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:36 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:36 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token05.sts b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token05.sts index 8f22f45773..cf5ecdf953 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token05.sts +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_parser_bad_token05.sts @@ -21,4 +21,5 @@ const invalidUsage1 = @@Log("value") ()=>{} /* @@? 19:23 Error SyntaxError: Unexpected token '@@'. */ /* @@? 19:25 Error SyntaxError: Unexpected token 'Log'. */ /* @@? 19:40 Error SyntaxError: Unexpected token '=>'. */ +/* @@? 19:40 Error SyntaxError: Unexpected token '=>'. */ /* @@? 19:40 Error SyntaxError: Unexpected token at */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotation_export_type.sts b/ets2panda/test/ast/parser/ets/annotations_tests/annotation_export_type.sts index 575bb33566..024fd7e241 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotation_export_type.sts +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotation_export_type.sts @@ -16,4 +16,4 @@ export type @/* @@ label */interface MyAnno {} /* @@@ label Error SyntaxError: Can only type export class or interface. */ -/* @@@ label Error SyntaxError: Can only type export class or interface! */ +/* @@@ label Error SyntaxError: Can only type export class or interface. */ diff --git a/ets2panda/test/ast/parser/ets/constant_expression_divide_zero.sts b/ets2panda/test/ast/parser/ets/constant_expression_divide_zero.sts index 6a53840dfa..f77025113d 100644 --- a/ets2panda/test/ast/parser/ets/constant_expression_divide_zero.sts +++ b/ets2panda/test/ast/parser/ets/constant_expression_divide_zero.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,5 +25,5 @@ enum Color { } -/* @@? 20:14 Error SyntaxError: Division by zero are not allowed in Enum or Annotation */ -/* @@? 24:11 Error SyntaxError: Division by zero are not allowed in Enum or Annotation */ +/* @@? 20:14 Error SyntaxError: Division by zero are not allowed in Enum or Annotation. */ +/* @@? 24:11 Error SyntaxError: Division by zero are not allowed in Enum or Annotation. */ diff --git a/ets2panda/test/ast/parser/ets/enum15.sts b/ets2panda/test/ast/parser/ets/enum15.sts index ef0d3470c1..ba5364e7bf 100644 --- a/ets2panda/test/ast/parser/ets/enum15.sts +++ b/ets2panda/test/ast/parser/ets/enum15.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,6 +20,6 @@ enum InvalidInitTypeEnum { } -/* @@? 19:7 Error SyntaxError: Only constant expression is expected in the field */ -/* @@? 18:11 Error SyntaxError: Invalid enum initialization value */ -/* @@? 19:7 Error SyntaxError: Invalid enum initialization value */ +/* @@? 18:11 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 19:7 Error SyntaxError: Only constant expression is expected in the field. */ +/* @@? 19:7 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum17.sts b/ets2panda/test/ast/parser/ets/enum17.sts index 223cce655b..d6f56270fa 100644 --- a/ets2panda/test/ast/parser/ets/enum17.sts +++ b/ets2panda/test/ast/parser/ets/enum17.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,5 +19,5 @@ enum InvalidInitTypeEnum { Blue } -/* @@@ label Error SyntaxError: Invalid enum initialization value */ -/* @@? 19:7 Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ +/* @@? 19:7 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum18.sts b/ets2panda/test/ast/parser/ets/enum18.sts index 0af8e2a031..eb71a4c548 100644 --- a/ets2panda/test/ast/parser/ets/enum18.sts +++ b/ets2panda/test/ast/parser/ets/enum18.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,5 +19,5 @@ enum InvalidInitTypeEnum { Blue } -/* @@@ label Error SyntaxError: Invalid enum initialization value */ -/* @@? 19:7 Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ +/* @@? 19:7 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum24.sts b/ets2panda/test/ast/parser/ets/enum24.sts index cde4c38a56..61f2b6d0af 100644 --- a/ets2panda/test/ast/parser/ets/enum24.sts +++ b/ets2panda/test/ast/parser/ets/enum24.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,4 +21,4 @@ enum Direction { } -/* @@@ label Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum27.sts b/ets2panda/test/ast/parser/ets/enum27.sts index c9e82b92ff..107017103e 100644 --- a/ets2panda/test/ast/parser/ets/enum27.sts +++ b/ets2panda/test/ast/parser/ets/enum27.sts @@ -21,5 +21,5 @@ enum Date { Day = /* @@ label1 */Date.now() } -/* @@@ label Error SyntaxError: Invalid enum initialization value */ -/* @@@ label1 Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ +/* @@@ label1 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum28.sts b/ets2panda/test/ast/parser/ets/enum28.sts index 27a06f2435..e3381675ec 100644 --- a/ets2panda/test/ast/parser/ets/enum28.sts +++ b/ets2panda/test/ast/parser/ets/enum28.sts @@ -17,5 +17,5 @@ enum Color { Red = /* @@ label */`Line 1\nLine 2 ${1}`, } -/* @@@ label Error SyntaxError: String Interpolation Expression is not constant expression */ -/* @@@ label Error SyntaxError: Invalid enum initialization value */ +/* @@@ label Error SyntaxError: String Interpolation Expression is not constant expression. */ +/* @@@ label Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum_default_invalid_value_type.sts b/ets2panda/test/ast/parser/ets/enum_default_invalid_value_type.sts index 9e5a5a16c1..386918e320 100644 --- a/ets2panda/test/ast/parser/ets/enum_default_invalid_value_type.sts +++ b/ets2panda/test/ast/parser/ets/enum_default_invalid_value_type.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,6 +27,6 @@ enum C { } -/* @@? 17:9 Error SyntaxError: Invalid enum initialization value */ -/* @@? 21:9 Error SyntaxError: Invalid enum initialization value */ -/* @@? 26:9 Error SyntaxError: Invalid enum initialization value */ +/* @@? 17:9 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 21:9 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 26:9 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/enum_default_negative.sts b/ets2panda/test/ast/parser/ets/enum_default_negative.sts index 15acda8071..6384f7d51b 100644 --- a/ets2panda/test/ast/parser/ets/enum_default_negative.sts +++ b/ets2panda/test/ast/parser/ets/enum_default_negative.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,13 +26,14 @@ enum D { } -/* @@? 1:1 Error SyntaxError: Invalid enum initialization value */ -/* @@? 17:9 Error SyntaxError: Invalid enum initialization value */ +/* @@? 1:1 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 17:9 Error SyntaxError: Invalid enum initialization value. */ /* @@? 17:10 Error SyntaxError: Unexpected token ')'. */ /* @@? 21:9 Error SyntaxError: Unexpected token ')'. */ /* @@? 21:9 Error SyntaxError: Unexpected token, expected ',' or '}'. */ /* @@? 21:9 Error SyntaxError: Unexpected token ')'. */ +/* @@? 21:9 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:1 Error SyntaxError: Unexpected token '}'. */ /* @@? 26:1 Error SyntaxError: Unexpected token, expected ':'. */ -/* @@? 39:1 Error SyntaxError: Unexpected token 'eos'. */ -/* @@? 39:1 Error SyntaxError: Unexpected token, expected ',' or '}'. */ +/* @@? 40:1 Error SyntaxError: Unexpected token 'eos'. */ +/* @@? 40:1 Error SyntaxError: Unexpected token, expected ',' or '}'. */ diff --git a/ets2panda/test/ast/parser/ets/enum_default_negative1.sts b/ets2panda/test/ast/parser/ets/enum_default_negative1.sts index ed76ae3193..f30764edb1 100644 --- a/ets2panda/test/ast/parser/ets/enum_default_negative1.sts +++ b/ets2panda/test/ast/parser/ets/enum_default_negative1.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,7 +23,7 @@ enum B { } -/* @@? 17:9 Error SyntaxError: Unsupported operator for String */ -/* @@? 22:9 Error SyntaxError: Only constant expression is expected in the field */ -/* @@? 17:9 Error SyntaxError: Invalid enum initialization value */ -/* @@? 22:9 Error SyntaxError: Invalid enum initialization value */ +/* @@? 17:9 Error SyntaxError: Unsupported operator for String. */ +/* @@? 17:9 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 22:9 Error SyntaxError: Only constant expression is expected in the field. */ +/* @@? 22:9 Error SyntaxError: Invalid enum initialization value. */ diff --git a/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_not_in_toplevel.sts b/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_not_in_toplevel.sts index 538be2e4d8..0c7c7b8462 100644 --- a/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_not_in_toplevel.sts +++ b/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_not_in_toplevel.sts @@ -34,6 +34,10 @@ function main() { /* @@? 20:20 Error SyntaxError: Expected '{', got 'this'. */ /* @@? 20:20 Error TypeError: Cannot reference 'this' in this context. */ /* @@? 20:24 Error SyntaxError: Unexpected token ':'. */ -/* @@? 20:31 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:24 Error SyntaxError: Unexpected token ':'. */ +/* @@? 20:24 Error SyntaxError: Unexpected token ':'. */ /* @@? 20:26 Error TypeError: Class name 'Fruit' used in the wrong context */ +/* @@? 20:31 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:31 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:31 Error SyntaxError: Unexpected token ')'. */ /* @@? 27:11 Error TypeError: Property 'price' does not exist on type 'Fruit' */ diff --git a/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_3.sts b/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_3.sts index 1b2b3e5257..32194d8ff0 100644 --- a/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_3.sts +++ b/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_3.sts @@ -15,4 +15,4 @@ export default * /* @@ err */from "./for_re-export" -/* @@@ err Error SyntaxError: Cannot use 'export default' in re-export context */ +/* @@@ err Error SyntaxError: Cannot use 'export default' in re-export context. */ diff --git a/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_4.sts b/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_4.sts index 63c006a72c..df144847ec 100644 --- a/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_4.sts +++ b/ets2panda/test/ast/parser/ets/import_tests/invalid_default_export/default_export_invalid_syntax_4.sts @@ -15,4 +15,4 @@ export default {foo} /* @@ err */from "./for_re-export" -/* @@@ err Error SyntaxError: Cannot use 'export default' in re-export context */ +/* @@@ err Error SyntaxError: Cannot use 'export default' in re-export context. */ diff --git a/ets2panda/test/ast/parser/ets/import_tests/type/type_3.sts b/ets2panda/test/ast/parser/ets/import_tests/type/type_3.sts index b1012203c0..ab681c0acc 100644 --- a/ets2panda/test/ast/parser/ets/import_tests/type/type_3.sts +++ b/ets2panda/test/ast/parser/ets/import_tests/type/type_3.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,5 +19,5 @@ class TestClass {} export {foo} export type {TestClass as /* @@ label */foo} -/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export */ -/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export */ +/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export. */ +/* @@@ label Error SyntaxError: The given name 'foo' is already used in another export. */ diff --git a/ets2panda/test/ast/parser/ets/invalidEnums.sts b/ets2panda/test/ast/parser/ets/invalidEnums.sts index ca9681bb4e..5a1a35d03d 100644 --- a/ets2panda/test/ast/parser/ets/invalidEnums.sts +++ b/ets2panda/test/ast/parser/ets/invalidEnums.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -58,14 +58,14 @@ enum MissingLeftBrace } -/* @@? 1:1 Error SyntaxError: Invalid enum initialization value */ -/* @@? 1:1 Error SyntaxError: Only constant expression is expected in the field */ +/* @@? 1:1 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 1:1 Error SyntaxError: Only constant expression is expected in the field. */ /* @@? 16:5 Error SyntaxError: Variable declaration expected. */ /* @@? 22:22 Error SyntaxError: Unexpected token, expected '{'. */ /* @@? 32:1 Error SyntaxError: Unexpected token ']'. */ /* @@? 32:1 Error SyntaxError: Unexpected token, expected ',' or '}'. */ -/* @@? 37:10 Error SyntaxError: Only constant expression is expected in the field */ -/* @@? 37:10 Error SyntaxError: Invalid enum initialization value */ +/* @@? 37:10 Error SyntaxError: Only constant expression is expected in the field. */ +/* @@? 37:10 Error SyntaxError: Invalid enum initialization value. */ /* @@? 38:1 Error SyntaxError: Unexpected token '}'. */ /* @@? 43:10 Error SyntaxError: Unexpected token '?'. */ /* @@? 44:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/invalidEnums1.sts b/ets2panda/test/ast/parser/ets/invalidEnums1.sts index a10a9c6e4f..a00a519723 100644 --- a/ets2panda/test/ast/parser/ets/invalidEnums1.sts +++ b/ets2panda/test/ast/parser/ets/invalidEnums1.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,7 +26,7 @@ enum EStrNotInit { } -/* @@? 18:15 Error SyntaxError: Invalid enum initialization value */ -/* @@? 19:12 Error SyntaxError: Invalid enum initialization value */ -/* @@? 20:12 Error SyntaxError: Invalid enum initialization value */ -/* @@? 25:9 Error SyntaxError: All items of string-type enumeration should be explicitly initialized. */ +/* @@? 18:15 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 19:12 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 20:12 Error SyntaxError: Invalid enum initialization value. */ +/* @@? 25:9 Error SyntaxError: All items of string-type enumeration should be explicitly initialized. */ diff --git a/ets2panda/test/ast/parser/ets/invalidTypes.sts b/ets2panda/test/ast/parser/ets/invalidTypes.sts index 4aab82d339..bf64b44a28 100644 --- a/ets2panda/test/ast/parser/ets/invalidTypes.sts +++ b/ets2panda/test/ast/parser/ets/invalidTypes.sts @@ -47,6 +47,8 @@ let var6: [a0: , a1: ]; /* @@? 32:19 Error SyntaxError: Unexpected token 'number'. */ /* @@? 32:19 Error TypeError: Unresolved reference number */ /* @@? 32:25 Error SyntaxError: Unexpected token ']'. */ +/* @@? 32:25 Error SyntaxError: Unexpected token ']'. */ +/* @@? 32:25 Error SyntaxError: Unexpected token ']'. */ /* @@? 35:21 Error SyntaxError: A 'this' type is available only as return type in a non-static method of a class or struct and extension functions. */ /* @@? 38:16 Error SyntaxError: Invalid Type. */ /* @@? 38:22 Error SyntaxError: Invalid Type. */ diff --git a/ets2panda/test/ast/parser/ets/namespace_badtoken04.sts b/ets2panda/test/ast/parser/ets/namespace_badtoken04.sts index 746ba6d8b4..5f618161da 100644 --- a/ets2panda/test/ast/parser/ets/namespace_badtoken04.sts +++ b/ets2panda/test/ast/parser/ets/namespace_badtoken04.sts @@ -17,3 +17,5 @@ declare namespace MySpace{ foo():void } /* @@? 17:10 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:10 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:10 Error SyntaxError: Unexpected token ':'. */ diff --git a/ets2panda/test/ast/parser/ets/non_constant_expression.sts b/ets2panda/test/ast/parser/ets/non_constant_expression.sts index db5e5d5fd7..e41420b70f 100644 --- a/ets2panda/test/ast/parser/ets/non_constant_expression.sts +++ b/ets2panda/test/ast/parser/ets/non_constant_expression.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,4 +22,4 @@ let cc = 1 function foo() {} -/* @@? 21:14 Error SyntaxError: Only constant expression is expected in the field */ +/* @@? 21:14 Error SyntaxError: Only constant expression is expected in the field. */ diff --git a/ets2panda/test/ast/parser/ets/selective_export/selective_export_bad.sts b/ets2panda/test/ast/parser/ets/selective_export/selective_export_bad.sts index 9b08c9f23d..bb493f22fa 100644 --- a/ets2panda/test/ast/parser/ets/selective_export/selective_export_bad.sts +++ b/ets2panda/test/ast/parser/ets/selective_export/selective_export_bad.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function bar(): int { return 1; } -/* @@@ label Error SyntaxError: Cannot find name 'foo' to export */ +/* @@@ label Error SyntaxError: Cannot find name 'foo' to export. */ diff --git a/ets2panda/test/ast/parser/ets/single_export/single_export_as_n.sts b/ets2panda/test/ast/parser/ets/single_export/single_export_as_n.sts index d0757c1297..783ddd8529 100644 --- a/ets2panda/test/ast/parser/ets/single_export/single_export_as_n.sts +++ b/ets2panda/test/ast/parser/ets/single_export/single_export_as_n.sts @@ -17,5 +17,6 @@ export a as A let a = 2; +/* @@? 16:10 Error SyntaxError: Unexpected token 'as'. */ /* @@? 16:10 Error SyntaxError: Unexpected token 'as'. */ /* @@? 16:13 Error TypeError: Cannot find type 'A'. */ diff --git a/ets2panda/test/ast/parser/ets/single_export/single_export_from_n.sts b/ets2panda/test/ast/parser/ets/single_export/single_export_from_n.sts index 57fc6a3084..6b49070609 100644 --- a/ets2panda/test/ast/parser/ets/single_export/single_export_from_n.sts +++ b/ets2panda/test/ast/parser/ets/single_export/single_export_from_n.sts @@ -12,7 +12,7 @@ export a /* @@ label */from /* @@ label1 */"./type" -/* @@? 13:8 Error SyntaxError: Cannot find name 'a' to export */ +/* @@? 13:8 Error SyntaxError: Cannot find name 'a' to export. */ /* @@? 13:24 Error SyntaxError: Unexpected token 'from'. */ /* @@? 13:24 Error TypeError: Unresolved reference from */ /* @@? 13:44 Error SyntaxError: Unexpected token './type'. */ diff --git a/ets2panda/test/ast/parser/ets/single_export/single_export_n.sts b/ets2panda/test/ast/parser/ets/single_export/single_export_n.sts index 53f02d69c6..44c554036e 100644 --- a/ets2panda/test/ast/parser/ets/single_export/single_export_n.sts +++ b/ets2panda/test/ast/parser/ets/single_export/single_export_n.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,3 +19,5 @@ let v = 1 let m = 2 /* @@? 16:9 Error SyntaxError: Unexpected token ','. */ +/* @@? 16:9 Error SyntaxError: Unexpected token ','. */ +/* @@? 16:9 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/string_literal_01.sts b/ets2panda/test/ast/parser/ets/string_literal_01.sts index d05deb7b2a..75f6aa94b0 100644 --- a/ets2panda/test/ast/parser/ets/string_literal_01.sts +++ b/ets2panda/test/ast/parser/ets/string_literal_01.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,6 +15,6 @@ let x = "\u{}"; -/* @@? 16:13 Error SyntaxError: Hexadecimal digit expected. */ -/* @@? 16:14 Error SyntaxError: Invalid unicode escape sequence */ -/* @@? 16:16 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 16:9 Error SyntaxError: Hexadecimal digit expected. */ +/* @@? 16:9 Error SyntaxError: Invalid Unicode escape. */ +/* @@? 16:9 Error SyntaxError: Newline is not allowed in strings. */ diff --git a/ets2panda/test/ast/parser/ets/trailing_comma_1.sts b/ets2panda/test/ast/parser/ets/trailing_comma_1.sts index b846708cd1..e9576c8261 100644 --- a/ets2panda/test/ast/parser/ets/trailing_comma_1.sts +++ b/ets2panda/test/ast/parser/ets/trailing_comma_1.sts @@ -53,7 +53,9 @@ foo(,) /* @@? 34:6 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 35:5 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 35:10 Error SyntaxError: Unexpected token 'a'. */ -/* @@? 35:10 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 35:10 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 35:10 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 35:14 Error SyntaxError: Unexpected token ')'. */ +/* @@? 35:14 Error SyntaxError: Unexpected token ')'. */ /* @@? 35:14 Error SyntaxError: Unexpected token ')'. */ /* @@? 36:5 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/tuple_type_3_neg.sts b/ets2panda/test/ast/parser/ets/tuple_type_3_neg.sts index 291fea3c45..576cc316c6 100644 --- a/ets2panda/test/ast/parser/ets/tuple_type_3_neg.sts +++ b/ets2panda/test/ast/parser/ets/tuple_type_3_neg.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,4 +20,6 @@ let a: [number, number number] = [1, 2, 3]; /* @@? 17:24 Error SyntaxError: Unexpected token 'number'. */ /* @@? 17:24 Error TypeError: Unresolved reference number */ /* @@? 17:30 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:30 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:30 Error SyntaxError: Unexpected token ']'. */ /* @@? 17:32 Error SyntaxError: Unexpected token '='. */ diff --git a/ets2panda/test/ast/parser/ets/type_references.sts b/ets2panda/test/ast/parser/ets/type_references.sts index dd13fc24ef..ae100b4cd7 100644 --- a/ets2panda/test/ast/parser/ets/type_references.sts +++ b/ets2panda/test/ast/parser/ets/type_references.sts @@ -22,12 +22,16 @@ let y: G<{a:String}, B> // Error /* @@? 19:8 Error TypeError: Cannot find type 'G'. */ /* @@? 19:10 Error SyntaxError: Unexpected token, expected '>'. */ /* @@? 19:10 Error SyntaxError: Unexpected token '>'. */ +/* @@? 19:10 Error SyntaxError: Unexpected token '>'. */ /* @@? 19:10 Error SyntaxError: Invalid Type. */ /* @@? 19:11 Error TypeError: Unresolved reference a */ /* @@? 19:12 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:12 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:12 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:13 Error TypeError: Class name 'String' used in the wrong context */ /* @@? 19:19 Error SyntaxError: Unexpected token '}'. */ /* @@? 19:20 Error SyntaxError: Unexpected token ','. */ -/* @@? 19:13 Error TypeError: Class name 'String' used in the wrong context */ +/* @@? 19:20 Error SyntaxError: Unexpected token ','. */ /* @@? 19:22 Error TypeError: Unresolved reference B */ /* @@? 19:22 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ -/* @@? 34:1 Error SyntaxError: Unexpected token 'eos'. */ +/* @@? 38:1 Error SyntaxError: Unexpected token 'eos'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_14.sts b/ets2panda/test/ast/parser/ets/unexpected_token_14.sts index 8cf75f4f62..91ee89cea3 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_14.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_14.sts @@ -23,5 +23,7 @@ enum HEHE /* @@? 17:9 Error SyntaxError: Identifier expected, got '='. */ /* @@? 17:11 Error SyntaxError: Unexpected token, expected ',' or '}'. */ /* @@? 17:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:21 Error SyntaxError: Unexpected token ','. */ /* @@? 18:5 Error TypeError: Unresolved reference Green */ /* @@? 19:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_25.sts b/ets2panda/test/ast/parser/ets/unexpected_token_25.sts index ee5c889be7..0677f01aa2 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_25.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_25.sts @@ -19,4 +19,6 @@ let y: int = x [0] /* @@? 16:13 Error SyntaxError: Unexpected token, expected ']'. */ /* @@? 16:13 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 16:13 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:13 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:13 Error SyntaxError: Unexpected token ']'. */ /* @@? 17:14 Error TypeError: Indexed access is not supported for such expression type. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_31.sts b/ets2panda/test/ast/parser/ets/unexpected_token_31.sts index 9fc60005ae..522434bf73 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_31.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_31.sts @@ -22,6 +22,8 @@ function foo(...^number: int[]): int { /* @@? 16:18 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 16:18 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 16:31 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:31 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:32 Error SyntaxError: Unexpected token ':'. */ /* @@? 16:32 Error SyntaxError: Unexpected token ':'. */ /* @@? 16:34 Error TypeError: Unresolved reference int */ /* @@? 16:38 Error SyntaxError: Unexpected token '{'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_35.sts b/ets2panda/test/ast/parser/ets/unexpected_token_35.sts index d504dea33a..1b1b372946 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_35.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_35.sts @@ -29,5 +29,7 @@ let sector: float /* @@? 23:19 Error SyntaxError: Unexpected token, expected ')'. */ /* @@? 23:20 Error SyntaxError: Unexpected token at */ /* @@? 23:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 23:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 23:21 Error SyntaxError: Unexpected token ','. */ /* @@? 24:16 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 26:1 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_38.sts b/ets2panda/test/ast/parser/ets/unexpected_token_38.sts index a82295da9d..f011e4b7fe 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_38.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_38.sts @@ -23,6 +23,7 @@ let func3: (f: (a: number, b: string) => number[]): number[] => (a: number, b: b // let func3: (f: (a: number, b: string) => number[]): number[]) => (a: number, b: boolean) => true; +/* @@? 19:8 Error TypeError: 'void' used as type annotation. */ /* @@? 19:8 Error TypeError: 'void' used as type annotation. */ /* @@? 22:51 Error SyntaxError: Unexpected token, expected '=>'. */ /* @@? 22:51 Error SyntaxError: Unexpected token, expected '('. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_40.sts b/ets2panda/test/ast/parser/ets/unexpected_token_40.sts index bd4be37821..63a96bec4a 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_40.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_40.sts @@ -15,6 +15,7 @@ let arr = new Array' is generic but type argument were not provided. */ /* @@? 16:15 Error TypeError: Type 'Array' is generic but type argument were not provided. */ /* @@? 16:41 Error SyntaxError: Unexpected token, expected '>'. */ -/* @@? 21:1 Error SyntaxError: Unexpected token 'eos'. */ +/* @@? 22:1 Error SyntaxError: Unexpected token 'eos'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_48.sts b/ets2panda/test/ast/parser/ets/unexpected_token_48.sts index 2a4ebb192a..1b975dea97 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_48.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_48.sts @@ -15,6 +15,7 @@ export type {B/* @@ label */] -/* @@? 16:14 Error SyntaxError: Can only type export class or interface! */ +/* @@? 16:14 Error SyntaxError: Can only type export class or interface. */ /* @@? 16:29 Error SyntaxError: Unexpected token, expected ',' or '}'. */ /* @@? 16:29 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:29 Error SyntaxError: Unexpected token ']'. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_53.sts b/ets2panda/test/ast/parser/ets/unexpected_token_53.sts index a6f7761eae..44d8281cf5 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_53.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_53.sts @@ -31,9 +31,14 @@ export class MathSpectralNorm { /* @@? 19:22 Error SyntaxError: Unexpected token ':'. */ /* @@? 19:22 Error SyntaxError: Expected ')', got ':'. */ /* @@? 19:22 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:22 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:22 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:22 Error SyntaxError: Unexpected token ':'. */ /* @@? 19:22 Error SyntaxError: Expected ';', got ':'. */ /* @@? 19:24 Error TypeError: Unresolved reference i */ /* @@? 19:27 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:27 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:27 Error SyntaxError: Unexpected token ')'. */ /* @@? 20:7 Error TypeError: Unresolved reference vbv */ /* @@? 20:14 Error TypeError: Unresolved reference u */ /* @@? 20:14 Error TypeError: Indexed access is not supported for such expression type. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_55.sts b/ets2panda/test/ast/parser/ets/unexpected_token_55.sts index 6d37de75e9..c05fbe30cd 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_55.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_55.sts @@ -31,10 +31,15 @@ export class MathSpectralNorm { /* @@? 19:23 Error TypeError: Unresolved reference i */ /* @@? 19:29 Error SyntaxError: Expected ';', got ':'. */ /* @@? 19:29 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:29 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:29 Error SyntaxError: Unexpected token ':'. */ /* @@? 19:29 Error SyntaxError: Expected ')', got ':'. */ /* @@? 19:29 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:29 Error SyntaxError: Unexpected token ':'. */ /* @@? 19:31 Error TypeError: Unresolved reference i */ /* @@? 19:34 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:34 Error SyntaxError: Unexpected token ')'. */ +/* @@? 19:34 Error SyntaxError: Unexpected token ')'. */ /* @@? 20:7 Error TypeError: Unresolved reference vbv */ /* @@? 20:14 Error TypeError: Unresolved reference u */ /* @@? 20:14 Error TypeError: Indexed access is not supported for such expression type. */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_56.sts b/ets2panda/test/ast/parser/ets/unexpected_token_56.sts index c07e0adea2..f2d77fb093 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_56.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_56.sts @@ -26,6 +26,8 @@ for (let i? : Number = 1;;) { break; } /* @@? 16:68 Error SyntaxError: Expected ')', got ';'. */ /* @@? 16:72 Error TypeError: Unresolved reference i */ /* @@? 16:87 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:87 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:87 Error SyntaxError: Unexpected token ')'. */ /* @@? 17:5 Error TypeError: Unresolved reference result */ /* @@? 17:14 Error TypeError: Unresolved reference result */ /* @@? 17:23 Error TypeError: Unresolved reference p */ diff --git a/ets2panda/test/ast/parser/js/InvalidParserImpl.js b/ets2panda/test/ast/parser/js/InvalidParserImpl.js index 615e66f8ae..c9a25dc5df 100644 --- a/ets2panda/test/ast/parser/js/InvalidParserImpl.js +++ b/ets2panda/test/ast/parser/js/InvalidParserImpl.js @@ -55,8 +55,8 @@ for (var i of a) { /* @@? 22:15 Error SyntaxError: Invalid accessor. */ /* @@? 24:12 Error SyntaxError: Unexpected modifier. */ /* @@? 24:12 Error SyntaxError: Duplicated modifier is not allowed. */ -/* @@? 26:6 Error SyntaxError: Unexpected identifier */ -/* @@? 30:6 Error SyntaxError: Private identifier can not be constructor */ +/* @@? 26:6 Error SyntaxError: Unexpected identifier. */ +/* @@? 30:6 Error SyntaxError: Private identifier can not be constructor. */ /* @@? 35:12 Error SyntaxError: Classes may not have static property named prototype. */ /* @@? 37:5 Error SyntaxError: Classes may not have a field named 'constructor'. */ /* @@? 38:12 Error SyntaxError: Classes may not have static property named prototype. */ diff --git a/ets2panda/test/ast/parser/js/module/unexpected_token_10.js b/ets2panda/test/ast/parser/js/module/unexpected_token_10.js index 51a44af2ac..c29ecd316c 100644 --- a/ets2panda/test/ast/parser/js/module/unexpected_token_10.js +++ b/ets2panda/test/ast/parser/js/module/unexpected_token_10.js @@ -19,6 +19,6 @@ flags: [module] import(import /* @@ label */) -/* @@? 20:29 Error SyntaxError: Expected '(', got ')'. */ -/* @@? 20:29 Error SyntaxError: Unexpected token ')'. */ +/* @@@ label Error SyntaxError: Expected '(', got ')'. */ +/* @@@ label Error SyntaxError: Unexpected token ')'. */ /* @@? 25:1 Error SyntaxError: Expected ')', got 'eos'. */ diff --git a/ets2panda/test/ast/parser/js/test-class-static-block6.js b/ets2panda/test/ast/parser/js/test-class-static-block6.js index 953fc1e593..b12cb5006b 100644 --- a/ets2panda/test/ast/parser/js/test-class-static-block6.js +++ b/ets2panda/test/ast/parser/js/test-class-static-block6.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,4 +21,4 @@ function *g() { } } -/* @@? 19:18 Error SyntaxError: Unexpected strict mode reserved keyword */ +/* @@? 19:13 Error SyntaxError: Unexpected strict mode reserved keyword. */ diff --git a/ets2panda/test/ast/parser/js/test-escaped-keyword.js b/ets2panda/test/ast/parser/js/test-escaped-keyword.js index d5ce873772..894e93267a 100644 --- a/ets2panda/test/ast/parser/js/test-escaped-keyword.js +++ b/ets2panda/test/ast/parser/js/test-escaped-keyword.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,4 +16,4 @@ cl\u0061ss; -/* @@? 17:11 Error SyntaxError: Escape sequences are not allowed in keywords */ +/* @@? 17:1 Error SyntaxError: Escape sequences are not allowed in keyword. */ diff --git a/ets2panda/test/ast/parser/js/test-for-1.js b/ets2panda/test/ast/parser/js/test-for-1.js index 51c8e3ee7b..9b2243661f 100644 --- a/ets2panda/test/ast/parser/js/test-for-1.js +++ b/ets2panda/test/ast/parser/js/test-for-1.js @@ -16,5 +16,6 @@ for () {} +/* @@? 17:6 Error SyntaxError: Unexpected token ')'. */ /* @@? 17:6 Error SyntaxError: Unexpected token ')'. */ /* @@? 17:6 Error SyntaxError: Expected ';', got ')'. */ diff --git a/ets2panda/test/ast/parser/js/test-member-expression-1.js b/ets2panda/test/ast/parser/js/test-member-expression-1.js index 5c13d76af3..332e76d609 100644 --- a/ets2panda/test/ast/parser/js/test-member-expression-1.js +++ b/ets2panda/test/ast/parser/js/test-member-expression-1.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,3 +18,5 @@ a.(b) /* @@? 17:3 Error SyntaxError: Identifier expected, got '('. */ /* @@? 17:4 Error SyntaxError: Unexpected token 'b'. */ /* @@? 17:5 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:5 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:5 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/parser/js/test-multi-line-string.js b/ets2panda/test/ast/parser/js/test-multi-line-string.js index 03a6faf2a9..33f59c93b9 100644 --- a/ets2panda/test/ast/parser/js/test-multi-line-string.js +++ b/ets2panda/test/ast/parser/js/test-multi-line-string.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,10 +14,10 @@ */ -"foo/* @@ label */ +"foo /* @@ label1 */ " -/* @@@ label Error SyntaxError: Newline is not allowed in strings */ -/* @@@ label1 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 17:1 Error SyntaxError: Newline is not allowed in strings. */ +/* @@@ label1 Error SyntaxError: Newline is not allowed in strings. */ diff --git a/ets2panda/test/ast/parser/js/test-numeric-separator1.js b/ets2panda/test/ast/parser/js/test-numeric-separator1.js index 290af1334d..3aa59dc009 100644 --- a/ets2panda/test/ast/parser/js/test-numeric-separator1.js +++ b/ets2panda/test/ast/parser/js/test-numeric-separator1.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,5 +15,5 @@ 1__1 -/* @@? 17:3 Error SyntaxError: Invalid numeric separator */ -/* @@? 17:5 Error SyntaxError: Numeric separators are not allowed at the end of numeric literals */ +/* @@? 17:1 Error SyntaxError: Invalid numeric separator. */ +/* @@? 17:1 Error SyntaxError: Numeric separators are not allowed at the end of numeric literals. */ diff --git a/ets2panda/test/ast/parser/js/test-numeric-separator2.js b/ets2panda/test/ast/parser/js/test-numeric-separator2.js index d8a2f479d2..9d599954e0 100644 --- a/ets2panda/test/ast/parser/js/test-numeric-separator2.js +++ b/ets2panda/test/ast/parser/js/test-numeric-separator2.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,4 +15,4 @@ 1111_ -/* @@? 17:6 Error SyntaxError: Numeric separators are not allowed at the end of numeric literals */ +/* @@? 17:1 Error SyntaxError: Numeric separators are not allowed at the end of numeric literals. */ diff --git a/ets2panda/test/ast/parser/js/test-private-field4.js b/ets2panda/test/ast/parser/js/test-private-field4.js index 396a4e25ea..aaafa582fd 100644 --- a/ets2panda/test/ast/parser/js/test-private-field4.js +++ b/ets2panda/test/ast/parser/js/test-private-field4.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,5 +17,5 @@ class A { #5; } -/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ -/* @@? 17:6 Error SyntaxError: Private identifier name can not be number */ +/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ +/* @@? 17:6 Error SyntaxError: Private identifier name can not be number. */ diff --git a/ets2panda/test/ast/parser/js/test-private-field5.js b/ets2panda/test/ast/parser/js/test-private-field5.js index 7710279f43..42d887f366 100644 --- a/ets2panda/test/ast/parser/js/test-private-field5.js +++ b/ets2panda/test/ast/parser/js/test-private-field5.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,5 +17,5 @@ class A { #"\"bar\""; } -/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ -/* @@? 17:6 Error SyntaxError: Private identifier name can not be string */ +/* @@? 17:6 Error SyntaxError: Unexpected token in private field. */ +/* @@? 17:6 Error SyntaxError: Private identifier name can not be string. */ diff --git a/ets2panda/test/ast/parser/js/test-private-field9.js b/ets2panda/test/ast/parser/js/test-private-field9.js index eeca143b1e..2ac3526e83 100644 --- a/ets2panda/test/ast/parser/js/test-private-field9.js +++ b/ets2panda/test/ast/parser/js/test-private-field9.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,4 +17,4 @@ class A { #constructor() { } } -/* @@? 17:6 Error SyntaxError: Private identifier can not be constructor */ +/* @@? 17:6 Error SyntaxError: Private identifier can not be constructor. */ diff --git a/ets2panda/test/ast/parser/js/test-template-literal-1.js b/ets2panda/test/ast/parser/js/test-template-literal-1.js index bb5f93dc83..ddae8ff487 100644 --- a/ets2panda/test/ast/parser/js/test-template-literal-1.js +++ b/ets2panda/test/ast/parser/js/test-template-literal-1.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,8 +13,9 @@ * limitations under the License. */ -/* @@? 21:1 Error SyntaxError: Unterminated string */ -/* @@? 21:1 Error SyntaxError: Unexpected token, expected '${' or '`' */ -/* @@? 21:1 Error SyntaxError: Unexpected token, expected '`' */ +/* @@? 21:1 Error SyntaxError: Unexpected token, expected '`'. */ +/* @@? 21:2 Error SyntaxError: Unterminated string. */ +/* @@? 21:2 Error SyntaxError: Unexpected token, expected '${' or '`' */ +/* @@? 21:2 Error SyntaxError: Unexpected token, expected '`'. */ ` diff --git a/ets2panda/test/ast/parser/js/test-use-strict-1.js b/ets2panda/test/ast/parser/js/test-use-strict-1.js index d40ae76399..2989a7dd81 100644 --- a/ets2panda/test/ast/parser/js/test-use-strict-1.js +++ b/ets2panda/test/ast/parser/js/test-use-strict-1.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,4 +18,4 @@ var a = 078; -/* @@? 19:10 Error SyntaxError: Implicit octal literal not allowed */ +/* @@? 19:9 Error SyntaxError: Implicit octal literal not allowed. */ diff --git a/ets2panda/test/ast/parser/js/unexpected_token_3.js b/ets2panda/test/ast/parser/js/unexpected_token_3.js index 8e3cef10e9..4d4e9a6cf5 100644 --- a/ets2panda/test/ast/parser/js/unexpected_token_3.js +++ b/ets2panda/test/ast/parser/js/unexpected_token_3.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,6 +18,8 @@ /* @@? 16:6 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 16:6 Error SyntaxError: Unexpected token, expected '=>'. */ /* @@? 16:10 Error SyntaxError: Unexpected token ')'. */ -/* @@? 16:18 Error SyntaxError: Unterminated RegExp */ -/* @@? 16:18 Error SyntaxError: Expected an identifier */ +/* @@? 16:10 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:10 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:12 Error SyntaxError: Unterminated RegExp. */ +/* @@? 16:18 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 16:18 Error SyntaxError: Unexpected token 'eos'. */ diff --git a/ets2panda/test/ast/parser/js/unexpected_token_5.js b/ets2panda/test/ast/parser/js/unexpected_token_5.js index 9372c85404..4dd1232230 100644 --- a/ets2panda/test/ast/parser/js/unexpected_token_5.js +++ b/ets2panda/test/ast/parser/js/unexpected_token_5.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,6 +16,6 @@ ()a/(d)-e; /* @@? 16:3 Error SyntaxError: Unexpected token, expected '=>'. */ -/* @@? 16:11 Error SyntaxError: Unterminated RegExp */ -/* @@? 16:11 Error SyntaxError: Expected an identifier */ +/* @@? 16:5 Error SyntaxError: Unterminated RegExp. */ +/* @@? 16:11 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 16:11 Error SyntaxError: Unexpected token 'eos'. */ diff --git a/ets2panda/test/ast/parser/ts/InvalidExpressions.ts b/ets2panda/test/ast/parser/ts/InvalidExpressions.ts index 31c8cd6fba..a833ab8f08 100644 --- a/ets2panda/test/ast/parser/ts/InvalidExpressions.ts +++ b/ets2panda/test/ast/parser/ts/InvalidExpressions.ts @@ -36,6 +36,11 @@ let x = new Type(1, 2, ; /* @@? 22:13 Error SyntaxError: Unexpected token. */ /* @@? 22:20 Error SyntaxError: Unexpected token. */ /* @@? 22:24 Error SyntaxError: Unexpected token ':'. */ +/* @@? 22:24 Error SyntaxError: Unexpected token ':'. */ +/* @@? 22:24 Error SyntaxError: Unexpected token ':'. */ +/* @@? 22:30 Error SyntaxError: Unexpected token ')'. */ +/* @@? 22:30 Error SyntaxError: Unexpected token ')'. */ +/* @@? 22:30 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:30 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:32 Error SyntaxError: Unexpected token '=>'. */ /* @@? 24:3 Error SyntaxError: Unexpected token '#'. */ diff --git a/ets2panda/test/ast/parser/ts/catch_or_finally_1.ts b/ets2panda/test/ast/parser/ts/catch_or_finally_1.ts index 57aa1e3589..d038313a4c 100644 --- a/ets2panda/test/ast/parser/ts/catch_or_finally_1.ts +++ b/ets2panda/test/ast/parser/ts/catch_or_finally_1.ts @@ -24,9 +24,12 @@ try /* @@ label6 */[] /* @@ label7 */finally {} /* @@? 17:23 Error SyntaxError: Missing catch or finally clause. */ /* @@? 17:51 Error SyntaxError: Unexpected token '{'. */ /* @@? 17:69 Error SyntaxError: Unexpected token 'finally'. */ +/* @@? 17:69 Error SyntaxError: Unexpected token 'finally'. */ /* @@? 18:46 Error SyntaxError: Unexpected token '{'. */ /* @@? 20:20 Error SyntaxError: Expected '{', got '['. */ /* @@? 20:20 Error SyntaxError: Expected '{', got '['. */ /* @@? 20:38 Error SyntaxError: Unexpected token 'finally'. */ -/* @@? 33:1 Error SyntaxError: Expected '}', got 'eos'. */ -/* @@? 33:1 Error SyntaxError: Missing catch or finally clause. */ +/* @@? 20:38 Error SyntaxError: Unexpected token 'finally'. */ +/* @@? 20:38 Error SyntaxError: Unexpected token 'finally'. */ +/* @@? 36:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 36:1 Error SyntaxError: Missing catch or finally clause. */ diff --git a/ets2panda/test/ast/parser/ts/trailing_comma_4.ts b/ets2panda/test/ast/parser/ts/trailing_comma_4.ts index 4178c55668..9518bba08f 100644 --- a/ets2panda/test/ast/parser/ts/trailing_comma_4.ts +++ b/ets2panda/test/ast/parser/ts/trailing_comma_4.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/ets2panda/test/ast/parser/ts/unexpected_token_7.ts b/ets2panda/test/ast/parser/ts/unexpected_token_7.ts index 83d2e4aaca..d8bc503952 100644 --- a/ets2panda/test/ast/parser/ts/unexpected_token_7.ts +++ b/ets2panda/test/ast/parser/ts/unexpected_token_7.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/ets2panda/util/diagnostic/syntax.yaml b/ets2panda/util/diagnostic/syntax.yaml index 37f7297995..5087d8231a 100644 --- a/ets2panda/util/diagnostic/syntax.yaml +++ b/ets2panda/util/diagnostic/syntax.yaml @@ -12,609 +12,609 @@ # limitations under the License. syntax: -- name: MISSING_TYPE_ANNOTATION +- name: NO_ERROR id: 1 + message: "No error." + +- name: MISSING_TYPE_ANNOTATION + id: 2 message: "Missing type annotation for property '{}'." - name: DIFFERENT_PACKAGE_NAME - id: 2 + id: 3 message: "Files '{}' and '{}' are in the same folder, but have different package names." - name: PACKAGE_MODULE_IMPORT_OWN_PACKAGE - id: 3 + id: 4 message: "Package module cannot import from a file in it's own package." - name: AMBIENT_CLASS_MISSING_BODY - id: 4 + id: 5 message: "Ambient class declarations must have a body." - name: EXPORT_DEFAULT_WITH_MUPLTIPLE_SPECIFIER - id: 5 + id: 6 message: "export default is not allowed to export multiple specifiers." - name: NAMESPACE_MERGE_ERROR - id: 6 + id: 7 message: "Unable to merge namespaces '{}', because their modifiers are different." - name: NAMESPACE_ANNOTATION_CONFLICT - id: 7 + id: 8 message: "Annotation conflict! Multiple namespace declarations for '{}' cannot each have annotations." - name: INVALID_NODE_NUMBER - id: 8 + id: 9 message: "Invalid node number in format expression." - name: INVALID_NODE_TYPE - id: 9 + id: 10 message: "Invalid node type in format expression." - name: INSERT_NODE_ABSENT - id: 10 + id: 11 message: "There is no any node to insert at the placeholder position." - name: INVALID_INSERT_NODE - id: 11 + id: 12 message: "Inserting node type differs from that required by format specification." - name: INVALID_CLASS_FIELD - id: 12 + id: 13 message: "Cannot parse class field definition property." - name: INVALID_CLASS_METHOD - id: 13 + id: 14 message: "Cannot parse class method definition property." - name: REQUIRED_PARAM_AFTER_DEFAULT - id: 14 + id: 15 message: "Required parameter follows default parameter(s)." - name: REST_AND_DEFAULT_SAME_TIME - id: 15 + id: 16 message: "Both optional and rest parameters are not allowed in function's parameter list." - name: UNEXPECTED_TOKEN - id: 16 + id: 17 message: "Unexpected token at" - name: INDEX_TYPE_EXPECTED - id: 17 + id: 18 message: "Index type expected in index signature." - name: INDEX_TYPE_NOT_NUMBER - id: 18 + id: 19 message: "Index type must be number in index signature." - name: EXPECTED_BRACKETS_IN_INDEX - id: 19 + id: 20 message: "] expected in index signature." - name: INDEX_MISSING_TYPE - id: 20 + id: 21 message: "An index signature must have a type annotation." - name: INDEX_MISSING_IDENTIFIER - id: 21 + id: 22 message: "Return type of index signature from exported class or interface need to be identifier." - name: EXTENSION_GETTER_WRONG_PARAM - id: 22 + id: 23 message: "Extension Getter can only have 1 parameter." - name: EXTENSION_SETTER_WRONG_PARAM - id: 23 + id: 24 message: "Extension Setter can only have 2 parameters." - name: ANNOTATION_PROPERTY_ACCESS_MODIFIERS - id: 24 + id: 25 message: "Annotation property can not have access modifiers." - name: ANNOTATION_METHOD_AS_PROP - id: 25 + id: 26 message: "Annotation can not have method as property." - name: INVALID_ARGUMENT_PASSED - id: 26 + id: 27 message: "Invalid argument passed to '{}'." - name: INVALID_VAL_ANNOTATION_FIELD - id: 27 + id: 28 message: "Invalid value for annotation field, expected a constant literal." - name: ANNOTATION_WRONG_DEC - id: 28 + id: 29 message: "Annotations are not allowed on this type of declaration." - name: ANNOTATION_ABSTRACT - id: 29 + id: 30 message: "Annotations are not allowed on an abstract class or methods." - name: LOCAL_CLASS_ACCESS_MOD - id: 30 + id: 31 message: "Local class or interface declaration members can not have access modifies." - name: GETTER_SETTER_NOT_ABSTRACT - id: 31 + id: 32 message: "Getter and setter methods must be abstracts in the interface body." - name: PRIVATE_INTERFACE_MISSING_BODY - id: 32 + id: 33 message: "Private interface methods must have body." - name: READONLY_INTERFACE_METHOD - id: 33 + id: 34 message: "Modifier 'readonly' cannot be applied to an interface method." - name: MULTIPLE_STATIC_BLOCK - id: 34 + id: 35 message: "Only one static block is allowed." - name: INVALID_ENUM_TYPE - id: 35 + id: 36 message: "Invalid enum initialization type." - name: INVALID_ENUM_VALUE - id: 36 + id: 37 message: "Invalid enum initialization value." - name: ONLY_CALL_AFTER_LAUNCH - id: 37 + id: 38 message: "Only call expressions are allowed after 'launch'." - name: MISSING_LOOP_AFTER_LABEL - id: 38 + id: 39 message: "Label must be followed by a loop statement." - name: MISSING_CATCH_OR_FINALLY_AFTER_TRY - id: 39 + id: 40 message: "A try statement should contain either finally clause or at least one catch clause." - name: ILLEGAL_START_STRUCT - id: 40 + id: 41 message: "Illegal start of STRUCT expression." - name: ONLY_EXPORT_CLASS_OR_INTERFACE - id: 41 + id: 42 message: "Can only type export class or interface." - name: INVALID_EXPORT_DEFAULT - id: 42 + id: 43 message: "Can not export annotation default." - name: EXPORT_NON_DECLARATION - id: 43 + id: 44 message: "Export is allowed only for declarations." - name: THIS_IN_NON_STATIC_METHOD - id: 44 + id: 45 message: "A 'this' type is available only as return type in a non-static method of a class or struct and extension functions." - name: UNEXPECTED_ID - id: 45 + id: 46 message: "Unexpected identifier." - name: AWAIT_IN_ARROW_FUN_PARAM - id: 46 + id: 47 message: "await is not allowed in arrow function parameters." - name: UNEXPECTED_PRIVATE - id: 47 + id: 48 message: "Unexpected private identifier." - name: IMPORT_META_DIRECT_EVAL - id: 48 + id: 49 message: "'import.Meta' is not allowed in direct eval in module code." - name: INVALID_DESTRUCTURING_TARGET - id: 49 + id: 50 message: "Invalid destructuring assignment target." - name: DELETING_LOCAL_VAR - id: 50 + id: 51 message: "Deleting local variable in strict mode." - name: ASSIGN_TO_EVAL_INVALID - id: 51 + id: 52 message: "Assigning to 'eval' in strict mode is invalid." - name: EXPECTED_EXPRESSION_GOT_ARROW - id: 52 + id: 53 message: "Expected expression, got '=>'." - name: INVALID_LEFT_SITE_OPERATOR - id: 53 + id: 54 message: "Invalid left-hand side operator." - name: YIELD_IN_GENERATOR_PARAM - id: 54 + id: 55 message: "Yield is not allowed in generator parameters." - name: INVALID_REST_ELEMENT - id: 55 + id: 56 message: "Invalid rest element." - name: TAGGED_TEMPLATE_LITERALS_IN_OPTIONALCHAIN - id: 56 + id: 57 message: "Tagged Template Literals are not allowed in optionalChain." - name: ASSIGN_TO_ARGS_INVALID - id: 57 + id: 58 message: "Assigning to 'arguments' in strict mode is invalid." - name: GETTER_FORMAL_PARAMS - id: 58 + id: 59 message: "Getter must not have formal parameters." - name: NULLISH_COALESCING_MISSING_PARENS - id: 59 + id: 60 message: "Nullish coalescing operator ?? requires parens when mixing with logical operators." - name: NEW_WITH_IMPORT - id: 60 + id: 61 message: "Cannot use new with import(...)." - name: UNEXPECTED_SUPER - id: 61 + id: 62 message: "Unexpected super keyword." - name: OBJECT_PATTER_CONTAIN_METHODS - id: 62 + id: 63 message: "Object pattern can't contain methods." - name: SETTER_FORMAL_PARAMS - id: 63 + id: 64 message: "Setter must have exactly one formal parameter." - name: INSUFFICIENT_PARAM_IN_ARROW_FUN - id: 64 + id: 65 message: "Insufficient formal parameter in arrow function." - name: ILLEGAL_AWAIT_IN_ASYNC_FUN - id: 65 + id: 66 message: "Illegal await-expression in formal parameters of async function." - name: YIELD_IN_ARROW_FUN_PARAM - id: 66 + id: 67 message: "yield is not allowed in arrow function parameters." - name: REST_PARAM_NOT_LAST - id: 67 + id: 68 message: "Rest parameter must be the last formal parameter." - name: META_PROP_FOR_IMPORT - id: 68 + id: 69 message: "The only valid meta property for import is import.Meta." - name: IMPORT_META_ONLY_MODULE - id: 69 + id: 70 message: "'import.Meta' may appear only with 'sourceType: module'." - name: DELETING_PRIVATE_FIELDS - id: 70 + id: 71 message: "Private fields can not be deleted." - name: INVALID_LEFT_IN_PREFIX - id: 71 + id: 72 message: "Invalid left-hand side in prefix operation." - name: INVALID_LEFT_SIDE_IN_ASSIGNMENT - id: 72 + id: 73 message: "Invalid left-hand side in assignment expression." - name: NEW_TARGET_IS_NOT_ALLOWED - id: 73 + id: 74 message: "'new.Target' is not allowed here." - name: NEW_TARGET_WITH_ESCAPED_CHARS - id: 74 + id: 75 message: "'new.Target' must not contain escaped characters." - name: INVALID_CLOSING_PARENTHESIS - id: 75 + id: 76 message: "Invalid closing parenthesis." - name: INVALID_CAPTURING_GROUP - id: 76 + id: 77 message: "Invalid capturing group." - name: INVALID_CHAR - id: 77 + id: 78 message: "Invalid character." - name: QUANTIFIER_OUT_OF_ORDER - id: 78 + id: 79 message: "Quantifier range out of order." - name: INVALIDE_CHAR_CLASS - id: 79 + id: 80 message: "Invalid character class." - name: CLASS_OUT_OF_ORDER - id: 80 + id: 81 message: "Class range out of order." - name: INVALID_DECIMAL_ESCAPE - id: 81 + id: 82 message: "Invalid decimal escape." - name: DUPLICATE_GROUP_NAME - id: 82 + id: 83 message: "Duplicate group name." - name: INVALID_HEX_ESCAPE - id: 83 + id: 84 message: "Invalid hex escape." - name: INVALID_GROUP_NAME - id: 84 + id: 85 message: "Invalid group name." - name: INVALID_GROUP - id: 85 + id: 86 message: "Invalid group." - name: UNTERMINATED_UNICODE_PROP_ESCAPE - id: 86 + id: 87 message: "Unterminated Unicode property escape." - name: INVALID_ESCAPE - id: 87 + id: 88 message: "Invalid escape." - name: INVALID_QUANTIFIER - id: 88 + id: 89 message: "Invalid quantifier, nothing to repeat." - name: INVALID_NAME_BACKREFERENCE - id: 89 + id: 90 message: "Invalid named backreference." - name: INVALID_NON_CAPTURING_GROUP - id: 90 + id: 91 message: "Invalid non-capturing group." - name: INVALID_UNICODE_ESCAPE - id: 91 + id: 92 message: "Invalid Unicode escape." - name: INVALID_CONTROL_ESCAPE - id: 92 + id: 93 message: "Invalid control escape." - name: INVALID_ASSERT - id: 93 + id: 94 message: "Invalid assertion." - name: INVALID_UNICODE_PROP_ESCAPE - id: 94 + id: 95 message: "Invalid Unicode property escape." - name: UNEXPECTED_TOKEN_AS - id: 95 + id: 96 message: "Unexpected token, expected 'as'." - name: OPTIONAL_VAR_IN_FOR_OF - id: 96 + id: 97 message: "Optional variable is not allowed in for of statements." - name: FOR_AWAIT_OF_VAR_NOT_INIT - id: 97 + id: 98 message: "for-await-of loop variable declaration may not have an initializer." - name: VARIANCE_NOD_ALLOWED - id: 98 + id: 99 message: "Variance modifier is not allowed here." - name: FUN_PARAM_THIS_MISSING_TYPE - id: 99 + id: 100 message: "The function parameter 'this' must explicitly specify the typeAnnotation." - name: MISSING_INIT_OR_CONST_DEC - id: 100 + id: 101 message: "Missing initializer in const declaration." - name: CATCH_CLAUSE_VAR_HAS_INIT - id: 101 + id: 102 message: "Catch clause variable cannot have an initializer." - name: ASTERIKS_NOT_ALLOWED_IN_SELECTIVE_BINDING - id: 102 + id: 103 message: "The '*' token is not allowed as a selective binding (between braces)." - name: ONLY_THROWS_IN_FUN_TYPE - id: 103 + id: 104 message: "Only 'throws' can be used with function types." - name: DECALRE_IN_AMBIENT_CONTEXT - id: 104 + id: 105 message: "A 'declare' modifier cannot be used in an already ambient context." - name: MISSING_INIT_OR_TYPE - id: 105 + id: 106 message: "Variable must be initialized or it's type must be declared." - name: ASYNC_IN_AMBIENT_CONTEXT - id: 106 + id: 107 message: "The modifier async cannot be used in an ambient context." - name: MODIFIERS_OF_GET_SET_LIMITED - id: 107 + id: 108 message: "Modifiers of getter and setter are limited to ('abstract', 'static', 'final', 'override')." - name: ESCAPE_SEQUENCES_IN_AS - id: 108 + id: 109 message: "Escape sequences are not allowed in 'as' keyword." - name: LOCAL_TYPE_DEC_NO_IMPLEMENTED - id: 109 + id: 110 message: "Local type declaration (class, struct, interface and enum) support is not yet implemented." - name: TYPE_IMPORT_MISSING_SELECTIVE_BINDING - id: 110 + id: 111 message: "Type import requires selective binding to define the required imported elements." - name: EXPORT_IN_NAMESPACE - id: 111 + id: 112 message: "Export declarations are not permitted in a namespace." - name: UNEXPECTED_TOKEN_ID - id: 112 + id: 113 message: "Unexpected token, expected an identifier." - name: ANNOTATION_NOT_ALLOWED - id: 113 + id: 114 message: "Annotations cannot be applied here." - name: ANNOTATION_ONLY_TOP_LEVEL - id: 114 + id: 115 message: "Annotations can only be declared at the top level." - name: DUPLICATED_MODIFIER - id: 115 + id: 116 message: "Duplicated modifier is not allowed." - name: NATIVE_METHOD_ASYNC - id: 116 + id: 117 message: "Native method cannot be async." - name: KEYWORD_CONTAINS_ESCAPED_CHARS - id: 117 + id: 118 message: "Keyword must not contain escaped characters." - name: ABSTRACT_METHOD_ASYNC - id: 118 + id: 119 message: "Abstract method cannot be async." - name: INTERFACE_FIELDS_TYPE_ANNOTATION - id: 119 + id: 120 message: "Interface fields must have type annotation." - name: ACCESS_BEFORE_FIELD_METHOD - id: 120 + id: 121 message: "Access modifier must precede field and method modifiers." - name: FIELD_TPYE_ANNOTATION_MISSING - id: 121 + id: 122 message: "Field type annotation expected." - name: ID_EXPECTED - id: 122 + id: 123 message: "Identifier expected." - name: INITIALIZERS_INTERFACE_PROPS - id: 123 + id: 124 message: "Initializers are not allowed on interface properties." - name: UNEXPECTED_TOKEN_PRIVATE_ID - id: 124 + id: 125 message: "Unexpected token, expected 'private' or identifier." - name: INITIALIZERS_IN_AMBIENT_CONTEXTS - id: 125 + id: 126 message: "Initializers are not allowed in ambient contexts." - name: VAR_DEC_EXPECTED - id: 126 + id: 127 message: "Variable declaration expected." - name: ENUM_MUST_HAVE_ONE_CONST - id: 127 + id: 128 message: "An enum must have at least one enum constant." - name: VALUE_IS_NOT_SET - id: 128 + id: 129 message: "You didn't set the value." - name: TYPE_ALIAS_ONLY_TOP_LEVEL - id: 129 + id: 130 message: "Type alias is allowed only as top-level declaration." - name: INVALID_RIGHT_INSTANCEOF - id: 130 + id: 131 message: "Invalid right-hand side in 'instanceof' expression." - name: IDENTIFIER_EXPECTED - id: 131 + id: 132 message: "Identifier is needed here." - name: DEFAULT_UNDEF_NOT_ALLOWED - id: 132 + id: 133 message: "Not enable default value with default undefined." - name: DEFAULT_ONLY_FOR_OPTIONAL - id: 133 + id: 134 message: "Default value is allowed only for optional parameters." - name: NAMESPACE_ONLY_TOP_OR_IN_NAMESPACE - id: 134 + id: 135 message: "Namespace is allowed only at the top level or inside a namespace." - name: NESTED_FUNCTIONS_NOT_ALLOWED - id: 135 + id: 136 message: "Nested functions are not allowed." - name: SPREAD_MUST_BE_LAST_IN_TUPLE - id: 136 + id: 137 message: "Spread type must be at the last index in the tuple type." - name: PRIMITIVE_NOT_ALLOWED - id: 137 + id: 138 message: "Primitive type is not allowed here." - name: INVALID_TYPE - id: 138 + id: 139 message: "Invalid Type." - name: SPREAD_TYPE_MUST_BE_ARRAY - id: 139 + id: 140 message: "Spread type must be an array type." - name: TYPE_ANNOTATION_FOR_CONSTRUCTOR - id: 140 + id: 141 message: "Type annotation isn't allowed for constructor." - name: READONLY_ONLY_ON_ARRAY_OR_TUPLE - id: 141 + id: 142 message: "'readonly' type modifier is only permitted on array and tuple types." - name: OPTIONAL_TYPES_IN_TUPLE_NOT_IMPLEMENTED - id: 142 + id: 143 message: "Optional types in tuples are not yet implemented." - name: ONLY_SPREAD_AT_LAST_INDEX - id: 143 + id: 144 message: "Only one spread type declaration allowed, at the last index." - name: CLASS_FIELD_CONSTRUCTOR - id: 144 + id: 145 message: "Classes may not have a field named 'constructor'." - name: NOT_ALLOWED_USER_DEFINED_TYPE - id: 145 + id: 146 message: "Cannot be used as user-defined type." - name: EXTENSION_ACCESSOR_RECEIVER - id: 146 + id: 147 message: "Extension Accessor must have a receiver." - name: UNEXPECTED_TOKEN_ID_FUN - id: 147 + id: 148 message: "Unexpected token, expected function identifier." - name: UNEXPECTED_ARROWPARAM_ELEMENT - id: 148 + id: 149 message: "Unexpected ArrowParameter element." - name: SPECIAL_METHOD_CONSTRUCTOR - id: 149 + id: 150 message: "Constructor can not be special method." - name: TRAILING_COMMA_NOT_ALLOWED - id: 150 - message: "Trailing comma is not allowed in this context." - -- name: STATIC_PROPERTY_PROTOTYPE_REMOOOVE id: 151 - message: "Classes may not have a static property named 'prototype'." + message: "Trailing comma is not allowed in this context." - name: UNEXPECTED_TOKEN_STRING_LITERAL id: 152 @@ -967,3 +967,179 @@ syntax: - name: READONLY_TYPE_EXPECTED id: 239 message: "Readonly utility type expected but readonly found." + +- name: INVALID_OCTAL_DIGIT + id: 240 + message: "Invalid octal digit." + +- name: UNTERMINATED_MULTI_LINE_COMMENT + id: 241 + message: "Unterminated multi-line comment." + +- name: INVALID_REGEX_FLAG + id: 242 + message: "Invalid RegExp flag." + +- name: OCTAL_ESCAPE_IN_TEMPLATE_STRINGS + id: 243 + message: "Octal escape sequences are not allowed in template strings." + +- name: HEXADECIMAL_EXPECTED + id: 244 + message: "Hexadecimal digit expected." + +- name: INVALID_NUM + id: 245 + message: "Invalid number." + +- name: INVALID_NUMERIC_SEP_AT_END_OF_NUM + id: 246 + message: "Numeric separators are not allowed at the end of numeric literals." + +- name: INVALID_NUMERIC_LIT + id: 247 + message: "Invalid numeric literal." + +- name: NUMERIC_SEP_UNDERSCORE_IN_NUMBER + id: 248 + message: "Numeric separator '_' is not allowed in numbers that start with '0'." + +- name: UNTERMINATED_STRING + id: 249 + message: "Unterminated string." + +- name: INVALID_NUMERIC_SEP + id: 250 + message: "Invalid numeric separator." + +- name: INVALID_BIGINT + id: 251 + message: "Invalid BigInt number." + +- name: NON_OCTAL_DECIAML_INTEGER_LIT_IN_STRICT_MODE + id: 252 + message: "NonOctalDecimalIntegerLiteral is not enabled in strict mode code." + +- name: IMPLICIT_OCTAL_NOT_ALLOWED + id: 253 + message: "Implicit octal literal not allowed." + +- name: INVALID_CHAR_ESCAPE + id: 254 + message: "Invalid character escape sequence." + +- name: UNEXPECTED_TOKEN_EXPECTED_BACKTICK_OR_DOLLAR_LBRACE + id: 255 + message: "Unexpected token, expected '${' or '`'" + +- name: UNTERMINATED_REGEX + id: 256 + message: "Unterminated RegExp." + +- name: UNSUPPORTED_CHAR_LIT + id: 257 + message: "Unsupported character literal." + +- name: TOO_LARGE_NUM + id: 258 + message: "Number is too large." + +- name: INVALID_IDENTIFIER_PART + id: 259 + message: "Invalid identifier part." + +- name: UNEXPECTED_STRICT_MODE_RESERVED_KEYWORD + id: 260 + message: "Unexpected strict mode reserved keyword." + +- name: NEWLINE_NOT_ALLOWED_IN_STRING + id: 261 + message: "Newline is not allowed in strings." + +- name: INVALID_DIGIT + id: 262 + message: "Invalid digit." + +- name: EXPORT_DEFAULT_IN_REEXPORT + id: 263 + message: "Cannot use 'export default' in re-export context." + +- name: PRIVATE_IDENTIFIER_NOT_CONSTRUCTOR + id: 264 + message: "Private identifier can not be constructor." + +- name: PRIVATE_IDENTIFIER_STRING + id: 265 + message: "Private identifier name can not be string." + +- name: PRIVATE_IDENTIFIER_NUMBER + id: 266 + message: "Private identifier name can not be number." + +- name: UNEXPECTED_CHAR_PRIVATE_IDENTIFIER + id: 267 + message: "Unexpected character in private identifier." + +- name: ESCAPE_SEQUENCES_IN_KEYWORD + id: 268 + message: "Escape sequences are not allowed in keyword." + +- name: ONLY_CONSTANT_EXPRESSION + id: 269 + message: "Only constant expression is expected in the field." + +- name: DIVISION_BY_ZERO + id: 270 + message: "Division by zero are not allowed in Enum or Annotation." + +- name: UNSUPPORTED_OPERATOR_FOR_STRING + id: 271 + message: "Unsupported operator for String." + +- name: STRING_INTERPOLATION_NOT_CONSTANT + id: 272 + message: "String Interpolation Expression is not constant expression." + +- name: ENUM_STRING_TYPE_ALL_ITEMS_INIT + id: 273 + message: "All items of string-type enumeration should be explicitly initialized." + +- name: UNEXPECTED_CHAR_ETSNOLINT + id: 274 + message: "Unexpected character for ETSNOLINT argument! [VALID ONLY: a-z, '-']." + +- name: INVALID_ARGUMENT_ETSNOLINT + id: 275 + message: "Invalid argument for ETSNOLINT!" + +- name: CAN_NOT_FIND_NAME_TO_EXPORT + id: 276 + message: "Cannot find name '{}' to export." + +- name: CAN_NOT_RENAME_ANNOTATION + id: 277 + message: "Can not rename annotation '{}' in export or import statements." + +- name: DUPLICATE_EXPORT_NAME + id: 278 + message: "The given name '{}' is already used in another export." + +- name: ALREADY_EXPORTED + id: 279 + message: "Cannot export '{}', it was already exported." + +- name: NAME_CANNOT_BE_EXPORTED_AND_TYPE_EXPORTED + id: 280 + message: "Name '{}' cannot be exported and type exported at the same time." + +- name: CANNOT_EXPORT_SAME_TYPE_TWICE + id: 281 + message: "Cannot export the same '{}' type twice." + +- name: DUPLICATE_PROTO_FIELDS + id: 282 + message: "Duplicate __proto__ fields are not allowed in object literals." + +- name: INVALID_SHORTHAND_PROPERTY_INITIALIZER + id: 283 + message: "Invalid shorthand property initializer." -- Gitee