Skip to content

Commit 6cdd840

Browse files
authored
Merge pull request #411 from jmid/implication-doc-warning
Add doc warning about ==> precedence
2 parents 67d0376 + af0435f commit 6cdd840

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
- Clarify documentation for the `int*` and `nat*` generators
5656
- Disabled duplicated pretty-printed feedback when using `QCheck_alcotest` runner
5757
- Fixed the overflow bug when `~count > max_int - 200` affecting `Test.{make_cell,make,make_neg}` in both QCheck and QCheck2
58+
- Add a documentation warning about the precedence of `==>` to `QCheck` and `QCheck2`
5859

5960

6061
## 0.91 (2025-12-21)

src/core/QCheck.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ val (==>) : bool -> bool -> bool
9090
better with {!Test.check_exn} and the likes, because they will know
9191
the precondition was not satisfied.).
9292
93+
{b Note}: [==>] inherits the precedence of OCaml's [=] operator,
94+
{{:https://ocaml.org/manual/5.4/expr.html#ss:precedence-and-associativity}which is higher than the logical connectives [&&] and [||]}.
95+
As a consequence OCaml will parse [a && b ==> c] as [a && (b ==> c)] - and
96+
similarly for [||] - which is likely not the intention. Put explicit
97+
parentheses [(a && b) ==> c] or use the {!assume} function to avoid this issue.
98+
9399
{b WARNING}: this function should only be used in a property
94100
(see {!Test.make}), because it raises a special exception in case of
95101
failure of the first argument, to distinguish between failed test

src/core/QCheck2.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,12 @@ val (==>) : bool -> bool -> bool
16101610
better with {!Test.check_exn} and the likes, because they will know
16111611
the precondition was not satisfied.).
16121612
1613+
{b Note}: [==>] inherits the precedence of OCaml's [=] operator,
1614+
{{:https://ocaml.org/manual/5.4/expr.html#ss:precedence-and-associativity}which is higher than the logical connectives [&&] and [||]}.
1615+
As a consequence OCaml will parse [a && b ==> c] as [a && (b ==> c)] - and
1616+
similarly for [||] - which is likely not the intention. Put explicit
1617+
parentheses [(a && b) ==> c] or use the {!assume} function to avoid this issue.
1618+
16131619
⚠️ This function should only be used in a property
16141620
(see {!Test.make}), because it raises a special exception in case of
16151621
failure of the first argument, to distinguish between failed test

0 commit comments

Comments
 (0)