Browse Source

* do not throw an internal error on typed constants with wrong element count, resolves #40066

florian 2 years ago
parent
commit
7affd78904
2 changed files with 15 additions and 2 deletions
  1. 3 2
      compiler/ngtcon.pas
  2. 12 0
      tests/webtbf/tw40066.pp

+ 3 - 2
compiler/ngtcon.pas

@@ -1804,7 +1804,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
            ) then
           Message1(parser_w_skipped_fields_after,sorg);
 
-        if not error then
+        if ErrorCount=0 then
           begin
             if not(is_packed) then
               fillbytes:=0
@@ -1816,9 +1816,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
               end;
             for i:=1 to fillbytes do
               ftcb.emit_tai(Tai_const.Create_8bit(0),u8inttype);
+
+            ftcb.maybe_end_aggregate(def);
           end;
 
-        ftcb.maybe_end_aggregate(def);
         consume(_RKLAMMER);
       end;
 

+ 12 - 0
tests/webtbf/tw40066.pp

@@ -0,0 +1,12 @@
+{ %fail }
+const
+	Outer: array[0 .. 1] of record
+		inner: array[0 .. 1] of uint32;
+	end =
+	(
+		(inner: ()),
+		(inner: (1))
+	);
+
+begin
+end.