Open ocharles opened 4 years ago
Is there a handy way of trying to reproduce this locally? e.g., I assume that it's not just a long command line that's the trigger, otherwise lens
would probably be being bitten by that.
I'm afraid I don't have a minimal repro. My guess is that it's more the number of packages being loaded, rather than the length of the command line. I can get doctest
to run if I run it on a single module, but only for some modules - other single module invocations produce the same error. It was the end of the day when I reported this issue, but I'll dig into it in more detail now.
Ok, I weirdly found the problem. Here's the diff that I need to stop doctest
crashing...
@@ -57,12 +57,6 @@ import qualified Data.MonotoneMap as MonotoneMap
import Data.Ratio.Extra
-{-# ann module "HLint: ignore Evaluate" #-}
-
-
-{-# ann module "HLint: ignore Use let" #-}
-
-
-- | Burden rates per role in $/hour
rates :: Durations Rational
rates =
``
That's right, it seems that module annotations are the source of the problem!
Ok, I might be slightly wrong there. The diff above is from a different branch I'm working on, but it doesn't fix master
. The good news is I have a minimal repro on our master
branch. The following single module is enough to crash doctest
. You will need a dependency on units
:
{-# language TemplateHaskell #-}
{-# language TypeFamilies #-}
module Data.Units.US.Money where
-- units
import Data.Metrology
import Data.Metrology.TH
declareDimension "Cost"
declareCanonicalUnit "Dollar" [t| Cost |] ( Just "USD" )
type instance DefaultUnitOfDim Cost =
Dollar
declareDerivedUnit "Cent" [t| Dollar |] ( 1 / 100 ) ( Just "cent" )
It seems to be related to actually starting the TH interpreter. If I compile this module with -ddump-splices
and inline all TH, I get:
{-# language TypeFamilies #-}
module Data.Units.US.Money where
-- units
import Data.Metrology
data Cost = Cost
instance Dimension Cost
data Dollar = Dollar
instance Unit Dollar where
type BaseUnit Dollar = Canonical
type DimOfUnit Dollar = Cost
instance Show Dollar where
show _ = "USD"
type instance DefaultUnitOfDim Cost =
Dollar
data Cent = Cent
instance Unit Cent where
type BaseUnit Cent = Dollar
conversionRatio _ = 1.0e-2
instance Show Cent where
show _ = "cent"
Which doctest
can happily evaluate.
Ok, final update - the ann module
stuff also has to removed on the master
branch. Perhaps these are two different problems that just manifest in the same failure. But TL;DR:
Data.Units.US.Money
andANN
pragmas Allows doctest
to run on this package.
I had a go at reproducing this in https://github.com/quasicomputational/doctest-271 but cabal v2-test
works fine with GHC 8.10.2.
If you've still got the reproducer handy, can you see if haddock works on it? doctest and haddock are actually quite similar: if haddock works, then it's some kind of doctest-specific bug, but if haddock fails it may ultimately be a GHC issue.
I unfortunately don't have a reproducible case around anymore. I'll close this for now. Hopefully the trail above may help anyone else who runs into this!
Seems I have this issue on ghc-8.10.3 on Linux (works on macOS). Is there any fix I can try to recipe how to debug it?
It's a huge project with TH and seems that not all the packages with TH fails, so I'm not sure if I can extract the minimal case.
Try haddocking the project as above, and also manually going in with GHCi and trying some of the doctest examples. If either of those break, it's fundamentally going to be a GHC issue. Otherwise, I'm not sure there's much for it except lopping off leaf modules or removing doctests and seeing if things still break.
I'm using
cabal-doctest
and the following whopper of a command line is built:If I call
ghci
with these exact same arguments, it works - so I guess this is something specific to doctest.