Open Heziode opened 1 year ago
Furthermore, the control in arithmetic seems wrong. There is missing cases too.
It should be something like:
6,7c6,8
< BinOp(f_op is OpDiv or OpMinus or OpMod or OpMult or
< OpPlus or OpPow or OpRem or OpXor) or
---
> BinOp(f_op is OpAndThen or OpAnd or OpDiv or OpMinus or
> OpMod or OpMult or OpOrElse or OpOr or OpPlus or OpPow or
> OpRem or OpXor) or
9d9
<
Thanks for the report. The first part (missing cases involving subtypes) is currently intentional and as documented at the top of the file (and in the gnatcheck documentation: https://docs.adacore.com/live/wave/lkql/html/gnatcheck_rm/gnatcheck_rm/predefined_rules.html#integer-types-as-enum), so we're talking about a possible enhancement to flag more cases.
The second part is also currently as documented ("and/or" are not arithmetic operators, these are bitwise operators in the case of modular types) although extending this rule to modular integers could be interesting indeed.
Finally note that OpAndThen and OpOrElse are not operators and do not apply to integers, so do not need to be taken into account.
Ok, As I was originally based on the tuto to use this rule, I did not pay attention to the comment.
is currently intentional
Is it a limitation of libadalang? Or LKQL?
"Is it a limitation of libadalang? Or LKQL?"
Neither, it's a decision based made when defining the rule precisely (and can be subject to changes/improvements in the future), to set expectations right and to allow precise testing.
There is no intrinsic limitation in LAL or LKQL here.
Was accidentally closed
Context
In the following exemple:
https://github.com/AdaCore/langkit-query-language/blob/75cec794bacac95cd20906998872ca484f728346/lkql_checker/share/lkql/integer_types_as_enum.lkql#L41-L45
The line 43 should be a conditional check. In the case of a type that is used by a subtype, and none of them uses operators, that case is not handled.
Solution
If types does not have a reference of the type, the we continue the other condition (this is actually what the code does).
However, if types have reference of the type, then we have to check
instantiations
andarithmetic_ops
for every references.So that, we can display a
integer type may be replaced by an enumeration
for type that do not have arithmetic operator, but have reference to this type (subtype, etc.) which also do not use operators.Example: