[GHC] #12229: Narrow the scope of record wildcards notation slightly
GHC
ghc-devs at haskell.org
Fri Jun 24 10:24:23 UTC 2016
#12229: Narrow the scope of record wildcards notation slightly
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Interestingly, at least some of the things that are now rejected were ALSO
rejected before, in a different and more confusing way. Consider
{{{
module T12229 where
data T = MkT { x, pi :: Float }
f x = MkT { .. } -- 'pi' is not initialised, because
-- there is no local binding
}}}
Previously the record-wildcard expansion said "oh, there is one `pi` in
scope that isn't a record selector, so fine, let's expand it"; so we got
{{{
f x = MkT { x = x, pi = pi }
}}}
But THEN we got (from 7.10)
{{{
T12229 .hs:7:7:
Ambiguous occurrence ‘pi’
It could refer to either ‘T12229.pi’,
defined at T12229.hs:5:19
or ‘Prelude.pi’,
imported from ‘Prelude’ at T12229.hs:3:8-19
(and originally defined in ‘GHC.Float’)
}}}
which is stupid and confusing. With our new change we get
{{{
T12229.hs:7:7: warning: [-Wmissing-fields (in -Wdefault)]
Fields of ‘MkT’ not initialised: pi
In the expression: MkT {..}
In an equation for ‘f’: f x = MkT {..}
}}}
which is better.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12229#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list