diff --git a/src/dune_file.ml b/src/dune_file.ml index 4c3b71e4..f202cf45 100644 --- a/src/dune_file.ml +++ b/src/dune_file.ml @@ -1485,18 +1485,19 @@ module Rule = struct } let ocamllex_jbuild = - enter - (if_list - ~then_:( - record - (let%map modules = field "modules" (list string) - and mode = Mode.field in - { modules; mode })) - ~else_:( - repeat string >>| fun modules -> - { modules - ; mode = Standard - })) + peek_exn >>= function + | List (_, Atom (_, _) :: _) -> + enter ( + repeat string >>| fun modules -> + { modules + ; mode = Standard + } + ) + | _ -> + record + (let%map modules = field "modules" (list string) + and mode = Mode.field in + { modules; mode }) let ocamllex_dune = if_eos diff --git a/test/blackbox-tests/test-cases/ocamllex-jbuild/run.t b/test/blackbox-tests/test-cases/ocamllex-jbuild/run.t index 75eaa6b7..5c26a28d 100644 --- a/test/blackbox-tests/test-cases/ocamllex-jbuild/run.t +++ b/test/blackbox-tests/test-cases/ocamllex-jbuild/run.t @@ -1,6 +1,2 @@ $ dune exec ./foo.exe - File "jbuild", line 2, characters 3-10: - ((modules (foo)))) - ^^^^^^^ - Error: S-expression of the form ( ...) expected - [1] + foo