tw2454.pp 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. { Source provided for Free Pascal Bug Report 2454 }
  2. { Submitted by "Nikolay Nikolov" on 2003-04-06 }
  3. { e-mail: [email protected] }
  4. {$MODE objfpc}
  5. Program Test;
  6. Type
  7. TFunClass = Class(TObject)
  8. data : Integer;
  9. Class Procedure FunProc(q : TFunClass);
  10. End;
  11. Class Procedure TFunClass.FunProc(q : TFunClass);
  12. Begin
  13. Writeln(q.data);
  14. With q Do
  15. Begin
  16. Writeln(q.data);
  17. Writeln(data); { fpc 1.1 says: Error: Only class methods can be accessed in class methods
  18. this is a bug, because 'data' actually means 'q.data' due to the 'with' statement,
  19. (this can be seen if you make this a normal method by removing the 'Class' keyword
  20. and running the program, it will writeln q.data, not self.data)
  21. so it shouldn't cause an error
  22. }
  23. End;
  24. End;
  25. Var
  26. c1, c2 : TFunClass;
  27. Begin
  28. c1 := TFunClass.Create;
  29. c2 := TFunClass.Create;
  30. c1.data := 5;
  31. c2.data := 7;
  32. c1.FunProc(c2);
  33. c1.Destroy;
  34. c2.Destroy;
  35. End.