瀏覽代碼

compiler: generate an error message if enumerator operator is declared with return object which has no valid MoveNext method, Current property

git-svn-id: trunk@16806 -
paul 14 年之前
父節點
當前提交
8102c480d7
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      compiler/htypechk.pas

+ 13 - 0
compiler/htypechk.pas

@@ -445,6 +445,19 @@ implementation
                   begin
                     result:=
                       is_class_or_interface_or_object(pf.returndef);
+                    if result then
+                      begin
+                        if not assigned(tobjectdef(pf.returndef).search_enumerator_move) then
+                          begin
+                            Message1(sym_e_no_enumerator_move, pf.returndef.typename);
+                            result:=false;
+                          end;
+                        if not assigned(tobjectdef(pf.returndef).search_enumerator_current) then
+                          begin
+                            Message1(sym_e_no_enumerator_current,pf.returndef.typename);
+                            result:=false;
+                          end;
+                      end;
                   end
                 else
                   begin