diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 716609bc6d72f12ae724ccf726be9ec6f9bb0e48..7d876cf09b6bf6ce04dfd042459fb882ef73ea3c 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -53,7 +53,7 @@ checker::Type *ETSAnalyzer::Check(ir::CatchClause *st) const checker::Type *catchParamAnnotationType = paramIdent->TypeAnnotation()->GetType(checker); exceptionType = checker->CheckExceptionOrErrorType(catchParamAnnotationType, st->Param()->Start()); } else { - exceptionType = checker->GlobalETSObjectType(); + exceptionType = checker->GlobalBuiltinErrorType(); } paramIdent->Variable()->SetTsType(exceptionType); } diff --git a/ets2panda/test/ast/parser/ets/dynmicImportUnimplemented.ets b/ets2panda/test/ast/parser/ets/dynmicImportUnimplemented.ets index 113b6cd6708e1901d8ee56ace99c9313b16601f7..a4ee09a24987b6be71a03f7e5a8fd7d71b3cbab9 100644 --- a/ets2panda/test/ast/parser/ets/dynmicImportUnimplemented.ets +++ b/ets2panda/test/ast/parser/ets/dynmicImportUnimplemented.ets @@ -17,7 +17,7 @@ function main() { try { await import("hello") .then((m: JSValue): null => null) - .catch((a: object | null | undefined): never => { + .catch((a): never => { throw a as Error }) } catch (e) { diff --git a/ets2panda/test/ast/parser/ts/unexpected_token_1.ts b/ets2panda/test/ast/parser/ts/unexpected_token_1.ts index 95d73ea9c1da530acdbb9317e0600a56f1013a6c..2f1e7898c4ec63c508ebf9c10562cc57fb491efa 100644 --- a/ets2panda/test/ast/parser/ts/unexpected_token_1.ts +++ b/ets2panda/test/ast/parser/ts/unexpected_token_1.ts @@ -14,6 +14,6 @@ */ -try {} catch (e: Error /* @@ label */{} finally {} +try {} catch (e /* @@ label */{} finally {} /* @@@ label Error SyntaxError: Unexpected token '{', expected ')'. */ diff --git a/ets2panda/test/ast/parser/ts/unexpected_token_2.ts b/ets2panda/test/ast/parser/ts/unexpected_token_2.ts index 31b139aadf6b976527f62fdbb4c66bb91250a08e..a58981b7a51c120e929c794d8a38f446a5194e7a 100644 --- a/ets2panda/test/ast/parser/ts/unexpected_token_2.ts +++ b/ets2panda/test/ast/parser/ts/unexpected_token_2.ts @@ -14,6 +14,6 @@ */ -try {} catch (e: Error) {} finally /* @@ label */} +try {} catch (e) {} finally /* @@ label */} /* @@@ label Error SyntaxError: Expected '{', got '}'. */ diff --git a/ets2panda/test/compiler/ets/catch-soft-keyword-expected.txt b/ets2panda/test/compiler/ets/catch-soft-keyword-expected.txt index 689d8a583f8d3fba32b086ad002181cd12e51170..a547e43015cdda47827922764f9ac5c17f5b18d8 100644 --- a/ets2panda/test/compiler/ets/catch-soft-keyword-expected.txt +++ b/ets2panda/test/compiler/ets/catch-soft-keyword-expected.txt @@ -718,7 +718,7 @@ "loc": { "start": { "line": 26, - "column": 26, + "column": 19, "program": "catch-soft-keyword.ets" }, "end": { @@ -731,52 +731,6 @@ "param": { "type": "Identifier", "name": "catch", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Error", - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "catch-soft-keyword.ets" - }, - "end": { - "line": 26, - "column": 24, - "program": "catch-soft-keyword.ets" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "catch-soft-keyword.ets" - }, - "end": { - "line": 26, - "column": 24, - "program": "catch-soft-keyword.ets" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "catch-soft-keyword.ets" - }, - "end": { - "line": 26, - "column": 24, - "program": "catch-soft-keyword.ets" - } - } - }, "loc": { "start": { "line": 26, @@ -913,4 +867,3 @@ } } } -Warning: The catch statement with type annotation is deprecated, use catch(e). [catch-soft-keyword.ets:26:19] diff --git a/ets2panda/test/compiler/ets/catch-soft-keyword.ets b/ets2panda/test/compiler/ets/catch-soft-keyword.ets index 343d46f5630b157b22c811b5aab8b8372edfeb87..989e9696a02bf0583613d569053f4e5a7071adb8 100644 --- a/ets2panda/test/compiler/ets/catch-soft-keyword.ets +++ b/ets2panda/test/compiler/ets/catch-soft-keyword.ets @@ -23,6 +23,6 @@ class cls { function foo(): void { let catch: int = 5; try { - } catch (catch: Error) { + } catch (catch) { } } diff --git a/ets2panda/test/compiler/ets/catchParamScope-expected.txt b/ets2panda/test/compiler/ets/catchParamScope-expected.txt index 5ef16e9c33c9c536f8a397d253550bcd76cda147..1f78142c57024c888f5fb6903fe3bd5ddc10c8d7 100644 --- a/ets2panda/test/compiler/ets/catchParamScope-expected.txt +++ b/ets2panda/test/compiler/ets/catchParamScope-expected.txt @@ -81,7 +81,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Object", + "name": "Error", "loc": { "start": { "line": 16, @@ -90,7 +90,7 @@ }, "end": { "line": 16, - "column": 30, + "column": 29, "program": "catchParamScope.ets" } } @@ -103,7 +103,7 @@ }, "end": { "line": 16, - "column": 30, + "column": 29, "program": "catchParamScope.ets" } } @@ -116,7 +116,7 @@ }, "end": { "line": 16, - "column": 30, + "column": 29, "program": "catchParamScope.ets" } } @@ -129,7 +129,7 @@ }, "end": { "line": 16, - "column": 30, + "column": 29, "program": "catchParamScope.ets" } } @@ -142,7 +142,7 @@ }, "end": { "line": 16, - "column": 30, + "column": 29, "program": "catchParamScope.ets" } } @@ -153,12 +153,12 @@ "loc": { "start": { "line": 16, - "column": 33, + "column": 32, "program": "catchParamScope.ets" }, "end": { "line": 16, - "column": 37, + "column": 36, "program": "catchParamScope.ets" } } @@ -169,7 +169,7 @@ "loc": { "start": { "line": 16, - "column": 38, + "column": 37, "program": "catchParamScope.ets" }, "end": { @@ -456,7 +456,7 @@ "loc": { "start": { "line": 22, - "column": 32, + "column": 25, "program": "catchParamScope.ets" }, "end": { @@ -469,52 +469,6 @@ "param": { "type": "Identifier", "name": "error", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Error", - "loc": { - "start": { - "line": 22, - "column": 25, - "program": "catchParamScope.ets" - }, - "end": { - "line": 22, - "column": 30, - "program": "catchParamScope.ets" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 25, - "program": "catchParamScope.ets" - }, - "end": { - "line": 22, - "column": 30, - "program": "catchParamScope.ets" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 25, - "program": "catchParamScope.ets" - }, - "end": { - "line": 22, - "column": 30, - "program": "catchParamScope.ets" - } - } - }, "loc": { "start": { "line": 22, @@ -719,4 +673,3 @@ } } } -Warning: The catch statement with type annotation is deprecated, use catch(e). [catchParamScope.ets:22:25] diff --git a/ets2panda/test/compiler/ets/catchParamScope.ets b/ets2panda/test/compiler/ets/catchParamScope.ets index 0d7fee1ee8ce9aaead14948c45c3d5e35d6fbef8..2dbd3ee7ab3d96557a8d99fd24091840f0b17944 100644 --- a/ets2panda/test/compiler/ets/catchParamScope.ets +++ b/ets2panda/test/compiler/ets/catchParamScope.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -function reject(error: Object): void { +function reject(error: Error): void { } function main(): void { let fn: () => void = (): void => { try { - } catch (error: Error) { + } catch (error) { reject(error); } } diff --git a/ets2panda/test/compiler/ets/tryDefaultCatches-expected.txt b/ets2panda/test/compiler/ets/tryDefaultCatches-expected.txt index 6ac688c6b1a7a8aa0231d4f1cb1cae5e7f4fcc6d..37b6a6d01108f5334be168e5403b2ad061af24d5 100644 --- a/ets2panda/test/compiler/ets/tryDefaultCatches-expected.txt +++ b/ets2panda/test/compiler/ets/tryDefaultCatches-expected.txt @@ -193,7 +193,7 @@ "loc": { "start": { "line": 19, - "column": 22, + "column": 15, "program": "tryDefaultCatches.ets" }, "end": { @@ -206,52 +206,6 @@ "param": { "type": "Identifier", "name": "e", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Error", - "loc": { - "start": { - "line": 19, - "column": 15, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 19, - "column": 20, - "program": "tryDefaultCatches.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 15, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 19, - "column": 20, - "program": "tryDefaultCatches.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 15, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 19, - "column": 20, - "program": "tryDefaultCatches.ets" - } - } - }, "loc": { "start": { "line": 19, @@ -277,53 +231,6 @@ "program": "tryDefaultCatches.ets" } } - }, - { - "type": "CatchClause", - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 21, - "column": 15, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "tryDefaultCatches.ets" - } - } - }, - "param": { - "type": "Identifier", - "name": "e", - "loc": { - "start": { - "line": 21, - "column": 12, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 21, - "column": 13, - "program": "tryDefaultCatches.ets" - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 5, - "program": "tryDefaultCatches.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "tryDefaultCatches.ets" - } - } } ], "finalizer": null, @@ -334,7 +241,7 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 23, + "line": 21, "column": 4, "program": "tryDefaultCatches.ets" } @@ -348,7 +255,7 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 24, + "line": 22, "column": 2, "program": "tryDefaultCatches.ets" } @@ -361,7 +268,7 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 24, + "line": 22, "column": 2, "program": "tryDefaultCatches.ets" } @@ -374,7 +281,7 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 24, + "line": 22, "column": 2, "program": "tryDefaultCatches.ets" } @@ -388,7 +295,7 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 24, + "line": 22, "column": 2, "program": "tryDefaultCatches.ets" } @@ -429,10 +336,9 @@ "program": "tryDefaultCatches.ets" }, "end": { - "line": 25, + "line": 23, "column": 1, "program": "tryDefaultCatches.ets" } } } -Warning: The catch statement with type annotation is deprecated, use catch(e). [tryDefaultCatches.ets:19:15] diff --git a/ets2panda/test/compiler/ets/tryDefaultCatches.ets b/ets2panda/test/compiler/ets/tryDefaultCatches.ets index accfa16406598f876189f920ee1652630ca269db..7aec62e6931969f4ab038c2d07364ab126822e04 100644 --- a/ets2panda/test/compiler/ets/tryDefaultCatches.ets +++ b/ets2panda/test/compiler/ets/tryDefaultCatches.ets @@ -16,8 +16,6 @@ function main(): void { try { throw new NullPointerError(); - } catch (e: Error) { - //Do something. } catch (e) { //Do something. } diff --git a/ets2panda/test/runtime/ets/CastReference3.ets b/ets2panda/test/runtime/ets/CastReference3.ets index e4c0300b0cd970eeb772cb945c06d95a993a7377..3f629b5bbd994967021c8fd8f8c5923855635f67 100644 --- a/ets2panda/test/runtime/ets/CastReference3.ets +++ b/ets2panda/test/runtime/ets/CastReference3.ets @@ -45,10 +45,8 @@ function main() { try { let As: FixedArray = new A[1]; let Bs = As as FixedArray; - } catch (e: ClassCastError) { - caught = true; } catch (e) { - arktest.assertTrue(false) + caught = true; } arktest.assertTrue(caught) } diff --git a/ets2panda/test/runtime/ets/CastReference4.ets b/ets2panda/test/runtime/ets/CastReference4.ets index 1d6541d0c413ae94b4726de489a02f86a5184261..7ae84977f95ab4dfb1fee5ed008b38c369bfb00e 100644 --- a/ets2panda/test/runtime/ets/CastReference4.ets +++ b/ets2panda/test/runtime/ets/CastReference4.ets @@ -32,10 +32,8 @@ function main() { // Element type in array in accumulator is of incompatible type 'A'. // Instruction 'checkcast' will always throw an exception here. It may be a sign of possible error here. let Bs: FixedArray = Is as FixedArray; - } catch (e: ClassCastError) { - caught = true; } catch (e) { - arktest.assertTrue(false) + caught = true } arktest.assertTrue(caught) diff --git a/ets2panda/test/runtime/ets/Enum4.ets b/ets2panda/test/runtime/ets/Enum4.ets index bfac7dcebc85a435ecec9896a98e2b461b0d6625..935d0aeb25f9e0d035da2404312486a235a5e697 100644 --- a/ets2panda/test/runtime/ets/Enum4.ets +++ b/ets2panda/test/runtime/ets/Enum4.ets @@ -86,9 +86,11 @@ function main(): void { try { let yellow: Color = Color.getValueOf("Yellow"); arktest.assertTrue( false) - } catch (e: Error) { - arktest.assertTrue( (e as Object).toString().startsWith("Error: No enum constant Color.Yellow")) - } catch (e) {} + } catch (e) { + if (e instanceof Error) { + arktest.assertTrue( (e as Object).toString().startsWith("Error: No enum constant Color.Yellow")) + } + } ord = 0; let green: Color = ord as Color; @@ -98,7 +100,7 @@ function main(): void { try { let x = 5 as Color; arktest.assertTrue( false) - } catch (e: Error) { + } catch (e) { arktest.assertTrue( (e as Object).toString().startsWith("Error: No enum Color with value 5")) } diff --git a/ets2panda/test/runtime/ets/OptionalChains.ets b/ets2panda/test/runtime/ets/OptionalChains.ets index f42438891591830a61ecae41c4d469191e355ea8..213bbe0f120629291efd7d06fedd680ea38c57c6 100644 --- a/ets2panda/test/runtime/ets/OptionalChains.ets +++ b/ets2panda/test/runtime/ets/OptionalChains.ets @@ -19,7 +19,7 @@ function assert_o(v: Object | null | undefined) { arktest.assertTrue(v !== null function assert_npe(f: () => void) { try { f(); - } catch (e: NullPointerError) { + } catch (e) { return; } arktest.assertTrue(false, "npe was not thrown") diff --git a/ets2panda/test/runtime/ets/SmartCast_08.ets b/ets2panda/test/runtime/ets/SmartCast_08.ets index 0e14d653491caf6d2b6f577265c8b733d75d4c4d..b545a4409018d6a036185998704225e035a14125 100644 --- a/ets2panda/test/runtime/ets/SmartCast_08.ets +++ b/ets2panda/test/runtime/ets/SmartCast_08.ets @@ -25,10 +25,12 @@ function foo(flag: boolean): int { if (flag) { throw new Error(); } - } catch(ex: NullPointerError) { - z = 2; } catch(ex) { - w = undefined; + if (ex instanceof NullPointerError) { + z = 2; + } else { + w = undefined; + } } return x + y! + z + w!; diff --git a/ets2panda/test/runtime/ets/UnboxingCheckcast.ets b/ets2panda/test/runtime/ets/UnboxingCheckcast.ets index d7ddb16a64e38e8862efe31fc98e118b161b9e92..4d32e69b60273a4b57f15e8f417bbaeb08944186 100644 --- a/ets2panda/test/runtime/ets/UnboxingCheckcast.ets +++ b/ets2panda/test/runtime/ets/UnboxingCheckcast.ets @@ -33,8 +33,10 @@ function main() { try{ c as double; - } catch (e: ClassCastError){ - } catch(other) { - arktest.assertEQ(1, 0) + } catch (e) { + if (e instanceof ClassCastError) { + } else { + arktest.assertEQ(1, 0) + } } } diff --git a/ets2panda/test/runtime/ets/array-new-catched.ets b/ets2panda/test/runtime/ets/array-new-catched.ets index 320374a0114ea3c7d44884151122096dc8cf0ce3..b99791248722edd9b454a777b2ca3193fe36dc59 100644 --- a/ets2panda/test/runtime/ets/array-new-catched.ets +++ b/ets2panda/test/runtime/ets/array-new-catched.ets @@ -20,8 +20,10 @@ function baz(): number { let catched = false; try { let a:FixedArray = new int[baz()] - } catch (e: TypeError) { - catched = true + } catch (e) { + if (e instanceof TypeError) { + catched = true + } } arktest.assertTrue(catched) } diff --git a/ets2panda/test/runtime/ets/division-by-zero.ets b/ets2panda/test/runtime/ets/division-by-zero.ets index e38756ea60228c21b53cae4b4e7e83a74734afa2..884c4b8ce0f1928c9b6e8f415cd21e2b4009cd68 100644 --- a/ets2panda/test/runtime/ets/division-by-zero.ets +++ b/ets2panda/test/runtime/ets/division-by-zero.ets @@ -23,29 +23,43 @@ function main() : void { try { let result : int = INT_ONE / INT_ZERO; - } catch (error: ArithmeticError) { - caught_counter++; + } catch (error) { + if (error instanceof ArithmeticError) { + caught_counter++; + } } arktest.assertEQ(caught_counter, 1) try { let result : long = LONG_ONE / LONG_ZERO; - } catch (error: ArithmeticError) { - caught_counter++; + } catch (error) { + if (error instanceof ArithmeticError) { + caught_counter++; + } else { + console.log(error); + } } arktest.assertEQ(caught_counter, 2) try { let result : int = INT_ONE % INT_ZERO; - } catch (error: ArithmeticError) { - caught_counter++; + } catch (error) { + if (error instanceof ArithmeticError) { + caught_counter++; + } else { + console.log(error); + } } arktest.assertEQ(caught_counter, 3) try { let result : long = LONG_ONE % LONG_ZERO; - } catch (error: ArithmeticError) { - caught_counter++; + } catch (error) { + if (error instanceof ArithmeticError) { + caught_counter++; + } else { + console.log(error); + } } arktest.assertEQ(caught_counter, 4) @@ -54,37 +68,61 @@ function main() : void { try { let result : double = DOUBLE_ONE / DOUBLE_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } try { let result = INT_ONE / DOUBLE_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } try { let result = DOUBLE_ONE / INT_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } try { let result : double = DOUBLE_ONE % DOUBLE_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } try { let result = INT_ONE % DOUBLE_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } try { let result = DOUBLE_ONE % INT_ZERO; - } catch (error: ArithmeticError) { - arktest.assertTrue(false) + } catch (error) { + if (error instanceof ArithmeticError) { + arktest.assertTrue(false) + } else { + console.log(error); + } } } diff --git a/ets2panda/test/runtime/ets/finallyClauseThrow.ets b/ets2panda/test/runtime/ets/finallyClauseThrow.ets index 55baa5cdc210a227354da74745216a83cff34b8e..1f988a0dd7d5eb1238673b84f7ca069ae881e999 100644 --- a/ets2panda/test/runtime/ets/finallyClauseThrow.ets +++ b/ets2panda/test/runtime/ets/finallyClauseThrow.ets @@ -17,14 +17,16 @@ function main() : int { try { try { throw new Error(); - } catch (e:Error) { + } catch (e) { arktest.assertTrue(false) } finally { throw new Error(); } - } catch (e:Error) { } catch (e) { - arktest.assertTrue(false) + if (e instanceof Error ) { + }else{ + arktest.assertTrue(false) + } } return 0; } \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/generic_Error_class.ets b/ets2panda/test/runtime/ets/generic_Error_class.ets index 50aa86c29d8a809c25b462be3dfa1a89073cb288..40f23d4b04ca974d9cf2c10260520a859977bdfe 100644 --- a/ets2panda/test/runtime/ets/generic_Error_class.ets +++ b/ets2panda/test/runtime/ets/generic_Error_class.ets @@ -18,10 +18,6 @@ class E extends Error {} function main(): int { try { throw new E(); - } catch (e: E) { - return 0; - } catch (e: E) { - return 0; } catch (e) { return 0; } diff --git a/ets2panda/test/runtime/ets/generic_exception.ets b/ets2panda/test/runtime/ets/generic_exception.ets index 7db4c0e4fb50035f4a54e2737dc3477b44a8497b..fa7f5e78c74f6f4aa7f51ae62d05919e563d8b61 100644 --- a/ets2panda/test/runtime/ets/generic_exception.ets +++ b/ets2panda/test/runtime/ets/generic_exception.ets @@ -18,10 +18,6 @@ class E extends Error {} function main(): int { try { throw new E(); - } catch (e: E) { - return 0; - } catch (e: E) { - return 0; } catch (e) { return 0; } diff --git a/ets2panda/test/runtime/ets/member-expression-nullptr.ets b/ets2panda/test/runtime/ets/member-expression-nullptr.ets index f0eeafcc767a9ebd12bdca097c5e7429ab7d2287..18217414b9cd59a9e774aa4b800ddb5de0f5e615 100644 --- a/ets2panda/test/runtime/ets/member-expression-nullptr.ets +++ b/ets2panda/test/runtime/ets/member-expression-nullptr.ets @@ -44,8 +44,10 @@ function main(): void { try { let residence = (john as Person).residence; - } catch (e: ClassCastError) { + } catch (e) { + if (e instanceof ClassCastError) { test = true; + } } arktest.assertEQ(test, true) @@ -54,7 +56,7 @@ function main(): void { try { let numbers: int = john!.residence.numberOfRooms; - } catch (e: NullPointerError) { + } catch (e) { test = true; } arktest.assertEQ(test, true) @@ -63,7 +65,7 @@ function main(): void { arktest.assertEQ(test, false) try { let numbers: int = foo() + bar() + john!.residence.numberOfRooms; - } catch (e: NullPointerError) { + } catch (e) { test = true; } arktest.assertEQ(test, true) diff --git a/ets2panda/test/runtime/ets/multi-array-new-catched-1.ets b/ets2panda/test/runtime/ets/multi-array-new-catched-1.ets index 353980fef8872f5ef352441052a8aefc8f01b89d..9bdd96e73000d85eea47523ec35ea7dd00537147 100644 --- a/ets2panda/test/runtime/ets/multi-array-new-catched-1.ets +++ b/ets2panda/test/runtime/ets/multi-array-new-catched-1.ets @@ -17,12 +17,12 @@ function main(): void { let A: Array = new Array(); let a: FixedArray>>; - let catched = false; - try { - a = new Number[A.length + 2.][4][A.length + 3.00001]; - } catch (e: TypeError) { - catched = true; - } + let catched = false; + try { + a = new Number[A.length + 2.][4][A.length + 3.00001]; + } catch (e) { + catched = true; + } arktest.assertTrue(catched) } diff --git a/ets2panda/test/runtime/ets/multi-array-new-catched-2.ets b/ets2panda/test/runtime/ets/multi-array-new-catched-2.ets index f518d1b800f8731cc3e75f064a6771df3bf80461..ebf7f0d802bd002836b6ec7f52700986077ae36a 100644 --- a/ets2panda/test/runtime/ets/multi-array-new-catched-2.ets +++ b/ets2panda/test/runtime/ets/multi-array-new-catched-2.ets @@ -23,8 +23,10 @@ function main(): void { let catched = false; try { a = new Number[baz()][4][A.length + 3.0000]; - } catch (e: TypeError) { - catched = true; + } catch (e) { + if (e instanceof TypeError) { + catched = true; + } } arktest.assertTrue(catched) diff --git a/ets2panda/test/runtime/ets/notNull.ets b/ets2panda/test/runtime/ets/notNull.ets index cf3943bff0f0f3c6fa2177f4c14075298bb0b577..f28e77b2c6fd00fa87b847c97268508c38a54c68 100644 --- a/ets2panda/test/runtime/ets/notNull.ets +++ b/ets2panda/test/runtime/ets/notNull.ets @@ -101,7 +101,7 @@ function testNPE() : void { try { (o as Object | null)!; arktest.assertTrue(false, "this must not be executed") - } catch (ex: NullPointerError) { + } catch (ex) { npe_caught = true; } @@ -110,7 +110,7 @@ function testNPE() : void { try { baz()!; arktest.assertTrue(false, "this must not be executed") - } catch (ex: NullPointerError) { + } catch (ex) { npe_caught = true; } diff --git a/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets b/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets index c1fe13d93e07aa815e93b5a3347f7a78448b5d84..0b2d399d649f7a0495fd9b7e312c3fd5339ace15 100644 --- a/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets +++ b/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets @@ -116,12 +116,12 @@ function main() { try { new DTree().up(); arktest.assertTrue(false) - } catch (e: NullPointerError) { } + } catch (e) { } testb(); try { testf(123); arktest.assertTrue(false) - } catch (e: NullPointerError) { } + } catch (e) { } arktest.assertTrue((testcond() instanceof Int) && (testcond() == 1)) foo(123); diff --git a/ets2panda/test/runtime/ets/optional-chaining-function-call.ets b/ets2panda/test/runtime/ets/optional-chaining-function-call.ets index b4b6bac3362b531b2c531339cdac4bd756f2e240..c716ddd26133f423dd903098e8ddcd046fcaecb2 100644 --- a/ets2panda/test/runtime/ets/optional-chaining-function-call.ets +++ b/ets2panda/test/runtime/ets/optional-chaining-function-call.ets @@ -34,7 +34,7 @@ function foo(a: funcType | null) { let test = false; try { fruit = a!(); - } catch (e: NullPointerError) { + } catch (e) { test = true; } diff --git a/ets2panda/test/runtime/ets/signature_match_lambda.ets b/ets2panda/test/runtime/ets/signature_match_lambda.ets index 5d7055c93cb0c9c301b275f40f0c1cfef9b24659..23b0d381450b8f647920adc0f0ec600f6e2864e5 100644 --- a/ets2panda/test/runtime/ets/signature_match_lambda.ets +++ b/ets2panda/test/runtime/ets/signature_match_lambda.ets @@ -35,8 +35,5 @@ class A { function main(){ let a = new A() arktest.assertEQ(a.catch(()=>{}),"first catch is matched") - arktest.assertEQ(a.catch((e:Error|undefined|null)=>{}),"second catch is matched") - arktest.assertEQ(a.catch((e:Error)=>{}),"second catch is matched") - arktest.assertEQ(a.catch((e:Error,e2:Error)=>{}),"third catch is matched") - arktest.assertEQ(a.catch((e:Error,e2:Error,e3:Error)=>{}),"fourth catch is matched") + arktest.assertEQ(a.catch((e)=>{}),"second catch is matched") } diff --git a/ets2panda/test/runtime/ets/top_level_02.ets b/ets2panda/test/runtime/ets/top_level_02.ets index a76b771d15a5cbb06e6e0fd153276c30c9923eb5..60342dd876310ba07267f479442560ca8c7fab52 100644 --- a/ets2panda/test/runtime/ets/top_level_02.ets +++ b/ets2panda/test/runtime/ets/top_level_02.ets @@ -38,10 +38,11 @@ try { q += 5; throw new TestError(); } -catch (e: TestError) { -} catch (e) { - arktest.assertTrue(false) + if (e instanceof TestError) { + } else { + arktest.assertTrue(false) + } } arktest.assertEQ(q, 8) diff --git a/ets2panda/test/runtime/ets/try-catch-error.ets b/ets2panda/test/runtime/ets/try-catch-error.ets index 5428c1e6c629ad2acc15364a1b43126d491fc0af..83c7cb8b28137a2108a344f35f71694bbe4bc723 100644 --- a/ets2panda/test/runtime/ets/try-catch-error.ets +++ b/ets2panda/test/runtime/ets/try-catch-error.ets @@ -20,40 +20,47 @@ let catchCode = 0; function main(): void { try { throw new DivideByZeroError(); - } catch (p: DivideByZeroError) { - catchCode = 1; - } catch (p: Error) { - arktest.assertTrue(false) + } catch (p) { + if (p instanceof DivideByZeroError) { + catchCode = 1; + } else if (p instanceof Error) { + arktest.assertTrue(false) + } } - arktest.assertEQ(catchCode, 1) try { throw new DivideByZeroError(); - } catch (p: Error) { - catchCode = 2; - } catch (p: DivideByZeroError) { - arktest.assertTrue(false) + } catch (p) { + if (p instanceof Error) { + catchCode = 2; + } else if (p instanceof DivideByZeroError) { + arktest.assertTrue(false) + } } arktest.assertEQ(catchCode, 2) try { throw new TestError(); - } catch (p: TestError) { - catchCode = 3; - } catch (p: Error) { - arktest.assertTrue(false) + } catch (p) { + if (p instanceof TestError) { + catchCode = 3; + } else if (p instanceof Error) { + arktest.assertTrue(false) + } } arktest.assertEQ(catchCode, 3) try { throw new TestError(); - } catch (p: Error) { - catchCode = 4; - } catch (p: TestError) { - arktest.assertTrue(false) + } catch (p) { + if (p instanceof Error) { + catchCode = 4; + } else if (p instanceof TestError) { + arktest.assertTrue(false) + } } arktest.assertEQ(catchCode, 4) diff --git a/ets2panda/test/runtime/ets/try-catch.ets b/ets2panda/test/runtime/ets/try-catch.ets index cfe155b47fe231e7af0005c8018b075a00724a47..f0777cd96911bc1e9fef65860b73c56ac2ae4425 100644 --- a/ets2panda/test/runtime/ets/try-catch.ets +++ b/ets2panda/test/runtime/ets/try-catch.ets @@ -20,49 +20,47 @@ let catchCode = 0; function main(): void { try { throw new NullPointerError(); - } catch (e: NullPointerError) { - catchCode = 1; - } catch (e: Error) { - arktest.assertTrue(false) } catch (e) { - arktest.assertTrue(false) + if (e instanceof NullPointerError) { + catchCode = 1; + } else { + arktest.assertTrue(false) + } } - arktest.assertEQ(catchCode, 1) try { throw new NullPointerError(); - } catch (e: Error) { - catchCode = 2; - } catch (e: NullPointerError) { - arktest.assertTrue(false) } catch (e) { - arktest.assertTrue(false) + if (e instanceof Error) { + catchCode = 2; + } else if (e instanceof NullPointerError) { + arktest.assertTrue(false) + } else { + arktest.assertTrue(false) + } } - arktest.assertEQ(catchCode, 2) try { throw new TestError(); - } catch(e: TestError) { - catchCode = 3; - } catch (e: Error) { - arktest.assertTrue(false) - } catch (e) { - arktest.assertTrue(false) + } catch(e) { + if (e instanceof TestError) { + catchCode = 3; + } else { + arktest.assertTrue(false) + } } - arktest.assertEQ(catchCode, 3) try { throw new TestError(); - } catch (e: Error) { - catchCode = 4; - } catch (e: TestError) { - arktest.assertTrue(false) } catch (e) { - arktest.assertTrue(false) + if (e instanceof Error) { + catchCode = 4; + } else { + arktest.assertTrue(false) + } } - arktest.assertEQ(catchCode, 4) } diff --git a/ets2panda/test/runtime/ets/union_type_RTE.ets b/ets2panda/test/runtime/ets/union_type_RTE.ets index 0c73ea88d3f91be6dc4b4bba1db151f30d794901..5412b37bfc0f342aceece312200ab3643bf3b0c8 100644 --- a/ets2panda/test/runtime/ets/union_type_RTE.ets +++ b/ets2panda/test/runtime/ets/union_type_RTE.ets @@ -29,8 +29,10 @@ function main() { try { foo(new A(11) as Object) - } catch (error: ClassCastError) { - caught_counter++ + } catch (error) { + if (error instanceof ClassCastError) { + caught_counter++ + } } arktest.assertEQ(caught_counter, 1) diff --git a/ets2panda/test/unit/public/ast_verifier_check_scope_declaration_test.cpp b/ets2panda/test/unit/public/ast_verifier_check_scope_declaration_test.cpp index c5d4a0d67cbea8e5f0fdb3ce737fb0e1386e37b1..3805861dfe28e0d0f6c108e01985e85127b4e0d3 100644 --- a/ets2panda/test/unit/public/ast_verifier_check_scope_declaration_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_check_scope_declaration_test.cpp @@ -90,7 +90,7 @@ TEST_F(ASTVerifierTest, TryCatch) try { throw new NullPointerError(); - } catch (e: NullPointerError) { + } catch (e) { catchCode = 1; } }