diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas index 2d7ea22d73..da43dc762e 100644 --- a/compiler/pdecvar.pas +++ b/compiler/pdecvar.pas @@ -1982,16 +1982,19 @@ implementation { including a field declaration? } fieldvs:=nil; - sorg:=orgpattern; - hs:=pattern; - searchsym(hs,srsym,srsymtable); - if not(assigned(srsym) and (srsym.typ in [typesym,unitsym])) then + if token=_ID then begin - consume(_ID); - consume(_COLON); - fieldvs:=cfieldvarsym.create(sorg,vs_value,generrordef,[]); - variantdesc^^.variantselector:=fieldvs; - symtablestack.top.insertsym(fieldvs); + sorg:=orgpattern; + hs:=pattern; + searchsym(hs,srsym,srsymtable); + if not(assigned(srsym) and (srsym.typ in [typesym,unitsym])) then + begin + consume(_ID); + consume(_COLON); + fieldvs:=cfieldvarsym.create(sorg,vs_value,generrordef,[]); + variantdesc^^.variantselector:=fieldvs; + symtablestack.top.insertsym(fieldvs); + end; end; read_anon_type(casetype,true); block_type:=bt_var; diff --git a/tests/test/tvrec1.pp b/tests/test/tvrec1.pp new file mode 100644 index 0000000000..67474a375e --- /dev/null +++ b/tests/test/tvrec1.pp @@ -0,0 +1,19 @@ +program tvrec1; + +type + TTestRec = record + case (A, B) of + A: (I: Integer); + B: (D: Double); + end; + +var + rec: TTestRec; +begin + if @rec.I=@rec.D then + begin + WriteLn('ok'); + halt(0); + end; + halt(1); +end.