Browse Source

* fix for Mantis #35955: when the element of an array constructer requires an operator for conversion we don't let the caller of compare_defs_ext know that, instead we simply say that some conversion is required and let the typecheck handler deal with the element wise conversion
+ added test

git-svn-id: trunk@42700 -

svenbarth 6 years ago
parent
commit
44bfa98a30
3 changed files with 24 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/defcmp.pas
  3. 18 0
      tests/webtbs/tw35955.pp

+ 1 - 0
.gitattributes

@@ -17787,6 +17787,7 @@ tests/webtbs/tw35937.pp svneol=native#text/plain
 tests/webtbs/tw3594.pp svneol=native#text/plain
 tests/webtbs/tw3594.pp svneol=native#text/plain
 tests/webtbs/tw3595.pp svneol=native#text/plain
 tests/webtbs/tw3595.pp svneol=native#text/plain
 tests/webtbs/tw35953.pp svneol=native#text/pascal
 tests/webtbs/tw35953.pp svneol=native#text/pascal
+tests/webtbs/tw35955.pp svneol=native#text/pascal
 tests/webtbs/tw35965.pp svneol=native#text/pascal
 tests/webtbs/tw35965.pp svneol=native#text/pascal
 tests/webtbs/tw3612.pp svneol=native#text/plain
 tests/webtbs/tw3612.pp svneol=native#text/plain
 tests/webtbs/tw3617.pp svneol=native#text/plain
 tests/webtbs/tw3617.pp svneol=native#text/plain

+ 5 - 0
compiler/defcmp.pas

@@ -1027,6 +1027,11 @@ implementation
                                       end
                                       end
                                     else if subeq>te_convert_l6 then
                                     else if subeq>te_convert_l6 then
                                       eq:=pred(subeq)
                                       eq:=pred(subeq)
+                                    else if subeq=te_convert_operator then
+                                      { the operater needs to be applied by element, so we tell
+                                        the caller that it's some unpreffered conversion and let
+                                        it handle the per-element stuff }
+                                      eq:=te_convert_l6
                                     else
                                     else
                                       eq:=subeq;
                                       eq:=subeq;
                                    doconv:=tc_arrayconstructor_2_dynarray;
                                    doconv:=tc_arrayconstructor_2_dynarray;

+ 18 - 0
tests/webtbs/tw35955.pp

@@ -0,0 +1,18 @@
+{ %NORUN }
+
+program tw35955;
+
+{$mode delphi}
+
+type
+  TVariantArray = array of Variant;
+
+var
+  S: string;
+  A: TVariantArray;
+begin
+  S := 'xyz';
+  A := [S]; // << project1.lpr(13,8) Error: Compilation raised exception internally
+  Writeln(A[0]);
+  Readln;
+end.