Skip to content

Extra type-defaults warnings (from OverloadedStrings) make doctests fail #390

@andreasabel

Description

@andreasabel

I have been using cabal-doctest to build a doctest testsuite (which is then run via cabal test). However, cabal-doctest requires custom setup in the .cabal file with a Cabal dependency, which is bad for the dependency footprint.

So I am trying the "new" recipe (not soo new anymore):

cabal repl -w doctest

This fails some doctests (that should pass) because I get mysterious type-defaults warnings (see below).
I can workaround this via

cabal repl -w doctest --repl-options=-Wno-type-defaults

(UPDATE: the OP used --ghc-options which does not work reliably, see discussion to follow.)

Couldn't this problem fixed generally by not counting GHCI warnings as part of the test result?

Example:

src/BNFC/Backend/Agda.hs:677: failure in expression `numberUniquely ["a", "b", "a", "a", "c", "b"]'
expected: [(Just 1,"a"),(Just 1,"b"),(Just 2,"a"),(Just 3,"a"),(Nothing,"c"),(Just 2,"b")]
 but got: 
          ^
          <interactive>:109:1: warning: [-Wtype-defaults]
              • Defaulting the following constraints to type ‘String’
                  (Show a0) arising from a use of ‘print’ at <interactive>:109:1-45
                  (Ord a0) arising from a use of ‘it’ at <interactive>:109:1-45
                  (IsString a0) arising from a use of ‘it’ at <interactive>:109:1-45
              • In a stmt of an interactive GHCi command: print it
          [(Just 1,"a"),(Just 1,"b"),(Just 2,"a"),(Just 3,"a"),(Nothing,"c"),(Just 2,"b")]

We can see here that this implementation of doctests does not deal properly with {-# LANGUAGE OverloadedStrings #-}.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions