Skip to content

Commit 1829150

Browse files
authored
flambda-backend: Bugfix for Translmod.all_idents (#659)
1 parent 454150b commit 1829150

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

lambda/translmod.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,9 @@ and all_idents = function
987987
| Tstr_class_type _ -> all_idents rem
988988

989989
| Tstr_include{incl_type; incl_mod={mod_desc =
990-
Tmod_constraint ({mod_desc = Tmod_structure str},
991-
_, _, _)}} ->
990+
( Tmod_constraint ({mod_desc = Tmod_structure str},
991+
_, _, _)
992+
| Tmod_structure str ) }} ->
992993
bound_value_identifiers incl_type
993994
@ all_idents str.str_items
994995
@ all_idents rem

testsuite/tests/typing-modules/struct_include_optimisation.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,20 @@ end : sig val d : int end)
4545

4646
let () = count "reordering coercion"
4747

48+
module Outer = struct
49+
include (struct
50+
module Inner = struct
51+
include (struct
52+
let e = next ()
53+
end)
54+
end
55+
end)
56+
end
57+
58+
let () =
59+
(* The above might actually allocate the module blocks Outer and Inner,
60+
but should not allocate more than 4 words (2 each) *)
61+
assert (Gc.minor_words () -. allocs.total <= 4.)
62+
4863
let () =
49-
Printf.printf "%20s: %d%d%d%d%d%d\n" "outputs" x y a b c d
64+
Printf.printf "%20s: %d%d%d%d%d%d%d\n" "outputs" x y a b c d Outer.Inner.e

testsuite/tests/typing-modules/struct_include_optimisation.reference

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
trivial coercion: 0
33
prefix coercion: 0
44
reordering coercion: 0
5-
outputs: 012347
5+
outputs: 0123478

0 commit comments

Comments
 (0)