[fpc-pascal] Overloading doubt: bug or feature
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed May 15 11:05:34 CEST 2013
On 15 May 2013, at 10:59, leledumbo wrote:
> Is the following a bug or undocumented "feature"?
>
> function f(s: string): string;
> begin
> f := '''' + s + '''';
> end;
>
> function f(s: string): integer;
> begin
> Val(s,f);
> end;
>
> var
> i: Integer;
> begin
> // i := f('123'); // Error: Incompatible types: got "ShortString"
> expected
> "SmallInt"
> WriteLn(f('123')); // Calls function f(s: string): string;
> end.
Looks like a bug. I guess they currently don't conflict because the
string result is passed via a hidden parameter while the integer
result is not.
Jonas
More information about the fpc-pascal
mailing list