From 56cd7b34509535c979a703111c783afc9e73ebfa Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 18 Apr 2011 03:15:58 +0000 Subject: [PATCH] compiler: allow use of default properties for records (issue #0019098) git-svn-id: trunk@17334 - --- .gitattributes | 1 + compiler/pexpr.pas | 2 +- tests/test/terecs10.pp | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/test/terecs10.pp diff --git a/.gitattributes b/.gitattributes index a97fa3771e..23d8234e35 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9694,6 +9694,7 @@ tests/test/tenum5.pp svneol=native#text/plain tests/test/tenum6.pp svneol=native#text/pascal tests/test/tenumerators1.pp svneol=native#text/pascal tests/test/terecs1.pp svneol=native#text/pascal +tests/test/terecs10.pp svneol=native#text/pascal tests/test/terecs2.pp svneol=native#text/pascal tests/test/terecs3.pp svneol=native#text/pascal tests/test/terecs4.pp svneol=native#text/pascal diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 409c7ec7e4..5f9520f9c8 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1927,7 +1927,7 @@ implementation _LECKKLAMMER: begin if is_class_or_interface_or_object(p1.resultdef) or - is_dispinterface(p1.resultdef) then + is_dispinterface(p1.resultdef) or is_record(p1.resultdef) then begin { default property } protsym:=search_default_property(tobjectdef(p1.resultdef)); diff --git a/tests/test/terecs10.pp b/tests/test/terecs10.pp new file mode 100644 index 0000000000..517396260c --- /dev/null +++ b/tests/test/terecs10.pp @@ -0,0 +1,23 @@ +program terecs10; + +{$ifdef fpc} + {$mode delphi} +{$endif} + +type + TTest = record + function GetTest(Index: Integer): Integer; + property Test[Index: Integer]: Integer read GetTest; default; + end; + +function TTest.GetTest(Index: Integer): Integer; +begin + Result := Index; +end; + +var + t: TTest; +begin + if t[42] <> 42 then + halt(1); +end.