Browse Source

Fixing bug where in const init no typecheck for symbol was performed

Frederic Kehrein 10 months ago
parent
commit
a188322e76
2 changed files with 17 additions and 1 deletions
  1. 1 1
      compiler/ngtcon.pas
  2. 16 0
      tests/test/trecinit1.pp

+ 1 - 1
compiler/ngtcon.pas

@@ -1682,7 +1682,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
             consume(_ID);
             consume(_COLON);
             recsym := tsym(def.symtable.Find(s));
-            if not assigned(recsym) then
+            if not assigned(recsym) or (recsym.typ<>fieldvarsym) then
               begin
                 Message1(sym_e_illegal_field,sorg);
                 error := true;

+ 16 - 0
tests/test/trecinit1.pp

@@ -0,0 +1,16 @@
+{ %FAIL }
+program trecinit1;
+
+{$mode delphi}
+{$ModeSwitch advancedrecords}
+
+type
+  TTestRec = record
+  A: Integer;
+  property B: Integer read A;
+  end;
+
+const
+  rec: TTestRec = (A:42; B:32);
+begin
+end.