diff --git a/.gitattributes b/.gitattributes index 2d3be3c9ba..97ba156c5b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14937,6 +14937,7 @@ tests/webtbs/tw2953.pp svneol=native#text/plain tests/webtbs/tw29546.pp svneol=native#text/pascal tests/webtbs/tw2956.pp svneol=native#text/plain tests/webtbs/tw2958.pp svneol=native#text/plain +tests/webtbs/tw29609.pp svneol=native#text/pascal tests/webtbs/tw2966.pp svneol=native#text/plain tests/webtbs/tw2975.pp svneol=native#text/plain tests/webtbs/tw2976.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 25bf41e0bc..d477abffaa 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -3093,7 +3093,11 @@ implementation { it as a class member } if (assigned(current_structdef) and (current_structdef<>hdef) and is_owned_by(current_structdef,hdef)) or (assigned(current_procinfo) and current_procinfo.get_normal_proc.procdef.no_self_node) then - p1:=cloadvmtaddrnode.create(ctypenode.create(hdef)) + begin + p1:=ctypenode.create(hdef); + if not is_record(hdef) then + p1:=cloadvmtaddrnode.create(p1); + end else p1:=load_self_node; { not srsymtable.symtabletype since that can be } diff --git a/tests/webtbs/tw29609.pp b/tests/webtbs/tw29609.pp new file mode 100644 index 0000000000..8f1327891d --- /dev/null +++ b/tests/webtbs/tw29609.pp @@ -0,0 +1,22 @@ +{ %NORUN } + +{$mode objfpc} +{$MODESWITCH AdvancedRecords} +program tw29609; + + +type t = record + class var v : Boolean; + class function f : Boolean; static; + class property p : Boolean read v; + end; + + +class function t.f : Boolean; +begin +Result := p; // "Error: Pointer to object expected" +end; + + +begin +end.