From 1407aa2b4be7a75a8448f61cbfa1aaac320c1982 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sat, 1 Feb 2020 17:51:46 +0000 Subject: [PATCH] * 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: trunk@44082 - --- .gitattributes | 2 ++ compiler/pexpr.pas | 36 +++++++++++++++++++++++------------- tests/webtbf/tw36631a.pp | 23 +++++++++++++++++++++++ tests/webtbf/tw36631b.pp | 23 +++++++++++++++++++++++ 4 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 tests/webtbf/tw36631a.pp create mode 100644 tests/webtbf/tw36631b.pp diff --git a/.gitattributes b/.gitattributes index 7d35576d9e..637c0fcca9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16197,6 +16197,8 @@ tests/webtbf/tw3643.pp svneol=native#text/plain tests/webtbf/tw3644.pp svneol=native#text/plain tests/webtbf/tw36554.pp svneol=native#text/pascal 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/tw3716.pp svneol=native#text/plain tests/webtbf/tw3738.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 3727aef828..97a07bd658 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -2463,22 +2463,32 @@ implementation begin if is_dynamic_array(p1.resultdef) then begin - if (token=_ID) and not try_type_helper(p1,nil) then + if token=_ID then begin - if pattern='CREATE' then + if not try_type_helper(p1,nil) 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); + 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 + else + begin + Message(parser_e_invalid_qualifier); + p1.destroy; + p1:=cerrornode.create; + consume(_ID); end; end else diff --git a/tests/webtbf/tw36631a.pp b/tests/webtbf/tw36631a.pp new file mode 100644 index 0000000000..b40bd17d2c --- /dev/null +++ b/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. diff --git a/tests/webtbf/tw36631b.pp b/tests/webtbf/tw36631b.pp new file mode 100644 index 0000000000..bc082765ce --- /dev/null +++ b/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.