You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod LinearExampleStub {
struct Linear {
x: i32,
y: i32,
}
fn main() -> i32 {
let mut xy: Linear =
Linear {
x: 0,
y: 1,
};
// linear value is written/consumed
consume_x(&xy);
return xy.x;
}
fn consume_x(value: & mut Linear) {
value.x = value.x + 1;
}
}
$cargo r build linearExample02.con --ir
Compiling linearExample02 (linearExample02.con)
thread 'main' panicked at crates/concrete_ir/src/lib.rs:475:38:
not yet implemented
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Changing parameter as non mutable yields an expected error conducting to make the parameter mutable. So this new feature (checking mutable types) should implement mutable parameters for being able to cover borrow checking part of LinearityCheck
mod LinearExampleStub {
struct Linear {
x: i32,
y: i32,
}
fn main() -> i32 {
let mut xy: Linear =
Linear {
x: 0,
y: 1,
};
// linear value is written/consumed
consume_x(&xy);
return xy.x;
}
fn consume_x(value: & Linear) {
value.x = value.x + 1;
}
}
$cargo r build linearExample02.con --ir
Compiling linearExample02 (linearExample02.con)
[NotMutable] Error:
╭─[linearExample02.con:22:3]
│
21 │ fn consume_x(value: & Linear) {
│ ──┬──
│ ╰──── variable declared here
22 │ value.x = value.x + 1;
│ ──────────┬──────────
│ ╰──────────── can't mutate this variable because it's not mutable
────╯
The text was updated successfully, but these errors were encountered:
The first example panics the compiler, it is better if it gives a compilation error than panic.
kenarab
changed the title
Need mutable parameters for building a test case for borrowing a Lineartype
Found a case where compiler should throw an Error but panics
May 11, 2024
Lines 474-475 of lib.rs
Changing parameter as non mutable yields an expected error conducting to make the parameter mutable. So this new feature (checking mutable types) should implement mutable parameters for being able to cover borrow checking part of LinearityCheck
The text was updated successfully, but these errors were encountered: