diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 5541ac57d5cccf3e8bd73bceeebf9e07e9ab73a1..fe84a350ef119b1d09f4192f9222de0e46925e4d 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2047,7 +2047,8 @@ ir::AstNode *ETSParser::ParseAmbientSignature(const lexer::SourcePosition &start } // eat ":" - if (Lexer()->NextToken(); Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_NUMBER) { + if (Lexer()->NextToken(); Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_NUMBER && + Lexer()->GetToken().KeywordType() != lexer::TokenType::KEYW_INT) { // ambient_indexer_3.ets LogError(diagnostic::INDEX_TYPE_NOT_NUMBER); diff --git a/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets b/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets index 7cf36bcc8b7057d45402c54cb177cf50fe9a53d4..4bc211702aec007aadc16ba78c9c77aae9a249f8 100644 --- a/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets +++ b/ets2panda/test/ast/compiler/ets/DeclareIndexerTest.ets @@ -17,6 +17,13 @@ declare class A { [index: number]: string // indexer declaration } +declare class B { + [index: int] : number +} + +declare interface C { + [index :int]: string + } function main () { diff --git a/ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets b/ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets deleted file mode 100644 index fdc663f300ef9f576d2d764f0a8638fa1446c038..0000000000000000000000000000000000000000 --- a/ets2panda/test/ast/compiler/ets/interface_ambient_indexer_3.ets +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ - -declare interface A { - [index :int]: string - } - /* @@? 17:14 Error SyntaxError: Index type must be number in index signature. */