!10 fix: 比较运算符支持返回 boolean 类型值

Merge pull request !10 from zhangxun/bugfix/fix-binary-operator-not-supports-boolean-result
This commit is contained in:
Luke 2025-06-13 14:07:02 +00:00 committed by Gitee
commit 010f649213
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -67,9 +67,9 @@ public class BinaryExpressionAnalyzer implements ExpressionAnalyzer<BinaryExpres
Type wide = Type.widen(left, right);
if (wide == null) wide = BuiltinType.INT; // 容错降级为 int
// 若为比较运算符统一返回 int 类型作为布尔值表示
// 若为比较运算符统一返回 boolean 类型作为布尔值表示
if ("< <= > >= == !=".contains(op)) {
return BuiltinType.INT;
return BuiltinType.BOOLEAN;
}
return wide;