Skip to content

Commit

Permalink
fix: 每天都在修outlive
Browse files Browse the repository at this point in the history
  • Loading branch information
Bylx666 committed Apr 16, 2024
1 parent 87bd09f commit 12a16b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 6 additions & 7 deletions samples/helloworld.ks
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

//mod D:\code\rs\tst\target\debug\tstlib.dll> m;

let a() {
try throw (299)
catch e {
:e
}
}

log(a())
let a = 5;
let f1() {
let a = 20;
:||:a // 相当于return (||return a)
}
log(f1()()) // 20
4 changes: 3 additions & 1 deletion src/runtime/outlive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ pub fn decrease_scope_count(mut scope: Scope) {

loop {
let prev = scope.outlives.fetch_sub(1, Ordering::Relaxed);
let parent = scope.parent;
if prev == 1 && scope.ended {
// println!("{:02}: scope drop by func: {:p}",ln(), scope.ptr);
unsafe{ std::ptr::drop_in_place(scope.ptr) }
scope.ptr = std::ptr::null_mut();
}
if let Some(prt) = scope.parent {
if let Some(prt) = parent {
scope = prt;
}else {
break;
Expand Down

0 comments on commit 12a16b7

Please sign in to comment.