diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index dd5d023d62c7fecbc4b73fddc9445fff3850ba46..8a8ad698f0dfe1d32a8f9fdd44022ae59d4a4e2a 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -443,7 +443,8 @@ Type *ETSChecker::ApplyUnaryOperatorPromotion(ir::Expression *expr, Type *type, [[fallthrough]]; case TypeFlag::INT: return GlobalIntBuiltinType(); - + case TypeFlag::LONG: + return GlobalLongBuiltinType(); default: break; } diff --git a/ets2panda/test/runtime/ets/long_enum_unary.ets b/ets2panda/test/runtime/ets/long_enum_unary.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ade249bed460f85f44e29c36c431d82afd45ade --- /dev/null +++ b/ets2panda/test/runtime/ets/long_enum_unary.ets @@ -0,0 +1,30 @@ +/* + * 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 LongEnum{ + Neg = -0x1_1111_1111, + Pos = 0x1_1111_1111, + Min = -923372036854775808, + Max = 923372036854775808 + +} + +function main() : void { + let l = +LongEnum.Neg + arktest.assertEQ(+LongEnum.Min,LongEnum.Min) + arktest.assertEQ(+LongEnum.Max,LongEnum.Max) + arktest.assertEQ(+LongEnum.Neg,LongEnum.Neg) + arktest.assertEQ(+LongEnum.Pos,LongEnum.Pos) +} \ No newline at end of file