Bladeren bron

* throw an error in iso/extended pascal mode if enum types are passed to writeln, resolves #40896

florian 11 maanden geleden
bovenliggende
commit
0735ac0d1f
2 gewijzigde bestanden met toevoegingen van 16 en 0 verwijderingen
  1. 6 0
      compiler/ninl.pas
  2. 10 0
      tests/webtbf/tw40896.pp

+ 6 - 0
compiler/ninl.pas

@@ -850,6 +850,12 @@ implementation
                 end;
               enumdef:
                 begin
+                  if m_isolike_io in current_settings.modeswitches then
+                    begin
+                      error_para := true;
+                      CGMessagePos(para.fileinfo,type_e_cant_read_write_type);
+                    end;
+
                   name:=procprefixes[do_read]+'enum';
                   if do_read then
                     { read is done with a var parameter so we need the correct

+ 10 - 0
tests/webtbf/tw40896.pp

@@ -0,0 +1,10 @@
+{ %fail }
+{$mode extendedpascal}
+type
+  fruits = (apple, banana, citrus);   
+var
+  a:fruits;
+begin
+  Writeln(pred(high(a)));
+  ReadLn;
+end.