Skip to content

Commit

Permalink
fix(hax-lib): refinements: various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Jul 10, 2024
1 parent 45be3ca commit 06e22f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion engine/lib/phases/phase_newtype_as_refinement.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ module Make (F : Features.T) =
inherit [_] Visitors.map as super

method! visit_expr () e =
let e = super#visit_expr () e in
match e.e with
| App { f = { e = GlobalVar f; _ }; args = [ inner ]; _ }
when Ast.Global_ident.eq_name Hax_lib__Refinement__new f
|| Ast.Global_ident.eq_name Hax_lib__RefineAs__into_checked f
|| Ast.Global_ident.eq_name Hax_lib__Refinement__get_mut f
|| Ast.Global_ident.eq_name Hax_lib__Refinement__get f ->
{ e with e = Ascription { typ = e.typ; e = inner } }
| _ -> super#visit_expr () e
| _ -> e

method! visit_item () i =
match i.v with
Expand Down
1 change: 0 additions & 1 deletion hax-lib/proofs/fstar/extraction/Hax_lib.Int.fst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Hax_lib.Int
open Core

unfold type t_Int = int
unfold type impl__Int__to_u16

unfold let impl__Int__to_u8 (#t:inttype) (n:range_t t) : int_t t = mk_int #t n
unfold let impl__Int__to_u16 (#t:inttype) (n:range_t t) : int_t t = mk_int #t n
Expand Down
9 changes: 9 additions & 0 deletions tests/attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,12 @@ mod refinement_types {
#[hax_lib::refinement_type(|x| x == 4 || x == 5 || x == 10 || x == 11)]
pub struct CompressionFactor(u8);
}
mod nested_refinement_elim {
use hax_lib::*;
#[hax_lib::refinement_type(|x| true)]
pub struct DummyRefinement(u16);

fn elim_twice(x: DummyRefinement) -> u16 {
(DummyRefinement::new(x.get())).get()
}
}

0 comments on commit 06e22f3

Please sign in to comment.