Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-05

Overloading doubt: bug or feature

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo

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.
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Overloading-doubt-bug-or-feature-tp5714798.html Sent from the Free Pascal - General mailing list .
Jonas Maebe
to leledumbo
leledumbo wrote 20 lines
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