Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#9973 closed bug (fixed)

Erroneous Redundant constraint warning

Reported by: alanz Owned by:
Priority: normal Milestone: 8.0.1
Component: Compiler Version: 7.11
Keywords: Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Using version 4425ab99d6410839fa7567950b0a4696b0a3d70f with D538 applied,

If the attached source file is loaded as is into ghci it generates the following warning for line 5, but otherwise loads fine

/home/alanz/mysrc/github/alanz/HaRe/Bug2.hs:5:18: Warning:
    Redundant constraint: SYB.Data t
    In the type signature for:
       duplicateDecl :: SYB.Data t =>
                        [GHC.LHsBind GHC.Name]
                        -> t -> GHC.Name -> GHC.Name -> IO [GHC.LHsBind GHC.Name]

If the constraint is commented out, it results in an error

/home/alanz/mysrc/github/alanz/HaRe/Bug2.hs:26:16:
    No instance for (SYB.Data t)
      arising from a use of ‘definingSigsNames’
    Possible fix:
      add (SYB.Data t) to the context of
        the type signature for:
        duplicateDecl :: [GHC.LHsBind GHC.Name]
                         -> t -> GHC.Name -> GHC.Name -> IO [GHC.LHsBind GHC.Name]
    In the expression: definingSigsNames [n] sigs
    In an equation for ‘typeSig’: typeSig = definingSigsNames [n] sigs
    In an equation for ‘duplicateDecl’:
        duplicateDecl decls sigs n newFunName
          = do { let sspan = ...;
                 newSpan <- case typeSig of {
                              [] -> return sspan
                              _ -> ... };
                 let rowOffset = ...;
                 .... }
          where
              typeSig = definingSigsNames [n] sigs
Failed, modules loaded: none.

This behaviour goes away if the following lines are commented out

     let rowOffset = case typeSig of
                        [] -> 2
                        _  -> 1

Attachments (1)

Bug2.hs (1.4 KB) - added by alanz 5 years ago.
Source to reproduce the problem

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by alanz

Attachment: Bug2.hs added

Source to reproduce the problem

comment:1 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In dd3e1dd7f8d81e2585a7d63c06c1a1501810fcaa/ghc:

Fix Trac #9973 (buglet in -fwarn-redundant-constraints)

comment:2 Changed 5 years ago by simonpj

Resolution: fixed
Status: newclosed

Excellent! Thank you for finding this.

Simon

comment:3 Changed 4 years ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.