Skip to content

Commit 4379788

Browse files
authored
Merge pull request #76 from FStarLang/_taramana_pure_ghost_stmt
Support _ghost_stmt in _pure functions
2 parents 2cd97d5 + 5959b39 commit 4379788

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/pass/emit.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,6 +2598,25 @@ impl<'a> Emitter<'a> {
25982598
)
25992599
}
26002600

2601+
StmtT::GhostStmt(code) => {
2602+
let env = &mut env.clone();
2603+
let ghost_doc = self.emit_inline_pulse_tokens(env, code);
2604+
let rest = self.emit_pure_body(env, &stmts[1..]);
2605+
parens(
2606+
Doc::text("let")
2607+
.append(Doc::line())
2608+
.append("_")
2609+
.append(Doc::line())
2610+
.append("=")
2611+
.group()
2612+
.nest(2)
2613+
.append(Doc::line().append(ghost_doc).nest(2))
2614+
.append(Doc::line())
2615+
.append("in")
2616+
.append(Doc::line().append(rest).nest(2)),
2617+
)
2618+
}
2619+
26012620
StmtT::Decl(x, ty) => {
26022621
// Look for the assignment to this variable in the next statement
26032622
if stmts.len() >= 3 {

test/pure_fn.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ void test() {
4949
bool pure_not_result = pure_not(true);
5050
_assert(pure_not_result == false);
5151
}
52+
53+
_pure int pure_ghost_stmt()
54+
_ensures(1 == 0)
55+
{
56+
_ghost_stmt(assume False);
57+
return 1;
58+
}

0 commit comments

Comments
 (0)