[fpc-devel] Minor debate with ISO standard on case blocks
thaddy
thaddy at localhost
Tue Jul 30 14:23:43 CEST 2019
On 2019-07-30 14:04, Sven Barth via fpc-devel wrote:
> thaddy <thaddy at localhost> schrieb am Di., 30. Juli 2019, 10:04:
>
>> On 2019-07-30 01:43, J. Gareth Moreton wrote:
>>> As someone on the issue pointed out... on page 2, section 3.1:
>>>
>>> 3.1 Error
>>
>> I have added this to the bug report. Consider that here all possible
>>
>> case labels are implemented, the compiler still throws a compile
>> time
>> error.
>> That means the implementation is wrong anyway.
>>
>> {$mode ISO}
>> program isobug(infile,outfile);
>> type
>> operator = (plus, minus, times);
>> var
>> x:integer;
>> o:operator = plus;
>> begin
>> x:=1;
>> case o of
>> plus : x := x; // all
>> minus : x := x; // possible
>> times : x := x; // cases
>> end;
>> end.
>>
>> The easy way out seems to revert to the 3.0.4 implementation given
>> the
>> section mentioned.
>> Gareth's suggestion would be nice to have, though.
>
> That's definitely a bug, cause the same code (with "operator" changed
> to "op") compiles in mode ObjFPC without any warning or error.
>
> Regards,
> Sven
>
>>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Yes, it is a bug, but note the case handling in mode objfpc (all modes
except macpas, iso and extended) differs.
It should only error out if the selector value has no case label.
Extended Pascal then throws a run-time error.
The other modes, like objfpc, silently continue.
It should not error out at all at compile time.
I provided a patch that makes the iso behavior equal to the extended
pascal behavior.
This solves both the above issue and the compile time vs run time error.
More information about the fpc-devel
mailing list