diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 6a1ca88c8ba51e4efcefd264f849c93a809e9a62..99bbca1b39a92171d3216b81c6ad95820559be7a 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2049,6 +2049,7 @@ ir::FunctionDeclaration *ETSParser::ParseFunctionDeclaration(bool canBeAnonymous } if (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_MULTIPLY)) { + LogError(diagnostic::GENERATOR_FUNCTION); newStatus |= ParserStatus::GENERATOR_FUNCTION; } diff --git a/ets2panda/test/ast/parser/ets/generator_function.ets b/ets2panda/test/ast/parser/ets/generator_function.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f865bb644004d26a4883231dd986a68aa88f577 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/generator_function.ets @@ -0,0 +1,17 @@ +/** + * 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() {} +/* @@? 16:11 Error SyntaxError: Generator functions are not supported, please use async/await mechanism for multitasking */ diff --git a/ets2panda/util/diagnostic/syntax.yaml b/ets2panda/util/diagnostic/syntax.yaml index a412c35ab549ada14459b3f41c431bdf0075ed09..47f5f4608b7bc2c76e267511278869a77b03821a 100644 --- a/ets2panda/util/diagnostic/syntax.yaml +++ b/ets2panda/util/diagnostic/syntax.yaml @@ -1230,4 +1230,8 @@ syntax: - name: DEEP_NESTING id: 305 - message: "Maximum allowed nesting level exceeded." \ No newline at end of file + message: "Maximum allowed nesting level exceeded." + +- name: GENERATOR_FUNCTION + id: 306 + message: "Generator functions are not supported, please use async/await mechanism for multitasking"