Result, can be used to make recursive call
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
I am not 100% sure, if this is allowed in pascal. But given the strangeness of the syntax....
See the program below, it compiles without error. I would have expected it to say, that there is no function "Result".
I am aware the following are equal:
Foo := 1;
Result := 1;
But in order to call the function, only Foo(n) should be allowed?
This is also highly unpredictable, since Result acts as a variable, and can be read. And if Foo did not have params, then Foo did not need brackets neither. So it wouldn't be clear what a right hand side result means in that case.
Additional information:
program Project1;
{$mode objfpc}{$H+}
function Foo(a: Integer): Integer;
begin
dec(a);
if a < 0 then exit;
Result := Result(a);
end;
begin
Foo(10);
end.
Mantis conversion info:
- Mantis ID: 14248
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 13492 (#6c997460)