From 6c8279a43bfbed4a33bef90f22b8f8f47df27525 Mon Sep 17 00:00:00 2001 From: Jonathan Protzenko Date: Wed, 25 Jan 2023 17:59:51 -0800 Subject: Fix a syntax error --- compiler/Extract.ml | 8 ++++++-- tests/lean/hashmap_on_disk/HashmapMain/Funs.lean | 15 +++++---------- 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 } -- cgit v1.2.3