summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Protzenko2023-01-25 17:59:51 -0800
committerSon HO2023-06-04 21:44:33 +0200
commit6c8279a43bfbed4a33bef90f22b8f8f47df27525 (patch)
tree41f920ef5cce08448ded9e3286470a75ac2830b7
parent20c076b2bae86450dbc63a0d4976e6338f5c9aa0 (diff)
Fix a syntax error
-rw-r--r--compiler/Extract.ml8
-rw-r--r--tests/lean/hashmap_on_disk/HashmapMain/Funs.lean15
2 files changed, 11 insertions, 12 deletions
diff --git a/compiler/Extract.ml b/compiler/Extract.ml
index 7ba64155..0207d1ea 100644
--- a/compiler/Extract.ml
+++ b/compiler/Extract.ml
@@ -1626,6 +1626,9 @@ and extract_adt_cons (ctx : extraction_ctx) (fmt : F.formatter) (inside : bool)
in
let is_lean_struct = !backend = Lean && adt_cons.variant_id = None in
if is_lean_struct then
+ (* TODO: enclosing curly brace is indented too far to the right *)
+ (* TODO: when only one or two fields differ, considering using the with
+ syntax (peephole optimization) *)
let decl_id = match adt_cons.adt_id with | AdtId id -> id | _ -> assert false in
let def_kind = (TypeDeclId.Map.find decl_id ctx.trans_ctx.type_context.type_decls).kind in
let fields = match def_kind with | T.Struct fields -> fields | _ -> assert false in
@@ -1673,8 +1676,9 @@ and extract_field_projector (ctx : extraction_ctx) (fmt : F.formatter)
F.pp_open_hovbox fmt ctx.indent_incr;
(* Extract the expression *)
extract_texpression ctx fmt true arg;
- (* We allow to break where the "." appears *)
- F.pp_print_break fmt 0 0;
+ (* We allow to break where the "." appears (except Lean, it's a syntax error) *)
+ if !backend <> Lean then
+ F.pp_print_break fmt 0 0;
F.pp_print_string fmt ".";
(* If in Coq, the field projection has to be parenthesized *)
(match !backend with
diff --git a/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean b/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
index 6be1f757..eb72cc97 100644
--- a/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
+++ b/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
@@ -161,8 +161,7 @@ def hashmap_hash_map_insert_no_resize_fwd_back
result.ret
{
hashmap_hash_map_num_entries := i0,
- hashmap_hash_map_max_load_factor := self
- .hashmap_hash_map_max_load_factor,
+ hashmap_hash_map_max_load_factor := self.hashmap_hash_map_max_load_factor,
hashmap_hash_map_max_load := self.hashmap_hash_map_max_load,
hashmap_hash_map_slots := v
}
@@ -175,8 +174,7 @@ def hashmap_hash_map_insert_no_resize_fwd_back
result.ret
{
hashmap_hash_map_num_entries := self.hashmap_hash_map_num_entries,
- hashmap_hash_map_max_load_factor := self
- .hashmap_hash_map_max_load_factor,
+ hashmap_hash_map_max_load_factor := self.hashmap_hash_map_max_load_factor,
hashmap_hash_map_max_load := self.hashmap_hash_map_max_load,
hashmap_hash_map_slots := v
}
@@ -405,8 +403,7 @@ def hashmap_hash_map_get_mut_back
result.ret
{
hashmap_hash_map_num_entries := self.hashmap_hash_map_num_entries,
- hashmap_hash_map_max_load_factor := self
- .hashmap_hash_map_max_load_factor,
+ hashmap_hash_map_max_load_factor := self.hashmap_hash_map_max_load_factor,
hashmap_hash_map_max_load := self.hashmap_hash_map_max_load,
hashmap_hash_map_slots := v
}
@@ -506,8 +503,7 @@ def hashmap_hash_map_remove_back
result.ret
{
hashmap_hash_map_num_entries := self.hashmap_hash_map_num_entries,
- hashmap_hash_map_max_load_factor := self
- .hashmap_hash_map_max_load_factor,
+ hashmap_hash_map_max_load_factor := self.hashmap_hash_map_max_load_factor,
hashmap_hash_map_max_load := self.hashmap_hash_map_max_load,
hashmap_hash_map_slots := v
}
@@ -522,8 +518,7 @@ def hashmap_hash_map_remove_back
result.ret
{
hashmap_hash_map_num_entries := i0,
- hashmap_hash_map_max_load_factor := self
- .hashmap_hash_map_max_load_factor,
+ hashmap_hash_map_max_load_factor := self.hashmap_hash_map_max_load_factor,
hashmap_hash_map_max_load := self.hashmap_hash_map_max_load,
hashmap_hash_map_slots := v
}