Skip to content
Snippets Groups Projects
Commit c68d1af3 authored by Wilma Krutrök's avatar Wilma Krutrök
Browse files

Update HOME_EXAM.md

parent 145e8ffc
Branches
No related tags found
No related merge requests found
......@@ -443,10 +443,16 @@ Let statements works in a similiar way.
##### Functioncall
```math
\frac{}{};
\frac{(<e_1,σ> → n_1 ... <e_i,σ> → n_i) → σ(arg1 := n_1, ..., argi := n_i))}{<c,σ> → (x,σ')}; \text{where x is the return value}
```
```rust
fn a(x: i32) -> () {
x = x + 1;
}
fn main() -> () {
a(5+2);
}
```
#### Showcase step by step
......@@ -555,7 +561,7 @@ fn b() -> bool {
##### Conditional command
```math
\frac{<e,σ>\text{ bool } <c0,σ> → t}{<\text{ if e then } c0 \text{ else } c1,σ> → t}, where t = type of last statement
\frac{<e,σ> → \text{ bool } <c0,σ> → t}{<\text{ if e then } c0 \text{ else } c1,σ> → t}, \text{ where t = type of last statement }
```
For the if statement to go through the type checker need the expression, e, be a boolean.
......@@ -586,10 +592,22 @@ The example above is valid for the type checker due to it only checking that the
##### Functioncall
```math
\frac{}{};
\frac{(<e_1,σ> → t1 ... <e_i,σ> → ti)}{<c,σ> → t_res}, \text{ where t_res = return type of function }
```
Each expression evaluating to the same type as the arguments connected to the function.
```rust
fn a(x: i32) -> bool {
x < 5;
}
fn b(x: bool, y: i32) -> () {
x = x + 1;
}
fn main() -> () {
a(5+2); // Valid
b(true, 5 < 7); //Invalid for type checker
}
```
#### Coverage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment