Opened 6 years ago

Closed 4 years ago

Last modified 3 years ago

#8101 closed bug (duplicate)

No pattern match non-exhaustiveness warnings when compiling with -fno-code

Reported by: exbb2 Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: T8101
Blocked By: Blocking:
Related Tickets: #10600 Differential Rev(s):
Wiki Page:

Description

{-# OPTIONS_GHC -Wall #-}
module A where

data ABC = A | B | C

abc :: ABC -> Int
abc x = case x of
    A -> 1
$ ghc -fno-code -fforce-recomp /tmp/A.hs 
[1 of 1] Compiling A                ( /tmp/A.hs, nothing )
$ ghc -fobject-code -fforce-recomp /tmp/A.hs 
[1 of 1] Compiling A                ( /tmp/A.hs, /tmp/A.o )

/tmp/A.hs:7:9: Warning:
    Pattern match(es) are non-exhaustive
    In a case alternative:
        Patterns not matched:
            B
            C

Attachments (1)

A.hs (111 bytes) - added by exbb2 6 years ago.

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by exbb2

Attachment: A.hs added

comment:1 Changed 6 years ago by ian@…

commit b475be321106f79da115ae203a5a27fabfbb80d8

Author: Ian Lynagh <ian@well-typed.com>
Date:   Sun Jul 28 17:01:50 2013 +0100

    desugar code even when -fno-code is used; fixes #8101
    
    We need to desugar the code, or we don't get the warnings from the
    desugarer.

 compiler/deSugar/Desugar.lhs |    7 +------
 compiler/main/HscMain.hs     |    4 ++--
 2 files changed, 3 insertions(+), 8 deletions(-)

comment:2 Changed 6 years ago by igloo

Milestone: 7.8.1
Resolution: fixed
Status: newclosed
Test Case: T8101

Thanks for the report; fixed.

comment:3 Changed 6 years ago by monoidal

There's a comment in DynFlags, line 882, which might suggest this was deliberate. At least I would remove it:

-- 'HscNothing' can be used to avoid generating any output, however, note
-- that:
--
--  * This will not run the desugaring step, thus no warnings generated in
--    this step will be output.  In particular, this includes warnings related
--    to pattern matching.  You can run the desugarer manually using
--    'GHC.desugarModule'.

comment:4 Changed 6 years ago by igloo

Hmm, thanks monoidal. It doesn't give a reason for that behaviour, so I've just removed the comment.

comment:5 Changed 6 years ago by ian@…

commit 9e185cc06d9efa833f7b0efdcf3a1d434781ceb6

Author: Ian Lynagh <ian@well-typed.com>
Date:   Sun Jul 28 18:49:07 2013 +0100

    Remove an out-of-date comment (see #8101)

 compiler/main/DynFlags.hs |    5 -----
 1 file changed, 5 deletions(-)

comment:6 Changed 4 years ago by DanielG

Resolution: fixed
Status: closednew

Looks to me like this is still an issue, I couldn't actually find a released version where this was ever fixed.

This is also biting us in ghc-mod land: https://github.com/kazu-yamamoto/ghc-mod/issues/507

$ ghc-7.8.1 -fno-code -fforce-recomp A.hs
[1 of 1] Compiling A                ( A.hs, nothing )

$ ghc-7.8.4 -fno-code -fforce-recomp A.hs
[1 of 1] Compiling A                ( A.hs, nothing )

$ ghc-7.10.2 -fno-code -fforce-recomp A.hs
[1 of 1] Compiling A                ( A.hs, nothing )


# ghc-7.8.1 -fobject-code -fforce-recomp A.hs 
[1 of 1] Compiling A                ( A.hs, A.o )

A.hs:7:9: Warning:
    Pattern match(es) are non-exhaustive
    In a case alternative:
        Patterns not matched:
            B
            C

$ ghc-7.8.4 -fobject-code -fforce-recomp A.hs
[1 of 1] Compiling A                ( A.hs, A.o )

A.hs:7:9: Warning:
    Pattern match(es) are non-exhaustive
    In a case alternative:
        Patterns not matched:
            B
            C

$ ghc-7.10.2 -fobject-code -fforce-recomp A.hs
[1 of 1] Compiling A                ( A.hs, A.o )

A.hs:7:9: Warning:
    Pattern match(es) are non-exhaustive
    In a case alternative:
        Patterns not matched:
            B
            C

comment:7 Changed 4 years ago by rwbarton

Resolution: duplicate
Status: newclosed

This was also recently reported in #10600, so closing in favor of that ticket.

The fix here applied to one-shot mode (-c), but not make mode.

comment:8 Changed 4 years ago by Edward Z. Yang <ezyang@…>

In 427f8a15/ghc:

Deduplicate one-shot/make compile paths.

Summary:
We had a duplicate copy of the code for --make and for -c
which was a pain.  The call graph looked something like this:

    compileOne -> genericHscCompileGetFrontendResult -> genericHscFrontend
                                   hscCompileOneShot ---^

with genericHscCompileGetFrontendResult and hscCompileOneShot
duplicating logic for deciding whether or not recompilation
was needed.

This patchset fixes it, so now everything goes through this call-chain:

    compileOne (--make entry point)
        Calls hscIncrementCompile, invokes the pipeline to do codegen
        and sets up linkables.
    hscIncrementalCompile (-c entry point)
        Calls hscIncrementalFrontend, and then simplifying,
        desugaring, and writing out the interface.
    hscIncrementalFrontend
        Performs recompilation avoidance, if recompilation needed,
        does parses typechecking.

I also cleaned up some of the MergeBoot nonsense by introducing
a FrontendResult type.

NB: this BREAKS #8101 again, because I can't unconditionally desugar
due to Haddock barfing on lint, see #10600

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, bgamari, simonmar, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1302

comment:9 Changed 3 years ago by Ben Gamari <ben@…>

In baa18de/ghc:

testsuite: add new test for desugar warnings/errors with -fno-code

Add a new (expect_broken) test T10600 that checks that the error:
Top-level bindings for unlifted types aren't allowed: is thrown when
compiling with -fno-code. This test currently fails because modules
compiled with -fno-code aren't desugared. There are several other errors
which can be thrown during desugaring that aren't tested for,
discoverable by grepping for "errDs".

Update .stderr files T8101 and T8101b. Presumably the compilation output
has changed slightly since they were written.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #10600, #8101

Differential Revision: https://phabricator.haskell.org/D3533
Note: See TracTickets for help on using tickets.