2021-05-05 18:29:44 +03:00
|
|
|
/*
|
|
|
|
namespace: Compile
|
|
|
|
expectation: Pass
|
|
|
|
input_file: input/dummy.in
|
|
|
|
*/
|
|
|
|
|
2020-08-01 06:59:50 +03:00
|
|
|
// Functions input in leo are pass-by-value.
|
2020-05-21 01:51:57 +03:00
|
|
|
//
|
|
|
|
// Program execution:
|
|
|
|
// line 15: variable `a` is defined with value `1`.
|
|
|
|
// line 16: value `1` is copied and passed into function `bad_mutate()`.
|
|
|
|
// line 10: variable `x` is defined with value `1`.
|
|
|
|
// line 11: variable `x` is set to value `0`.
|
|
|
|
// line 18: program returns the value of `a`.
|
|
|
|
|
2021-03-19 18:30:24 +03:00
|
|
|
function bad_mutate(x: u32) {
|
2020-05-21 01:51:57 +03:00
|
|
|
x = 0; // <- does not change `a`
|
|
|
|
}
|
|
|
|
|
2021-05-13 16:56:17 +03:00
|
|
|
function main(y: bool) -> bool {
|
2021-03-18 22:19:07 +03:00
|
|
|
const a = 1u32;
|
2020-05-21 01:51:57 +03:00
|
|
|
bad_mutate(a);
|
|
|
|
|
2021-05-13 16:56:17 +03:00
|
|
|
return a == 1u32 == y; // <- value `a` is still `1u32`
|
2021-05-05 18:29:44 +03:00
|
|
|
}
|