Skip to content

Commit c0aad41

Browse files
committed
fix(menhir): sandbox infer rule
Infer rules should not observe any modules not listed as dependencies. This can lead to "inconsistent assumptions" errors. Signed-off-by: Rudi Grinberg <me@rgrinberg.com> ps-id: 4494FD38-3CAC-4641-A478-A8E103F82CF6
1 parent 8c19607 commit c0aad41

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/dune_rules/compilation_context.ml

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ let js_of_ocaml t = t.js_of_ocaml
104104

105105
let sandbox t = t.sandbox
106106

107+
let set_sandbox t sandbox = { t with sandbox }
108+
107109
let package t = t.package
108110

109111
let vimpl t = t.vimpl

src/dune_rules/compilation_context.mli

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ val js_of_ocaml : t -> Dune_file.Js_of_ocaml.t option
7979

8080
val sandbox : t -> Sandbox_config.t
8181

82+
val set_sandbox : t -> Sandbox_config.t -> t
83+
8284
val package : t -> Package.t option
8385

8486
val vimpl : t -> Vimpl.t option

src/dune_rules/menhir.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ module Run (P : PARAMS) = struct
204204
(Compilation_context.preprocessing cctx)
205205
name mock_module ~lint:false
206206
in
207-
let cctx = Compilation_context.without_bin_annot cctx in
207+
let cctx =
208+
Compilation_context.set_sandbox cctx Sandbox_config.needs_sandboxing
209+
|> Compilation_context.without_bin_annot
210+
in
208211
let* deps = Dep_rules.for_module cctx mock_module in
209212
let* () =
210213
Module_compilation.ocamlc_i ~deps cctx mock_module

0 commit comments

Comments
 (0)