#11328 closed bug (fixed)

Auto complete in ghci shows $sel:function:Type for DuplicateRecordFields fields

Reported by: kolmodin Owned by: adamgundry
Priority: normal Milestone: 8.0.1
Component: GHCi Version: 8.0.1-rc1
Keywords: DuplicateRecordFields, ORF Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: ghci/should_run/T11328
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1870
Wiki Page:


Given a haskell file;

{-# LANGUAGE DuplicateRecordFields #-}
-- t.hs

data A = A { name :: String }
data B = B { name :: String }

and in GHCi;

ghci t.hs
GHCi, version 8.1.20151231: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( tnum.hs, interpreted )
Ok, modules loaded: Main.
*Main> <TAB> <TAB>

The records show up as $sel:function:Type, a function which you cannot refer to by name.

Even if you enable OverloadedLabels, the #labels don't show up in the auto completion.

Change History (7)

comment:1 Changed 19 months ago by hvr

I wonder if this is related to #11051

comment:2 in reply to:  1 Changed 18 months ago by thomie

Cc: adamgundry added
Keywords: DuplicateRecordFields added

Replying to hvr:

I wonder if this is related to #11051

That bug is fixed, but this one is still present.

comment:3 Changed 18 months ago by adamgundry

Keywords: ORF added
Owner: set to adamgundry

The $sel-prefixed things are the internal Names of record fields in modules for which DuplicateRecordFields is enabled. I tried to catch all the places where they might show up in user-facing output, but it's not at all surprising that I've missed some. I'll take a look.

comment:4 Changed 18 months ago by adamgundry

Component: CompilerGHCi
Differential Rev(s): Phab:D1870
Status: newpatch
Test Case: ghci/should_run/T11328

Fortunately this one was an easy fix. I noticed that generated names (e.g. beginning with $tc or $tr) were turning up in the autocomplete after defining datatypes interactively, so I fixed that too. It's a tiny patch, so maybe worth backporting to 8.0.1? But the bug is fairly obscure, so not a disaster if that's too much trouble.

Even if you enable OverloadedLabels, the #labels don't show up in the auto completion.

I've not changed this; I think it's the correct behaviour. A #label is not an identifier, it's a separate syntactic form, and there's no obvious basis for auto-completing it.

comment:5 Changed 18 months ago by Ben Gamari <ben@…>

In dd0b7c7/ghc:

Avoid mangled/derived names in GHCi autocomplete (fixes #11328)

This changes `getRdrNamesInScope` to use field labels rather than
selector names for fields from modules with `DuplicateRecordFields`
enabled. Moreover, it filters out derived names (e.g. type
representation bindings) that shouldn't show up in autocomplete.

Test Plan: New test ghci/should_run/T11328

Reviewers: kolmodin, austin, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #11328

comment:6 Changed 18 months ago by bgamari

Status: patchmerge

comment:7 Changed 18 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.