| Issue 33: | Type checking in compiler | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The compiler should check types in expressions, assignments, function calls, and return statements. There is no polymorphism to worry about. The only real difficulty is that expressions (e.g. return value of function) can be ignored. So, here's what to check: Expressions: (x # y); has type depending on types of x and y and operator #. Types of x, y, and # must be a valid combination. (These will be hardcoded for each arithmetic operator; probably just int based initially.) Similarly for (#x). For f(x, y), type of expression is return type of f. If an expression is ignored, no check is done (e.g. a function call that's not assigned to anything). Assignments: x = y; x and y must have same type. Function calls: f(x, y); if types of x and y and T and Y, type of f must be (T, U) -> W. Return values: return x; if surrounding function is of type (T -> W), x must be of type W.
Aug 23, 2015
Project Member
#1
ejrh00@gmail.com
Status:
WontFix
|