Browse Source

* fix for Mantis #34332: allow 2 parameter form of Copy also for ShortString variables
+ added test

git-svn-id: trunk@39802 -

svenbarth 6 years ago
parent
commit
bf91991bae
3 changed files with 16 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/ninl.pas
  3. 14 0
      tests/webtbs/tw34332.pp

+ 1 - 0
.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

+ 1 - 1
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);

+ 14 - 0
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.