diff --git a/cabal-testsuite/PackageTests/VersionPriority/0-local.out b/cabal-testsuite/PackageTests/VersionPriority/0-local.out
new file mode 100644
index 0000000000000000000000000000000000000000..309b61103e36b1f87fdbe31f4999a3526fc4aa53
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/0-local.out
@@ -0,0 +1,12 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/0-local.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config <ROOT>/0-local.project requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/0-local.project b/cabal-testsuite/PackageTests/VersionPriority/0-local.project
new file mode 100644
index 0000000000000000000000000000000000000000..262cd6eefbcdd1aba396855a96fdd3e3bd5de4c7
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/0-local.project
@@ -0,0 +1,3 @@
+packages: .
+constraints: hashable ==1.4.3.0
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/0-local.test.hs b/cabal-testsuite/PackageTests/VersionPriority/0-local.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..07fe0af96a94eb61080f9c63f7d2d90b81dadffd
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/0-local.test.hs
@@ -0,0 +1,4 @@
+import Test.Cabal.Prelude
+
+main = cabalTest . withRepo "repo" . withProjectFile "0-local.project" $ do
+    fails $ cabal "v2-build" ["--dry-run"]
\ No newline at end of file
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-local-constraints-import.project b/cabal-testsuite/PackageTests/VersionPriority/1-local-constraints-import.project
new file mode 100644
index 0000000000000000000000000000000000000000..986ca4376f212142552da6fa2af9d6f58b131a7d
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-local-constraints-import.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+constraints: hashable ==1.4.2.0
+import: stackage-local.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-local-import-constraints.project b/cabal-testsuite/PackageTests/VersionPriority/1-local-import-constraints.project
new file mode 100644
index 0000000000000000000000000000000000000000..1ee9a90ccccb03cf48015510af15da02d3573d24
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-local-import-constraints.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+import: stackage-local.config
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-local.out b/cabal-testsuite/PackageTests/VersionPriority/1-local.out
new file mode 100644
index 0000000000000000000000000000000000000000..c9aca7097d417fcb6d882230515ef74428424745
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-local.out
@@ -0,0 +1,22 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/1-local-constraints-import.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config stackage-local.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/1-local-import-constraints.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config stackage-local.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-local.test.hs b/cabal-testsuite/PackageTests/VersionPriority/1-local.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..14723adb06723d5d043e947a93d176b94d2b521f
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-local.test.hs
@@ -0,0 +1,9 @@
+import Test.Cabal.Prelude
+
+testVersionWin project =
+    withProjectFile project $ do
+        fails $ cabal "v2-build" ["--dry-run"]
+
+main = cabalTest . withRepo "repo" $ do
+    testVersionWin "1-local-constraints-import.project"
+    testVersionWin "1-local-import-constraints.project"
\ No newline at end of file
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-web-constraints-import.project b/cabal-testsuite/PackageTests/VersionPriority/1-web-constraints-import.project
new file mode 100644
index 0000000000000000000000000000000000000000..461ab31539bf8becd4e5e2f4597192fc40116e8b
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-web-constraints-import.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+constraints: hashable ==1.4.2.0
+import: https://www.stackage.org/nightly-2023-12-07/cabal.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-web-import-constraints.project b/cabal-testsuite/PackageTests/VersionPriority/1-web-import-constraints.project
new file mode 100644
index 0000000000000000000000000000000000000000..6eebd83af30ad91ea2744811097e9524614a2a61
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-web-import-constraints.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+import: https://www.stackage.org/nightly-2023-12-07/cabal.config
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-web.out b/cabal-testsuite/PackageTests/VersionPriority/1-web.out
new file mode 100644
index 0000000000000000000000000000000000000000..82dd065c7cefda3663a9c846ba675bd647dd3dbf
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-web.out
@@ -0,0 +1,22 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/1-web-constraints-import.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/1-web-import-constraints.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/1-web.test.hs b/cabal-testsuite/PackageTests/VersionPriority/1-web.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..8d695dfe710668bc18e3803b88bfc442f5c86caa
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/1-web.test.hs
@@ -0,0 +1,13 @@
+import Test.Cabal.Prelude
+
+testVersionWin project =
+    withProjectFile project $ do
+        fails $ cabal "v2-build" ["--dry-run"]
+
+main = cabalTest . withRepo "repo" $ do
+    -- To avoid this diff:
+    --   -Build profile: -w ghc-9.6.3 -O1
+    --   +Build profile: -w ghc-<GHCVER> -O1
+    skipIfGhcVersion "== 9.6.3"
+    testVersionWin "1-web-constraints-import.project"
+    testVersionWin "1-web-import-constraints.project"
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-local-constraints-import.project b/cabal-testsuite/PackageTests/VersionPriority/2-local-constraints-import.project
new file mode 100644
index 0000000000000000000000000000000000000000..b34145826a681fc6928bc491f1ca8fa4fdafa724
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-local-constraints-import.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+constraints: hashable ==1.4.2.0
+import: hop-local.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-local-import-constraints.project b/cabal-testsuite/PackageTests/VersionPriority/2-local-import-constraints.project
new file mode 100644
index 0000000000000000000000000000000000000000..783f5f24617ab9689d4451c27f4724070a4420c8
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-local-import-constraints.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+import: hop-local.config
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-local.out b/cabal-testsuite/PackageTests/VersionPriority/2-local.out
new file mode 100644
index 0000000000000000000000000000000000000000..cefdd9616374590c3b3d52807c8dc7c9da93617b
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-local.out
@@ -0,0 +1,22 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/2-local-constraints-import.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config stackage-local.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/2-local-import-constraints.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config stackage-local.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-local.test.hs b/cabal-testsuite/PackageTests/VersionPriority/2-local.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..4e4e61266be7f5575e23ce58b89af0f499789460
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-local.test.hs
@@ -0,0 +1,9 @@
+import Test.Cabal.Prelude
+
+testVersionWin project =
+    withProjectFile project $ do
+        fails $ cabal "v2-build" ["--dry-run"]
+
+main = cabalTest . withRepo "repo" $ do
+    testVersionWin "2-local-constraints-import.project"
+    testVersionWin "2-local-import-constraints.project"
\ No newline at end of file
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-web-constraints-import.project b/cabal-testsuite/PackageTests/VersionPriority/2-web-constraints-import.project
new file mode 100644
index 0000000000000000000000000000000000000000..2be7836ec6ec6ec8d57a7108865858a963fc6058
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-web-constraints-import.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+constraints: hashable ==1.4.2.0
+import: stackage-web.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-web-import-constraints.project b/cabal-testsuite/PackageTests/VersionPriority/2-web-import-constraints.project
new file mode 100644
index 0000000000000000000000000000000000000000..512f235dbbfb6350c037392b83fa443c5d2cdd01
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-web-import-constraints.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+import: stackage-web.config
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-web.out b/cabal-testsuite/PackageTests/VersionPriority/2-web.out
new file mode 100644
index 0000000000000000000000000000000000000000..a8b4cf8c29a15922de0ad9abdc2b360fa919dc52
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-web.out
@@ -0,0 +1,22 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/2-web-constraints-import.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/2-web-import-constraints.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/2-web.test.hs b/cabal-testsuite/PackageTests/VersionPriority/2-web.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..11450ddd396118188194850cbebcdb7f4597d883
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/2-web.test.hs
@@ -0,0 +1,13 @@
+import Test.Cabal.Prelude
+
+testVersionWin project =
+    withProjectFile project $ do
+        fails $ cabal "v2-build" ["--dry-run"]
+
+main = cabalTest . withRepo "repo" $ do
+    -- To avoid this diff:
+    --   -Build profile: -w ghc-9.6.3 -O1
+    --   +Build profile: -w ghc-<GHCVER> -O1
+    skipIfGhcVersion "== 9.6.3"
+    testVersionWin "2-web-constraints-import.project"
+    testVersionWin "2-web-import-constraints.project"
diff --git a/cabal-testsuite/PackageTests/VersionPriority/3-web-constraints-import.project b/cabal-testsuite/PackageTests/VersionPriority/3-web-constraints-import.project
new file mode 100644
index 0000000000000000000000000000000000000000..11f33600f96f82aee7bd94f82350218b87d923eb
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/3-web-constraints-import.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+constraints: hashable ==1.4.2.0
+import: hop-web.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/3-web-import-constraints.project b/cabal-testsuite/PackageTests/VersionPriority/3-web-import-constraints.project
new file mode 100644
index 0000000000000000000000000000000000000000..79b3be193273441f318af0f9ff01d893011a8d59
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/3-web-import-constraints.project
@@ -0,0 +1,4 @@
+packages: .
+allow-newer: hashable:*
+import: hop-web.config
+constraints: hashable ==1.4.2.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/3-web.out b/cabal-testsuite/PackageTests/VersionPriority/3-web.out
new file mode 100644
index 0000000000000000000000000000000000000000..ff14e477cd6ad4688421ce700df56ca819aa63a0
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/3-web.out
@@ -0,0 +1,22 @@
+# cabal v2-update
+Downloading the latest package list from test-local-repo
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/3-web-constraints-import.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
+# cabal v2-build
+Resolving dependencies...
+Error: [Cabal-7107]
+Could not resolve dependencies:
+[__0] trying: cabal-version-override-0.1.0.0 (user goal)
+[__1] next goal: hashable (dependency of cabal-version-override)
+[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/3-web-import-constraints.project requires ==1.4.2.0)
+[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
+[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
diff --git a/cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs b/cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..94a0cbc86b8af32af965b1728a821d03c8abcaa1
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs
@@ -0,0 +1,13 @@
+import Test.Cabal.Prelude
+
+testVersionWin project =
+    withProjectFile project $ do
+        fails $ cabal "v2-build" ["--dry-run"]
+
+main = cabalTest . withRepo "repo" $ do
+    -- To avoid this diff:
+    --   -Build profile: -w ghc-9.6.3 -O1
+    --   +Build profile: -w ghc-<GHCVER> -O1
+    skipIfGhcVersion "== 9.6.3"
+    testVersionWin "3-web-constraints-import.project"
+    testVersionWin "3-web-import-constraints.project"
diff --git a/cabal-testsuite/PackageTests/VersionPriority/README.md b/cabal-testsuite/PackageTests/VersionPriority/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..8f76f53f3ac89707dc5217b87ea3f551698a8759
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/README.md
@@ -0,0 +1,51 @@
+# Version Priority Tests
+
+The `1-` prefix projects have an import depth of 1, the `2-` prefix projects
+have a depth of 2 and `3-` prefix has depth 3. The `0-` prefix project have any
+imports.  Only projects have the `.project` extension. Imported configuration
+has a `.config` extension.
+
+- *0-local.project*
+    ```
+    .
+    └── 0-local.project
+    ```
+
+- *1-local.project*
+    ```
+    .
+    └── 1-local.project
+        └── stackage-local.config
+    ```
+
+- *2-local.project*
+    ```
+    .
+    └── 2-local.project
+        └── hop-local.config
+            └── stackage-local.config
+    ```
+
+- *1-web.project*
+    ```
+    .
+    └── 1-web.project
+        └── https://www.stackage.org/nightly-2023-12-07/cabal.config
+    ```
+
+- *2-web.project*
+    ```
+    .
+    └── 2-web.project
+        └── stackage-web.config
+            └── https://www.stackage.org/nightly-2023-12-07/cabal.config
+    ```
+
+- *3-web.project*
+    ```
+    .
+    └── 3-web.project
+        └── hop-web.config
+            └── stackage-web.config
+                └── https://www.stackage.org/nightly-2023-12-07/cabal.config
+    ```
diff --git a/cabal-testsuite/PackageTests/VersionPriority/app/Main.hs b/cabal-testsuite/PackageTests/VersionPriority/app/Main.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a170ab7732ddf65dacab72f5db76933af38f952f
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import Data.Hashable
+
+main :: IO ()
+main = print $ hash "foo"
diff --git a/cabal-testsuite/PackageTests/VersionPriority/cabal-version-override.cabal b/cabal-testsuite/PackageTests/VersionPriority/cabal-version-override.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..181bdef8e7dd0af61af36b0edb2491b7de327669
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/cabal-version-override.cabal
@@ -0,0 +1,17 @@
+cabal-version:      3.0
+name:               cabal-version-override
+version:            0.1.0.0
+license:            MPL-2.0
+author:             Phil de Joux
+category:           Development
+build-type:         Simple
+
+common warnings
+    ghc-options: -Wall
+
+executable cabal-version-override
+    import:           warnings
+    main-is:          Main.hs
+    build-depends:    base, hashable
+    hs-source-dirs:   app
+    default-language: Haskell2010
diff --git a/cabal-testsuite/PackageTests/VersionPriority/hop-local.config b/cabal-testsuite/PackageTests/VersionPriority/hop-local.config
new file mode 100644
index 0000000000000000000000000000000000000000..fc9024b3bb56ac2f3cd6b3045a163572a59e581d
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/hop-local.config
@@ -0,0 +1 @@
+import: stackage-local.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/hop-web.config b/cabal-testsuite/PackageTests/VersionPriority/hop-web.config
new file mode 100644
index 0000000000000000000000000000000000000000..848f0c5920daef411b5abbe065fa0a32872e3a00
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/hop-web.config
@@ -0,0 +1 @@
+import: stackage-web.config
diff --git a/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.2.0/hashable.cabal b/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.2.0/hashable.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..be8d96b783dae89de975af2747f2fad298f635f2
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.2.0/hashable.cabal
@@ -0,0 +1,186 @@
+cabal-version:      1.12
+name:               hashable
+version:            1.4.2.0
+synopsis:           A class for types that can be converted to a hash value
+description:
+  This package defines a class, 'Hashable', for types that
+  can be converted to a hash value.  This class
+  exists for the benefit of hashing-based data
+  structures.  The package provides instances for
+  basic types and a way to combine hash values.
+
+homepage:           http://github.com/haskell-unordered-containers/hashable
+
+-- SPDX-License-Identifier : BSD-3-Clause
+license:            BSD3
+license-file:       LICENSE
+author:
+  Milan Straka <fox@ucw.cz>
+  Johan Tibell <johan.tibell@gmail.com>
+
+maintainer:         Oleg Grenrus <oleg.grenrus@iki.fi>
+bug-reports:
+  https://github.com/haskell-unordered-containers/hashable/issues
+
+stability:          Provisional
+category:           Data
+build-type:         Simple
+tested-with:
+  GHC ==8.2.2
+   || ==8.4.4
+   || ==8.6.5
+   || ==8.8.3
+   || ==8.10.4
+   || ==8.10.7
+   || ==9.0.1
+   || ==9.0.2
+   || ==9.2.5
+   || ==9.4.4
+
+extra-source-files:
+  CHANGES.md
+  include/HsHashable.h
+  README.md
+
+flag integer-gmp
+  description:
+    Are we using @integer-gmp@ to provide fast Integer instances? No effect on GHC-9.0 or later.
+
+  manual:      False
+  default:     True
+
+flag random-initial-seed
+  description:
+    Randomly initialize the initial seed on each final executable invocation
+    This is useful for catching cases when you rely on (non-existent)
+    stability of hashable's hash functions.
+    This is not a security feature.
+
+  manual:      True
+  default:     False
+
+library
+  exposed-modules:
+    Data.Hashable
+    Data.Hashable.Generic
+    Data.Hashable.Lifted
+
+  other-modules:
+    Data.Hashable.Class
+    Data.Hashable.Generic.Instances
+    Data.Hashable.Imports
+    Data.Hashable.LowLevel
+
+  c-sources:        cbits/fnv.c
+  include-dirs:     include
+  hs-source-dirs:   src
+  build-depends:
+    -- REMOVED constraint on base for test
+    -- base        >=4.10.1.0 && <4.18
+      base
+    , bytestring  >=0.10.8.2 && <0.12
+    , containers  >=0.5.10.2 && <0.7
+    , deepseq     >=1.4.3.0  && <1.5
+    , filepath    >=1.4.1.2  && <1.5
+    , ghc-prim
+    , text        >=1.2.3.0  && <1.3  || >=2.0 && <2.1
+
+  -- REMOVED conditional compilation pulling in extra dependencies
+  -- if !impl(ghc >=9.2)
+  --   build-depends: base-orphans >=0.8.6 && <0.9
+
+  -- if !impl(ghc >=9.4)
+  --   build-depends: data-array-byte >=0.1.0.1 && <0.2
+
+  -- Integer internals
+  if impl(ghc >=9)
+    build-depends: ghc-bignum >=1.0 && <1.4
+
+    if !impl(ghc >=9.0.2)
+      build-depends: ghc-bignum-orphans >=0.1 && <0.2
+
+  else
+    if flag(integer-gmp)
+      build-depends: integer-gmp >=0.4 && <1.1
+
+    else
+      -- this is needed for the automatic flag to be well-balanced
+      build-depends: integer-simple
+
+  if (flag(random-initial-seed) && impl(ghc))
+    cpp-options: -DHASHABLE_RANDOM_SEED=1
+
+    if os(windows)
+      c-sources: cbits-win/init.c
+
+    else
+      c-sources: cbits-unix/init.c
+
+  default-language: Haskell2010
+  other-extensions:
+    BangPatterns
+    CPP
+    DeriveDataTypeable
+    FlexibleContexts
+    FlexibleInstances
+    GADTs
+    KindSignatures
+    MagicHash
+    MultiParamTypeClasses
+    ScopedTypeVariables
+    Trustworthy
+    TypeOperators
+    UnliftedFFITypes
+
+  ghc-options:      -Wall -fwarn-tabs
+
+  if impl(ghc >=9.0)
+    -- these flags may abort compilation with GHC-8.10
+    -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295
+    ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode
+
+test-suite hashable-tests
+  type:             exitcode-stdio-1.0
+  hs-source-dirs:   tests
+  main-is:          Main.hs
+  other-modules:
+    Properties
+    Regress
+
+  build-depends:
+      base
+    , bytestring
+    , ghc-prim
+    , hashable
+    , HUnit
+    , QuickCheck                  >=2.4.0.1
+    , random                      >=1.0      && <1.3
+    , test-framework              >=0.3.3
+    , test-framework-hunit
+    , test-framework-quickcheck2  >=0.2.9
+    , text                        >=0.11.0.5
+
+  if !os(windows)
+    build-depends:    unix
+    cpp-options:      -DHAVE_MMAP
+    other-modules:    Regress.Mmap
+    other-extensions: CApiFFI
+
+  ghc-options:      -Wall -fno-warn-orphans
+  default-language: Haskell2010
+
+test-suite hashable-examples
+  type:             exitcode-stdio-1.0
+  build-depends:
+      base
+    , ghc-prim
+    , hashable
+
+  hs-source-dirs:   examples
+  main-is:          Main.hs
+  default-language: Haskell2010
+
+source-repository head
+  type:     git
+  location:
+    https://github.com/haskell-unordered-containers/hashable.git
diff --git a/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.3.0/hashable.cabal b/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.3.0/hashable.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..69efe15c0863a9b51b293631e7e089867525ac1e
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/repo/hashable-1.4.3.0/hashable.cabal
@@ -0,0 +1,188 @@
+cabal-version:      1.12
+name:               hashable
+version:            1.4.3.0
+synopsis:           A class for types that can be converted to a hash value
+description:
+  This package defines a class, 'Hashable', for types that
+  can be converted to a hash value.  This class
+  exists for the benefit of hashing-based data
+  structures.  The package provides instances for
+  basic types and a way to combine hash values.
+  .
+  The 'Hashable' 'hash' values are not guaranteed to be stable across library versions, operating systems or architectures. For stable hashing use named hashes: SHA256, CRC32 etc.
+
+homepage:           http://github.com/haskell-unordered-containers/hashable
+
+-- SPDX-License-Identifier : BSD-3-Clause
+license:            BSD3
+license-file:       LICENSE
+author:
+  Milan Straka <fox@ucw.cz>
+  Johan Tibell <johan.tibell@gmail.com>
+
+maintainer:         Oleg Grenrus <oleg.grenrus@iki.fi>
+bug-reports:
+  https://github.com/haskell-unordered-containers/hashable/issues
+
+stability:          Provisional
+category:           Data
+build-type:         Simple
+tested-with:
+  GHC ==8.2.2
+   || ==8.4.4
+   || ==8.6.5
+   || ==8.8.3
+   || ==8.10.4
+   || ==8.10.7
+   || ==9.0.1
+   || ==9.0.2
+   || ==9.2.5
+   || ==9.4.4
+   || ==9.6.1
+
+extra-source-files:
+  CHANGES.md
+  include/HsHashable.h
+  README.md
+
+flag integer-gmp
+  description:
+    Are we using @integer-gmp@ to provide fast Integer instances? No effect on GHC-9.0 or later.
+
+  manual:      False
+  default:     True
+
+flag random-initial-seed
+  description:
+    Randomly initialize the initial seed on each final executable invocation
+    This is useful for catching cases when you rely on (non-existent)
+    stability of hashable's hash functions.
+    This is not a security feature.
+
+  manual:      True
+  default:     False
+
+library
+  exposed-modules:
+    Data.Hashable
+    Data.Hashable.Generic
+    Data.Hashable.Lifted
+
+  other-modules:
+    Data.Hashable.Class
+    Data.Hashable.Generic.Instances
+    Data.Hashable.Imports
+    Data.Hashable.LowLevel
+
+  c-sources:        cbits/fnv.c
+  include-dirs:     include
+  hs-source-dirs:   src
+  build-depends:
+    -- REMOVED constraint on base for test
+    --  base        >=4.10.1.0 && <4.19
+      base
+    , bytestring  >=0.10.8.2 && <0.12
+    , containers  >=0.5.10.2 && <0.7
+    , deepseq     >=1.4.3.0  && <1.5
+    , filepath    >=1.4.1.2  && <1.5
+    , ghc-prim
+    , text        >=1.2.3.0  && <1.3  || >=2.0 && <2.1
+
+  if !impl(ghc >=9.2)
+    build-depends: base-orphans >=0.8.6 && <0.10
+
+  if !impl(ghc >=9.4)
+    build-depends: data-array-byte >=0.1.0.1 && <0.2
+
+  -- Integer internals
+  if impl(ghc >=9)
+    build-depends: ghc-bignum >=1.0 && <1.4
+
+    if !impl(ghc >=9.0.2)
+      build-depends: ghc-bignum-orphans >=0.1 && <0.2
+
+  else
+    if flag(integer-gmp)
+      build-depends: integer-gmp >=0.4 && <1.1
+
+    else
+      -- this is needed for the automatic flag to be well-balanced
+      build-depends: integer-simple
+
+  if (flag(random-initial-seed) && impl(ghc))
+    cpp-options: -DHASHABLE_RANDOM_SEED=1
+
+    if os(windows)
+      c-sources: cbits-win/init.c
+
+    else
+      c-sources: cbits-unix/init.c
+
+  default-language: Haskell2010
+  other-extensions:
+    BangPatterns
+    CPP
+    DeriveDataTypeable
+    FlexibleContexts
+    FlexibleInstances
+    GADTs
+    KindSignatures
+    MagicHash
+    MultiParamTypeClasses
+    ScopedTypeVariables
+    Trustworthy
+    TypeOperators
+    UnliftedFFITypes
+
+  ghc-options:      -Wall -fwarn-tabs
+
+  if impl(ghc >=9.0)
+    -- these flags may abort compilation with GHC-8.10
+    -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295
+    ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode
+
+test-suite hashable-tests
+  type:             exitcode-stdio-1.0
+  hs-source-dirs:   tests
+  main-is:          Main.hs
+  other-modules:
+    Properties
+    Regress
+
+  build-depends:
+      base
+    , bytestring
+    , ghc-prim
+    , hashable
+    , HUnit
+    , QuickCheck                  >=2.4.0.1
+    , random                      >=1.0      && <1.3
+    , test-framework              >=0.3.3
+    , test-framework-hunit
+    , test-framework-quickcheck2  >=0.2.9
+    , text                        >=0.11.0.5
+
+  if !os(windows)
+    build-depends:    unix
+    cpp-options:      -DHAVE_MMAP
+    other-modules:    Regress.Mmap
+    other-extensions: CApiFFI
+
+  ghc-options:      -Wall -fno-warn-orphans
+  default-language: Haskell2010
+
+test-suite hashable-examples
+  type:             exitcode-stdio-1.0
+  build-depends:
+      base
+    , ghc-prim
+    , hashable
+
+  hs-source-dirs:   examples
+  main-is:          Main.hs
+  default-language: Haskell2010
+
+source-repository head
+  type:     git
+  location:
+    https://github.com/haskell-unordered-containers/hashable.git
diff --git a/cabal-testsuite/PackageTests/VersionPriority/stackage-local.config b/cabal-testsuite/PackageTests/VersionPriority/stackage-local.config
new file mode 100644
index 0000000000000000000000000000000000000000..23e32e2f5a87a7ae30af5f4804f61f3f439a1dcc
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/stackage-local.config
@@ -0,0 +1,2 @@
+-- Same constraint as on stackage at https://www.stackage.org/nightly-2023-12-07/cabal.config
+constraints: hashable ==1.4.3.0
diff --git a/cabal-testsuite/PackageTests/VersionPriority/stackage-web.config b/cabal-testsuite/PackageTests/VersionPriority/stackage-web.config
new file mode 100644
index 0000000000000000000000000000000000000000..35603680c01e50a872541e97abfcaeb6dd1ff36a
--- /dev/null
+++ b/cabal-testsuite/PackageTests/VersionPriority/stackage-web.config
@@ -0,0 +1 @@
+import: https://www.stackage.org/nightly-2023-12-07/cabal.config