diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 1667cf0370a18f7b374f54b3d1ae6dcc5702ddeb..d990bf0c275fee5fd3b7f6e3b0247a73b8382f35 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -927,7 +927,7 @@ static ir::AstNode *HandleBitwiseLogicalExpression(const ir::BinaryExpression *e return HandleNumericBitwiseLogicalExpression(expr, context); } - if (!left->IsBooleanLiteral() && !right->IsBooleanLiteral()) { + if (!left->IsBooleanLiteral() || !right->IsBooleanLiteral()) { LogError(context, diagnostic::WRONG_OPERAND_TYPE_FOR_BINARY_EXPRESSION, {}, expr->Start()); return CreateErrorIdentifier(expr, context->allocator); } diff --git a/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets b/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets new file mode 100644 index 0000000000000000000000000000000000000000..69ec693282a4dbdeaa781a7c0070ec839ebf2b9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/bit_wise_expr.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +let tup : [['arkTs' | boolean, 1 | true]] = [['arkTs', 1]]; + +/* @@? 16:32 Error SyntaxError: Invalid Type. */ +/* @@? 16:32 Error SyntaxError: Unexpected token, expected ',' or ']'. */ +/* @@? 16:32 Error SyntaxError: Unexpected token '1'. */ +/* @@? 16:32 Error TypeError: Wrong type of operands for binary expression */ +/* @@? 16:40 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:41 Error SyntaxError: Unexpected token ']'. */