[fpc-devel] [Patch/RFC] Warnings for (in/over)complete case statements

Benito van der Zander benito at benibela.de
Wed Jan 2 17:49:22 CET 2019


> Wait - why does that code not raise a 5033 "Function Result does not seem to be
> set"? Add a second property "Property MyOtherString : String Index 2 Read
> GetString;", and now its provably wrong. No warning. This seems wrong,
> considering what we just talked about on fpc-pascal.


Because there is no SetLength call in the function?


Am 02.01.19 um 17:41 schrieb Martok:
> Am 02.01.2019 um 11:19 schrieb Michael Van Canneyt:
>
>> Consider the following:
>>
>> Type
>>     TMyClass = class
>>     Private
>>       function GetString(AIndex: Integer): string;
>>     Published
>>       Property MyString : String Index 1 Read GetString;
>>     end;
>>
>> function TMyClass.GetString(AIndex: Integer): string;
>>
>> begin
>>     case AIndex of
>>      1 : Result:=GenerateSomestringvalue;
>>     end;
>> end;
>>
>> I don't think there should be errors or warnings.
> Good example.
>
> Although... you *could* call GetString from some other class member function,
> and at that point Result would be undefined. I don't think the compiler can
> prove that?
> Wait - why does that code not raise a 5033 "Function Result does not seem to be
> set"? Add a second property "Property MyOtherString : String Index 2 Read
> GetString;", and now its provably wrong. No warning. This seems wrong,
> considering what we just talked about on fpc-pascal.
>



More information about the fpc-devel mailing list