diff --git a/ets2panda/parser/ETSparserAnnotations.cpp b/ets2panda/parser/ETSparserAnnotations.cpp index cdf4dfb5d05b408c149bf73bba8ab6c6bf43c8ec..452d35330ecb2e5e3207a5e5e735ea08865e2e28 100644 --- a/ets2panda/parser/ETSparserAnnotations.cpp +++ b/ets2panda/parser/ETSparserAnnotations.cpp @@ -373,6 +373,9 @@ static lexer::SourcePosition GetExpressionEndLoc(ir::Expression *expr) return expr->AsIdentifier()->End(); } auto *part = expr->AsETSTypeReference()->Part(); + if (part->Name()->IsBrokenExpression()) { + return part->Name()->End(); + } return part->Name()->AsTSQualifiedName()->Right()->End(); } diff --git a/ets2panda/test/ast/compiler/ets/function_namespace.ets b/ets2panda/test/ast/compiler/ets/function_namespace.ets new file mode 100644 index 0000000000000000000000000000000000000000..218177cc0576f25a40a0bc47a2be2213941a7d5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/function_namespace.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 main () { +export namespace taskpool { + function taskfinished(task:Task) : boolean {} + +/* @@? 17:1 Error SyntaxError: Unexpected token 'export'. */ +/* @@? 17:8 Error SyntaxError: Namespace is allowed only at the top level or inside a namespace. */ +/* @@? 18:32 Error TypeError: Cannot find type 'Task'. */ +/* @@? 25:1 Error SyntaxError: Unexpected token. */ +/* @@? 25:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/compiler/ets/function_signature.ets b/ets2panda/test/ast/compiler/ets/function_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a516601825d7ffa8052117ce023a471493a9ce0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/function_signature.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. + */ + +final class TypeCreateCtx { + internal static native getObjectArrayForCCtor(ctxPtr: long): FixedArray must have only one type parameter. */ +/* @@? 17:88 Error SyntaxError: Unexpected token, expected '>'. */ +/* @@? 17:88 Error SyntaxError: Unexpected token '>'. */ +/* @@? 17:97 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:120 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:138 Error TypeError: Cannot find type 'RuntimeTypeDescriptor'. */