Entry No.
504
|
Compiler - Error during compile
Internal errors SY1703 (in Delphi 3), SY2149 (in Delphi 4),
SY2192 (in Delphi 5), SY2358 (in Kylix) and SY2394 (in Delphi 6).
|
|
| 1.02 |
2.01 |
3.0 |
3.01 |
3.02 |
4.0 |
4.01 |
4.02 |
4.03 |
5.0 |
5.01 |
6.0 |
6.01 |
6.02 |
Kylix 1.0 |
| Absent | Absent | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists | Exists |
|
|
|
Description | |
Reported by Vladimir Merzliakov; checked by Reinier Sterkenburg
To reproduce:
Attach the following unit to any project and compile.
unit uTest504;
interface
type
TClass1 = object
protected
function Func1: integer;
property Prop1: integer read Func1;
end;
TClass2 = object(TClass1)
public
property Prop1;
end;
TClass3 = object(TClass1)
public
property Prop1: integer read Func1;
end;
function Main: integer;
implementation
function TClass1.Func1;
begin
Result := 1;
end;
function Main: integer;
var
C2: TClass2;
C3: TClass3;
begin
Result := C3.Prop1; // no crash
Result := C2.Prop1; // Compiler crash with SY2149 internal error
end;
end.
The characteristics are:
- If an old object model type (TClass1) has a protected property (Prop1)
- and Prop1 has a read method
- and a descendant of TClass1 (TClass2) changes the visibility of
Prop1 to public
- and variable (C2) has type TClass2
then the compiler gives the error message
"Internal error SY2149" on the expression C2.Prop1. |
|
|
Solution / workaround | |
|
Do not use visibility change of properties in old object model types.
Redefine the property in descendant, instead.
|
|