Browse Source

* also initalize default helper variables of initialization sections, resolves #40183

florian 2 years ago
parent
commit
0d3ec87492
3 changed files with 30 additions and 0 deletions
  1. 1 0
      compiler/psub.pas
  2. 5 0
      tests/webtbs/tw40183.pp
  3. 24 0
      tests/webtbs/uw40183.pp

+ 1 - 0
compiler/psub.pas

@@ -424,6 +424,7 @@ implementation
                         { The library init code is already called and does not
                         { The library init code is already called and does not
                           need to be in the initfinal table (PFV) }
                           need to be in the initfinal table (PFV) }
                         block:=statement_block(_INITIALIZATION);
                         block:=statement_block(_INITIALIZATION);
+                        init_main_block_syms(block);
                      end
                      end
                    else if token=_FINALIZATION then
                    else if token=_FINALIZATION then
                      begin
                      begin

+ 5 - 0
tests/webtbs/tw40183.pp

@@ -0,0 +1,5 @@
+uses  
+  uw40183;
+
+begin
+end.

+ 24 - 0
tests/webtbs/uw40183.pp

@@ -0,0 +1,24 @@
+unit uw40183;
+
+{$mode ObjFPC}{$H+}
+
+interface
+
+uses
+  Types;
+
+type
+  TBuffer = packed record
+    Mask: Int64;     
+    DataArray: TObjectDynArray;
+  end;
+
+var
+  GlobalBuffer: TBuffer;
+
+implementation
+
+initialization  
+  GlobalBuffer := Default(TBuffer);
+
+end.