From bf91991bae1d0d92c44c7d7c2a9f98d3e9c4b30b Mon Sep 17 00:00:00 2001 From: svenbarth Date: Tue, 25 Sep 2018 19:10:06 +0000 Subject: [PATCH] * fix for Mantis #34332: allow 2 parameter form of Copy also for ShortString variables + added test git-svn-id: trunk@39802 - --- .gitattributes | 1 + compiler/ninl.pas | 2 +- tests/webtbs/tw34332.pp | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw34332.pp diff --git a/.gitattributes b/.gitattributes index 54cb48c4fd..46b9dbc5e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16252,6 +16252,7 @@ tests/webtbs/tw34239.pp svneol=native#text/pascal tests/webtbs/tw34287.pp svneol=native#text/pascal tests/webtbs/tw3429.pp svneol=native#text/plain tests/webtbs/tw3433.pp svneol=native#text/plain +tests/webtbs/tw34332.pp svneol=native#text/pascal tests/webtbs/tw3435.pp svneol=native#text/plain tests/webtbs/tw3441.pp svneol=native#text/plain tests/webtbs/tw3443.pp svneol=native#text/plain diff --git a/compiler/ninl.pas b/compiler/ninl.pas index f1125aff7d..53beb4e816 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -1834,7 +1834,7 @@ implementation begin { generic fallback that will give an error if a wrong type is passed } - if (counter=3) then + if (counter=3) or (counter=2) then resultdef:=cshortstringtype else CGMessagePos(ppn.left.fileinfo,type_e_mismatch); diff --git a/tests/webtbs/tw34332.pp b/tests/webtbs/tw34332.pp new file mode 100644 index 0000000000..096ee08261 --- /dev/null +++ b/tests/webtbs/tw34332.pp @@ -0,0 +1,14 @@ +{ %NORUN } + +program tw34332; + +{$mode objfpc}{$h+} + +var + SS: ShortString; + S: String; +begin + SS := Copy(SS, 1); // << project1.lpr(9,14) Error: Type mismatch + S := Copy(S, 1); // << OK + SS := Copy(SS, 1, 1); // << OK +end.