Opened 5 years ago

Last modified 3 years ago

#10600 closed bug

-fwarn-incomplete-patterns doesn't work with -fno-code — at Version 13

Reported by: akio Owned by: ezyang
Priority: normal Milestone: 8.4.1
Component: Compiler Version: 7.10.1
Keywords: Cc: duog
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: driver/T8101b
Blocked By: Blocking:
Related Tickets: #8101 Differential Rev(s): Phab:D1278
Wiki Page:

Description (last modified by bgamari)

-fwarn-incomplete-patterns doesn't seem to generate any warnings when -fno-code is specified.

To reproduce, save this module as foo.hs.

module Foo where
foo True = 4

and compile with -fwarn-incomplete-patterns, with and without -fno-code.

% ghc -fwarn-incomplete-patterns -fforce-recomp foo.hs
[1 of 1] Compiling Foo              ( foo.hs, foo.o )

foo.hs:2:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘foo’: Patterns not matched: False
% ghc -fwarn-incomplete-patterns -fforce-recomp -fno-code foo.hs
[1 of 1] Compiling Foo              ( foo.hs, nothing )

Change History (13)

comment:1 Changed 5 years ago by thomie

Milestone: 7.12.1

This has been addressed before in #8101. The fix there doesn't seem to work, and is missing a test.

comment:2 Changed 4 years ago by rwbarton

Actually the fix in #8101 works in one-shot mode (-c), but not in make mode (the default).

comment:3 Changed 4 years ago by Reid Barton <rwbarton@…>

In aa230540/ghc:

Add test for #10600 (exhaustiveness check with --make and -fno-code)

comment:4 Changed 4 years ago by rwbarton

Test Case: driver/T8101b

comment:5 Changed 4 years ago by ntc2

This causes Emacs Flycheck to not warn for non-exhaustive patterns, because it runs GHC with -fno-code:

comment:6 Changed 4 years ago by simonpj

This can't be hard to fix... would anyone like to look at it?


comment:7 Changed 4 years ago by thoughtpolice


Milestone renamed

comment:8 Changed 4 years ago by thomie

Keywords: newcomer added

comment:9 Changed 4 years ago by ezyang

Owner: set to ezyang

comment:10 Changed 4 years ago by ezyang

So... I implemented this. But then I got a lint error!

"/home/hs01/ezyang/ghc-validate/inplace/bin/haddock" --verbosity=0 --odir="libraries/ghc-prim/dist-install/doc/html/ghc-prim" --no-tmp-comp-dir --dump-interface=libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock --html --hoogle --title="ghc-prim- GHC primitives" --prologue="libraries/ghc-prim/dist-install/haddock-prologue.txt"   --optghc=-hisuf --optghc=dyn_hi --optghc=-osuf --optghc=dyn_o --optghc=-hcsuf --optghc=dyn_hc --optghc=-fPIC --optghc=-dynamic --optghc=-O0 --optghc=-H64m --optghc=-Werror --optghc=-this-package-key --optghc=8TmvWUcS1U1IKHT0levwg3 --optghc=-hide-all-packages --optghc=-i --optghc=-ilibraries/ghc-prim/. --optghc=-ilibraries/ghc-prim/dist-install/build --optghc=-ilibraries/ghc-prim/dist-install/build/autogen --optghc=-Ilibraries/ghc-prim/dist-install/build --optghc=-Ilibraries/ghc-prim/dist-install/build/autogen --optghc=-Ilibraries/ghc-prim/. --optghc=-optP-include --optghc=-optPlibraries/ghc-prim/dist-install/build/autogen/cabal_macros.h --optghc=-package-id --optghc=builtin_rts --optghc=-this-package-key --optghc=ghc-prim --optghc=-XHaskell2010 --optghc=-O --optghc=-dcore-lint --optghc=-no-user-package-db --optghc=-rtsopts --optghc=-fno-warn-trustworthy-safe --optghc=-fno-warn-deprecated-flags --optghc=-fno-warn-tabs --optghc=-odir --optghc=libraries/ghc-prim/dist-install/build --optghc=-hidir --optghc=libraries/ghc-prim/dist-install/build --optghc=-stubdir --optghc=libraries/ghc-prim/dist-install/build --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html#%{NAME}   libraries/ghc-prim/./GHC/CString.hs  libraries/ghc-prim/./GHC/Classes.hs  libraries/ghc-prim/./GHC/Debug.hs  libraries/ghc-prim/./GHC/IntWord64.hs  libraries/ghc-prim/./GHC/Magic.hs  libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs  libraries/ghc-prim/./GHC/Tuple.hs  libraries/ghc-prim/./GHC/Types.hs libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs +RTS -t"libraries/ghc-prim/dist-install/haddock.t" --machine-readable
*** Core Lint errors : in result of Desugar (after optimization) ***
<wired into compiler>: warning:
    [RHS of proxy# :: forall a_a3EW. Proxy# a_a3EW]
    The type of this binder is primitive: proxy#
    Binder's type: forall a_a3EW. Proxy# a_a3EW


Rec {
proxy# [Occ=LoopBreaker] :: forall a_a3EW. Proxy# a_a3EW
[LclIdX, Str=DmdType]
proxy# = proxy#
end Rec }

If I recall correctly, this is just a fake module that we give Haddock so it can generate documentation for it. So... I guess we should not desugar it? We could force the desugarer not to run by turning off warnings, but it's awfully delicate.

Last edited 4 years ago by ezyang (previous) (diff)

comment:11 Changed 4 years ago by bgamari

Either we could explicitly blacklist GHC.Prim from desugaring or we could forego Core linting when we aren't going to codegen. Neither option seems terribly great although the first seems a bit more straightforward.

comment:12 Changed 4 years ago by thoughtpolice

Differential Rev(s): Phab:D1278

comment:13 Changed 4 years ago by bgamari

Description: modified (diff)
Status: newpatch
Note: See TracTickets for help on using tickets.