Explorar o código

Fix for Mantis #23776.

ninl.pas, tinlinenode.pass_typecheck:
  * don't generate a type error if Length() is used inside generics with a generic argument

+ added test

git-svn-id: trunk@27533 -
svenbarth %!s(int64=11) %!d(string=hai) anos
pai
achega
256c852631
Modificáronse 3 ficheiros con 23 adicións e 1 borrados
  1. 1 0
      .gitattributes
  2. 7 1
      compiler/ninl.pas
  3. 15 0
      tests/webtbs/tw23776.pp

+ 1 - 0
.gitattributes

@@ -13819,6 +13819,7 @@ tests/webtbs/tw23667.pp svneol=native#text/plain
 tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
+tests/webtbs/tw23776.pp svneol=native#text/pascal
 tests/webtbs/tw2378.pp svneol=native#text/plain
 tests/webtbs/tw23819.pp svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain

+ 7 - 1
compiler/ninl.pas

@@ -2772,7 +2772,13 @@ implementation
                           begin
                             { will be handled in simplify }
                           end;
-                      end
+                      end;
+                    undefineddef :
+                      begin
+                        if not (df_generic in current_procinfo.procdef.defoptions) then
+                          CGMessage(type_e_mismatch);
+                        { otherwise nothing }
+                      end;
                     else
                       CGMessage(type_e_mismatch);
                   end;

+ 15 - 0
tests/webtbs/tw23776.pp

@@ -0,0 +1,15 @@
+{ %NORUN }
+
+program tw23776;
+{$mode objfpc}
+type
+generic tg<T>= class
+    public
+        class function len(a: T): integer;
+end;
+    class function tg.len(a: T): integer;
+    begin
+        result:= length(a);
+    end;
+begin
+end.