diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index d7a1834407264781a3745bca70895a5f129c55bb..86f4690bbb1205436527c4641805e43f63e329d8 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -609,6 +609,10 @@ ArenaVector TypedParser::ParseTypeLiteralOrInterfaceBody() LogExpectedToken(lexer::TokenType::PUNCTUATOR_COMMA); } + if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_NEW) { + LogError(diagnostic::ERROR_ARKTS_NO_INTERFACE_CONSTRUCTOR_SIGNATURES); + } + if (Lexer()->GetToken().IsKeyword() && (Lexer()->GetToken().Type() != lexer::TokenType::KEYW_STATIC && Lexer()->GetToken().Type() != lexer::TokenType::KEYW_PRIVATE && Lexer()->GetToken().Type() != lexer::TokenType::KEYW_DEFAULT)) { diff --git a/ets2panda/test/ast/compiler/ets/interface-constructor-signatures_1.ets b/ets2panda/test/ast/compiler/ets/interface-constructor-signatures_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..be0a8fb68ee19ce59912152d8d7b7b64868896e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface-constructor-signatures_1.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. + */ + +class C { + constructor() { } +} + +interface I { + fn(): boolean; + new(): C; +} + +/* @@? 22:5 Error SyntaxError: Constructor signatures are not supported in interfaces, use methods instead! */