فهرست منبع

* give a proper error when a type identifier is missing in a
class operator declaration (mantis #19213)

git-svn-id: trunk@19226 -

Jonas Maebe 14 سال پیش
والد
کامیت
d714eeb84b
3فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/pdecsub.pas
  3. 16 0
      tests/webtbf/tw19213.pp

+ 1 - 0
.gitattributes

@@ -10974,6 +10974,7 @@ tests/webtbf/tw1842.pp svneol=native#text/plain
 tests/webtbf/tw1858.pp svneol=native#text/plain
 tests/webtbf/tw1858.pp svneol=native#text/plain
 tests/webtbf/tw18620.pp svneol=native#text/pascal
 tests/webtbf/tw18620.pp svneol=native#text/pascal
 tests/webtbf/tw1905.pp svneol=native#text/plain
 tests/webtbf/tw1905.pp svneol=native#text/plain
+tests/webtbf/tw19213.pp svneol=native#text/plain
 tests/webtbf/tw1927.pp svneol=native#text/plain
 tests/webtbf/tw1927.pp svneol=native#text/plain
 tests/webtbf/tw1928.pp svneol=native#text/plain
 tests/webtbf/tw1928.pp svneol=native#text/plain
 tests/webtbf/tw1939.pp svneol=native#text/plain
 tests/webtbf/tw1939.pp svneol=native#text/plain

+ 4 - 1
compiler/pdecsub.pas

@@ -1467,7 +1467,10 @@ implementation
                                break;
                                break;
                              end;
                              end;
                          if not found then
                          if not found then
-                           Message1(parser_e_at_least_one_argument_must_be_of_type,pd.struct.RttiName);
+                           if assigned(pd.struct) then
+                             Message1(parser_e_at_least_one_argument_must_be_of_type,pd.struct.RttiName)
+                           else
+                             MessagePos(pd.fileinfo,type_e_type_id_expected);
                        end;
                        end;
                      if (optoken in [_EQ,_NE,_GT,_LT,_GTE,_LTE,_OP_IN]) and
                      if (optoken in [_EQ,_NE,_GT,_LT,_GTE,_LTE,_OP_IN]) and
                         ((pd.returndef.typ<>orddef) or
                         ((pd.returndef.typ<>orddef) or

+ 16 - 0
tests/webtbf/tw19213.pp

@@ -0,0 +1,16 @@
+{ %fail }
+
+unit tw19213;
+
+{$mode objfpc}
+
+interface
+
+implementation
+
+class operator + (a, b: String): Integer;
+begin
+  Result := Length(a) + Length(b);
+end;
+
+end.