Type Checking
Type checking is the compiler's task that validates the type-correctness of the source program
with respect to the source language type rules (a subset of the language semantic's rules).
After parsing the input (to find its structure),
the compiler must check whether the input program is type-correct.
This is called type checking and is part of the semantic analysis.
During type checking, a compiler checks whether the use of names (such as variables, functions, type names)
in the proper body (statements part) is consistent with their definition in the declarations part.
For example, if a variable x has been defined to be of type int, then x+1
is correct since it adds two integers while x[1] is wrong.
When the type checker detects an inconsistency, it reports an error
(such as ``Error: an integer was expected").
Another example of an inconsistency is calling a function with fewer or more
parameters or passing parameters of the wrong type.
|