Commit 39f0eea5 authored by Iustin Pop's avatar Iustin Pop
Browse files

Automatically enable version-dependent GHC flags

Some GHC flags are very useful, but only appear in more recent GHC
versions. To support the use of such flags while still supporting
older compilers, let's add conditional checks and enabling based on
the results.

Currently only `-fwarn-incomplete-uni-patterns` is enabled, which
detects refutable patterns in lambda expressions and pattern bindings
(e.g. "let (Just x) = y"); such constructs are bad as they can lead to
runtime exceptions.

Additionally, fix an existing such bad construct in a test case; we
workaround it by using error, since that should never fail.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent 43b3b5c1
......@@ -401,7 +401,12 @@ HS_ALL_PROGS = \
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
-O -Wall -Werror -ihtools \
-fwarn-monomorphism-restriction \
-fwarn-tabs \
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
# internal extra flags (used for htest/test mainly)
......@@ -430,6 +430,17 @@ if test -z "$GHC"; then
AC_MSG_FAILURE([ghc not found, compilation will not possible])
AC_MSG_CHECKING([checking for extra GHC flags])
# check for GHC supported flags that vary accross versions
for flag in -fwarn-incomplete-uni-patterns; do
if $GHC -e "0" $flag >/dev/null 2>/dev/null; then
# Check for ghc-pkg
AC_ARG_VAR(GHC_PKG, [ghc-pkg path])
AC_PATH_PROG(GHC_PKG, [ghc-pkg], [])
......@@ -346,7 +346,11 @@ prop_AllocBalance =
prop_CheckConsistency :: Node.Node -> Instance.Instance -> Bool
prop_CheckConsistency node inst =
let nl = makeSmallCluster node 3
[node1, node2, node3] = Container.elems nl
(node1, node2, node3) =
case Container.elems nl of
[a, b, c] -> (a, b, c)
l -> error $ "Invalid node list out of makeSmallCluster/3: " ++
show l
node3' = node3 { = 1 }
nl' = Container.add (Node.idx node3') node3' nl
inst1 = Instance.setBoth inst (Node.idx node1) (Node.idx node2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment