Browse Source

FPC procvar syntax problems

pierre 27 years ago
parent
commit
cc7b1a48c4
3 changed files with 39 additions and 8 deletions
  1. 27 2
      bugs/bug0188.pp
  2. 8 3
      bugs/bug0189.pp
  3. 4 3
      bugs/readme.txt

+ 27 - 2
bugs/bug0188.pp

@@ -1,5 +1,10 @@
+{ this are no bugs, just wrong 
+  understanding of FPC syntax }
+
 type testfunc = function:longint;
 
+var f : testfunc;
+
 var test: testfunc;
 
 function test_temp: longint;
@@ -9,9 +14,29 @@ end;
 
 procedure sound(test: testfunc);
 begin
-  writeln(test);
+  {writeln(test); this is wrong because
+   test is the function itself and write does not know how to
+   output a function !
+   to call test you must use test() !! }
+  writeln(test()); 
 end; { proc. sound }
 
+var i : longint;
 begin
-  sound(test_temp);
+  i:=test_temp;
+  f:=@test_temp;
+  if f()<>i then
+    begin
+       Writeln('error calling f');
+       Halt(1);
+    end;
+
+  { this works for FPC
+   sound(test_temp);
+  but the correct syntax would be }
+  sound(@test_temp);
+  { imagine if a function would return its own type !! }
+ 
+  { for f var this is correct also ! }
+  sound(f);
 end.

+ 8 - 3
bugs/bug0189.pp

@@ -10,8 +10,13 @@ end;
 
 begin
  if @test <> @test2 then
-   writeln('different!');
+   writeln('different!')
+ else
+   writeln('error');
+ m:=@test;
 
- if @m <> @test then
-   writeln('hi!');
+ { here also the syntax was wrong !! }
+ {  @m <> @test have different types !! }
+ if m <> @test then
+   writeln('error');
 end.

+ 4 - 3
bugs/readme.txt

@@ -216,6 +216,10 @@ Fixed bugs:
   bug0182.pp   @record.field doesn't work in constant expr           OK 0.99.9 (PM)
   bug0184.pp   multiple copies of the same constant set are stored in executable OK 0.99.9 (PFV)
   bug0186.pp   Erroneous array syntax is accepted.                   OK 0.99.9 (PFV)
+  bug0188.pp   can't print function result of procedural var that returns a
+               function. Not a bug : wrong syntax !! See source (PM)
+  bug0189.pp   cant compare adresses of function variables !!
+               As bug0188 FPC syntax problem see source (PM)
 
 Unproducable bugs:
 ------------------
@@ -250,9 +254,6 @@ bug0171.pp   missing typecasting in constant expressions
 bug0183.pp   internal error 10
 bug0185.pp   missing range checking for Val and subrange types
 bug0187.pp   constructor in a WIth statement isn't called correct.
-bug0188.pp   can't print function result of procedural var that returns a
-             function.
-bug0189.pp   cant compare adresses of function variables !!
 bug0190.pp   can't have typecast for var params ??
 bug0191.pp   missing vecn constant evaluation
 bug0192.pp   can't compare boolean result with true/false, because the