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
A closure passed into a promise that got dropped on the rust side gets called anyway.
Steps to Reproduce
Use this code as an ondrop handler.
let drop_handler = {move |e:DragEvent| {let c = Closure::new(|v| {debug!("handler called! v: {:#?}", v);});
e.prevent_default();debug!("Drop ev: {:#?}",
e.data_transfer().unwrap().files().unwrap().item(0).unwrap().text().then(&c));}};
Drop a file there
Expected Behavior
The compiler doesn't allow this code to compile, as only a reference to c is passed to .then(), the value behind which being dropped immediately after. The closure gets called anyway.
Actual Behavior
The code compiles, leading to the error message below.
Uncaught (in promise) Error: closure invoked recursively or destroyed already
Additional Context
This is happening inside of a yew project, but I suspect this is an issue with web-sys.
The text was updated successfully, but these errors were encountered:
This is expected. It'd be impossible to enforce at compile time that JS never calls a closure after it's dropped, since there's nothing stopping JS from just holding onto it for the rest of the program. So, this is the best we can do, just throwing an error if the closure gets mistakenly called after being dropped.
Describe the Bug
A closure passed into a promise that got dropped on the rust side gets called anyway.
Steps to Reproduce
ondrop
handler.Expected Behavior
The compiler doesn't allow this code to compile, as only a reference to
c
is passed to.then()
, the value behind which being dropped immediately after. The closure gets called anyway.Actual Behavior
The code compiles, leading to the error message below.
Additional Context
This is happening inside of a
yew
project, but I suspect this is an issue withweb-sys
.The text was updated successfully, but these errors were encountered: