diff --git a/compiler/oxidate/src/compiler.rs b/compiler/oxidate/src/compiler.rs index 695eff1..7cfa714 100644 --- a/compiler/oxidate/src/compiler.rs +++ b/compiler/oxidate/src/compiler.rs @@ -326,8 +326,17 @@ impl Compiler { // push RESET arr.push(ByteCode::RESET(bytecode::FrameType::CallFrame)) } - Decl::WaitStmt(_) => {} - Decl::PostStmt(_) => {} + // These don't return anything, so push unit after as well + Decl::WaitStmt(sem) => { + arr.push(ByteCode::ld(sem)); + arr.push(ByteCode::WAIT); + arr.push(ByteCode::ldc(Value::Unit)); + } + Decl::PostStmt(sem) => { + arr.push(ByteCode::ld(sem)); + arr.push(ByteCode::POST); + arr.push(ByteCode::ldc(Value::Unit)); + } }; Ok(()) diff --git a/compiler/oxidate/src/tests.rs b/compiler/oxidate/src/tests.rs index 8e6dc14..404b3d6 100644 --- a/compiler/oxidate/src/tests.rs +++ b/compiler/oxidate/src/tests.rs @@ -1162,4 +1162,14 @@ mod tests { ], ); } + + #[test] + fn test_compile_wait_post() { + let t = r" + wait sem; + 2; + post sem; + "; + // test_comp(t, vec![]); + } } diff --git a/example/concurrency-03.rst b/example/concurrency-03.rst index e4dba51..f5415a7 100644 --- a/example/concurrency-03.rst +++ b/example/concurrency-03.rst @@ -1,3 +1,5 @@ +// Expected: inconsistent count on each run due to race on count + let count = 0; fn increment(times: int) { diff --git a/example/concurrency-04.rst b/example/concurrency-04.rst index 4cdbc47..e95a80e 100644 --- a/example/concurrency-04.rst +++ b/example/concurrency-04.rst @@ -1,3 +1,5 @@ +// Expected: count = 3000 on each run + let count = 0; let sem = sem_create();