Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,410
    • Issues 5,410
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 604
    • Merge requests 604
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #23177
Closed
Open
Issue created Mar 24, 2023 by sheaf@sheafMaintainer

The icReaderEnv invariant is not being upheld

In GHCi, there's a special mechanism to recompute shadowing after importing a module. For example:

module M where { foo = False }

-- In ghci:
> foo = 3
> foo = 4
> import M
> foo
4
> Ghci1.foo
3

The implementation is described in Note [icReaderEnv recalculation]: we keep track of things defined at the prompt, so that they can shadow things that are imported. The Note states the following invariant:

INVARIANT: Every OccName in igre_prompt_env is present unqualified as well (else it would not be right to pass igre_prompt_env to shadowNames.)

This is because, in order to shadow imports, we only need to know the names defined in the prompt that are available unqualified.
However, currently, nothing is done to ensure that all names in igre_prompt_env are available unqualified. In particular, in the above example, Ghci1.foo will also be present in igre_prompt_env, even though it can't shadow anything anymore (as it has itself been shadowed).

This means we can potentially end up carrying around a much bigger igre_prompt_env than necessary. Test cases T14052 and T14052Type are affected.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking