Incorrect module dependency in generated parser
My parser is in a foo
library, wrapped as Foo
by Dune. With a particular grammar, Menhir prefixes a reference to my Ast
module with Foo.
. This is invalid because the parser itself is in the foo
library .
Here is a minimal example:
.
├── ast.ml
├── dune
├── dune-project
└── parser.mly
parser.mly
:
%token Return
%token Eof
%start <Ast.Block.t> block
%%
let block :=
| ~ = retstat; Eof; <Some>
let retstat :=
| Return; {[]}
%%
ast.ml
:
module Retstat = struct
type t = int list
[@@deriving eq,ord,show]
end
module Block = struct
type t = Retstat.t option
[@@deriving eq,ord,show]
end
dune
:
(menhir
(modules parser))
(library
(name foo))
dune-project
:
(lang dune 1.10)
(using fmt 1.1 (enabled_for dune))
(using menhir 2.0)
This results in the following error:
> dune build @check
Module Parser in directory _build/default depends on Foo.
This doesn't make sense to me.
Foo is the main module of the library and is the only module exposed
outside of the library. Consequently, it should be the one depending
on all the other modules in the library.
Indeed, you can see lines like the following in the generated parser:
let _v : (Foo.Ast.Retstat.t) =
If I turn the int list
into int
or the Retstat.t option
into Retstat.t
, the problem disappears. That's why I couldn't minimize this example further. I hope this helps!
This is with menhir 20190626
and Dune 1.10.0.