creusot
creusot copied to clipboard
Creusot panics when using `gh!` inside a closure
This code crashes creusot with "called Option::unwrap()
on a None
value":
fn f() {
let x = 1;
let clos = || {
let y = gh!(x);
};
}
It seems this is because creusot assumes a variable captured in gh!
is always defined in the enclosing function.
Maybe the following is enough
// creusot/src/translation/specification.rs:125
- Place(p) => p.as_local().unwrap(),
+ Place(p) => p.local,
Am I missing something ?
Have you tested?
I haven't tested anything, but it seems to me that p should be the closure itself, with the projection being the the captured variable. So no, I would rather bet (but I'm unsure) there is something more subtle to be done here.
Yea it is that line but that's not going to be a correct fix, the purpose of that line is to identify the captures of ghost closures, which need to be erased and I think it glitches out for "ghost captures".
Fixed by #1106