Given a list of arguments $\overrightarrow{v} = [v_1, \ldots, v_n]$ the call of function $p$ will evaulate to a value $n$ (the return value, if any) according to
Given a list of arguments $`\overrightarrow{v} = [v_1, \ldots, v_n]`$ the call of function $`p`$ will evaulate to a value $`n`$ (the return value, if any) according to
@@ -550,9 +556,9 @@ Error: Mismatched type for operation '=='
...
@@ -550,9 +556,9 @@ Error: Mismatched type for operation '=='
Note: expected i32, found bool
Note: expected i32, found bool
Could not compile 'input.rs'
Could not compile 'input.rs'
```
```
By this it can be seen that the type checker assumes that the type of ```a``` is correct when checking the assignment of ```b``` which indeed would be correctly typed if the former variable would have been correctly assigned a i32 value. This is done by concluding that `5 * true` would evaluate to a i32 value if it was correctly typed and then the entire expression `5 + 5 * true` will be correctly typed.
By this it can be seen that the type checker assumes that the type of `a` is correct when checking the assignment of `b` which indeed would be correctly typed if the former variable would have been correctly assigned a i32 value. This is done by concluding that `5 * true` would evaluate to a i32 value if it was correctly typed and then the entire expression `5 + 5 * true` will be correctly typed.
Thus by following this pattern the type checker is able to continue type checking and reporting new errors, which can be seen when it reports that the assignment of ```c``` is incorrect (boolean equals requires the same type on each side).
Thus by following this pattern the type checker is able to continue type checking and reporting new errors, which can be seen when it reports that the assignment of `c` is incorrect (boolean equals requires the same type on each side).
The type checker also makes sure that functions with a specified return type always returns. This is done by going through each function and making sure that a tailing return statement or a return inside an else-statement exists. If this is not the case the error is reported along with all other type errors found.
The type checker also makes sure that functions with a specified return type always returns. This is done by going through each function and making sure that a tailing return statement or a return inside an else-statement exists. If this is not the case the error is reported along with all other type errors found.
...
@@ -567,7 +573,8 @@ It also needs to keep track of the kind of borrow that have been made to a resou
...
@@ -567,7 +573,8 @@ It also needs to keep track of the kind of borrow that have been made to a resou
# Your LLVM backend
# Your LLVM backend
- Let your backend produces LLVM-IR for your example program.
- Let your backend produces LLVM-IR for your example program.