[GHC] #16261: [] interpreted as an overloaded list in rule LHS (was: Mysterious rule shadowing warning)
GHC
ghc-devs at haskell.org
Thu Jan 31 09:55:59 UTC 2019
#16261: [] interpreted as an overloaded list in rule LHS
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
error/warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Description changed by dfeuer:
Old description:
> Compiling `Data.Set.Internal` produces the following:
>
> {{{
> Data/Set/Internal.hs:958:11: warning: [-Winline-rule-shadowing]
> Rule "Set.toAscListBack" may never fire
> because rule "Class op fromListN" for ‘GHCExts.fromListN’ might
> fire first
> Probable fix: add phase [n] or [~n] to the competing rule
> |
> 958 | {-# RULES "Set.toAscListBack" [1] foldrFB (:) [] = toAscList #-}
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Data/Set/Internal.hs:960:11: warning: [-Winline-rule-shadowing]
> Rule "Set.toDescListBack" may never fire
> because rule "Class op fromListN" for ‘GHCExts.fromListN’ might
> fire first
> Probable fix: add phase [n] or [~n] to the competing rule
> |
> 960 | {-# RULES "Set.toDescListBack" [1] foldlFB (\xs x -> x : xs) [] =
> toDescList #-}
> |
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> }}}
>
> What the heck does the class op rule for `fromListN` have to do with
> anything anywhere near here? Note in particular that this module neither
> defines `fromListN` (it takes its default definition) nor uses it in code
> or `RULES`.
New description:
Compiling `Data.Set.Internal` produces the following:
{{{
Data/Set/Internal.hs:958:11: warning: [-Winline-rule-shadowing]
Rule "Set.toAscListBack" may never fire
because rule "Class op fromListN" for ‘GHCExts.fromListN’ might fire
first
Probable fix: add phase [n] or [~n] to the competing rule
|
958 | {-# RULES "Set.toAscListBack" [1] foldrFB (:) [] = toAscList #-}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Data/Set/Internal.hs:960:11: warning: [-Winline-rule-shadowing]
Rule "Set.toDescListBack" may never fire
because rule "Class op fromListN" for ‘GHCExts.fromListN’ might fire
first
Probable fix: add phase [n] or [~n] to the competing rule
|
960 | {-# RULES "Set.toDescListBack" [1] foldlFB (\xs x -> x : xs) [] =
toDescList #-}
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}}}
As mpickering figured out, the trouble is that `[]` in the rule LHS is
being interpreted as an overloaded list. The module does ''not'' enable
`OverloadedLists`. Furthermore, even if it ''did'', I would argue that it
is ''never'' correct to put one in a rule LHS, so we should always
interpret `[]` as the empty list constructor in `RULES` left-hand sides.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16261#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list