diff --git a/ets2panda/parser/ETSparserAnnotations.cpp b/ets2panda/parser/ETSparserAnnotations.cpp index d377daed371c12ab551e5258e7ae29e4283e6722..1f28da767405023f0ad85ef60104ca7fe9c5dd30 100644 --- a/ets2panda/parser/ETSparserAnnotations.cpp +++ b/ets2panda/parser/ETSparserAnnotations.cpp @@ -200,6 +200,7 @@ ir::AstNode *ETSParser::ParseAnnotationProperty(ir::Identifier *fieldName, ir::M if (typeAnnotation == nullptr && (memberModifiers & ir::ModifierFlags::ANNOTATION_DECLARATION) != 0 && !fieldName->IsErrorPlaceHolder()) { LogError(diagnostic::MISSING_TYPE_ANNOTATION, {fieldName->Name().Mutf8()}, Lexer()->GetToken().Start()); + typeAnnotation = AllocBrokenType(Lexer()->GetToken().Loc()); } if (typeAnnotation != nullptr) { diff --git a/ets2panda/test/ast/compiler/ets/annotation_type.ets b/ets2panda/test/ast/compiler/ets/annotation_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..031907ccff4ad968a38bbb2ddca8bc5f0de6c00a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_type.ets @@ -0,0 +1,63 @@ +/* + * 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 MyValue { + siz([1, 2, 3]) + +class A { + @MyValue([1, 2, 3]) + foo() {} +} + +@MyValue([1, 2, 3]) +function globalFunc() {} + +function main(){}unction main() + +/* @@? 17:8 Error SyntaxError: Missing type annotation for property 'siz'. */ +/* @@? 17:8 Error SyntaxError: Annotation can not have method as property. */ +/* @@? 17:8 Error SyntaxError: Identifier expected, got '('. */ +/* @@? 17:10 Error SyntaxError: Identifier expected, got '['. */ +/* @@? 17:11 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 17:13 Error SyntaxError: Identifier expected, got 'number literal'. */ +/* @@? 17:14 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 17:16 Error SyntaxError: Identifier expected, got 'number literal'. */ +/* @@? 17:17 Error SyntaxError: Identifier expected, got ']'. */ +/* @@? 17:18 Error SyntaxError: Identifier expected, got ')'. */ +/* @@? 19:1 Error SyntaxError: Identifier expected, got 'class'. */ +/* @@? 19:9 Error SyntaxError: Missing type annotation for property 'A'. */ +/* @@? 19:9 Error SyntaxError: Identifier expected, got '{'. */ +/* @@? 20:5 Error SyntaxError: Identifier expected, got '@'. */ +/* @@? 20:13 Error SyntaxError: Annotation can not have method as property. */ +/* @@? 20:13 Error SyntaxError: Missing type annotation for property 'MyValue'. */ +/* @@? 20:13 Error SyntaxError: Identifier expected, got '('. */ +/* @@? 20:15 Error SyntaxError: Identifier expected, got '['. */ +/* @@? 20:16 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 20:18 Error SyntaxError: Identifier expected, got 'number literal'. */ +/* @@? 20:19 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 20:21 Error SyntaxError: Identifier expected, got 'number literal'. */ +/* @@? 20:22 Error SyntaxError: Identifier expected, got ']'. */ +/* @@? 20:23 Error SyntaxError: Identifier expected, got ')'. */ +/* @@? 21:8 Error SyntaxError: Annotation can not have method as property. */ +/* @@? 21:8 Error SyntaxError: Identifier expected, got '('. */ +/* @@? 21:8 Error SyntaxError: Missing type annotation for property 'foo'. */ +/* @@? 21:9 Error SyntaxError: Identifier expected, got ')'. */ +/* @@? 21:11 Error SyntaxError: Identifier expected, got '{'. */ +/* @@? 21:12 Error SyntaxError: Identifier expected, got '}'. */ +/* @@? 22:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 24:2 Error TypeError: Annotation 'MyValue' requires multiple fields to be specified. */ +/* @@? 24:10 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */ +/* @@? 27:18 Error TypeError: Unresolved reference unction */ +/* @@? 27:26 Error SyntaxError: Unexpected token 'main'. */ diff --git a/ets2panda/test/ast/compiler/ets/bigInt_unbox.ets b/ets2panda/test/ast/compiler/ets/bigInt_unbox.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0844fc01dc5ab9546328eda907d6648a9d4f7f7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/bigInt_unbox.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 checker(id_main: int) { + return (id_main != id_current) ? 0 : 1n's{ +} + +/* @@? 17:10 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ +/* @@? 17:22 Error TypeError: Unresolved reference id_current */ +/* @@? 17:42 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 17:42 Error SyntaxError: Unexpected token 's{'. */ diff --git a/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets b/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets index f8549d009358117bff9f746d9bc5c1b29952d70c..e7656e6b36c9d723693d25cd04240b051c8f41c8 100644 --- a/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets +++ b/ets2panda/test/ast/parser/ets/anno_interface_invalid_error.ets @@ -47,3 +47,4 @@ class C{ /* @@? 29:4 Error SyntaxError: Missing type annotation for property 'b'. */ /* @@? 42:11 Error SyntaxError: Only constant expression is expected in the field */ +/* @@? 44:16 Error TypeError: Invalid annotation field type. Only numeric, boolean, string, enum, or arrays of these types are permitted for annotation fields. */