diff options
Diffstat (limited to 'tests/fstar/misc')
-rw-r--r-- | tests/fstar/misc/Bitwise.fst | 6 | ||||
-rw-r--r-- | tests/fstar/misc/Constants.fst | 34 | ||||
-rw-r--r-- | tests/fstar/misc/External.Funs.fst | 12 | ||||
-rw-r--r-- | tests/fstar/misc/External.FunsExternal.fsti | 9 | ||||
-rw-r--r-- | tests/fstar/misc/External.TypesExternal.fsti | 3 | ||||
-rw-r--r-- | tests/fstar/misc/Loops.Funs.fst | 143 | ||||
-rw-r--r-- | tests/fstar/misc/NoNestedBorrows.fst | 133 | ||||
-rw-r--r-- | tests/fstar/misc/Paper.fst | 30 | ||||
-rw-r--r-- | tests/fstar/misc/PoloniusList.fst | 12 | ||||
-rw-r--r-- | tests/fstar/misc/Primitives.fst | 56 |
10 files changed, 212 insertions, 226 deletions
diff --git a/tests/fstar/misc/Bitwise.fst b/tests/fstar/misc/Bitwise.fst index 7330f07a..11ef6861 100644 --- a/tests/fstar/misc/Bitwise.fst +++ b/tests/fstar/misc/Bitwise.fst @@ -18,15 +18,15 @@ let shift_i32 (a : i32) : result i32 = (** [bitwise::xor_u32]: Source: 'src/bitwise.rs', lines 17:0-17:37 *) let xor_u32 (a : u32) (b : u32) : result u32 = - Return (u32_xor a b) + Ok (u32_xor a b) (** [bitwise::or_u32]: Source: 'src/bitwise.rs', lines 21:0-21:36 *) let or_u32 (a : u32) (b : u32) : result u32 = - Return (u32_or a b) + Ok (u32_or a b) (** [bitwise::and_u32]: Source: 'src/bitwise.rs', lines 25:0-25:37 *) let and_u32 (a : u32) (b : u32) : result u32 = - Return (u32_and a b) + Ok (u32_and a b) diff --git a/tests/fstar/misc/Constants.fst b/tests/fstar/misc/Constants.fst index 8d1cf3ce..4fbafb83 100644 --- a/tests/fstar/misc/Constants.fst +++ b/tests/fstar/misc/Constants.fst @@ -7,17 +7,17 @@ open Primitives (** [constants::X0] Source: 'src/constants.rs', lines 5:0-5:17 *) -let x0_body : result u32 = Return 0 +let x0_body : result u32 = Ok 0 let x0 : u32 = eval_global x0_body (** [constants::X1] Source: 'src/constants.rs', lines 7:0-7:17 *) -let x1_body : result u32 = Return core_u32_max +let x1_body : result u32 = Ok core_u32_max let x1 : u32 = eval_global x1_body (** [constants::X2] Source: 'src/constants.rs', lines 10:0-10:17 *) -let x2_body : result u32 = Return 3 +let x2_body : result u32 = Ok 3 let x2 : u32 = eval_global x2_body (** [constants::incr]: @@ -33,7 +33,7 @@ let x3 : u32 = eval_global x3_body (** [constants::mk_pair0]: Source: 'src/constants.rs', lines 23:0-23:51 *) let mk_pair0 (x : u32) (y1 : u32) : result (u32 & u32) = - Return (x, y1) + Ok (x, y1) (** [constants::Pair] Source: 'src/constants.rs', lines 36:0-36:23 *) @@ -42,7 +42,7 @@ type pair_t (t1 t2 : Type0) = { x : t1; y : t2; } (** [constants::mk_pair1]: Source: 'src/constants.rs', lines 27:0-27:55 *) let mk_pair1 (x : u32) (y1 : u32) : result (pair_t u32 u32) = - Return { x = x; y = y1 } + Ok { x = x; y = y1 } (** [constants::P0] Source: 'src/constants.rs', lines 31:0-31:24 *) @@ -56,12 +56,12 @@ let p1 : pair_t u32 u32 = eval_global p1_body (** [constants::P2] Source: 'src/constants.rs', lines 33:0-33:24 *) -let p2_body : result (u32 & u32) = Return (0, 1) +let p2_body : result (u32 & u32) = Ok (0, 1) let p2 : (u32 & u32) = eval_global p2_body (** [constants::P3] Source: 'src/constants.rs', lines 34:0-34:28 *) -let p3_body : result (pair_t u32 u32) = Return { x = 0; y = 1 } +let p3_body : result (pair_t u32 u32) = Ok { x = 0; y = 1 } let p3 : pair_t u32 u32 = eval_global p3_body (** [constants::Wrap] @@ -71,7 +71,7 @@ type wrap_t (t : Type0) = { value : t; } (** [constants::{constants::Wrap<T>}::new]: Source: 'src/constants.rs', lines 54:4-54:41 *) let wrap_new (t : Type0) (value : t) : result (wrap_t t) = - Return { value = value } + Ok { value = value } (** [constants::Y] Source: 'src/constants.rs', lines 41:0-41:22 *) @@ -81,7 +81,7 @@ let y : wrap_t i32 = eval_global y_body (** [constants::unwrap_y]: Source: 'src/constants.rs', lines 43:0-43:30 *) let unwrap_y : result i32 = - Return y.value + Ok y.value (** [constants::YVAL] Source: 'src/constants.rs', lines 47:0-47:19 *) @@ -90,13 +90,13 @@ let yval : i32 = eval_global yval_body (** [constants::get_z1::Z1] Source: 'src/constants.rs', lines 62:4-62:17 *) -let get_z1_z1_body : result i32 = Return 3 +let get_z1_z1_body : result i32 = Ok 3 let get_z1_z1 : i32 = eval_global get_z1_z1_body (** [constants::get_z1]: Source: 'src/constants.rs', lines 61:0-61:28 *) let get_z1 : result i32 = - Return get_z1_z1 + Ok get_z1_z1 (** [constants::add]: Source: 'src/constants.rs', lines 66:0-66:39 *) @@ -105,12 +105,12 @@ let add (a : i32) (b : i32) : result i32 = (** [constants::Q1] Source: 'src/constants.rs', lines 74:0-74:17 *) -let q1_body : result i32 = Return 5 +let q1_body : result i32 = Ok 5 let q1 : i32 = eval_global q1_body (** [constants::Q2] Source: 'src/constants.rs', lines 75:0-75:17 *) -let q2_body : result i32 = Return q1 +let q2_body : result i32 = Ok q1 let q2 : i32 = eval_global q2_body (** [constants::Q3] @@ -125,7 +125,7 @@ let get_z2 : result i32 = (** [constants::S1] Source: 'src/constants.rs', lines 80:0-80:18 *) -let s1_body : result u32 = Return 6 +let s1_body : result u32 = Ok 6 let s1 : u32 = eval_global s1_body (** [constants::S2] @@ -135,7 +135,7 @@ let s2 : u32 = eval_global s2_body (** [constants::S3] Source: 'src/constants.rs', lines 82:0-82:29 *) -let s3_body : result (pair_t u32 u32) = Return p3 +let s3_body : result (pair_t u32 u32) = Ok p3 let s3 : pair_t u32 u32 = eval_global s3_body (** [constants::S4] @@ -149,11 +149,11 @@ type v_t (t : Type0) (n : usize) = { x : array t n; } (** [constants::{constants::V<T, N>#1}::LEN] Source: 'src/constants.rs', lines 91:4-91:24 *) -let v_len_body (t : Type0) (n : usize) : result usize = Return n +let v_len_body (t : Type0) (n : usize) : result usize = Ok n let v_len (t : Type0) (n : usize) : usize = eval_global (v_len_body t n) (** [constants::use_v]: Source: 'src/constants.rs', lines 94:0-94:42 *) let use_v (t : Type0) (n : usize) : result usize = - Return (v_len t n) + Ok (v_len t n) diff --git a/tests/fstar/misc/External.Funs.fst b/tests/fstar/misc/External.Funs.fst index 3ba20022..d4247b8f 100644 --- a/tests/fstar/misc/External.Funs.fst +++ b/tests/fstar/misc/External.Funs.fst @@ -22,10 +22,10 @@ let test_new_non_zero_u32 (** [external::test_vec]: Source: 'src/external.rs', lines 17:0-17:17 *) let test_vec : result unit = - let* _ = alloc_vec_Vec_push u32 (alloc_vec_Vec_new u32) 0 in Return () + let* _ = alloc_vec_Vec_push u32 (alloc_vec_Vec_new u32) 0 in Ok () (** Unit test for [external::test_vec] *) -let _ = assert_norm (test_vec = Return ()) +let _ = assert_norm (test_vec = Ok ()) (** [external::custom_swap]: Source: 'src/external.rs', lines 24:0-24:66 *) @@ -34,8 +34,8 @@ let custom_swap result (state & (t & (t -> state -> result (state & (t & t))))) = let* (st1, (x1, y1)) = core_mem_swap t x y st in - let back_'a = fun ret st2 -> Return (st2, (ret, y1)) in - Return (st1, (x1, back_'a)) + let back = fun ret st2 -> Ok (st2, (ret, y1)) in + Ok (st1, (x1, back)) (** [external::test_custom_swap]: Source: 'src/external.rs', lines 29:0-29:59 *) @@ -43,12 +43,12 @@ let test_custom_swap (x : u32) (y : u32) (st : state) : result (state & (u32 & u32)) = let* (st1, (_, custom_swap_back)) = custom_swap u32 x y st in let* (_, (x1, y1)) = custom_swap_back 1 st1 in - Return (st1, (x1, y1)) + Ok (st1, (x1, y1)) (** [external::test_swap_non_zero]: Source: 'src/external.rs', lines 35:0-35:44 *) let test_swap_non_zero (x : u32) (st : state) : result (state & u32) = let* (st1, p) = swap u32 x 0 st in let (x1, _) = p in - if x1 = 0 then Fail Failure else Return (st1, x1) + if x1 = 0 then Fail Failure else Ok (st1, x1) diff --git a/tests/fstar/misc/External.FunsExternal.fsti b/tests/fstar/misc/External.FunsExternal.fsti index a412aea9..4c1c58b7 100644 --- a/tests/fstar/misc/External.FunsExternal.fsti +++ b/tests/fstar/misc/External.FunsExternal.fsti @@ -7,16 +7,19 @@ include External.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [core::mem::swap]: - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 *) + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 + Name pattern: core::mem::swap *) val core_mem_swap (t : Type0) : t -> t -> state -> result (state & (t & t)) (** [core::num::nonzero::{core::num::nonzero::NonZeroU32#14}::new]: - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 79:16-79:57 *) + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 79:16-79:57 + Name pattern: core::num::nonzero::{core::num::nonzero::NonZeroU32}::new *) val core_num_nonzero_NonZeroU32_new : u32 -> state -> result (state & (option core_num_nonzero_NonZeroU32_t)) (** [core::option::{core::option::Option<T>}::unwrap]: - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 *) + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 + Name pattern: core::option::{core::option::Option<@T>}::unwrap *) val core_option_Option_unwrap (t : Type0) : option t -> state -> result (state & t) diff --git a/tests/fstar/misc/External.TypesExternal.fsti b/tests/fstar/misc/External.TypesExternal.fsti index 4bfbe0c5..45174c7e 100644 --- a/tests/fstar/misc/External.TypesExternal.fsti +++ b/tests/fstar/misc/External.TypesExternal.fsti @@ -6,7 +6,8 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [core::num::nonzero::NonZeroU32] - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 *) + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 + Name pattern: core::num::nonzero::NonZeroU32 *) val core_num_nonzero_NonZeroU32_t : Type0 (** The state type used in the state-error monad *) diff --git a/tests/fstar/misc/Loops.Funs.fst b/tests/fstar/misc/Loops.Funs.fst index 7c099da2..26cb91d2 100644 --- a/tests/fstar/misc/Loops.Funs.fst +++ b/tests/fstar/misc/Loops.Funs.fst @@ -70,7 +70,7 @@ let rec sum_array_loop let* s1 = u32_add s i1 in let* i2 = usize_add i 1 in sum_array_loop n a i2 s1 - else Return s + else Ok s (** [loops::sum_array]: Source: 'src/loops.rs', lines 50:0-50:52 *) @@ -92,7 +92,7 @@ let rec clear_loop let* i2 = usize_add i 1 in let* v1 = index_mut_back 0 in clear_loop v1 i2 - else Return v + else Ok v (** [loops::clear]: Source: 'src/loops.rs', lines 62:0-62:30 *) @@ -106,8 +106,8 @@ let rec list_mem_loop Tot (result bool) (decreases (list_mem_loop_decreases x ls)) = begin match ls with - | List_Cons y tl -> if y = x then Return true else list_mem_loop x tl - | List_Nil -> Return false + | List_Cons y tl -> if y = x then Ok true else list_mem_loop x tl + | List_Nil -> Ok false end (** [loops::list_mem]: @@ -125,12 +125,12 @@ let rec list_nth_mut_loop_loop begin match ls with | List_Cons x tl -> if i = 0 - then let back = fun ret -> Return (List_Cons ret tl) in Return (x, back) + then let back = fun ret -> Ok (List_Cons ret tl) in Ok (x, back) else let* i1 = u32_sub i 1 in let* (x1, back) = list_nth_mut_loop_loop t tl i1 in - let back1 = fun ret -> let* tl1 = back ret in Return (List_Cons x tl1) in - Return (x1, back1) + let back1 = fun ret -> let* tl1 = back ret in Ok (List_Cons x tl1) in + Ok (x1, back1) | List_Nil -> Fail Failure end @@ -151,7 +151,7 @@ let rec list_nth_shared_loop_loop begin match ls with | List_Cons x tl -> if i = 0 - then Return x + then Ok x else let* i1 = u32_sub i 1 in list_nth_shared_loop_loop t tl i1 | List_Nil -> Fail Failure end @@ -171,11 +171,11 @@ let rec get_elem_mut_loop begin match ls with | List_Cons y tl -> if y = x - then let back = fun ret -> Return (List_Cons ret tl) in Return (y, back) + then let back = fun ret -> Ok (List_Cons ret tl) in Ok (y, back) else let* (i, back) = get_elem_mut_loop x tl in - let back1 = fun ret -> let* tl1 = back ret in Return (List_Cons y tl1) in - Return (i, back1) + let back1 = fun ret -> let* tl1 = back ret in Ok (List_Cons y tl1) in + Ok (i, back1) | List_Nil -> Fail Failure end @@ -190,7 +190,7 @@ let get_elem_mut (core_slice_index_SliceIndexUsizeSliceTInst (list_t usize)) slots 0 in let* (i, back) = get_elem_mut_loop x ls in let back1 = fun ret -> let* l = back ret in index_mut_back l in - Return (i, back1) + Ok (i, back1) (** [loops::get_elem_shared]: loop 0: Source: 'src/loops.rs', lines 129:0-143:1 *) @@ -199,7 +199,7 @@ let rec get_elem_shared_loop Tot (result usize) (decreases (get_elem_shared_loop_decreases x ls)) = begin match ls with - | List_Cons y tl -> if y = x then Return y else get_elem_shared_loop x tl + | List_Cons y tl -> if y = x then Ok y else get_elem_shared_loop x tl | List_Nil -> Fail Failure end @@ -218,12 +218,12 @@ let id_mut (t : Type0) (ls : list_t t) : result ((list_t t) & (list_t t -> result (list_t t))) = - Return (ls, Return) + Ok (ls, Ok) (** [loops::id_shared]: Source: 'src/loops.rs', lines 149:0-149:45 *) let id_shared (t : Type0) (ls : list_t t) : result (list_t t) = - Return ls + Ok ls (** [loops::list_nth_mut_loop_with_id]: loop 0: Source: 'src/loops.rs', lines 154:0-165:1 *) @@ -235,12 +235,12 @@ let rec list_nth_mut_loop_with_id_loop begin match ls with | List_Cons x tl -> if i = 0 - then let back = fun ret -> Return (List_Cons ret tl) in Return (x, back) + then let back = fun ret -> Ok (List_Cons ret tl) in Ok (x, back) else let* i1 = u32_sub i 1 in let* (x1, back) = list_nth_mut_loop_with_id_loop t i1 tl in - let back1 = fun ret -> let* tl1 = back ret in Return (List_Cons x tl1) in - Return (x1, back1) + let back1 = fun ret -> let* tl1 = back ret in Ok (List_Cons x tl1) in + Ok (x1, back1) | List_Nil -> Fail Failure end @@ -253,7 +253,7 @@ let list_nth_mut_loop_with_id let* (ls1, id_mut_back) = id_mut t ls in let* (x, back) = list_nth_mut_loop_with_id_loop t i ls1 in let back1 = fun ret -> let* l = back ret in id_mut_back l in - Return (x, back1) + Ok (x, back1) (** [loops::list_nth_shared_loop_with_id]: loop 0: Source: 'src/loops.rs', lines 168:0-179:1 *) @@ -265,7 +265,7 @@ let rec list_nth_shared_loop_with_id_loop begin match ls with | List_Cons x tl -> if i = 0 - then Return x + then Ok x else let* i1 = u32_sub i 1 in list_nth_shared_loop_with_id_loop t i1 tl | List_Nil -> Fail Failure end @@ -289,18 +289,17 @@ let rec list_nth_mut_loop_pair_loop | List_Cons x1 tl1 -> if i = 0 then - let back_'a = fun ret -> Return (List_Cons ret tl0) in - let back_'b = fun ret -> Return (List_Cons ret tl1) in - Return ((x0, x1), back_'a, back_'b) + let back'a = fun ret -> Ok (List_Cons ret tl0) in + let back'b = fun ret -> Ok (List_Cons ret tl1) in + Ok ((x0, x1), back'a, back'b) else let* i1 = u32_sub i 1 in - let* (p, back_'a, back_'b) = list_nth_mut_loop_pair_loop t tl0 tl1 i1 - in - let back_'a1 = - fun ret -> let* tl01 = back_'a ret in Return (List_Cons x0 tl01) in - let back_'b1 = - fun ret -> let* tl11 = back_'b ret in Return (List_Cons x1 tl11) in - Return (p, back_'a1, back_'b1) + let* (p, back'a, back'b) = list_nth_mut_loop_pair_loop t tl0 tl1 i1 in + let back'a1 = + fun ret -> let* tl01 = back'a ret in Ok (List_Cons x0 tl01) in + let back'b1 = + fun ret -> let* tl11 = back'b ret in Ok (List_Cons x1 tl11) in + Ok (p, back'a1, back'b1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -326,7 +325,7 @@ let rec list_nth_shared_loop_pair_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then Return (x0, x1) + then Ok (x0, x1) else let* i1 = u32_sub i 1 in list_nth_shared_loop_pair_loop t tl0 tl1 i1 | List_Nil -> Fail Failure end @@ -352,18 +351,18 @@ let rec list_nth_mut_loop_pair_merge_loop | List_Cons x1 tl1 -> if i = 0 then - let back_'a = + let back = fun ret -> - let (x, x2) = ret in Return (List_Cons x tl0, List_Cons x2 tl1) in - Return ((x0, x1), back_'a) + let (x, x2) = ret in Ok (List_Cons x tl0, List_Cons x2 tl1) in + Ok ((x0, x1), back) else let* i1 = u32_sub i 1 in - let* (p, back_'a) = list_nth_mut_loop_pair_merge_loop t tl0 tl1 i1 in - let back_'a1 = + let* (p, back) = list_nth_mut_loop_pair_merge_loop t tl0 tl1 i1 in + let back1 = fun ret -> - let* (tl01, tl11) = back_'a ret in - Return (List_Cons x0 tl01, List_Cons x1 tl11) in - Return (p, back_'a1) + let* (tl01, tl11) = back ret in + Ok (List_Cons x0 tl01, List_Cons x1 tl11) in + Ok (p, back1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -389,7 +388,7 @@ let rec list_nth_shared_loop_pair_merge_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then Return (x0, x1) + then Ok (x0, x1) else let* i1 = u32_sub i 1 in list_nth_shared_loop_pair_merge_loop t tl0 tl1 i1 @@ -416,15 +415,13 @@ let rec list_nth_mut_shared_loop_pair_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then - let back_'a = fun ret -> Return (List_Cons ret tl0) in - Return ((x0, x1), back_'a) + then let back = fun ret -> Ok (List_Cons ret tl0) in Ok ((x0, x1), back) else let* i1 = u32_sub i 1 in - let* (p, back_'a) = list_nth_mut_shared_loop_pair_loop t tl0 tl1 i1 in - let back_'a1 = - fun ret -> let* tl01 = back_'a ret in Return (List_Cons x0 tl01) in - Return (p, back_'a1) + let* (p, back) = list_nth_mut_shared_loop_pair_loop t tl0 tl1 i1 in + let back1 = fun ret -> let* tl01 = back ret in Ok (List_Cons x0 tl01) + in + Ok (p, back1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -450,16 +447,14 @@ let rec list_nth_mut_shared_loop_pair_merge_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then - let back_'a = fun ret -> Return (List_Cons ret tl0) in - Return ((x0, x1), back_'a) + then let back = fun ret -> Ok (List_Cons ret tl0) in Ok ((x0, x1), back) else let* i1 = u32_sub i 1 in - let* (p, back_'a) = - list_nth_mut_shared_loop_pair_merge_loop t tl0 tl1 i1 in - let back_'a1 = - fun ret -> let* tl01 = back_'a ret in Return (List_Cons x0 tl01) in - Return (p, back_'a1) + let* (p, back) = list_nth_mut_shared_loop_pair_merge_loop t tl0 tl1 i1 + in + let back1 = fun ret -> let* tl01 = back ret in Ok (List_Cons x0 tl01) + in + Ok (p, back1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -485,15 +480,13 @@ let rec list_nth_shared_mut_loop_pair_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then - let back_'b = fun ret -> Return (List_Cons ret tl1) in - Return ((x0, x1), back_'b) + then let back = fun ret -> Ok (List_Cons ret tl1) in Ok ((x0, x1), back) else let* i1 = u32_sub i 1 in - let* (p, back_'b) = list_nth_shared_mut_loop_pair_loop t tl0 tl1 i1 in - let back_'b1 = - fun ret -> let* tl11 = back_'b ret in Return (List_Cons x1 tl11) in - Return (p, back_'b1) + let* (p, back) = list_nth_shared_mut_loop_pair_loop t tl0 tl1 i1 in + let back1 = fun ret -> let* tl11 = back ret in Ok (List_Cons x1 tl11) + in + Ok (p, back1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -519,16 +512,14 @@ let rec list_nth_shared_mut_loop_pair_merge_loop begin match ls1 with | List_Cons x1 tl1 -> if i = 0 - then - let back_'a = fun ret -> Return (List_Cons ret tl1) in - Return ((x0, x1), back_'a) + then let back = fun ret -> Ok (List_Cons ret tl1) in Ok ((x0, x1), back) else let* i1 = u32_sub i 1 in - let* (p, back_'a) = - list_nth_shared_mut_loop_pair_merge_loop t tl0 tl1 i1 in - let back_'a1 = - fun ret -> let* tl11 = back_'a ret in Return (List_Cons x1 tl11) in - Return (p, back_'a1) + let* (p, back) = list_nth_shared_mut_loop_pair_merge_loop t tl0 tl1 i1 + in + let back1 = fun ret -> let* tl11 = back ret in Ok (List_Cons x1 tl11) + in + Ok (p, back1) | List_Nil -> Fail Failure end | List_Nil -> Fail Failure @@ -550,12 +541,12 @@ let rec ignore_input_mut_borrow_loop = if i > 0 then let* i1 = u32_sub i 1 in ignore_input_mut_borrow_loop i1 - else Return () + else Ok () (** [loops::ignore_input_mut_borrow]: Source: 'src/loops.rs', lines 345:0-345:56 *) let ignore_input_mut_borrow (_a : u32) (i : u32) : result u32 = - let* _ = ignore_input_mut_borrow_loop i in Return _a + let* _ = ignore_input_mut_borrow_loop i in Ok _a (** [loops::incr_ignore_input_mut_borrow]: loop 0: Source: 'src/loops.rs', lines 353:0-358:1 *) @@ -565,14 +556,14 @@ let rec incr_ignore_input_mut_borrow_loop = if i > 0 then let* i1 = u32_sub i 1 in incr_ignore_input_mut_borrow_loop i1 - else Return () + else Ok () (** [loops::incr_ignore_input_mut_borrow]: Source: 'src/loops.rs', lines 353:0-353:60 *) let incr_ignore_input_mut_borrow (a : u32) (i : u32) : result u32 = let* a1 = u32_add a 1 in let* _ = incr_ignore_input_mut_borrow_loop i in - Return a1 + Ok a1 (** [loops::ignore_input_shared_borrow]: loop 0: Source: 'src/loops.rs', lines 362:0-366:1 *) @@ -582,10 +573,10 @@ let rec ignore_input_shared_borrow_loop = if i > 0 then let* i1 = u32_sub i 1 in ignore_input_shared_borrow_loop i1 - else Return () + else Ok () (** [loops::ignore_input_shared_borrow]: Source: 'src/loops.rs', lines 362:0-362:59 *) let ignore_input_shared_borrow (_a : u32) (i : u32) : result u32 = - let* _ = ignore_input_shared_borrow_loop i in Return _a + let* _ = ignore_input_shared_borrow_loop i in Ok _a diff --git a/tests/fstar/misc/NoNestedBorrows.fst b/tests/fstar/misc/NoNestedBorrows.fst index db63eb0d..ac443a99 100644 --- a/tests/fstar/misc/NoNestedBorrows.fst +++ b/tests/fstar/misc/NoNestedBorrows.fst @@ -151,20 +151,20 @@ let cast_bool_to_i32 (x : bool) : result i32 = (** [no_nested_borrows::cast_bool_to_bool]: Source: 'src/no_nested_borrows.rs', lines 137:0-137:41 *) let cast_bool_to_bool (x : bool) : result bool = - Return x + Ok x (** [no_nested_borrows::test2]: Source: 'src/no_nested_borrows.rs', lines 142:0-142:14 *) let test2 : result unit = - let* _ = u32_add 23 44 in Return () + let* _ = u32_add 23 44 in Ok () (** Unit test for [no_nested_borrows::test2] *) -let _ = assert_norm (test2 = Return ()) +let _ = assert_norm (test2 = Ok ()) (** [no_nested_borrows::get_max]: Source: 'src/no_nested_borrows.rs', lines 154:0-154:37 *) let get_max (x : u32) (y : u32) : result u32 = - if x >= y then Return x else Return y + if x >= y then Ok x else Ok y (** [no_nested_borrows::test3]: Source: 'src/no_nested_borrows.rs', lines 162:0-162:14 *) @@ -172,26 +172,26 @@ let test3 : result unit = let* x = get_max 4 3 in let* y = get_max 10 11 in let* z = u32_add x y in - if not (z = 15) then Fail Failure else Return () + if not (z = 15) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test3] *) -let _ = assert_norm (test3 = Return ()) +let _ = assert_norm (test3 = Ok ()) (** [no_nested_borrows::test_neg1]: Source: 'src/no_nested_borrows.rs', lines 169:0-169:18 *) let test_neg1 : result unit = - let* y = i32_neg 3 in if not (y = -3) then Fail Failure else Return () + let* y = i32_neg 3 in if not (y = -3) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_neg1] *) -let _ = assert_norm (test_neg1 = Return ()) +let _ = assert_norm (test_neg1 = Ok ()) (** [no_nested_borrows::refs_test1]: Source: 'src/no_nested_borrows.rs', lines 176:0-176:19 *) let refs_test1 : result unit = - if not (1 = 1) then Fail Failure else Return () + if not (1 = 1) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::refs_test1] *) -let _ = assert_norm (refs_test1 = Return ()) +let _ = assert_norm (refs_test1 = Ok ()) (** [no_nested_borrows::refs_test2]: Source: 'src/no_nested_borrows.rs', lines 187:0-187:19 *) @@ -204,18 +204,18 @@ let refs_test2 : result unit = else if not (2 = 2) then Fail Failure - else if not (2 = 2) then Fail Failure else Return () + else if not (2 = 2) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::refs_test2] *) -let _ = assert_norm (refs_test2 = Return ()) +let _ = assert_norm (refs_test2 = Ok ()) (** [no_nested_borrows::test_list1]: Source: 'src/no_nested_borrows.rs', lines 203:0-203:19 *) let test_list1 : result unit = - Return () + Ok () (** Unit test for [no_nested_borrows::test_list1] *) -let _ = assert_norm (test_list1 = Return ()) +let _ = assert_norm (test_list1 = Ok ()) (** [no_nested_borrows::test_box1]: Source: 'src/no_nested_borrows.rs', lines 208:0-208:18 *) @@ -223,56 +223,53 @@ let test_box1 : result unit = let* (_, deref_mut_back) = alloc_boxed_Box_deref_mut i32 0 in let* b = deref_mut_back 1 in let* x = alloc_boxed_Box_deref i32 b in - if not (x = 1) then Fail Failure else Return () + if not (x = 1) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_box1] *) -let _ = assert_norm (test_box1 = Return ()) +let _ = assert_norm (test_box1 = Ok ()) (** [no_nested_borrows::copy_int]: Source: 'src/no_nested_borrows.rs', lines 218:0-218:30 *) let copy_int (x : i32) : result i32 = - Return x + Ok x (** [no_nested_borrows::test_unreachable]: Source: 'src/no_nested_borrows.rs', lines 224:0-224:32 *) let test_unreachable (b : bool) : result unit = - if b then Fail Failure else Return () + if b then Fail Failure else Ok () (** [no_nested_borrows::test_panic]: Source: 'src/no_nested_borrows.rs', lines 232:0-232:26 *) let test_panic (b : bool) : result unit = - if b then Fail Failure else Return () + if b then Fail Failure else Ok () (** [no_nested_borrows::test_copy_int]: Source: 'src/no_nested_borrows.rs', lines 239:0-239:22 *) let test_copy_int : result unit = - let* y = copy_int 0 in if not (0 = y) then Fail Failure else Return () + let* y = copy_int 0 in if not (0 = y) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_copy_int] *) -let _ = assert_norm (test_copy_int = Return ()) +let _ = assert_norm (test_copy_int = Ok ()) (** [no_nested_borrows::is_cons]: Source: 'src/no_nested_borrows.rs', lines 246:0-246:38 *) let is_cons (t : Type0) (l : list_t t) : result bool = - begin match l with - | List_Cons _ _ -> Return true - | List_Nil -> Return false - end + begin match l with | List_Cons _ _ -> Ok true | List_Nil -> Ok false end (** [no_nested_borrows::test_is_cons]: Source: 'src/no_nested_borrows.rs', lines 253:0-253:21 *) let test_is_cons : result unit = let* b = is_cons i32 (List_Cons 0 List_Nil) in - if not b then Fail Failure else Return () + if not b then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_is_cons] *) -let _ = assert_norm (test_is_cons = Return ()) +let _ = assert_norm (test_is_cons = Ok ()) (** [no_nested_borrows::split_list]: Source: 'src/no_nested_borrows.rs', lines 259:0-259:48 *) let split_list (t : Type0) (l : list_t t) : result (t & (list_t t)) = begin match l with - | List_Cons hd tl -> Return (hd, tl) + | List_Cons hd tl -> Ok (hd, tl) | List_Nil -> Fail Failure end @@ -281,18 +278,18 @@ let split_list (t : Type0) (l : list_t t) : result (t & (list_t t)) = let test_split_list : result unit = let* p = split_list i32 (List_Cons 0 List_Nil) in let (hd, _) = p in - if not (hd = 0) then Fail Failure else Return () + if not (hd = 0) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_split_list] *) -let _ = assert_norm (test_split_list = Return ()) +let _ = assert_norm (test_split_list = Ok ()) (** [no_nested_borrows::choose]: Source: 'src/no_nested_borrows.rs', lines 274:0-274:70 *) let choose (t : Type0) (b : bool) (x : t) (y : t) : result (t & (t -> result (t & t))) = if b - then let back_'a = fun ret -> Return (ret, y) in Return (x, back_'a) - else let back_'a = fun ret -> Return (x, ret) in Return (y, back_'a) + then let back = fun ret -> Ok (ret, y) in Ok (x, back) + else let back = fun ret -> Ok (x, ret) in Ok (y, back) (** [no_nested_borrows::choose_test]: Source: 'src/no_nested_borrows.rs', lines 282:0-282:20 *) @@ -305,15 +302,15 @@ let choose_test : result unit = let* (x, y) = choose_back z1 in if not (x = 1) then Fail Failure - else if not (y = 0) then Fail Failure else Return () + else if not (y = 0) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::choose_test] *) -let _ = assert_norm (choose_test = Return ()) +let _ = assert_norm (choose_test = Ok ()) (** [no_nested_borrows::test_char]: Source: 'src/no_nested_borrows.rs', lines 294:0-294:26 *) let test_char : result char = - Return 'a' + Ok 'a' (** [no_nested_borrows::Tree] Source: 'src/no_nested_borrows.rs', lines 299:0-299:16 *) @@ -332,7 +329,7 @@ and nodeElem_t (t : Type0) = let rec list_length (t : Type0) (l : list_t t) : result u32 = begin match l with | List_Cons _ l1 -> let* i = list_length t l1 in u32_add 1 i - | List_Nil -> Return 0 + | List_Nil -> Ok 0 end (** [no_nested_borrows::list_nth_shared]: @@ -340,9 +337,7 @@ let rec list_length (t : Type0) (l : list_t t) : result u32 = let rec list_nth_shared (t : Type0) (l : list_t t) (i : u32) : result t = begin match l with | List_Cons x tl -> - if i = 0 - then Return x - else let* i1 = u32_sub i 1 in list_nth_shared t tl i1 + if i = 0 then Ok x else let* i1 = u32_sub i 1 in list_nth_shared t tl i1 | List_Nil -> Fail Failure end @@ -355,15 +350,13 @@ let rec list_nth_mut begin match l with | List_Cons x tl -> if i = 0 - then - let back_'a = fun ret -> Return (List_Cons ret tl) in Return (x, back_'a) + then let back = fun ret -> Ok (List_Cons ret tl) in Ok (x, back) else let* i1 = u32_sub i 1 in let* (x1, list_nth_mut_back) = list_nth_mut t tl i1 in - let back_'a = - fun ret -> let* tl1 = list_nth_mut_back ret in Return (List_Cons x tl1) - in - Return (x1, back_'a) + let back = + fun ret -> let* tl1 = list_nth_mut_back ret in Ok (List_Cons x tl1) in + Ok (x1, back) | List_Nil -> Fail Failure end @@ -373,7 +366,7 @@ let rec list_rev_aux (t : Type0) (li : list_t t) (lo : list_t t) : result (list_t t) = begin match li with | List_Cons hd tl -> list_rev_aux t tl (List_Cons hd lo) - | List_Nil -> Return lo + | List_Nil -> Ok lo end (** [no_nested_borrows::list_rev]: @@ -414,10 +407,10 @@ let test_list_functions : result unit = then Fail Failure else let* i6 = list_nth_shared i32 ls 2 in - if not (i6 = 2) then Fail Failure else Return () + if not (i6 = 2) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_list_functions] *) -let _ = assert_norm (test_list_functions = Return ()) +let _ = assert_norm (test_list_functions = Ok ()) (** [no_nested_borrows::id_mut_pair1]: Source: 'src/no_nested_borrows.rs', lines 414:0-414:89 *) @@ -425,7 +418,7 @@ let id_mut_pair1 (t1 t2 : Type0) (x : t1) (y : t2) : result ((t1 & t2) & ((t1 & t2) -> result (t1 & t2))) = - Return ((x, y), Return) + Ok ((x, y), Ok) (** [no_nested_borrows::id_mut_pair2]: Source: 'src/no_nested_borrows.rs', lines 418:0-418:88 *) @@ -433,7 +426,7 @@ let id_mut_pair2 (t1 t2 : Type0) (p : (t1 & t2)) : result ((t1 & t2) & ((t1 & t2) -> result (t1 & t2))) = - let (x, x1) = p in Return ((x, x1), Return) + let (x, x1) = p in Ok ((x, x1), Ok) (** [no_nested_borrows::id_mut_pair3]: Source: 'src/no_nested_borrows.rs', lines 422:0-422:93 *) @@ -441,7 +434,7 @@ let id_mut_pair3 (t1 t2 : Type0) (x : t1) (y : t2) : result ((t1 & t2) & (t1 -> result t1) & (t2 -> result t2)) = - Return ((x, y), Return, Return) + Ok ((x, y), Ok, Ok) (** [no_nested_borrows::id_mut_pair4]: Source: 'src/no_nested_borrows.rs', lines 426:0-426:92 *) @@ -449,7 +442,7 @@ let id_mut_pair4 (t1 t2 : Type0) (p : (t1 & t2)) : result ((t1 & t2) & (t1 -> result t1) & (t2 -> result t2)) = - let (x, x1) = p in Return ((x, x1), Return, Return) + let (x, x1) = p in Ok ((x, x1), Ok, Ok) (** [no_nested_borrows::StructWithTuple] Source: 'src/no_nested_borrows.rs', lines 433:0-433:34 *) @@ -458,17 +451,17 @@ type structWithTuple_t (t1 t2 : Type0) = { p : (t1 & t2); } (** [no_nested_borrows::new_tuple1]: Source: 'src/no_nested_borrows.rs', lines 437:0-437:48 *) let new_tuple1 : result (structWithTuple_t u32 u32) = - Return { p = (1, 2) } + Ok { p = (1, 2) } (** [no_nested_borrows::new_tuple2]: Source: 'src/no_nested_borrows.rs', lines 441:0-441:48 *) let new_tuple2 : result (structWithTuple_t i16 i16) = - Return { p = (1, 2) } + Ok { p = (1, 2) } (** [no_nested_borrows::new_tuple3]: Source: 'src/no_nested_borrows.rs', lines 445:0-445:48 *) let new_tuple3 : result (structWithTuple_t u64 i64) = - Return { p = (1, 2) } + Ok { p = (1, 2) } (** [no_nested_borrows::StructWithPair] Source: 'src/no_nested_borrows.rs', lines 450:0-450:33 *) @@ -477,7 +470,7 @@ type structWithPair_t (t1 t2 : Type0) = { p : pair_t t1 t2; } (** [no_nested_borrows::new_pair1]: Source: 'src/no_nested_borrows.rs', lines 454:0-454:46 *) let new_pair1 : result (structWithPair_t u32 u32) = - Return { p = { x = 1; y = 2 } } + Ok { p = { x = 1; y = 2 } } (** [no_nested_borrows::test_constants]: Source: 'src/no_nested_borrows.rs', lines 462:0-462:23 *) @@ -498,44 +491,44 @@ let test_constants : result unit = then Fail Failure else let* swp = new_pair1 in - if not (swp.p.x = 1) then Fail Failure else Return () + if not (swp.p.x = 1) then Fail Failure else Ok () (** Unit test for [no_nested_borrows::test_constants] *) -let _ = assert_norm (test_constants = Return ()) +let _ = assert_norm (test_constants = Ok ()) (** [no_nested_borrows::test_weird_borrows1]: Source: 'src/no_nested_borrows.rs', lines 471:0-471:28 *) let test_weird_borrows1 : result unit = - Return () + Ok () (** Unit test for [no_nested_borrows::test_weird_borrows1] *) -let _ = assert_norm (test_weird_borrows1 = Return ()) +let _ = assert_norm (test_weird_borrows1 = Ok ()) (** [no_nested_borrows::test_mem_replace]: Source: 'src/no_nested_borrows.rs', lines 481:0-481:37 *) let test_mem_replace (px : u32) : result u32 = let (y, _) = core_mem_replace u32 px 1 in - if not (y = 0) then Fail Failure else Return 2 + if not (y = 0) then Fail Failure else Ok 2 (** [no_nested_borrows::test_shared_borrow_bool1]: Source: 'src/no_nested_borrows.rs', lines 488:0-488:47 *) let test_shared_borrow_bool1 (b : bool) : result u32 = - if b then Return 0 else Return 1 + if b then Ok 0 else Ok 1 (** [no_nested_borrows::test_shared_borrow_bool2]: Source: 'src/no_nested_borrows.rs', lines 501:0-501:40 *) let test_shared_borrow_bool2 : result u32 = - Return 0 + Ok 0 (** [no_nested_borrows::test_shared_borrow_enum1]: Source: 'src/no_nested_borrows.rs', lines 516:0-516:52 *) let test_shared_borrow_enum1 (l : list_t u32) : result u32 = - begin match l with | List_Cons _ _ -> Return 1 | List_Nil -> Return 0 end + begin match l with | List_Cons _ _ -> Ok 1 | List_Nil -> Ok 0 end (** [no_nested_borrows::test_shared_borrow_enum2]: Source: 'src/no_nested_borrows.rs', lines 528:0-528:40 *) let test_shared_borrow_enum2 : result u32 = - Return 0 + Ok 0 (** [no_nested_borrows::incr]: Source: 'src/no_nested_borrows.rs', lines 539:0-539:24 *) @@ -550,7 +543,7 @@ let call_incr (x : u32) : result u32 = (** [no_nested_borrows::read_then_incr]: Source: 'src/no_nested_borrows.rs', lines 548:0-548:41 *) let read_then_incr (x : u32) : result (u32 & u32) = - let* x1 = u32_add x 1 in Return (x, x1) + let* x1 = u32_add x 1 in Ok (x, x1) (** [no_nested_borrows::Tuple] Source: 'src/no_nested_borrows.rs', lines 554:0-554:24 *) @@ -559,12 +552,12 @@ type tuple_t (t1 t2 : Type0) = t1 * t2 (** [no_nested_borrows::use_tuple_struct]: Source: 'src/no_nested_borrows.rs', lines 556:0-556:48 *) let use_tuple_struct (x : tuple_t u32 u32) : result (tuple_t u32 u32) = - let (_, i) = x in Return (1, i) + let (_, i) = x in Ok (1, i) (** [no_nested_borrows::create_tuple_struct]: Source: 'src/no_nested_borrows.rs', lines 560:0-560:61 *) let create_tuple_struct (x : u32) (y : u64) : result (tuple_t u32 u64) = - Return (x, y) + Ok (x, y) (** [no_nested_borrows::IdType] Source: 'src/no_nested_borrows.rs', lines 565:0-565:20 *) @@ -573,10 +566,10 @@ type idType_t (t : Type0) = t (** [no_nested_borrows::use_id_type]: Source: 'src/no_nested_borrows.rs', lines 567:0-567:40 *) let use_id_type (t : Type0) (x : idType_t t) : result t = - Return x + Ok x (** [no_nested_borrows::create_id_type]: Source: 'src/no_nested_borrows.rs', lines 571:0-571:43 *) let create_id_type (t : Type0) (x : t) : result (idType_t t) = - Return x + Ok x diff --git a/tests/fstar/misc/Paper.fst b/tests/fstar/misc/Paper.fst index ddc5e7a8..e6b4eb25 100644 --- a/tests/fstar/misc/Paper.fst +++ b/tests/fstar/misc/Paper.fst @@ -13,18 +13,18 @@ let ref_incr (x : i32) : result i32 = (** [paper::test_incr]: Source: 'src/paper.rs', lines 8:0-8:18 *) let test_incr : result unit = - let* x = ref_incr 0 in if not (x = 1) then Fail Failure else Return () + let* x = ref_incr 0 in if not (x = 1) then Fail Failure else Ok () (** Unit test for [paper::test_incr] *) -let _ = assert_norm (test_incr = Return ()) +let _ = assert_norm (test_incr = Ok ()) (** [paper::choose]: Source: 'src/paper.rs', lines 15:0-15:70 *) let choose (t : Type0) (b : bool) (x : t) (y : t) : result (t & (t -> result (t & t))) = if b - then let back_'a = fun ret -> Return (ret, y) in Return (x, back_'a) - else let back_'a = fun ret -> Return (x, ret) in Return (y, back_'a) + then let back = fun ret -> Ok (ret, y) in Ok (x, back) + else let back = fun ret -> Ok (x, ret) in Ok (y, back) (** [paper::test_choose]: Source: 'src/paper.rs', lines 23:0-23:20 *) @@ -37,10 +37,10 @@ let test_choose : result unit = let* (x, y) = choose_back z1 in if not (x = 1) then Fail Failure - else if not (y = 0) then Fail Failure else Return () + else if not (y = 0) then Fail Failure else Ok () (** Unit test for [paper::test_choose] *) -let _ = assert_norm (test_choose = Return ()) +let _ = assert_norm (test_choose = Ok ()) (** [paper::List] Source: 'src/paper.rs', lines 35:0-35:16 *) @@ -57,15 +57,13 @@ let rec list_nth_mut begin match l with | List_Cons x tl -> if i = 0 - then - let back_'a = fun ret -> Return (List_Cons ret tl) in Return (x, back_'a) + then let back = fun ret -> Ok (List_Cons ret tl) in Ok (x, back) else let* i1 = u32_sub i 1 in let* (x1, list_nth_mut_back) = list_nth_mut t tl i1 in - let back_'a = - fun ret -> let* tl1 = list_nth_mut_back ret in Return (List_Cons x tl1) - in - Return (x1, back_'a) + let back = + fun ret -> let* tl1 = list_nth_mut_back ret in Ok (List_Cons x tl1) in + Ok (x1, back) | List_Nil -> Fail Failure end @@ -74,7 +72,7 @@ let rec list_nth_mut let rec sum (l : list_t i32) : result i32 = begin match l with | List_Cons x tl -> let* i = sum tl in i32_add x i - | List_Nil -> Return 0 + | List_Nil -> Ok 0 end (** [paper::test_nth]: @@ -86,10 +84,10 @@ let test_nth : result unit = let* x1 = i32_add x 1 in let* l2 = list_nth_mut_back x1 in let* i = sum l2 in - if not (i = 7) then Fail Failure else Return () + if not (i = 7) then Fail Failure else Ok () (** Unit test for [paper::test_nth] *) -let _ = assert_norm (test_nth = Return ()) +let _ = assert_norm (test_nth = Ok ()) (** [paper::call_choose]: Source: 'src/paper.rs', lines 76:0-76:44 *) @@ -98,5 +96,5 @@ let call_choose (p : (u32 & u32)) : result u32 = let* (pz, choose_back) = choose u32 true px py in let* pz1 = u32_add pz 1 in let* (px1, _) = choose_back pz1 in - Return px1 + Ok px1 diff --git a/tests/fstar/misc/PoloniusList.fst b/tests/fstar/misc/PoloniusList.fst index b477802b..c0bc592e 100644 --- a/tests/fstar/misc/PoloniusList.fst +++ b/tests/fstar/misc/PoloniusList.fst @@ -20,13 +20,13 @@ let rec get_list_at_x begin match ls with | List_Cons hd tl -> if hd = x - then Return (List_Cons hd tl, Return) + then Ok (List_Cons hd tl, Ok) else let* (l, get_list_at_x_back) = get_list_at_x tl x in - let back_'a = - fun ret -> - let* tl1 = get_list_at_x_back ret in Return (List_Cons hd tl1) in - Return (l, back_'a) - | List_Nil -> Return (List_Nil, Return) + let back = + fun ret -> let* tl1 = get_list_at_x_back ret in Ok (List_Cons hd tl1) + in + Ok (l, back) + | List_Nil -> Ok (List_Nil, Ok) end diff --git a/tests/fstar/misc/Primitives.fst b/tests/fstar/misc/Primitives.fst index fca80829..acdb09dc 100644 --- a/tests/fstar/misc/Primitives.fst +++ b/tests/fstar/misc/Primitives.fst @@ -23,11 +23,11 @@ type error : Type0 = | OutOfFuel type result (a : Type0) : Type0 = -| Return : v:a -> result a +| Ok : v:a -> result a | Fail : e:error -> result a // Monadic return operator -unfold let return (#a : Type0) (x : a) : result a = Return x +unfold let return (#a : Type0) (x : a) : result a = Ok x // Monadic bind operator. // Allows to use the notation: @@ -36,17 +36,17 @@ unfold let return (#a : Type0) (x : a) : result a = Return x // ... // ``` unfold let (let*) (#a #b : Type0) (m: result a) - (f: (x:a) -> Pure (result b) (requires (m == Return x)) (ensures fun _ -> True)) : + (f: (x:a) -> Pure (result b) (requires (m == Ok x)) (ensures fun _ -> True)) : result b = match m with - | Return x -> f x + | Ok x -> f x | Fail e -> Fail e // Monadic assert(...) -let massert (b:bool) : result unit = if b then Return () else Fail Failure +let massert (b:bool) : result unit = if b then Ok () else Fail Failure // Normalize and unwrap a successful result (used for globals). -let eval_global (#a : Type0) (x : result a{Return? (normalize_term x)}) : a = Return?.v x +let eval_global (#a : Type0) (x : result a{Ok? (normalize_term x)}) : a = Ok?.v x (*** Misc *) type char = FStar.Char.char @@ -144,7 +144,7 @@ let scalar_max (ty : scalar_ty) : int = type scalar (ty : scalar_ty) : eqtype = x:int{scalar_min ty <= x && x <= scalar_max ty} let mk_scalar (ty : scalar_ty) (x : int) : result (scalar ty) = - if scalar_min ty <= x && scalar_max ty >= x then Return x else Fail Failure + if scalar_min ty <= x && scalar_max ty >= x then Ok x else Fail Failure let scalar_neg (#ty : scalar_ty) (x : scalar ty) : result (scalar ty) = mk_scalar ty (-x) @@ -498,9 +498,9 @@ type core_ops_range_Range (a : Type0) = { (*** [alloc] *) -let alloc_boxed_Box_deref (t : Type0) (x : t) : result t = Return x +let alloc_boxed_Box_deref (t : Type0) (x : t) : result t = Ok x let alloc_boxed_Box_deref_mut (t : Type0) (x : t) : result (t & (t -> result t)) = - Return (x, (fun x -> Return x)) + Ok (x, (fun x -> Ok x)) // Trait instance let alloc_boxed_Box_coreopsDerefInst (self : Type0) : core_ops_deref_Deref self = { @@ -528,20 +528,20 @@ let mk_array (a : Type0) (n : usize) l let array_index_usize (a : Type0) (n : usize) (x : array a n) (i : usize) : result a = - if i < length x then Return (index x i) + if i < length x then Ok (index x i) else Fail Failure let array_update_usize (a : Type0) (n : usize) (x : array a n) (i : usize) (nx : a) : result (array a n) = - if i < length x then Return (list_update x i nx) + if i < length x then Ok (list_update x i nx) else Fail Failure let array_index_mut_usize (a : Type0) (n : usize) (x : array a n) (i : usize) : result (a & (a -> result (array a n))) = match array_index_usize a n x i with | Fail e -> Fail e - | Return v -> - Return (v, array_update_usize a n x i) + | Ok v -> + Ok (v, array_update_usize a n x i) (*** Slice *) type slice (a : Type0) = s:list a{length s <= usize_max} @@ -549,30 +549,30 @@ type slice (a : Type0) = s:list a{length s <= usize_max} let slice_len (a : Type0) (s : slice a) : usize = length s let slice_index_usize (a : Type0) (x : slice a) (i : usize) : result a = - if i < length x then Return (index x i) + if i < length x then Ok (index x i) else Fail Failure let slice_update_usize (a : Type0) (x : slice a) (i : usize) (nx : a) : result (slice a) = - if i < length x then Return (list_update x i nx) + if i < length x then Ok (list_update x i nx) else Fail Failure let slice_index_mut_usize (a : Type0) (s : slice a) (i : usize) : result (a & (a -> result (slice a))) = match slice_index_usize a s i with | Fail e -> Fail e - | Return x -> - Return (x, slice_update_usize a s i) + | Ok x -> + Ok (x, slice_update_usize a s i) (*** Subslices *) -let array_to_slice (a : Type0) (n : usize) (x : array a n) : result (slice a) = Return x +let array_to_slice (a : Type0) (n : usize) (x : array a n) : result (slice a) = Ok x let array_from_slice (a : Type0) (n : usize) (x : array a n) (s : slice a) : result (array a n) = - if length s = n then Return s + if length s = n then Ok s else Fail Failure let array_to_slice_mut (a : Type0) (n : usize) (x : array a n) : result (slice a & (slice a -> result (array a n))) = - Return (x, array_from_slice a n x) + Ok (x, array_from_slice a n x) // TODO: finish the definitions below (there lacks [List.drop] and [List.take] in the standard library *) let array_subslice (a : Type0) (n : usize) (x : array a n) (r : core_ops_range_Range usize) : result (slice a) = @@ -598,16 +598,16 @@ let alloc_vec_Vec_len (a : Type0) (v : alloc_vec_Vec a) : usize = length v // Helper let alloc_vec_Vec_index_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : result a = - if i < length v then Return (index v i) else Fail Failure + if i < length v then Ok (index v i) else Fail Failure // Helper let alloc_vec_Vec_update_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) = - if i < length v then Return (list_update v i x) else Fail Failure + if i < length v then Ok (list_update v i x) else Fail Failure let alloc_vec_Vec_index_mut_usize (#a : Type0) (v: alloc_vec_Vec a) (i: usize) : result (a & (a → result (alloc_vec_Vec a))) = match alloc_vec_Vec_index_usize v i with - | Return x -> - Return (x, alloc_vec_Vec_update_usize v i) + | Ok x -> + Ok (x, alloc_vec_Vec_update_usize v i) | Fail e -> Fail e let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) : @@ -616,17 +616,17 @@ let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) : (ensures (fun res -> match res with | Fail e -> e == Failure - | Return v' -> length v' = length v + 1)) = + | Ok v' -> length v' = length v + 1)) = if length v < usize_max then begin (**) assert_norm(length [x] == 1); (**) append_length v [x]; (**) assert(length (append v [x]) = length v + 1); - Return (append v [x]) + Ok (append v [x]) end else Fail Failure let alloc_vec_Vec_insert (a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) = - if i < length v then Return (list_update v i x) else Fail Failure + if i < length v then Ok (list_update v i x) else Fail Failure // Trait declaration: [core::slice::index::private_slice_index::Sealed] type core_slice_index_private_slice_index_Sealed (self : Type0) = unit @@ -650,7 +650,7 @@ let core_slice_index_Slice_index let* x = inst.get i s in match x with | None -> Fail Failure - | Some x -> Return x + | Some x -> Ok x // [core::slice::index::Range:::get]: forward function let core_slice_index_RangeUsize_get (t : Type0) (i : core_ops_range_Range usize) (s : slice t) : |