daml/bazel_tools/haskell-ghcide-binary-q.patch
Moritz Kiefer 15bf131fed
Enable assertions in Haskell builds (#6853)
GHC hates its users and defaults to optimizing out assertions. We
fixed that in Buck at some point but clearly that got lost when
migrating to Bazel.

Turns out enabling assertions catches bugs. This insight was brought to
you from the people that also brought you “Turns out writing tests
catches bugs”.

fixes #5624

changelog_begin
changelog_end
2020-07-24 14:29:25 +00:00

21 lines
785 B
Diff

diff --git a/src/Development/IDE/Core/Shake.hs b/src/Development/IDE/Core/Shake.hs
index a471070..a2b3183 100644
--- a/src/Development/IDE/Core/Shake.hs
+++ b/src/Development/IDE/Core/Shake.hs
@@ -503,7 +503,14 @@ isBadDependency x
newtype Q k = Q (k, NormalizedFilePath)
deriving (Eq,Hashable,NFData, Generic)
-instance Binary k => Binary (Q k)
+instance Binary k => Binary (Q k) where
+ put (Q (k, fp)) = put (k, fp)
+ get = do
+ (k, fp) <- get
+ -- The `get` implementation of NormalizedFilePath
+ -- does not handle empty file paths so we
+ -- need to handle this ourselves here.
+ pure (Q (k, toNormalizedFilePath' fp))
instance Show k => Show (Q k) where
show (Q (k, file)) = show k ++ "; " ++ fromNormalizedFilePath file