Skip to content

Commit

Permalink
Adding a mk_struct test
Browse files Browse the repository at this point in the history
  • Loading branch information
lfrenot committed Jan 16, 2025
1 parent e75d960 commit 662fa50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sail_lean_backend/pretty_print_lean.ml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ let rec doc_exp ctxt (E_aux (e, (l, annot)) as full_exp) =
nest 2 (flow (break 1) [string "let"; string id; coloneq; doc_exp ctxt lexp]) ^^ hardline ^^ doc_exp ctxt e
| E_struct fexps ->
let args = List.map (doc_fexp ctxt) fexps in
braces (separate comma args)
braces (separate (comma ^^ space) args)
| E_field (exp, id) -> doc_exp ctxt exp ^^ dot ^^ doc_id_ctor id
| E_struct_update (exp, fexps) ->
let args = List.map (doc_fexp ctxt) fexps in
Expand Down
4 changes: 4 additions & 0 deletions test/lean/struct.expected.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def struct_field2 (s : My_struct) : (BitVec 1) :=
def struct_update_field2 (s : My_struct) (b : (BitVec 1)) : My_struct :=
{s with field2 := b}

/-- Type quantifiers: i : Int -/
def mk_struct (i : Int) (b : (BitVec 1)) : My_struct :=
{field1 := i, field2 := b}

def initialize_registers : Unit :=
()

8 changes: 8 additions & 0 deletions test/lean/struct.sail
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ function struct_field2(s) = {
val struct_update_field2 : (My_struct, bit) -> My_struct
function struct_update_field2(s, b) = {
{ s with field2 = b }
}

val mk_struct : (int, bit) -> My_struct
function mk_struct(i, b) = {
struct {
field1 = i,
field2 = b
}
}

0 comments on commit 662fa50

Please sign in to comment.