diff --git a/.gitattributes b/.gitattributes index be9039e1c2..ecf8efd2a5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8390,6 +8390,7 @@ tests/tbf/tb0217.pp svneol=native#text/plain tests/tbf/tb0218.pp svneol=native#text/plain tests/tbf/tb0219.pp svneol=native#text/pascal tests/tbf/tb0220.pp svneol=native#text/plain +tests/tbf/tb0221.pp svneol=native#text/plain tests/tbf/ub0115.pp svneol=native#text/plain tests/tbf/ub0149.pp svneol=native#text/plain tests/tbf/ub0158a.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 5f9520f9c8..2ef96b7bff 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1930,7 +1930,7 @@ implementation is_dispinterface(p1.resultdef) or is_record(p1.resultdef) then begin { default property } - protsym:=search_default_property(tobjectdef(p1.resultdef)); + protsym:=search_default_property(tabstractrecorddef(p1.resultdef)); if not(assigned(protsym)) then begin p1.destroy; diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 0328995a7c..e7355278c7 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -247,7 +247,7 @@ interface function defined_macro(const s : string):boolean; {*** Object Helpers ***} - function search_default_property(pd : tobjectdef) : tpropertysym; + function search_default_property(pd : tabstractrecorddef) : tpropertysym; function find_real_objcclass_definition(pd: tobjectdef; erroronfailure: boolean): tobjectdef; {*** Macro Helpers ***} @@ -2854,7 +2854,7 @@ implementation Object Helpers ****************************************************************************} - function search_default_property(pd : tobjectdef) : tpropertysym; + function search_default_property(pd : tabstractrecorddef) : tpropertysym; { returns the default property of a class, searches also anchestors } var _defaultprop : tpropertysym; @@ -2881,7 +2881,10 @@ implementation pd.symtable.SymList.ForEachCall(@tstoredsymtable(pd.symtable).testfordefaultproperty,@_defaultprop); if assigned(_defaultprop) then break; - pd:=pd.childof; + if (pd.typ=objectdef) then + pd:=tobjectdef(pd).childof + else + break; end; search_default_property:=_defaultprop; end; diff --git a/tests/tbf/tb0221.pp b/tests/tbf/tb0221.pp new file mode 100644 index 0000000000..5f55209e5b --- /dev/null +++ b/tests/tbf/tb0221.pp @@ -0,0 +1,14 @@ +{ %fail } + +{ should not crash the compiler } + +type + tr = record + a,b: longint; + end; + +var + r: tr; +begin + r[0].a:=1; +end.