E2082
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
E2082 means you tried to use a Delphi reserved word (like begin, end, class, type, or record) as a name for a variable, function, or type. Reserved words have special meaning to the compiler and cannot be used as identifiers. Fix it by renaming the identifier to something that is not a Delphi keyword.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- Naming a variable or parameter with a reserved word such as 'type', 'begin', 'end', 'class', or 'record'
- Using a keyword from another language (like 'class' in C++ style) as a Delphi identifier
- Porting code from another language that used valid identifiers that happen to be Delphi keywords
- Using newer Delphi keywords (like 'string', 'object') as names in code written for older Delphi
- Naming an event or property the same as a Delphi keyword in a component
How to Fix It
-
Find the identifier named in the error and rename it to something that is not a Delphi keyword.
For example, rename 'type' to 'ItemType', rename 'class' to 'ItemClass', rename 'end' to 'EndValue'.
-
Use descriptive names that convey meaning rather than single-word generic names — this avoids keyword conflicts and also makes the code more readable.
Instead of 'type' as a variable name, use 'RecordType' or 'CategoryType' which describe what the value represents.
-
When porting code from C, C++, or C#, scan for identifiers that match Delphi keywords: begin, end, type, class, record, object, string, array, set, file, label, goto, var, const, unit, program, procedure, function.
A complete list of Delphi reserved words is in the Delphi documentation under 'Reserved Words'.
-
Use the IDE's Rename refactoring (right-click > Refactor > Rename) to safely rename the identifier in all places it is used at once.
Manual find-and-replace can miss some occurrences. The refactoring tool is safer.
-
Note that Delphi also has directive words (like 'message', 'index', 'stored') that can be used as identifiers in some contexts but not others — avoid them as identifiers for clarity.
When in doubt, choose a clearly descriptive multi-word name to avoid conflicts with any current or future Delphi keywords.
When to Call a Professional
This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.
Frequently Asked Questions
What are the most common Delphi reserved words that trip people up?
The most frequently accidentally used ones are: type (as a variable name), string (as a parameter name), class (as a field name), object, array, set, and file. Programmers coming from C or JavaScript often accidentally use these as variable names. Memorizing the most common ones saves time — the IDE highlights reserved words in bold.
Can I use reserved words as record field names?
No — reserved words cannot be used anywhere as identifiers, including record field names, class property names, or parameter names. Even inside a record or class declaration, reserved words retain their special meaning. Always choose non-keyword names for all identifiers.
Is 'string' a reserved word in Delphi?
Yes — string is a reserved word in Delphi and cannot be used as an identifier. This surprises developers coming from C# or Java where 'string' is a type alias that can occasionally appear in different contexts. In Delphi, use names like 'StringValue', 'TextData', or 'InputString' instead.