[Patch] Clarity in directive conflict error messages
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch aims to give clearer error messages if a procedure directive conflicts with another (e.g. using "virtual" and "inline" together). Currently, it doesn't explain exactly what the conflict is and can be very confusing. For example, if you have the following:
----
type
TestClass = class
procedure Test; virtual;
end;
procedure TestClass.Test; inline;
begin
{ Do something }
end;
----
The error received is "Procedure directive "VIRTUAL" has conflicts with other directives", giving very few clues that it's conflicting with "inline" and it should be the latter that should be removed. When inside a class declaration, it might throw an additional error when it tries to then interpret the conflicting keyword as an identifier, since it is not consumed by the compiler when the conflict error is thrown.
The new message is of the format:
Procedure directive "$1" cannot be used with $2
Normally, $2 is a keyword surrounded in double quotation marks, but in some instances might be a short title such as 'variable argument lists' (to represent the option "po_varargs") or not actually be a directive, but the method type (e.g. "CONSTRUCTOR"). Compilation code has been modified to find the best keyword or language-neutral phrase (as best as possible) to use in these instances.
The keyword is also now consumed prior to the conflict checks (since at this point it's definitely known to be a keyword) in order to avoid the error cascade.
Steps to reproduce:
N/A
Additional information:
The patch contains the modified msgidx.inc and msgtxt.inc files compiled from msg2inc with the modified errore.msg file. Other language files have not yet been touched if only because I'm not fluent enough in them, but the error messages should still work because the first parameter has not been modified, while the second one is silently ignored.
The other error message calls in parse_proc_direc have been modified so Lazarus correctly highlights the erroneous keyword rather than the trailing semicolon.
A possibly-erroneous calling convention string was fixed (MS_ABI_CDecl was changed to SysV_ABI_CDecl at one point) and a "TODO" comment was put in because there seems to be a missing 'exit'.
Mantis conversion info:
- Mantis ID: 33754
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: x86_64-win64-win32/win64 (38866)
- Platform: win64
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 39407 (#0eea2141)
- Target version: 3.3.1