浏览代码

compiler:
- don't find MoveNext functions with the required arguments
- add some test from Alexander S. Klenin
(issue #0014990)

git-svn-id: trunk@14044 -

paul 15 年之前
父节点
当前提交
2f0cde4625
共有 4 个文件被更改,包括 35 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 6 0
      compiler/nflw.pas
  3. 1 0
      compiler/symdef.pas
  4. 27 0
      tests/test/tforin22.pp

+ 1 - 0
.gitattributes

@@ -8240,6 +8240,7 @@ tests/test/tforin19.pp svneol=native#text/pascal
 tests/test/tforin2.pp svneol=native#text/pascal
 tests/test/tforin20.pp svneol=native#text/pascal
 tests/test/tforin21.pp svneol=native#text/pascal
+tests/test/tforin22.pp svneol=native#text/pascal
 tests/test/tforin3.pp svneol=native#text/pascal
 tests/test/tforin4.pp svneol=native#text/pascal
 tests/test/tforin5.pp svneol=native#text/pascal

+ 6 - 0
compiler/nflw.pas

@@ -584,6 +584,8 @@ begin
       if movenext = nil then
       begin
         result:=cerrornode.create;
+        hloopvar.free;
+        hloopbody.free;
         Message1(sym_e_no_enumerator_move,pd.returndef.GetTypeName);
       end
       else
@@ -592,6 +594,8 @@ begin
         if current = nil then
         begin
           result:=cerrornode.create;
+          hloopvar.free;
+          hloopbody.free;
           Message1(sym_e_no_enumerator_current,pd.returndef.GetTypeName);
         end
         else
@@ -607,6 +611,8 @@ begin
       else
         begin
           result:=cerrornode.create;
+          hloopvar.free;
+          hloopbody.free;
           Message1(sym_e_no_enumerator,expr.resultdef.GetTypeName);
         end;
       end;

+ 1 - 0
compiler/symdef.pas

@@ -4334,6 +4334,7 @@ implementation
                   pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
                   if (pd.proctypeoption = potype_function) and
                      is_boolean(pd.returndef) and
+                     (pd.minparacount = 0) and
                      (pd.visibility >= vis_public) then
                   begin
                     result:=pd;

+ 27 - 0
tests/test/tforin22.pp

@@ -0,0 +1,27 @@
+{ %FAIL}
+{$mode objfpc}
+{$apptype console}
+
+type 
+  T = class
+    F: Integer;
+    function MoveNext(a: Integer): Boolean;
+    property Current: Integer read F;
+  end;
+
+function T.MoveNext(a: Integer): Boolean; 
+begin 
+  Result := true; 
+end;
+
+operator enumerator(a: Integer): T;
+begin
+  Result := T.Create;
+  Result.F := a;
+end;
+
+var
+  i: Integer;
+begin
+  for i in 1 do Writeln(i);
+end.