Skip to content

Commit

Permalink
fix(opam): cleanly reject argumentless (and)/(or)
Browse files Browse the repository at this point in the history
Otherwise they would raise a code error later.

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed May 15, 2023
1 parent ea22fdd commit e0eb621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/dune_rules/package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ module Dependency = struct
fix (fun t ->
let logops =
[ ( "and"
, let+ x = repeat t in
, let+ x = repeat1 t in
And x )
; ( "or"
, let+ x = repeat t in
, let+ x = repeat1 t in
Or x )
]
in
Expand Down
16 changes: 12 additions & 4 deletions test/blackbox-tests/test-cases/opam-constraints.t
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ constraints.
> (p (and))))
> EOF

$ dune build 2>&1 | grep 'Internal error'
Internal error, please report upstream including the contents of _build/log.
$ dune build
File "dune-project", line 6, characters 5-10:
6 | (p (and))))
^^^^^
Error: Not enough arguments for and
[1]

$ cat > dune-project << EOF
> (lang dune 2.1)
Expand All @@ -91,5 +95,9 @@ constraints.
> (p (or))))
> EOF

$ dune build 2>&1 | grep 'Internal error'
Internal error, please report upstream including the contents of _build/log.
$ dune build
File "dune-project", line 6, characters 5-9:
6 | (p (or))))
^^^^
Error: Not enough arguments for or
[1]

0 comments on commit e0eb621

Please sign in to comment.