bug0188.pp 805 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. { this are no bugs, just wrong
  2. understanding of FPC syntax }
  3. type testfunc = function:longint;
  4. var f : testfunc;
  5. var test: testfunc;
  6. function test_temp: longint;
  7. begin
  8. test_temp:=12;
  9. end;
  10. procedure sound(test: testfunc);
  11. begin
  12. {writeln(test); this is wrong because
  13. test is the function itself and write does not know how to
  14. output a function !
  15. to call test you must use test() !! }
  16. writeln(test());
  17. end; { proc. sound }
  18. var i : longint;
  19. begin
  20. i:=test_temp;
  21. f:=@test_temp;
  22. if f()<>i then
  23. begin
  24. Writeln('error calling f');
  25. Halt(1);
  26. end;
  27. { this works for FPC
  28. sound(test_temp);
  29. but the correct syntax would be }
  30. sound(@test_temp);
  31. { imagine if a function would return its own type !! }
  32. { for f var this is correct also ! }
  33. sound(f);
  34. end.