diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index a36144f45d6b2f8c142c0f01cfdc65786e791fbf..60a7d7e5d1d0f1c105d8e31b33bcf59ccc2edb4b 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -292,7 +292,7 @@ ir::ClassDeclaration *EnumLoweringPhase::CreateClass(ir::TSEnumDeclaration *cons { auto *ident = Allocator()->New(enumDecl->Key()->Name(), Allocator()); ident->SetRange(enumDecl->Key()->Range()); - auto enumFlag = enumType == EnumType::INT || enumType == EnumType::LONG + auto enumFlag = enumType == EnumType::INT || enumType == EnumType::LONG || enumType == EnumType::DOUBLE ? ir::ClassDefinitionModifiers::INT_ENUM_TRANSFORMED : ir::ClassDefinitionModifiers::STRING_ENUM_TRANSFORMED; auto baseClassDefinitionFlag = ir::ClassDefinitionModifiers::CLASS_DECL | enumFlag; diff --git a/ets2panda/test/runtime/ets/double_enum_assignment.ets b/ets2panda/test/runtime/ets/double_enum_assignment.ets new file mode 100644 index 0000000000000000000000000000000000000000..94a712dd5544abb1e17bf14162ddf3c13e00ce68 --- /dev/null +++ b/ets2panda/test/runtime/ets/double_enum_assignment.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. + */ + +enum E { + x = 1.0, y = 1.1 +} + +function main() { + let x0: number = E.x + arktest.assertEQ(x0, 1.0) + let y0: number = E.y + arktest.assertEQ(y0, 1.1) +}