
#11547: Accessing shadowed definitions in GHCi -------------------------------------+------------------------------------- Reporter: mniip | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1-rc1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Apparently GHCi creates a qualified namespace for each line it interprets, as can be observed with: {{{#!hs
data A = A data A = B :t A A :: Ghci3.A }}} Apparently accessing shadowed definitions in this way sometimes breaks GHCi: {{{#!hs let a = a let a = a :t Ghci7.a
<interactive>:1:1: error: • GHC internal error: ‘Ghci7.a’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [] • In the expression: Ghci7.a }}} More specifically, complete reproduction instructions: {{{#!hs GHCi, version 8.1.20160205: http://www.haskell.org/ghc/ :? for help
let foo = foo :t Ghci1.foo Ghci1.foo :: t let foo = foo :t Ghci1.foo
<interactive>:1:1: error: • GHC internal error: ‘Ghci1.foo’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [] • In the expression: Ghci1.foo }}} 7.10.2 (and 7.8.3 as verified over IRC by monochrom) appears to have a slightly different behavior. It seems it only creates namespaces for data/newtype/class declarations. Yet still, it fails with an error the first time but works completely fine thereafter: {{{#!hs
data A = A data A = A :t Ghci1.A Failed to load interface for ‘Ghci1’ no package key matching ‘interactive’ was found :t Ghci1.A Ghci1.A :: Ghci1.A }}}
7.6.3 uses a different approach to displaying out of scope names so the behavior doesn't apply: {{{#!hs
data A = A data A = B :t A A :: main::Interactive.A }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11547 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler