Default() intrinsic gives multiple (sometimes incorrect) error messages when passed a variable
Original Reporter info from Mantis: Hixie
-
Reporter name: Ian Hickson
Original Reporter info from Mantis: Hixie
- Reporter name: Ian Hickson
Description:
When you pass Default() a variable (as opposed to a type), the compiler complains twice about the identifier not being a type. If the variable is an object's member variable, it first complains about not being able to find the identifier at all, then complains about expecting a type.
There should be at most one error message here, complaining about wanting a type (or, alternatively, it should just act on the variable's static type, the way TypeInfo() does).
{$MODE OBJFPC}
program test;
type
TTestClass = class
FS: AnsiString;
procedure TestMethod();
end;
procedure TTestClass.TestMethod();
begin
FS := Default(FS); // 'Error: Identifier not found "FS"' and 'Error: Type identifier expected'
end;
var
S: AnsiString;
begin
S := Default(S); // two times 'Error: Type identifier expected'
end.
Mantis conversion info:
- Mantis ID: 25915
- OS: Debian
- Build: trunk 2014/03/18
- Platform: x86_64
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 27464 (#b9a59c33)