From 615009421ff237f14fb3a2c03a7ffd91d580a50f Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Tue, 3 Jan 2023 12:44:22 +0100 Subject: [PATCH] Initialize Compiler::Error as INVALID Do not print Error object when its type is INVALID. Change-Id: I911dfe4dd1275495d89e1289cdfa6da26bbe8d5c Signed-off-by: Roland Takacs --- aot/main.cpp | 3 ++- es2panda.h | 3 ++- test/compiler/ts/arrayDestructuring-expected.txt | 1 - test/compiler/ts/assignment_unknown-expected.txt | 1 - test/compiler/ts/functionCall-expected.txt | 1 - test/compiler/ts/interfaceAssignment-expected.txt | 1 - .../interfacePropertyReferenceContainingInterface-expected.txt | 1 - test/compiler/ts/interface_enum_member-expected.txt | 1 - test/compiler/ts/memberExpTests-expected.txt | 1 - test/compiler/ts/member_expression_78-expected.txt | 1 - test/compiler/ts/member_expression_79-expected.txt | 1 - test/compiler/ts/member_expression_9-expected.txt | 1 - test/compiler/ts/objectDestructuring-expected.txt | 1 - test/compiler/ts/objectLiteralAssignability-expected.txt | 1 - test/compiler/ts/test-interface-expected.txt | 1 - test/compiler/ts/test-type-literal-expected.txt | 1 - test/compiler/ts/tupleAssignability-expected.txt | 1 - test/compiler/ts/undefined_as_value-expected.txt | 1 - test/compiler/ts/varRedeclaration-expected.txt | 1 - 19 files changed, 4 insertions(+), 19 deletions(-) diff --git a/aot/main.cpp b/aot/main.cpp index 3db96ff20..54295a061 100644 --- a/aot/main.cpp +++ b/aot/main.cpp @@ -137,7 +137,8 @@ int Run(int argc, const char **argv) if (program == nullptr) { const auto &err = compiler.GetError(); - if (err.Message().empty() && options->ParseOnly()) { + // Intentional exit or --parse-only option usage. + if (err.Type() == ErrorType::INVALID) { return 0; } diff --git a/es2panda.h b/es2panda.h index 77fa3a8e4..0f328a953 100644 --- a/es2panda.h +++ b/es2panda.h @@ -73,6 +73,7 @@ struct CompilerOptions { }; enum class ErrorType { + INVALID, GENERIC, SYNTAX, TYPE, @@ -143,7 +144,7 @@ public: } private: - ErrorType type_ {ErrorType::GENERIC}; + ErrorType type_ {ErrorType::INVALID}; std::string file_; std::string message_; size_t line_ {}; diff --git a/test/compiler/ts/arrayDestructuring-expected.txt b/test/compiler/ts/arrayDestructuring-expected.txt index e6ad2a68f..ae094194a 100644 --- a/test/compiler/ts/arrayDestructuring-expected.txt +++ b/test/compiler/ts/arrayDestructuring-expected.txt @@ -8755,4 +8755,3 @@ } } } -Error: [arrayDestructuring.ts:0:0] diff --git a/test/compiler/ts/assignment_unknown-expected.txt b/test/compiler/ts/assignment_unknown-expected.txt index bdf591b33..a05df3d19 100644 --- a/test/compiler/ts/assignment_unknown-expected.txt +++ b/test/compiler/ts/assignment_unknown-expected.txt @@ -407,4 +407,3 @@ } } } -Error: [assignment_unknown.ts:0:0] diff --git a/test/compiler/ts/functionCall-expected.txt b/test/compiler/ts/functionCall-expected.txt index e8cf67536..d917eae1d 100644 --- a/test/compiler/ts/functionCall-expected.txt +++ b/test/compiler/ts/functionCall-expected.txt @@ -5475,4 +5475,3 @@ } } } -Error: [functionCall.ts:0:0] diff --git a/test/compiler/ts/interfaceAssignment-expected.txt b/test/compiler/ts/interfaceAssignment-expected.txt index 93661c502..8aa74554e 100644 --- a/test/compiler/ts/interfaceAssignment-expected.txt +++ b/test/compiler/ts/interfaceAssignment-expected.txt @@ -4101,4 +4101,3 @@ } } } -Error: [interfaceAssignment.ts:0:0] diff --git a/test/compiler/ts/interfacePropertyReferenceContainingInterface-expected.txt b/test/compiler/ts/interfacePropertyReferenceContainingInterface-expected.txt index d72a8ca0c..cef1e6bf6 100644 --- a/test/compiler/ts/interfacePropertyReferenceContainingInterface-expected.txt +++ b/test/compiler/ts/interfacePropertyReferenceContainingInterface-expected.txt @@ -1077,4 +1077,3 @@ } } } -Error: [interfacePropertyReferenceContainingInterface.ts:0:0] diff --git a/test/compiler/ts/interface_enum_member-expected.txt b/test/compiler/ts/interface_enum_member-expected.txt index a6a33734d..5f3e4aec4 100644 --- a/test/compiler/ts/interface_enum_member-expected.txt +++ b/test/compiler/ts/interface_enum_member-expected.txt @@ -203,4 +203,3 @@ } } } -Error: [interface_enum_member.ts:0:0] diff --git a/test/compiler/ts/memberExpTests-expected.txt b/test/compiler/ts/memberExpTests-expected.txt index b48db1f9e..6f0b1ce2e 100644 --- a/test/compiler/ts/memberExpTests-expected.txt +++ b/test/compiler/ts/memberExpTests-expected.txt @@ -5931,4 +5931,3 @@ } } } -Error: [memberExpTests.ts:0:0] diff --git a/test/compiler/ts/member_expression_78-expected.txt b/test/compiler/ts/member_expression_78-expected.txt index f9dadc6e0..fa7436069 100644 --- a/test/compiler/ts/member_expression_78-expected.txt +++ b/test/compiler/ts/member_expression_78-expected.txt @@ -332,4 +332,3 @@ } } } -Error: [member_expression_78.ts:0:0] diff --git a/test/compiler/ts/member_expression_79-expected.txt b/test/compiler/ts/member_expression_79-expected.txt index 515f12895..4c63bd917 100644 --- a/test/compiler/ts/member_expression_79-expected.txt +++ b/test/compiler/ts/member_expression_79-expected.txt @@ -388,4 +388,3 @@ } } } -Error: [member_expression_79.ts:0:0] diff --git a/test/compiler/ts/member_expression_9-expected.txt b/test/compiler/ts/member_expression_9-expected.txt index 570482b03..713af92f8 100644 --- a/test/compiler/ts/member_expression_9-expected.txt +++ b/test/compiler/ts/member_expression_9-expected.txt @@ -430,4 +430,3 @@ } } } -Error: [member_expression_9.ts:0:0] diff --git a/test/compiler/ts/objectDestructuring-expected.txt b/test/compiler/ts/objectDestructuring-expected.txt index 5e728496b..bb02d9ce4 100644 --- a/test/compiler/ts/objectDestructuring-expected.txt +++ b/test/compiler/ts/objectDestructuring-expected.txt @@ -8724,4 +8724,3 @@ } } } -Error: [objectDestructuring.ts:0:0] diff --git a/test/compiler/ts/objectLiteralAssignability-expected.txt b/test/compiler/ts/objectLiteralAssignability-expected.txt index aa7b53851..9d55aed3b 100644 --- a/test/compiler/ts/objectLiteralAssignability-expected.txt +++ b/test/compiler/ts/objectLiteralAssignability-expected.txt @@ -8851,4 +8851,3 @@ } } } -Error: [objectLiteralAssignability.ts:0:0] diff --git a/test/compiler/ts/test-interface-expected.txt b/test/compiler/ts/test-interface-expected.txt index ebda8543d..e2c6a65af 100644 --- a/test/compiler/ts/test-interface-expected.txt +++ b/test/compiler/ts/test-interface-expected.txt @@ -1079,4 +1079,3 @@ } } } -Error: [test-interface.ts:0:0] diff --git a/test/compiler/ts/test-type-literal-expected.txt b/test/compiler/ts/test-type-literal-expected.txt index 91a075c80..b982eec26 100644 --- a/test/compiler/ts/test-type-literal-expected.txt +++ b/test/compiler/ts/test-type-literal-expected.txt @@ -1799,4 +1799,3 @@ } } } -Error: [test-type-literal.ts:0:0] diff --git a/test/compiler/ts/tupleAssignability-expected.txt b/test/compiler/ts/tupleAssignability-expected.txt index 4d6016f59..8225600c8 100644 --- a/test/compiler/ts/tupleAssignability-expected.txt +++ b/test/compiler/ts/tupleAssignability-expected.txt @@ -7622,4 +7622,3 @@ } } } -Error: [tupleAssignability.ts:0:0] diff --git a/test/compiler/ts/undefined_as_value-expected.txt b/test/compiler/ts/undefined_as_value-expected.txt index a68f938fe..9b39f2f0a 100644 --- a/test/compiler/ts/undefined_as_value-expected.txt +++ b/test/compiler/ts/undefined_as_value-expected.txt @@ -493,4 +493,3 @@ } } } -Error: [undefined_as_value.ts:0:0] diff --git a/test/compiler/ts/varRedeclaration-expected.txt b/test/compiler/ts/varRedeclaration-expected.txt index f2bdff3ec..a18fe84cd 100644 --- a/test/compiler/ts/varRedeclaration-expected.txt +++ b/test/compiler/ts/varRedeclaration-expected.txt @@ -6858,4 +6858,3 @@ } } } -Error: [varRedeclaration.ts:0:0] -- Gitee