Browse Source

Fix for Mantis #26180. Accept undefineddef as first parameter type of an Assert if it is used inside a generic.

ninl.pas, tinlinenode.pass_typecheck:
  * if the first parameter of an Assert is a undefineddef node then accept it as well if the node is part of a generic function/method

+ added test

git-svn-id: trunk@27875 -
svenbarth 11 years ago
parent
commit
34394d6925
3 changed files with 29 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ninl.pas
  3. 23 0
      tests/webtbs/tw26180.pp

+ 1 - 0
.gitattributes

@@ -13939,6 +13939,7 @@ tests/webtbs/tw25959.pp svneol=native#text/pascal
 tests/webtbs/tw2602.pp svneol=native#text/plain
 tests/webtbs/tw2607.pp svneol=native#text/plain
 tests/webtbs/tw26162.pp svneol=native#text/pascal
+tests/webtbs/tw26180.pp svneol=native#text/pascal
 tests/webtbs/tw2620.pp svneol=native#text/plain
 tests/webtbs/tw26226.pp -text svneol=native#text/plain
 tests/webtbs/tw26230.pp svneol=native#text/plain

+ 5 - 1
compiler/ninl.pas

@@ -3168,7 +3168,11 @@ implementation
                     begin
                       set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
                       { check type }
-                      if is_boolean(left.resultdef) then
+                      if is_boolean(left.resultdef) or
+                          (
+                            (left.resultdef.typ=undefineddef) and
+                            (df_generic in current_procinfo.procdef.defoptions)
+                          ) then
                         begin
                            set_varstate(tcallparanode(tcallparanode(left).right).left,vs_read,[vsf_must_be_valid]);
                            { must always be a string }

+ 23 - 0
tests/webtbs/tw26180.pp

@@ -0,0 +1,23 @@
+{ %NORUN }
+
+program tw26180;
+
+{$MODE DELPHI}
+{$Assertions on}
+
+type
+  TA<T> = class
+  private
+    F: T;
+    procedure Foo;
+  end;
+
+procedure TA<T>.Foo;
+begin
+  Assert(F <> 0); // Error: Boolean expression expected, but got "<undefined type>"
+                  // same for >, <, <=, >=, =
+end;
+
+begin
+end.
+