1
1
# Flag all explicit calls to the predefined equality operations for
2
2
# floating-point types and private types whose completions are floating-point
3
3
# types. Both '=' and '/=' operations are checked. User-defined equality
4
- # operations are not flagged, nor are uses of operators that are renamings of
5
- # the predefined equality operations. Also, the '=' and '/=' operations for
6
- # fixed-point types are not flagged.
4
+ # operations are not flagged. Also, the '=' and '/=' operations for fixed-point
5
+ # types are not flagged. Uses of operators that are renamings of the predefined
6
+ # equality operations will be flagged if `follow_renamings` is true .
7
7
8
8
import stdlib
9
9
@@ -12,11 +12,13 @@ fun is_float(n) =
12
12
when t.p_full_view().p_is_float_type()
13
13
14
14
@check(message="use of equality operation for float values", category="Feature")
15
- fun float_equality_checks(node) =
16
- node is (RelationOp(f_op is op@(OpEq or OpNeq))
17
- when stdlib.is_predefined_op(op) and is_float(node.f_left))
15
+ fun float_equality_checks(node, follow_renamings=false) =
16
+ node is (
17
+ RelationOp(f_op is op@(OpEq or OpNeq))
18
+ when stdlib.is_predefined_op(op, follow_renamings) and is_float(node.f_left)
19
+ )
18
20
or CallExpr
19
21
when (node.f_name.p_name_is("\"=\"") or
20
22
node.f_name.p_name_is("\"/=\""))
21
- and stdlib.is_predefined_op(node)
23
+ and stdlib.is_predefined_op(node, follow_renamings )
22
24
and is_float(node.f_suffix[1].f_r_expr)
0 commit comments