Przeglądaj źródła

* fix #39849: it's an error when the file (or string) parameter of a Read*/Write* is followed by a ":"
+ added test

Sven/Sarah Barth 3 lat temu
rodzic
commit
c122e16beb
2 zmienionych plików z 23 dodań i 0 usunięć
  1. 9 0
      compiler/ninl.pas
  2. 14 0
      tests/webtbf/tw39849.pp

+ 9 - 0
compiler/ninl.pas

@@ -1329,6 +1329,15 @@ implementation
               filepara := nil;
           end;
 
+        if assigned(filepara) and
+            assigned(filepara.right) and
+            (cpf_is_colon_para in tcallparanode(filepara.right).callparaflags) then
+          begin
+            CGMessagePos(filepara.fileinfo,parser_e_illegal_colon_qualifier);
+            { for recovery we can simply continue, because the compiler will
+              simply treat the next parameters as normal parameters }
+          end;
+
         { create a blocknode in which the successive write/read statements will be  }
         { put, since they belong together. Also create a dummy statement already to }
         { make inserting of additional statements easier                            }

+ 14 - 0
tests/webtbf/tw39849.pp

@@ -0,0 +1,14 @@
+{ %FAIL }
+
+PROGRAM tw39849;
+   {$APPTYPE CONSOLE}
+VAR
+   F: TEXT;
+BEGIN
+   ASSIGN(F, 'doublepoint.txt');
+   REWRITE(F);
+   WRITELN(F, 'Hello');   { ',' is legal - compiler just do its job }
+   WRITELN(F: 'Hello');   { ':' is not legal - compiler should emit an error, but 3.2.2 fail to }
+   CLOSE(F);
+END.
+