Error Messages

In case of an error the interpreter produces a descriptive error message. An error message consists of a source code coordinate and a description. The source code coordinate links the error to its origin in the GST-program. It defines a range of source code stretching from the first character of the code range to the last character of the code range. Both, first and last character, are defined by their file, line and column. Note that the last character actually points to the first character behind the range, which is a common technical convention.

Example:

In the following example an integer variable i is declared and initialized. The initialization uses a floatingpoint literal. Since an implicit conversion from floatingpoint to integer is not allowed in ST, the interpreter produces the descriptive error message given below when the program is loaded. The error message does not only report that a type-error has occured, it also gives the precise position: File aaa.nc, line 3, column 14 to 17. This code range displays the literal ‘1.5’. In addition, the programmed type (real) and the expected type (int) are reported. With such a detailed error message bugs can be fixed by the developer easily.

{
VAR
    i : int := 1.5;
END_VAR
}
M02

Error message:

aaa.nc: 3.14-3.17: Invalid implicit conversion from type
'<real literal>' to 'int'.