Browse Source

* makes compiler report nice error when one tries to use specialize for function result type, based on a patch by Aleksa Todorovic, part of #15875

git-svn-id: trunk@16438 -
florian 14 years ago
parent
commit
675c3391d1
4 changed files with 237 additions and 225 deletions
  1. 1 1
      compiler/msg/errore.msg
  2. 1 1
      compiler/msgidx.inc
  3. 221 221
      compiler/msgtxt.inc
  4. 14 2
      compiler/ptype.pas

+ 1 - 1
compiler/msg/errore.msg

@@ -1183,7 +1183,7 @@ parser_e_field_not_allowed_here=03251_E_Fields cannot appear after a method or p
 % without starting a new visibility section (such as \var{public}, \var{private}, etc.). The reason is
 % without starting a new visibility section (such as \var{public}, \var{private}, etc.). The reason is
 % that otherwise the source code can appear ambiguous to the compiler, since it is possible to use modifiers
 % that otherwise the source code can appear ambiguous to the compiler, since it is possible to use modifiers
 % such as \var{default} and \var{register} also as field names.
 % such as \var{default} and \var{register} also as field names.
-parser_e_no_local_para_def=03252_E_Parameters cannot contain local type definitions. Use a separate type definition in a type block.
+parser_e_no_local_para_def=03252_E_Parameters or result types cannot contain local type definitions. Use a separate type definition in a type block.
 % In Pascal, types are not considered to be identical simply because they are semantically equivalent.
 % In Pascal, types are not considered to be identical simply because they are semantically equivalent.
 % Two variables or parameters are only considered to be of the same type if they refer to the
 % Two variables or parameters are only considered to be of the same type if they refer to the
 % same type definition.
 % same type definition.

+ 1 - 1
compiler/msgidx.inc

@@ -871,7 +871,7 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 57889;
+  MsgTxtSize = 57905;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
     24,88,298,97,82,54,111,22,202,63,
     24,88,298,97,82,54,111,22,202,63,

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


+ 14 - 2
compiler/ptype.pas

@@ -453,8 +453,20 @@ implementation
                  begin
                  begin
                    if try_to_consume(_SPECIALIZE) then
                    if try_to_consume(_SPECIALIZE) then
                      begin
                      begin
-                       dospecialize:=true;
-                       again:=true;
+                       if not(allowtypedef) then
+                         begin
+                           Message(parser_e_no_local_para_def);
+
+                           { try to recover }
+                           while token<>_SEMICOLON do
+                             consume(token);
+                           def:=generrordef;
+                         end
+                       else
+                         begin
+                           dospecialize:=true;
+                           again:=true;
+                         end;
                      end
                      end
                    else
                    else
                      begin
                      begin

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