Classes with extended syntax off
Original Reporter info from Mantis: Adriaan van Os
-
Reporter name: Adriaan van Os
Original Reporter info from Mantis: Adriaan van Os
- Reporter name: Adriaan van Os
Description:
Compiling this program:
{$mode macpas}
{$extendedsyntax off}
{$modeswitch exceptions+}
{$modeswitch class+}
program classproblem;
uses
sysutils;
type
EMyException =
class( Exception)
constructor Create( theMessage: Ansistring);
end;
constructor EMyException.Create( theMessage: Ansistring);
begin
inherited Create( theMessage)
end;
begin
try
raise EMyException.Create( 'my exception raised')
except
ShowException( ExceptObject, ExceptAddr)
end
end.
gives
classproblem.pas(20,5) Error: Illegal expression
classproblem.pas(29) Fatal: There were 1 errors compiling module, stopping
The problem seems to be that the constructor has an implicit function result. When I change the program to assign the implicit function result to a local variable, as follows:
{$mode macpas}
{$extendedsyntax off}
{$modeswitch exceptions+}
{$modeswitch class+}
program classproblem;
uses
sysutils;
type
EMyException =
class( Exception)
constructor Create( theMessage: Ansistring);
end;
constructor EMyException.Create( theMessage: Ansistring);
var
theResult: Exception;
begin
theResult := inherited Create( theMessage)
end;
begin
try
raise EMyException.Create( 'my exception raised')
except
ShowException( ExceptObject, ExceptAddr)
end
end.
the compiler outputs:
classproblem.pas(19,7) Note: Local variable "theResult" is assigned but never used
classproblem.pas(20,5) Error: Operation ">" not supported for types "Pointer" and "Pointer"
classproblem.pas(31) Fatal: There were 1 errors compiling module, stopping
This is confusing.
Mantis conversion info:
- Mantis ID: 17598
- OS: Mac OS X
- OS Build: 10.5.4
- Build: svn trunk r16122
- Platform: Darwin
- Version: 2.5.1
- Fixed in version: 3.0.0
- Fixed in revision: 25068 (#407e9d17)