Browse Source

Merged revision(s) 44082 from trunk:
* fix for Mantis #36631: it's an error if a POINT after an array is not followed by an identifier
+ added tests
........

git-svn-id: branches/fixes_3_2@44143 -

svenbarth 5 years ago
parent
commit
a1f78b242a
4 changed files with 71 additions and 13 deletions
  1. 2 0
      .gitattributes
  2. 23 13
      compiler/pexpr.pas
  3. 23 0
      tests/webtbf/tw36631a.pp
  4. 23 0
      tests/webtbf/tw36631b.pp

+ 2 - 0
.gitattributes

@@ -15854,6 +15854,8 @@ tests/webtbf/tw3631.pp svneol=native#text/plain
 tests/webtbf/tw3643.pp svneol=native#text/plain
 tests/webtbf/tw3643.pp svneol=native#text/plain
 tests/webtbf/tw3644.pp svneol=native#text/plain
 tests/webtbf/tw3644.pp svneol=native#text/plain
 tests/webtbf/tw3662.pp svneol=native#text/plain
 tests/webtbf/tw3662.pp svneol=native#text/plain
+tests/webtbf/tw36631a.pp svneol=native#text/pascal
+tests/webtbf/tw36631b.pp svneol=native#text/pascal
 tests/webtbf/tw3680.pp svneol=native#text/plain
 tests/webtbf/tw3680.pp svneol=native#text/plain
 tests/webtbf/tw3716.pp svneol=native#text/plain
 tests/webtbf/tw3716.pp svneol=native#text/plain
 tests/webtbf/tw3738.pp svneol=native#text/plain
 tests/webtbf/tw3738.pp svneol=native#text/plain

+ 23 - 13
compiler/pexpr.pas

@@ -2445,22 +2445,32 @@ implementation
                    begin
                    begin
                      if is_dynamic_array(p1.resultdef) then
                      if is_dynamic_array(p1.resultdef) then
                        begin
                        begin
-                         if (token=_ID) and not try_type_helper(p1,nil) then
+                         if token=_ID then
                            begin
                            begin
-                             if pattern='CREATE' then
+                             if not try_type_helper(p1,nil) then
                                begin
                                begin
-                                 consume(_ID);
-                                 p2:=parse_array_constructor(tarraydef(p1.resultdef));
-                                 p1.destroy;
-                                 p1:=p2;
-                               end
-                             else
-                               begin
-                                 Message2(scan_f_syn_expected,'CREATE',pattern);
-                                 p1.destroy;
-                                 p1:=cerrornode.create;
-                                 consume(_ID);
+                                 if pattern='CREATE' then
+                                   begin
+                                     consume(_ID);
+                                     p2:=parse_array_constructor(tarraydef(p1.resultdef));
+                                     p1.destroy;
+                                     p1:=p2;
+                                   end
+                                 else
+                                   begin
+                                     Message2(scan_f_syn_expected,'CREATE',pattern);
+                                     p1.destroy;
+                                     p1:=cerrornode.create;
+                                     consume(_ID);
+                                   end;
                                end;
                                end;
+                           end
+                         else
+                           begin
+                             Message(parser_e_invalid_qualifier);
+                             p1.destroy;
+                             p1:=cerrornode.create;
+                             consume(_ID);
                            end;
                            end;
                        end
                        end
                      else
                      else

+ 23 - 0
tests/webtbf/tw36631a.pp

@@ -0,0 +1,23 @@
+{ %FAIL }
+
+program tw36631a;
+
+{$APPTYPE CONSOLE}
+{$mode objfpc}{$H+}
+
+uses
+  Classes,
+  SysUtils;
+
+var
+  LongStr: String;
+  SingleStr: String;
+
+begin
+  LongStr := 'Some example, test text. Another one, or something like that.';
+
+  SingleStr := LongStr.Split([',', '.']).[1];
+  writeln(SingleStr); // ' test text'
+
+  writeln('done');
+end.

+ 23 - 0
tests/webtbf/tw36631b.pp

@@ -0,0 +1,23 @@
+{ %FAIL }
+
+program tw36631b;
+
+{$APPTYPE CONSOLE}
+{$mode delphi}
+
+uses
+  Classes,
+  SysUtils;
+
+var
+  LongStr: String;
+  SingleStr: String;
+
+begin
+  LongStr := 'Some example, test text. Another one, or something like that.';
+
+  SingleStr := LongStr.Split([',', '.']).[1];
+  writeln(SingleStr); // ' test text'
+
+  writeln('done');
+end.