Sfoglia il codice sorgente

* better estimation of compatibility of array constructors with open arrays, resolves issue #29244

git-svn-id: trunk@32846 -
florian 9 anni fa
parent
commit
a4d2f71d3d
3 ha cambiato i file con 23 aggiunte e 5 eliminazioni
  1. 1 0
      .gitattributes
  2. 10 5
      compiler/defcmp.pas
  3. 12 0
      tests/webtbs/tw29244.pp

+ 1 - 0
.gitattributes

@@ -14905,6 +14905,7 @@ tests/webtbs/tw29153.pp svneol=native#text/plain
 tests/webtbs/tw2916.pp svneol=native#text/plain
 tests/webtbs/tw2920.pp svneol=native#text/plain
 tests/webtbs/tw2923.pp svneol=native#text/plain
+tests/webtbs/tw29244.pp svneol=native#text/pascal
 tests/webtbs/tw29250.pp svneol=native#text/pascal
 tests/webtbs/tw2926.pp svneol=native#text/plain
 tests/webtbs/tw2927.pp svneol=native#text/plain

+ 10 - 5
compiler/defcmp.pas

@@ -990,11 +990,16 @@ implementation
                                       eq:=te_convert_l1;
                                     end
                                   else
-                                   if (subeq>te_incompatible) then
-                                    begin
-                                      doconv:=hct;
-                                      eq:=te_convert_l2;
-                                    end;
+                                    { an array constructor is not an open array, so
+                                      use a lower level of compatibility than that one of
+                                      of the elements }
+                                    if subeq>te_convert_l6 then
+                                     begin
+                                       doconv:=hct;
+                                       eq:=pred(subeq);
+                                     end
+                                   else
+                                     eq:=subeq;
                                 end;
                              end
                             else

+ 12 - 0
tests/webtbs/tw29244.pp

@@ -0,0 +1,12 @@
+program project1;
+
+{$mode objfpc}{$H+}
+
+uses
+  Classes, SysUtils;
+
+Var
+  AStr : String = '';
+begin
+  WriteLn(ConcatPaths(['one', 'two']));
+end.