Forum > Options
Not used enum
(1/1)
Okoba:
Hello,
There is a very good feature in FPC and Lazarus that shows hints for many unused things.
But I can not find such feature for Enum types, so if one of them is not used, there will be a hint that it is unused so I can take care of that. For example eB is not used in this sample and I like a hint for it.
Is there any option I can turn on, or should I request it as a feature request, to FPC team I guess?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; interface uses not_used_unit; //Unit1.pas(8,3) Hint: Unit "not_used_unit" not used in Unit1 type TEnum = (eA, eB); //Prefer a message here saying "eB" is not used procedure Test;function Test2: TEnum; implementation procedure Test;var V: TEnum; //Unit1.pas(19,3) Note: Local variable "V" not usedbegin end; function Test2: TEnum;begin Result := eA;end; end.
Red_prig:
If I'm not mistaken, there is no such hint for data types.
PascalDragon:
--- Quote from: Okoba on October 08, 2023, 12:31:38 pm ---Is there any option I can turn on, or should I request it as a feature request, to FPC team I guess?
--- End quote ---
First of, in your specific example TEnum is located in the interface-section of the unit, so the compiler can't warn about the enum value eB not being used unside the unit Unit1, because it might be used from another unit.
And secondly enum values can also be accessed through Str, Val, Read(Str/Ln) and Write(Str/Ln), which complicates things as variables might be used to carry the enum value, thus it's easier and less error prone to simply say nothing for enum values that are not used.
Navigation
[0] Message Index