* give a more understandable error message if a procedure "result" is tried to be a

ssigned, resolves #19122 (and breaks hopefully nothing procvar related)

git-svn-id: trunk@18267 -
This commit is contained in:
florian 2011-08-18 21:10:05 +00:00
parent 31d11c0321
commit cf874a3465
4 changed files with 325 additions and 313 deletions

View File

@ -1761,7 +1761,10 @@ type_e_class_helper_must_extend_subclass=04101_E_Derived class helper must exten
type_e_record_helper_must_extend_same_record=04102_E_Derived record helper must extend "$1" type_e_record_helper_must_extend_same_record=04102_E_Derived record helper must extend "$1"
% If a record helper inherits from another record helper it must extend the same % If a record helper inherits from another record helper it must extend the same
% record that the parent record helper extended. % record that the parent record helper extended.
% type_e_procedures_return_no_value=04103_E_Invalid assignment, procedures return no value
% This error occurs when one tries to assign the result of a procedure or destructor call.
% A procedure or destructor returns no value so this is not
% possible.
% \end{description} % \end{description}
# #
# Symtable # Symtable

View File

@ -498,6 +498,7 @@ const
type_e_record_type_expected=04100; type_e_record_type_expected=04100;
type_e_class_helper_must_extend_subclass=04101; type_e_class_helper_must_extend_subclass=04101;
type_e_record_helper_must_extend_same_record=04102; type_e_record_helper_must_extend_same_record=04102;
type_e_procedures_return_no_value=04103;
sym_e_id_not_found=05000; sym_e_id_not_found=05000;
sym_f_internal_error_in_symtablestack=05001; sym_f_internal_error_in_symtablestack=05001;
sym_e_duplicate_id=05002; sym_e_duplicate_id=05002;
@ -900,9 +901,9 @@ const
option_info=11024; option_info=11024;
option_help_pages=11025; option_help_pages=11025;
MsgTxtSize = 60991; MsgTxtSize = 61046;
MsgIdxMax : array[1..20] of longint=( MsgIdxMax : array[1..20] of longint=(
26,89,314,103,85,54,111,23,202,63, 26,89,314,104,85,54,111,23,202,63,
49,20,1,1,1,1,1,1,1,1 49,20,1,1,1,1,1,1,1,1
); );

File diff suppressed because it is too large Load Diff

View File

@ -625,7 +625,16 @@ implementation
begin begin
{ check if the assignment may cause a range check error } { check if the assignment may cause a range check error }
check_ranges(fileinfo,right,left.resultdef); check_ranges(fileinfo,right,left.resultdef);
inserttypeconv(right,left.resultdef);
{ beginners might be confused about an error message like
Incompatible types: got "untyped" expected "LongInt"
when trying to assign the result of a procedure, so give
a better error message, see also #19122 }
if (left.resultdef.typ<>procvardef) and
(right.nodetype=calln) and is_void(right.resultdef) then
CGMessage(type_e_procedures_return_no_value)
else
inserttypeconv(right,left.resultdef);
end; end;
{ call helpers for interface } { call helpers for interface }