@@ -464,8 +464,9 @@ resolveHackPaths ps = do
464464 trees <- liftIO $ for ps $ \(p, a) -> pathToTree a <$> canonicalizePath p
465465 pure $ foldr1 mergeRightBias <$> nonEmpty trees
466466 where
467− -- | Merge two 'PathTree's preferring paths on the right in as much as they overlap with paths on the left.
467+ -- | Merge two 'PathTree's preferring leaves on the right in as much as they overlap with paths on the left.
468468 mergeRightBias :: PathTree a -> PathTree a -> PathTree a
469− mergeRightBias (PathTree_Node Nothing a) (PathTree_Node Nothing b) = PathTree_Node Nothing $ Map.unionWith mergeRightBias a b
470− mergeRightBias (PathTree_Node (Just v) _) (PathTree_Node Nothing b) = PathTree_Node (Just v) b
471− mergeRightBias _ b = b
469+ mergeRightBias = go
470+ where
471+ go _ b@(PathTree_Node (Just _) _) = b -- When a leaf is present on the right, right always wins.
472+ go (PathTree_Node v a) (PathTree_Node Nothing b) = PathTree_Node v $ Map.unionWith go a b