Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#10520 closed bug (fixed)

RecordWildCards causes “is not a (visible) field of constructor” in ghci

Reported by: ion1 Owned by:
Priority: normal Milestone: 8.0.1
Component: GHCi Version: 7.10.1
Keywords: RecordWildCards Cc: hvr
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


% ghc -ignore-dot-ghci -e 'data Foo = Bar { baz :: Integer } deriving Show' -e 'Bar 42' -e '(Bar 42){ baz = 43 }' -e 'Bar { baz = 42 }'
Bar {baz = 42}
Bar {baz = 43}
Bar {baz = 42}
% ghc -ignore-dot-ghci -XRecordWildCards -e 'data Foo = Bar { baz :: Integer } deriving Show' -e 'Bar 42' -e '(Bar 42){ baz = 43 }' -e 'Bar { baz = 42 }'
Bar {baz = 42}
Bar {baz = 43}

    ‘baz’ is not a (visible) field of constructor ‘Bar’
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.1

Change History (5)

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

In a3f6239d905ad4b8fb597f43bd4ef9947c83362f/ghc:

GHCi: fix scoping for record selectors

This fixes Trac #10520.  See the "Ugh" note about
record selectors in HscTypes.icExtendGblRdrEnv.

comment:2 Changed 5 years ago by simonpj

Milestone: 7.10.3
Status: newmerge

Thanks for the report. Hopefully can merge into 7.10.3

comment:3 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed

I'm afraid this isn't entirely trivial to backport as it requires 9b73cb16485f331d9dc1f37826c6d503e24a5b0b which is a rather major rework.

comment:4 Changed 4 years ago by bgamari


comment:5 Changed 4 years ago by Ben Gamari <ben@…>

In cd85dc84/ghc:

Make sure record pattern synonym selectors are in scope in GHCi.

Beforehand, when a record pattern synonym was defined in GHCi
the selectors would not be in scope. This is because of `is_sub_bndr`
in `HscTypes.icExtendGblRdrEnv` was throwing away the selectors.

This was broken by the fix to #10520 but it is easy to resolve.

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11985
Note: See TracTickets for help on using tickets.