Next: , Previous: TypeEq, Up: Top


9 Error Reporting in Type Analysis

The Expression module provides default error reporting associated with the following roles:

ExpressionSymbol
Condition:
It is not possible to coerce a value of the type specified by the Type attribute to a value of the type specified by the Required attribute.
Message:
`Incorrect type for this context'
Override symbols:
ExpMsg, ExpErr, ExpError

OperatorSymbol
Condition:
The indication is valid but no operator could be identified.
Message:
`Incorrect operand type(s) for this operator'
Override symbols:
OprMsg, OprErr, OprError

ArgumentListRoot
Condition:
The procedure requires more arguments than are present.
Message:
`Too few arguments'
Override symbols:
LstMsg, LstErr, LstError

ArgumentListElem
Condition:
The procedure requires fewer arguments than are present.
Message:
`Too many arguments'
Override symbols:
ArgMsg, ArgErr, ArgError

This error reporting can be changed by overriding computations for the `xxx'Msg attribute. The `xxx'Err attribute has the value 1 if the error condition is met, 0 otherwise. Thus the overriding computation might be of the form:

     `s'.`xxx'Msg=
       IF(`s'.`xxx'Err,message(ERROR,"My report",0,COORDREF));

Because `s'.`xxx'Msg is of type VOID, you can remove a report completely by setting `s'.`xxx'Msg to "no".

If you wish to override the message in every context, write the overriding computation as a symbol computation in the lower context of the override symbol specified above. In this case, `xxx' would be SYNT. Here is an example, changing the error report for invalid operators in all contexts:

     SYMBOL OprError COMPUTE
       SYNT.OprMsg=
         IF(SYNT.OprErr,message(ERROR,"Invalid operator",0,COORDREF));
     END;

If you wish to override the message in a few specific contexts, write the overriding computation as a rule computation in the lower context of a symbol inheriting the computational role. In this case, `xxx' would be the symbol on the left-hand side of the rule. Here is an example, changing the error report for procedure arguments of the wrong type in Mystery:

     RULE: Actual ::= Expr
     COMPUTE
       Actual.ExpMsg=
         IF(Actual.ExpErr,message(ERROR,"Wrong argument type",0,COORDREF));
     END;