Skip to content

Commit

Permalink
fix(menhir): sandbox infer rule
Browse files Browse the repository at this point in the history
Infer rules should not observe any modules not listed as dependencies.
This can lead to "inconsistent assumptions" errors.

Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: A64A3962-362D-4FFF-9FFB-0E0A6702F5B3
  • Loading branch information
rgrinberg committed Oct 18, 2021
1 parent 8c19607 commit 82df217
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Unreleased
----------

- Sandbox infer rules for menhir. Fixes possible "inconsistent assumptions"
errors (#5015, @rgrinberg)

- Experimental support for ctypes stubs (#3905, fixes #135, @mbacarella)

- Fix interpretation of `binaries` defined in the `env stanza`. Binaries
Expand Down
2 changes: 2 additions & 0 deletions src/dune_rules/compilation_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ let js_of_ocaml t = t.js_of_ocaml

let sandbox t = t.sandbox

let set_sandbox t sandbox = { t with sandbox }

let package t = t.package

let vimpl t = t.vimpl
Expand Down
2 changes: 2 additions & 0 deletions src/dune_rules/compilation_context.mli
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ val js_of_ocaml : t -> Dune_file.Js_of_ocaml.t option

val sandbox : t -> Sandbox_config.t

val set_sandbox : t -> Sandbox_config.t -> t

val package : t -> Package.t option

val vimpl : t -> Vimpl.t option
Expand Down
5 changes: 4 additions & 1 deletion src/dune_rules/menhir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ module Run (P : PARAMS) = struct
(Compilation_context.preprocessing cctx)
name mock_module ~lint:false
in
let cctx = Compilation_context.without_bin_annot cctx in
let cctx =
Compilation_context.set_sandbox cctx Sandbox_config.needs_sandboxing
|> Compilation_context.without_bin_annot
in
let* deps = Dep_rules.for_module cctx mock_module in
let* () =
Module_compilation.ocamlc_i ~deps cctx mock_module
Expand Down

0 comments on commit 82df217

Please sign in to comment.