diff --git a/HOME_EXAM.md b/HOME_EXAM.md index 170ab95bbb3ec8bcd2cc6301149258585e6dcee6..f5809c0537cc8cc55a64fb1a3627dc206249d56a 100644 --- a/HOME_EXAM.md +++ b/HOME_EXAM.md @@ -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