Browse Source

* better error messages for non-overloadable operators:
* only suggest = if the user tried to overload <>
* suggest ** if the user tried to overload ^ (mantis #9606)
* no suggestion otherwise
(instead of always suggesting '=')

git-svn-id: trunk@8402 -

Jonas Maebe 18 years ago
parent
commit
91629f810f
5 changed files with 253 additions and 245 deletions
  1. 1 1
      compiler/msg/errore.msg
  2. 1 1
      compiler/msgidx.inc
  3. 242 241
      compiler/msgtxt.inc
  4. 8 1
      compiler/pdecsub.pas
  5. 1 1
      compiler/scanner.pas

+ 1 - 1
compiler/msg/errore.msg

@@ -638,7 +638,7 @@ parser_e_no_new_or_dispose_for_classes=03086_E_The extended syntax of new or dis
 parser_e_procedure_overloading_is_off=03088_E_Procedure overloading is switched off
 % When using the \var{-So} switch, procedure overloading is switched off.
 % Turbo Pascal does not support function overloading.
-parser_e_overload_operator_failed=03089_E_It is not possible to overload this operator (overload = instead)
+parser_e_overload_operator_failed=03089_E_It is not possible to overload this operator. Related overloadable operators (if any) are: $1
 % You are trying to overload an operator which cannot be overloaded.
 % The following operators can be overloaded :
 % \begin{verbatim}

+ 1 - 1
compiler/msgidx.inc

@@ -731,7 +731,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 45039;
+  MsgTxtSize = 45067;
 
   MsgIdxMax : array[1..20] of longint=(
     24,86,237,83,63,49,107,22,135,60,

File diff suppressed because it is too large
+ 242 - 241
compiler/msgtxt.inc


+ 8 - 1
compiler/pdecsub.pas

@@ -1055,7 +1055,14 @@ implementation
                end
               else
                begin
-                 Message(parser_e_overload_operator_failed);
+                 case token of
+                   _CARET:
+                     Message1(parser_e_overload_operator_failed,'**');
+                   _UNEQUAL:
+                     Message1(parser_e_overload_operator_failed,'=');
+                   else
+                     Message1(parser_e_overload_operator_failed,'');
+                 end;
                  { Use the dummy NOTOKEN that is also declared
                    for the overloaded_operator[] }
                  optoken:=NOTOKEN;

+ 1 - 1
compiler/scanner.pas

@@ -3498,7 +3498,7 @@ In case not, the value returned can be arbitrary.
                     readchar;
                     c:=upcase(c);
                     if (block_type in [bt_type,bt_specialize]) or
-                       (lasttoken=_ID) or (lasttoken=_NIL) or
+                       (lasttoken=_ID) or (lasttoken=_NIL) or (lasttoken=_OPERATOR) or
                        (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
                      begin
                        token:=_CARET;

Some files were not shown because too many files changed in this diff