summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw12597.pp
blob: d17556a13c39e1cba73a840611c6330053954bfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
program Project1;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils;

type

  { TFoo }

  TFoo = Object
    a : integer;
    function b : TFoo;
  end;

  tfoo2 = object(tfoo)
  end;

{ TFoo }

function TFoo.b: TFoo;
begin
  result.a := 5;
  writeln(IntToStr(self.a));
  if (self.a<>2) then
    halt(1);
end;

procedure t;
var x : TFoo;
begin
  x.a := 2;
  x := tfoo2(x).b;
  writeln(IntToStr(x.a));
  if (x.a<>5) then
    halt(2);
end;

begin
  t;
end.