AdaCore / AdaCore/langkit-query-language
integer_types_as_enum: missing case
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Context
In the following exemple:
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 and arithmetic_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:
procedure Integer_Types_As_Enum is
type T1 is mod 10;
type T2 is new T1;
V1 : T1;
V2 : T2;
begin
declare
type T11 is range 1 .. 10; -- FLAGGED
type T12 is new T1; -- FLAGGED
V11 : T11;
V12 : T12;
begin
if V1 > 1 then
null;
end if;
if V12 in 5 .. 7 then
null;
end if;
end;
V1 := V1 and 1;
V2 := V2 + 1;
declare
type T13 is range 1 .. 10;
type T14 is new T13; -- FLAGGED
subtype ST13 is T13 range 1 .. 5;
function "+" (L, R : ST13) return ST13 is
begin
return L;
end "+";
type Arr_1_13 is array (T1) of Character;
V13 : array (T14) of T2;
VST13 : ST13;
begin
VST13 := VST13 + 1;
end;
declare
type T15 is range 1 .. 10; -- FLAGGED
type T16 is new T15 range 1 .. 5; -- FLAGGED
subtype ST15 is T15 range 1 .. 5;
subtype ST16 is T16 range 1 .. 2;
VST15 : ST15;
VST16 : ST16;
begin
if VST16 in 1 .. 1 then
VST16 := 1;
elsif VST15 < 3 or VST15 = 10 then
VST15 := 9;
end if;
end;
end Integer_Types_As_Enum;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lkql_checker/share/lkql/integer_types_as_enum.lkql at lines 41-45 and compare its handling of referenced types with the Ada example in the issue. The change is complete when types referenced through subtypes or derived types are checked for instantiations and arithmetic operators, and the expected integer-type warnings appear for the shown cases.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100