diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 6a08c0793267ff64310552dba8c2f47a6080a596..505e6eaa95f07d9c747d7d553b9352c16434cdf8 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -616,6 +616,9 @@ static TargetType PerformMultiplicativeOperation(TargetType leftNum, TargetType return std::numeric_limits::max(); } if constexpr (std::is_integral_v) { + if (isIntegralDivideResOverflow()) { + return 0; + } return leftNum % rightNum; } else { return std::fmod(leftNum, rightNum); diff --git a/ets2panda/test/runtime/ets/intmin_mod_minus_1.ets b/ets2panda/test/runtime/ets/intmin_mod_minus_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..0070beeee90568c7c2d25177620a0313638be0a1 --- /dev/null +++ b/ets2panda/test/runtime/ets/intmin_mod_minus_1.ets @@ -0,0 +1,20 @@ +/* + * 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 main() { + const INT_MIN:int = -2147483648; + let a = INT_MIN % -1; + arktest.assertEQ(a, 0); +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/large_number_parse.ets b/ets2panda/test/runtime/ets/large_number_parse.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2d8d033891ecda6e9337a9af75fb0d9340c6cf3 --- /dev/null +++ b/ets2panda/test/runtime/ets/large_number_parse.ets @@ -0,0 +1,18 @@ +/* + * 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. + */ + +const INT_MIN = 0x800000013; +let a = INT_MIN % 10; +arktest.assertEQ(a,7); \ No newline at end of file diff --git a/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt b/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt index e06e50c35de870fd8f1d692f4560aaa42511a845..92528c5c1809707da33564ee5d486d92da0ed261 100644 --- a/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt +++ b/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt @@ -124,3 +124,6 @@ RecursiveTypeAlias10.ets first_match/namespace.ets first_match/namespace2.ets first_match/namespace3.ets + +# Issue #28214 +large_number_parse.ets \ No newline at end of file