FROM M2Base IMPORT Nil, IsRealType, GetBaseTypeMinMax,
Cardinal, Integer, ZType, IsComplexType,
- IsAssignmentCompatible,
IsExpressionCompatible,
IsParameterCompatible,
ExceptionAssign,
PROCEDURE FoldTypeReturnFunc (q: CARDINAL; tokenNo: CARDINAL; func, val: CARDINAL; r: CARDINAL) ;
VAR
+ valType,
returnType: CARDINAL ;
BEGIN
returnType := GetType (func) ;
func, val) ;
SubQuad(q)
END
- ELSIF AssignmentTypeCompatible (tokenNo, "", returnType, val, FALSE)
- THEN
- SubQuad (q)
ELSE
- IF NOT reportedError (r)
+ valType := val ;
+ IF IsVar (val) AND (GetMode (val) = LeftValue)
THEN
- MetaErrorsT2 (tokenNo,
- 'the return type {%1Etad} used in procedure {%1Da}',
- 'is incompatible with the returned expression {%1ad}}',
- func, val) ;
- setReported (r) ;
- FlushErrors
+ valType := GetType (val)
+ END ;
+ IF AssignmentTypeCompatible (tokenNo, "", returnType, valType, FALSE)
+ THEN
+ SubQuad (q)
+ ELSE
+ IF NOT reportedError (r)
+ THEN
+ MetaErrorsT2 (tokenNo,
+ 'the return type {%1Etad} used in procedure {%1Da}',
+ 'is incompatible with the returned expression {%1ad}}',
+ func, val) ;
+ setReported (r) ;
+ FlushErrors
+ END
END
END
END FoldTypeReturnFunc ;
ELSE
exprType := GetType (expr)
END ;
- IF IsAssignmentCompatible (desType, exprType)
+ IF AssignmentTypeCompatible (tokenNo, "", GetType (des), GetType (expr), FALSE)
THEN
SubQuad(q)
ELSE
*)
PROCEDURE CodeTypeReturnFunc (tokenNo: CARDINAL; func, val: CARDINAL; r: CARDINAL) ;
+VAR
+ valType,
+ returnType: CARDINAL ;
BEGIN
- IF NOT AssignmentTypeCompatible (tokenNo, "", GetType (func), val, FALSE)
+ returnType := GetType (func) ;
+ IF returnType = NulSym
THEN
IF NOT reportedError (r)
THEN
MetaErrorsT2 (tokenNo,
- 'the return type {%1Etad} used in procedure function {%1Da}',
- 'is incompatible with the returned expression {%2EUa} {%2tad:of type {%2tad}}',
+ 'procedure {%1Da} is not a procedure function',
+ '{%2ad} cannot be returned from {%1Da}',
func, val) ;
- setReported (r)
+ END
+ ELSE
+ valType := val ;
+ IF IsVar (val) AND (GetMode (val) = LeftValue)
+ THEN
+ valType := GetType (val)
+ END ;
+ IF NOT AssignmentTypeCompatible (tokenNo, "", returnType, valType, FALSE)
+ THEN
+ IF NOT reportedError (r)
+ THEN
+ MetaErrorsT2 (tokenNo,
+ 'the return type {%1Etad} used in procedure function {%1Da}',
+ 'is incompatible with the returned expression {%2EUa} {%2tad:of type {%2tad}}',
+ func, val)
+ END
END
END
END CodeTypeReturnFunc ;
PROCEDURE CodeTypeIndrX (tokenNo: CARDINAL; des, expr: CARDINAL; r: CARDINAL) ;
BEGIN
- IF NOT IsAssignmentCompatible (GetType (des), GetType (expr))
+ IF NOT AssignmentTypeCompatible (tokenNo, "", GetType (des), GetType (expr), FALSE)
THEN
IF NOT reportedError (r)
THEN
des, expr) ;
ELSE
MetaErrorT2 (tokenNo,
- 'assignment designator {%1Ea} {%1ta:of type {%1ta}} {%1d:is a {%1d}} and expression {%2a} {%2tad:of type {%2tad}} are incompatible',
+ 'assignment designator {%1Ea} {%1ta:of type {%1ta}}' +
+ ' {%1d:is a {%1d}} and expression {%2a}' +
+ ' {%2tad:of type {%2tad}} are incompatible',
des, expr)
END ;
setReported (r)