I need to mark as deprecated an array type declaration (well, actually more than just one), in order to help migrate our code to the more advanced and flexible TArray<T>
generic type.
I've tried this:
type
TArrayChars = array of Char deprecated;
but I got a compilation error: E2029 ';' expected but identifier 'deprecated' found
The same works if the declared type isn't an array, for example:
type
TFieldChars = set of Char deprecated;
Note that this should be feasible by design.
What am I missing?
This seems to be a bug in Delphi (at least 10.1 Berlin and 10.2 Tokyo).
My accepted answer proposes a neat workaround, that is:
type
TArrayCharsOld = array of Char;
TArrayChars = TArrayCharsOld deprecated;
I'll file a bug report to Embarcadero.
This is the Embarcadero QC issue I've submitted: https://quality.embarcadero.com/browse/RSP-18316
There is a way around it (at least in 10.1 Berlin).
type
TArrayCharsOld = array of Char;
TArrayChars = TArrayCharsOld deprecated;
compiles.
There's nothing much to say. Dynamic array type declarations cannot be marked as deprecated.
I would consider this to be a defect. The documentation says:
The 'hint' directives platform, deprecated, and library may be appended to any declaration. These directives will produce warnings at compile time. Hint directives can be applied to type declarations, variable declarations, class, interface, and structure declarations, field declarations within classes or records, procedure, function, and method declarations, and unit declarations.
Your dynamic array type declaration meets the requirements listed here since it is a type declaration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With