diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/catch_clause_var_has_init.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/catch_clause_var_has_init.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a5b1b28d15983aaa66a881198d9cf75f94a383f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/catch_clause_var_has_init.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ + +try { + throw new Exception(); +} catch (e = 0) { + //Do something. +} + +/* @@? 18:12 Error SyntaxError: Catch clause variable cannot have an initializer. */ +/* @@? 18:12 Error SyntaxError: Expected ')', got '='. */ +/* @@? 18:12 Error SyntaxError: Expected '{', got '='. */ +/* @@? 18:12 Error SyntaxError: Expected '{', got '='. */ +/* @@? 18:12 Error SyntaxError: Unexpected token '='. */ +/* @@? 18:15 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:15 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:15 Error SyntaxError: Unexpected token ')'. */ +/* @@? 31:1 Error SyntaxError: Expected '}', got 'eos'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/default_undef_not_allowed.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/default_undef_not_allowed.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d2a8f5d68853e3045cdb135a6a2381339a2e24e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/default_undef_not_allowed.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. + */ + +function f2(a?: int = /* @@ label */44): void {} + +/* @@@ label Error SyntaxError: Not enable default value with default undefined. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/duplicated_modifier.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/duplicated_modifier.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c69efec0b9cb39a9d19e0b0aebe3e6ae849c5d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/duplicated_modifier.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. + */ + +abstract /* @@ label */abstract class B { +} + +/* @@@ label Error SyntaxError: Duplicated modifier is not allowed. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/extension_setter_wrong_param.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/extension_setter_wrong_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef9ca5d36f2a16d56782687825321364aa14945a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/extension_setter_wrong_param.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. + */ + +class A{ + field_: int; +} + +/* @@ label */set field(this: A, a: int, b: int) { + +} + +/* @@@ label Error SyntaxError: Extension Setter can only have 2 parameters. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/for_in_loop_has_init.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/for_in_loop_has_init.ets new file mode 100644 index 0000000000000000000000000000000000000000..84ec416e04acbb0800353546879834150e93bafb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/for_in_loop_has_init.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. + */ + +for (let i = 1 /* @@ label */of [0, 1, 2]) {} + +/* @@@ label Error SyntaxError: for-of loop variable declaration may not have an initializer. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/identifier_expected.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/identifier_expected.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f80ede9948b2bb63a70d553ffc217d5469a7ad0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/identifier_expected.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 f1(a: int, ...b: int[] = /* @@ label */47/* @@ label1 */) { +} + +/* @@@ label Error SyntaxError: Rest parameter cannot have the default value. */ +/* @@@ label1 Error SyntaxError: Identifier is needed here. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/illegal_use_strict.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/illegal_use_strict.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0be055b3eee20c456b39424d789d3f2c59313a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/illegal_use_strict.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 f(x: number, ... args: number[]) { + /* @@ label */"use strict" +} + +/* @@@ label Error SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/implements_clause_empty.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/implements_clause_empty.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b59264af71a10bd6445cfd19e101a90c833c0aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/implements_clause_empty.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. + */ + +class A implements /* @@ label */{} + +/* @@@ label Error SyntaxError: Implements clause can not be empty. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/implicit_octal_literal_not_allowed.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/implicit_octal_literal_not_allowed.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3ef93cc2f8c0abd5703e2766bfe3d18266699a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/implicit_octal_literal_not_allowed.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. + */ + +const n2 = 0134 + +/* @@? 16:12 Error SyntaxError: Implicit octal literal not allowed. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/initializers_interface_props.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/initializers_interface_props.ets new file mode 100644 index 0000000000000000000000000000000000000000..f645ec780d5aef1252a2fbe500925ed96f7c216c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/initializers_interface_props.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 { + readonly filed: number /* @@ label */== /* @@ label1 */1/* @@ label2 */; +} + +/* @@@ label Error SyntaxError: Initializers are not allowed on interface properties. */ +/* @@@ label1 Error SyntaxError: Unexpected token, expected ','. */ +/* @@@ label1 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@@ label2 Error SyntaxError: Identifier expected. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/insert_node_absent.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/insert_node_absent.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d265db7678ec5eac0a0ca52c9350430ffcd0c77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/insert_node_absent.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. + */ + +let /* @@ label */@@/* @@ label1 */I2 + +/* @@@ label Error SyntaxError: There is no any node to insert at the placeholder position. */ +/* @@@ label Error SyntaxError: Identifier expected, got '@@'. */ +/* @@@ label1 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@@ label1 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@@ label1 Error SyntaxError: Unexpected token 'I2'. */ +/* @@@ label1 Error TypeError: Unresolved reference I2 */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_bigInt_number.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_bigInt_number.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e466348ea32cb1d3ad78d56e8ea6a62a8f8fcba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_bigInt_number.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. + */ + +0x291n + +/* @@? 16:1 Error SyntaxError: Invalid BigInt number. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_character.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_character.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2392d48d111004115802b3718cea9e0302b69b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_character.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. + */ + +\U4444 + +/* @@? 16:1 Error SyntaxError: Invalid character. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_digit.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_digit.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd28141a871b35165ac0bbacb1a1f38cf6d7d4d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_digit.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. + */ + +const badBin = 0bF0011101 + +/* @@? 16:16 Error SyntaxError: Invalid digit. */ +/* @@? 16:18 Error SyntaxError: Unexpected token 'F0011101'. */ +/* @@? 16:18 Error TypeError: Unresolved reference F0011101 */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_end_numeric_separators.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_end_numeric_separators.ets new file mode 100644 index 0000000000000000000000000000000000000000..d885c4b2f61a5b18dc25944750a5c37570363513 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_end_numeric_separators.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. + */ + +0o251042_ + +/* @@? 16:1 Error SyntaxError: Numeric separators are not allowed at the end of numeric literals. */ +/* @@? 16:9 Error SyntaxError: Unexpected token '_'. */ +/* @@? 16:9 Error TypeError: Unresolved reference _ */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_identifier_part.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_identifier_part.ets new file mode 100644 index 0000000000000000000000000000000000000000..053437bd52f84f8d1230f454bace5e2d2ecfa6a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_identifier_part.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. + */ + +undef\u0xFF00ned + +/* @@? 16:1 Error SyntaxError: Invalid Unicode escape. */ +/* @@? 16:1 Error SyntaxError: Invalid identifier part. */ +/* @@? 16:1 Error TypeError: Unresolved reference undefFF00ned */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_in_prefix.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_in_prefix.ets new file mode 100644 index 0000000000000000000000000000000000000000..ebcb9d578fa72cb7e45c6f63577dc0b13d76a9da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_in_prefix.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. + */ + +--58 + +/* @@? 19:1 Error SyntaxError: Invalid left-hand side in prefix operation. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_site_operator.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_site_operator.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6ad5986a6008050916fb66b17447a817097773b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_left_site_operator.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 f4() { + 69/* @@ label */++ +} + +/* @@@ label Error SyntaxError: Invalid left-hand side operator. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_literal.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_literal.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c896865fd6d2475a88c853fcf68ee1a91876c27 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_literal.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. + */ + +const f1 = 1.00000000f1 + +/* @@? 16:12 Error SyntaxError: Invalid numeric literal. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_separator.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_separator.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e116eb766477285ee4bddc1dcc4de51a32a0979 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_numeric_separator.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. + */ + +/* @@ label */0x0D00__0000 + +/* @@@ label Error SyntaxError: Invalid numeric separator. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_decimal_integer_literal.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_decimal_integer_literal.ets new file mode 100644 index 0000000000000000000000000000000000000000..18a234867f6db0aaa64a212fd36b3e2718a6c5d6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_decimal_integer_literal.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. + */ + +const n2 = /* @@ label */0999 + +/* @@@ label Error SyntaxError: NonOctalDecimalIntegerLiteral is not enabled in strict mode code. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_digit.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_digit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb4f84dfca9db85e7dd0db6eae37de0b7ffa5cce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_octal_digit.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. + */ + +const o1 = /* @@ label */0o0008 + +/* @@@ label Error SyntaxError: Invalid octal digit. */ +/* @@@ label Error SyntaxError: Invalid numeric literal. */ +/* @@? 16:31 Error SyntaxError: Unexpected token '8'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_unicode_escape_sequence.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_unicode_escape_sequence.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f6fdb1da821b782cb82eea31f6888784b9536cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_unicode_escape_sequence.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. + */ + +/* @@ label */"\u{0x0096}" + +/* @@@ label Error SyntaxError: Invalid Unicode escape. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_union_type.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_union_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e012dde996d4b3fbddd4b21f0be18d8a9028c4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/invalid_union_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. + */ + +type A = undefined | null | int +/* @@ label */new A() + +/* @@@ label Error TypeError: The union type is not constructible. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/label_already_declared.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/label_already_declared.ets new file mode 100644 index 0000000000000000000000000000000000000000..5637c2cb74b6631926423e30c2de386412f246a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/label_already_declared.ets @@ -0,0 +1,30 @@ +/* + * 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 f(x: int): void { + for (let i = 0; i < x; ++i) { + aa: + while (i < 10) { + /* @@ label */aa: + while (i > 10) { + ++i + break aa + } + ++i + } + } +} + +/* @@@ label Error SyntaxError: Label already declared. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/multiple_default.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/multiple_default.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5238645f17d08df486a94111fc800bd9d9e438a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/multiple_default.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. + */ + +function g(x: int): int { + switch (x) { + case 1: return 0; + default: return -1; + /* @@ label */default: return -2; + } +} + +/* @@@ label Error SyntaxError: Multiple default clauses. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/native_flag_only_for_top_fun.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/native_flag_only_for_top_fun.ets new file mode 100644 index 0000000000000000000000000000000000000000..22854ecb34d9bcdfe6030c4d673c66a98b1073f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/native_flag_only_for_top_fun.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. + */ + +native /* @@ label */class /* @@ label1 */Z /* @@ label2 */{/* @@ label3 */} + +/* @@@ label Error SyntaxError: 'native' flags must be used for functions only at top-level. */ +/* @@@ label1 Error TypeError: Native and Declare methods should have explicit return type. */ +/* @@@ label2 Error SyntaxError: Unexpected token, expected '('. */ +/* @@@ label3 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@@ label3 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@@ label3 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@@ label3 Error SyntaxError: Unexpected token '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/number_is_too_large.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/number_is_too_large.ets new file mode 100644 index 0000000000000000000000000000000000000000..80a0bed4897bb1717552dad80f8c730192fe0ff0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/number_is_too_large.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. + */ + +const n4 = /* @@ label */0xFFFFFFFFFFFFFFFF0 + +/* @@@ label Error SyntaxError: Number is too large. */ +/* @@? 16:44 Error SyntaxError: Unexpected token '0'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/numeric_separator_start_with_zero.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/numeric_separator_start_with_zero.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fd6a07cec50ef31ecad013b8d94a2cac4e13005 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/numeric_separator_start_with_zero.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. + */ + +const n3 = /* @@ label */0_01 + +/* @@@ label Error SyntaxError: Numeric separator '_' is not allowed in numbers that start with '0'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/only_array_for_rest.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/only_array_for_rest.ets new file mode 100644 index 0000000000000000000000000000000000000000..291e5944a84dbfce88d20bf954f9e526d2c691f7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/only_array_for_rest.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 foo(...p: Object/* @@ label */): Object { + return new Object(); +} + +/* @@@ label Error SyntaxError: Rest parameter should be either array or tuple type. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/return_in_fun_body.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/return_in_fun_body.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e6352e1964629923338e081988bd9da1b1231da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/return_in_fun_body.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. + */ + +/* @@ label */return /* @@ label1 */48; + +/* @@@ label Error SyntaxError: return keyword should be used in function body. */ +/* @@@ label1 Error TypeError: All return statements in the function should be empty or have a value. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_cannot_be_async.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_cannot_be_async.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc2f2f12abe0beb00ef8244fb1a4f5f4b7a257fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_cannot_be_async.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +abstract class B { + /* @@ label */async $_get(a: int): Promise { + return 5; + } +} + +/* @@@ label Error SyntaxError: The special predefined method '$_get' cannot be asynchronous. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_one_param.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_one_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..9faf2196ec8a22ce171eed6b5db6db7b9ddb333b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_one_param.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +abstract class B { + /* @@ label */$_get(): int { + return 5; + } +} + +/* @@@ label Error SyntaxError: The special predefined method '$_get' should have exactly one required parameter. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_two_params.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_two_params.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce818cbf8fccdfcea74c786fbeddd8a3b8c105e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_have_two_params.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. + */ + +abstract class B { + /* @@ label */$_set(): void {} +} + +/* @@@ label Error SyntaxError: The special predefined method '$_set' should have exactly two required parameter. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_not_have_params.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_not_have_params.ets new file mode 100644 index 0000000000000000000000000000000000000000..72cc6e625ab025d167974ae0c3d40030f2b1e828 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/special_predefined_method_should_not_have_params.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. + */ + +abstract class B { + /* @@ label */abstract $_iterator(a: int): Iterator +} + +/* @@@ label Error SyntaxError: The special predefined method '$_iterator' should not have parameters. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/unexpected_super.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/unexpected_super.ets new file mode 100644 index 0000000000000000000000000000000000000000..962c5a4e4449fea934f3884791cf628dd8dc7b29 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/unexpected_super.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. + */ + +/* @@ label */super/* @@ label1 */() + +/* @@@ label Error TypeError: Call to 'super' must be first statement in constructor */ +/* @@@ label1 Error SyntaxError: Unexpected super keyword. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/unsupported_character_literal.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/unsupported_character_literal.ets new file mode 100644 index 0000000000000000000000000000000000000000..863e9aa4434b7bc4e615c584abc9ab74e59cbb38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/unsupported_character_literal.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. + */ + +const c2 = /* @@ label */c'😀' + +/* @@@ label Error SyntaxError: Unsupported character literal. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/syntax/unterminated_string.ets b/ets2panda/test/ast/compiler/ets/errors/syntax/unterminated_string.ets new file mode 100644 index 0000000000000000000000000000000000000000..d806127547b37038cc3a9af978b41f7575080cfd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/syntax/unterminated_string.ets @@ -0,0 +1,22 @@ +/* + * 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 expr = "test"; +`string ${expr + +/* @@? 23:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 23:1 Error SyntaxError: Unterminated string. */ +/* @@? 23:1 Error SyntaxError: Unexpected token, expected '${' or '`' */ +/* @@? 23:1 Error SyntaxError: Unexpected token, expected '`'. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/abstract_in_concrete.ets b/ets2panda/test/ast/compiler/ets/errors/type/abstract_in_concrete.ets new file mode 100644 index 0000000000000000000000000000000000000000..225b5e23718b2bf49dd24933ca697021e44acc14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/abstract_in_concrete.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. + */ + +class A /* @@ label */{ + /* @@ label1 */abstract foo(); +} + +/* @@@ label Error TypeError: A is not abstract and does not override abstract method foo(): void in A */ +/* @@@ label1 Error TypeError: Non abstract class has abstract method. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/abstract_instantiation.ets b/ets2panda/test/ast/compiler/ets/errors/type/abstract_instantiation.ets new file mode 100644 index 0000000000000000000000000000000000000000..afad3f8848d536cccc4203bed26e10d336f768da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/abstract_instantiation.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. + */ + +abstract class AbstractLocalClass{ + method1(){} +} +let a:AbstractLocalClass = /* @@ label */new AbstractLocalClass(); + +/* @@@ label Error TypeError: AbstractLocalClass is abstract therefore cannot be instantiated. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/abstract_is_final.ets b/ets2panda/test/ast/compiler/ets/errors/type/abstract_is_final.ets new file mode 100644 index 0000000000000000000000000000000000000000..0213d29343933143d1a33a0f5006c36842406b04 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/abstract_is_final.ets @@ -0,0 +1,22 @@ +/* + * 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_class{ + foo(){ + abstract final class AbstractFinalLocalClass/* @@ label */{} + } +} + +/* @@@ label Error TypeError: Cannot use both 'final' and 'abstract' modifiers. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/ambient_const_invalid_lit.ets b/ets2panda/test/ast/compiler/ets/errors/type/ambient_const_invalid_lit.ets new file mode 100644 index 0000000000000000000000000000000000000000..943a1a72d7117ba4250d5a0f9003375021544d11 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/ambient_const_invalid_lit.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. + */ + +export declare const int_1 = /* @@ label */1 + 2 + 3 + 4 + +/* @@@ label Error TypeError: A 'const' initializer in an ambient context must be a string or numeric literal: int_1 */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/assert_not_logical.ets b/ets2panda/test/ast/compiler/ets/errors/type/assert_not_logical.ets new file mode 100644 index 0000000000000000000000000000000000000000..a56bb6730a4bcf4785bd3bab4db7ef681bb71d14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/assert_not_logical.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. + */ + +! + +/* @@? 20:1 Error SyntaxError: Unexpected token 'eos'. */ +/* @@? 20:1 Error TypeError: Bad operand type, the type of the operand must be boolean type. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/assignment_invalid_lhs.ets b/ets2panda/test/ast/compiler/ets/errors/type/assignment_invalid_lhs.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f30b4e7d15542d8e1ad0372d8d5d3af9ce18148 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/assignment_invalid_lhs.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. + */ + +function foo() { + /* @@ label */55 /* @@ label1 */= int; +} + +/* @@@ label Error TypeError: Invalid left-hand side of assignment expression */ +/* @@@ label1 Error SyntaxError: Invalid left-hand side in assignment expression. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/binop_union.ets b/ets2panda/test/ast/compiler/ets/errors/type/binop_union.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9fbd78c3c90b5dbbf0afad49859f61db998f845 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/binop_union.ets @@ -0,0 +1,34 @@ +/* + * 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 Cat { + name: string = 'cat'; +} + +class Dog { + name: string = 'dog'; +} + +type Animal = Cat | Dog | number; + +let cat: Animal = new Cat(); +let dog: Animal = new Dog(); +cat < dog; +cat & dog; +cat << 2; + +/* @@? 28:1 Error TypeError: Bad operand type, unions are not allowed in binary expressions except equality. */ +/* @@? 29:1 Error TypeError: Bad operand type, unions are not allowed in binary expressions except equality. */ +/* @@? 30:1 Error TypeError: Bad operand type, unions are not allowed in binary expressions except equality. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/infer_failure_func_param.ets b/ets2panda/test/ast/compiler/ets/errors/type/infer_failure_func_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc13add92695138f5f581a50c43e6f82c1a66f9f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/infer_failure_func_param.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. + */ + +function f(/* @@ label */a/* @@ label1 */): void {} + +/* @@@ label Error TypeError: The type of parameter 'a' cannot be inferred */ +/* @@@ label1 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/invalid_enums.ets b/ets2panda/test/ast/compiler/ets/errors/type/invalid_enums.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e930b55fa0eeb52c806fb470b3811a862ec700e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/invalid_enums.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. + */ + +enum EStrNotInit { + Str1 = "str1", + Str2 +} + +/* @@? 18:9 Error SyntaxError: All items of string-type enumeration should be explicitly initialized. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/mixed_void_nonvoid.ets b/ets2panda/test/ast/compiler/ets/errors/type/mixed_void_nonvoid.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e6352e1964629923338e081988bd9da1b1231da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/mixed_void_nonvoid.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. + */ + +/* @@ label */return /* @@ label1 */48; + +/* @@@ label Error SyntaxError: return keyword should be used in function body. */ +/* @@@ label1 Error TypeError: All return statements in the function should be empty or have a value. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/multiple_spreads.ets b/ets2panda/test/ast/compiler/ets/errors/type/multiple_spreads.ets new file mode 100644 index 0000000000000000000000000000000000000000..3860e66de592afefe2e8b5894f35077b70e91362 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/multiple_spreads.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(...numbers: number[]): number { + return numbers[0] +} +let a = [0,1,2] +/* @@ label */foo(a[0], a[1], /* @@ label1 */...a) + +/* @@@ label Error TypeError: No matching call signature for foo(double, double, double) */ +/* @@@ label1 Error TypeError: Spread argument for the rest parameter can be only one. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/not_generic.ets b/ets2panda/test/ast/compiler/ets/errors/type/not_generic.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d52da0ac4fec60a2160f780cd4f31a8d9dc3e6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/not_generic.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. + */ + +let entry: /* @@ label */Int = new Int(); + +/* @@@ label Error TypeError: Type 'Int' is not generic. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/not_interface.ets b/ets2panda/test/ast/compiler/ets/errors/type/not_interface.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5ad29b7566e012d59db9fb90c4ecf1a61df3a31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/not_interface.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. + */ + +namespace MySpace { + let a:string = "1" +} + +class B implements /* @@ label */MySpace{} + +/* @@@ label Error TypeError: Namespace 'MySpace' cannot be used as a type. */ +/* @@@ label Error TypeError: Interface expected here. */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/switch_case_invalid_type.ets b/ets2panda/test/ast/compiler/ets/errors/type/switch_case_invalid_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..27a58739aabd2efc6178e2803569dd06aee00366 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/switch_case_invalid_type.ets @@ -0,0 +1,35 @@ +/* + * 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 with_param(fn: () => int): void { + fn() +} + +function main(): void { + const switch_arg = 2 + const aa = 1.0; + with_param() { + switch (switch_arg) { + /* @@ label */case aa: + break + case 2: + break + default: assertTrue(false, "Not expected execution here"); + } + return 0; + } +} + +/* @@@ label Error TypeError: Unexpected type double */ diff --git a/ets2panda/test/ast/compiler/ets/errors/type/template_count_mismatch.ets b/ets2panda/test/ast/compiler/ets/errors/type/template_count_mismatch.ets new file mode 100644 index 0000000000000000000000000000000000000000..4794212cce1de548db14d0bb77d2122ae58f9eef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/errors/type/template_count_mismatch.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. + */ + +const o = /* @@ label */`\251` + +/* @@@ label Error TypeError: Invalid string template expression */ +/* @@@ label Error SyntaxError: Invalid character escape sequence. */ +/* @@? 16:26 Error SyntaxError: Invalid character escape sequence. */ +/* @@? 16:26 Error SyntaxError: Octal escape sequences are not allowed in template strings. */