From 8507ad67477d9abbe488145dee0f13610517aa06 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Fri, 28 Mar 2025 19:24:30 +0800 Subject: [PATCH] partII: Add test case for CTS about SyntaxError TypeError Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBVBDJ Signed-off-by: liujia178 --- .../ets/errors/syntax/escape_sequences.ets | 19 ++++++++++++ .../invalid_left_side_array_destructuring.ets | 21 ++++++++++++++ .../syntax/required_param_after_default.ets | 26 +++++++++++++++++ .../ets/errors/syntax/rest_param_last.ets | 29 +++++++++++++++++++ .../ets/errors/type/annot_multiple_field.ets | 24 +++++++++++++++ ..._null_or_undefined_to_non_nullish_type.ets | 19 ++++++++++++ .../ets/errors/type/cannot_reassign.ets | 24 +++++++++++++++ .../errors/type/cast_to_never_prohibited.ets | 19 ++++++++++++ .../conflicting_generic_interface_impls.ets | 23 +++++++++++++++ .../type/ctor_ref_invalid_ctx_global.ets | 23 +++++++++++++++ .../errors/type/exception_redeclaration.ets | 23 +++++++++++++++ .../compiler/ets/errors/type/index_oob.ets | 18 ++++++++++++ .../errors/type/local_class_invalid_ctx.ets | 25 ++++++++++++++++ .../ets/errors/type/postcond_failed.ets | 20 +++++++++++++ .../errors/type/read_from_writeonly_prop.ets | 26 +++++++++++++++++ .../ets/errors/type/repeated_interface.ets | 20 +++++++++++++ .../type/rtype_param_count_mismatch.ets | 23 +++++++++++++++ .../type/tuple_types_rest_arguments.ets | 24 +++++++++++++++ .../astchecker/astchecker-ets-ignored.txt | 2 ++ 19 files changed, 408 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/errors/syntax/escape_sequences.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_side_array_destructuring.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/syntax/required_param_after_default.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/syntax/rest_param_last.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/annot_multiple_field.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/cannot_cast_null_or_undefined_to_non_nullish_type.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/cannot_reassign.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/cast_to_never_prohibited.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/conflicting_generic_interface_impls.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/ctor_ref_invalid_ctx_global.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/exception_redeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/index_oob.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/local_class_invalid_ctx.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/postcond_failed.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/read_from_writeonly_prop.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/repeated_interface.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/rtype_param_count_mismatch.ets create mode 100644 ets2panda/test/ast/compiler/ets/errors/type/tuple_types_rest_arguments.ets diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/escape_sequences.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/escape_sequences.ets new file mode 100644 index 0000000000..3b73c6a3f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/escape_sequences.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +funct\u{0069}on + +/* @@? 16:1 Error TypeError: Unresolved reference function */ +/* @@? 16:16 Error SyntaxError: Escape sequences are not allowed in keywords */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_side_array_destructuring.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_side_array_destructuring.ets new file mode 100644 index 0000000000..0b01f1bb94 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_side_array_destructuring.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +({...a, b} =) + +/* @@? 16:2 Error SyntaxError: Invalid left-hand side in array destructuring pattern. */ +/* @@? 16:2 Error TypeError: need to specify target type for class composite */ +/* @@? 16:2 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 16:13 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/required_param_after_default.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/required_param_after_default.ets new file mode 100644 index 0000000000..48bbd2b945 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/required_param_after_default.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class testEntry { + value: number; + + constructor(x: number, y?: number, /* @@ label */z: number) { + this.value = x; + } +} + +let entry = new testEntry(1, 2, 3); + +/* @@@ label Error SyntaxError: Required parameter follows default parameter(s). */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/rest_param_last.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/rest_param_last.ets new file mode 100644 index 0000000000..408f825ad9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/rest_param_last.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let lam = (...num: number[]/* @@ label1 */, /* @@ label2 */p/* @@ label3 */: /* @@ label4 */string = "default"/* @@ label5 */) /* @@ label6 */=> {} + +/* @@@ label1 Error SyntaxError: Rest parameter must be the last formal parameter.*/ +/* @@@ label2 Error SyntaxError: Expected '=>', got 'identification literal'. */ +/* @@@ label2 Error TypeError: Unresolved reference p */ +/* @@@ label3 Error SyntaxError: Unexpected token ':'. */ +/* @@@ label3 Error SyntaxError: Unexpected token ':'. */ +/* @@@ label3 Error SyntaxError: Unexpected token ':'. */ +/* @@@ label4 Error TypeError: Type name 'string' used in the wrong context */ +/* @@@ label5 Error SyntaxError: Unexpected token ')'. */ +/* @@@ label5 Error SyntaxError: Unexpected token ')'. */ +/* @@@ label5 Error SyntaxError: Unexpected token ')'. */ +/* @@@ label6 Error SyntaxError: Unexpected token '=>'. */ +/* @@@ label6 Error SyntaxError: Unexpected token '=>'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/annot_multiple_field.ets b/ets2panda/test/ast/compiler/ets/errors/type/annot_multiple_field.ets new file mode 100644 index 0000000000..7139302975 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/annot_multiple_field.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@interface deprecated { + fromVersion: string + endVersion: string +} + +@/* @@ label */deprecated("5.18") +function foo() {} + +/* @@@ label Error TypeError: Annotation 'deprecated' requires multiple fields to be specified. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/cannot_cast_null_or_undefined_to_non_nullish_type.ets b/ets2panda/test/ast/compiler/ets/errors/type/cannot_cast_null_or_undefined_to_non_nullish_type.ets new file mode 100644 index 0000000000..a99cf542aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/cannot_cast_null_or_undefined_to_non_nullish_type.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let entry: undefined = undefined; +/* @@ label */entry as string; + +/* @@@ label Error TypeError: Cannot cast 'null' or 'undefined' to non-nullish type. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/cannot_reassign.ets b/ets2panda/test/ast/compiler/ets/errors/type/cannot_reassign.ets new file mode 100644 index 0000000000..97df923214 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/cannot_reassign.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const /* @@ label */entry: number = 11; + +class testEntry { + constructor() { + entry = 22; + } +} + +/* @@@ label Error TypeError: Cannot reassign constant entry */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/cast_to_never_prohibited.ets b/ets2panda/test/ast/compiler/ets/errors/type/cast_to_never_prohibited.ets new file mode 100644 index 0000000000..e565130a2d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/cast_to_never_prohibited.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let entry: string = 'undefined'; +/* @@ label */entry as never; + +/* @@@ label Error TypeError: Cast to 'never' is prohibited */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/conflicting_generic_interface_impls.ets b/ets2panda/test/ast/compiler/ets/errors/type/conflicting_generic_interface_impls.ets new file mode 100644 index 0000000000..f836c53d64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/conflicting_generic_interface_impls.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface A { +} + +class B implements A, /* @@ label */A { + +} + +/* @@@ label Error TypeError: Implements generic interface 'A' with different instantiations. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/ctor_ref_invalid_ctx_global.ets b/ets2panda/test/ast/compiler/ets/errors/type/ctor_ref_invalid_ctx_global.ets new file mode 100644 index 0000000000..530bd88f64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/ctor_ref_invalid_ctx_global.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function method() { + let a = () => { + console.println(/* @@ label */this./* @@ label1 */prop) + } +} + +/* @@@ label Error TypeError: Cannot reference 'this' in this context. */ +/* @@@ label1 Error TypeError: Property 'prop' does not exist on type 'Error' */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/exception_redeclaration.ets b/ets2panda/test/ast/compiler/ets/errors/type/exception_redeclaration.ets new file mode 100644 index 0000000000..4a93bbea0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/exception_redeclaration.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function main(): void { + try { + } catch (e: Exception) { + } catch (e: Exception) { + } +} + +/* @@? 19:7 Error TypeError: Redeclaration of exception type */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/index_oob.ets b/ets2panda/test/ast/compiler/ets/errors/type/index_oob.ets new file mode 100644 index 0000000000..74905e373a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/index_oob.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +[1][/* @@ label */1] + +/* @@@ label Error TypeError: Index value cannot be greater than or equal to the array size. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/local_class_invalid_ctx.ets b/ets2panda/test/ast/compiler/ets/errors/type/local_class_invalid_ctx.ets new file mode 100644 index 0000000000..48a7d5b772 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/local_class_invalid_ctx.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let arg = '1'; + +function foo () { + switch(arg) { + case '1': + class LocalClass /* @@ label */{} + } +} + +/* @@@ label Error TypeError: Local classes must be defined between balanced braces */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/postcond_failed.ets b/ets2panda/test/ast/compiler/ets/errors/type/postcond_failed.ets new file mode 100644 index 0000000000..bf8016ffe3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/postcond_failed.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function f3(a: int = /* @@ label*/): void; + +/* @@@ label Error TypeError: Postcondition check failed for DefaultParametersLowering */ +/* @@@ label Error SyntaxError: You didn't set the value. */ +/* @@@ label Error SyntaxError: Unexpected token ')'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/errors/type/read_from_writeonly_prop.ets b/ets2panda/test/ast/compiler/ets/errors/type/read_from_writeonly_prop.ets new file mode 100644 index 0000000000..9dbbca0128 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/read_from_writeonly_prop.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class A { + private _filed: number = 1; + set filed(value: number) { + this._filed = value; + } +} + +let instance = new A(); +instance./* @@ label */filed; + +/* @@@ label Error TypeError: Cannot read from this property because it is writeonly. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/repeated_interface.ets b/ets2panda/test/ast/compiler/ets/errors/type/repeated_interface.ets new file mode 100644 index 0000000000..2ec5908e3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/repeated_interface.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface A {} + +class B implements A, /* @@ label */A {} + +/* @@@ label Error TypeError: Repeated interface. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/rtype_param_count_mismatch.ets b/ets2panda/test/ast/compiler/ets/errors/type/rtype_param_count_mismatch.ets new file mode 100644 index 0000000000..3747a11bda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/rtype_param_count_mismatch.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function foo (a: X, b: T) { + return; +} + +/* @@ label */foo("a", "b"); + +/* @@@ label Error TypeError: Expected 2 type arguments, got 1 . */ +/* @@@ label Error TypeError: No matching call signature for foo("a", "b") */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/tuple_types_rest_arguments.ets b/ets2panda/test/ast/compiler/ets/errors/type/tuple_types_rest_arguments.ets new file mode 100644 index 0000000000..ed419fe7a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/tuple_types_rest_arguments.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let tuple: [number, string] = [4, "5"] + +/* @@ label */bar(/* @@ label1 */tuple) + +function bar(...tuple: [number, string]/* @@ label2 */) { } + +/* @@@ label Error TypeError: No matching call signature for bar([Double, String]) */ +/* @@@ label1 Error TypeError: Tuple types for rest arguments are not yet implemented */ +/* @@@ label2 Error SyntaxError: Rest parameter should be of an array type. */ diff --git a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt index 890deb39b0..1b8c2ec726 100644 --- a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt +++ b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt @@ -105,3 +105,5 @@ ast/parser/ets/lambdaWithWrongOptionalParameter.ets # Issue: #24253 ast/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.ets + +ast/compiler/ets/errors/type/postcond_failed.ets \ No newline at end of file -- Gitee