Above is a minus operation of two integers, following integer expressions can be described in the same way:
Above is a subtraction operation of two integers, following integer expressions can be described in the same way:
- +, Addition
-*, Multiplication
- /, Division
...
...
@@ -427,6 +427,7 @@ while a < 10 {
> - Give a simplified set of Type Checking Rules for your language (those rules look very much like the SOS rules, but over types not values). Also here you don't need to detail rules that are similar (follow the same pattern).
> - Demonstrate each "type rule" by an example. You may use one or several "programs" to showcase where rules successfully apply.
> - For your implementation, give a set of programs demonstrating that ill-typed programs are rejected, connect back to the Type Checking Rules to argue why these are illegal and thus should be rejected.
> - For your implementation, give a set of programs demonstrating that ill-typed programs are rejected, connect back to the Type Checking Rules to argue why these are illegal and thus should be rejected.
### If true/false expression
```math
\frac{<e, σ> → bool <c_1, σ> → t <c_2, σ> → t}{<\text{if } e \text{ then }c_1 \text{ else } c_2,σ> → t}
```
``` rust
if3>5{
func();
}
else{
anotherfunc();
}
if3-5{// Type missmatch
func();
}
else{
anotherfunc();
}
```
### While expression
```math
\frac{<e, σ> → bool <c, σ> → σ'}{<\text{while } e \text{ do } c, σ> → ()}
```
```math
\frac{<b, σ> → false}{<\text{while } b \text{ do } c, σ> → σ}
```
``` rust
leta=0;
whilea<10{
// something that should loop 10 times
a=a+1;
}
leta=0;
whilea*10{// Type missmatch
// something that should loop 10 times
a=a+1;
}
```
> - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
Our type checker rejects bad programs according to our rules and depending on what the error is you will get a error custom message.
## Your borrrow checker
- Give a specification for well versus ill formed borrows. (What are the rules the borrow checker should check).