Skip to content

Fix GHCi crashing on local Prelude

Max requested to merge ulidtko/ghc:fix/ghci-local-prelude into master

Hi, team. This patch fixes issue #10920.

I'm adding a corresponding test.

The fix is completely on the side of GHCi-the-program... modulo trivial "wibbles" about debug tracing within compiler.

I'm including a Note that mentions relevant signpost concepts.

Since GHCi had already been performing the home-unit filtering of imports (in setContextAfterLoad path, but not at startup) — the crux of the fix is essentially a single-line change in getImplicitPreludeImports.

To validate, I'd poked it interactively, wrote the new test, and had run hadrian/build test --test-root-dirs=testsuite/tests/ghci — all of it passes. I'll leave testing the rest to CI.

No breakage is expected, because it seems that GHCi had never worked in this condition: namely, with a project-local Prelude.hs module. (Merely empty file triggers the bug)

Git-wise, I'm pushing the branch raw, but will immediately rewrite it to make more sense and simplify review. I didn't arrive at the fix on the 1st try exactly! 😅 But for posterity, that's not important.

As a first-time contributor, I did check the guidelines — but of course, kindly point out gaps, I'll try my best to fill in. Thanks in advance!

  • ensure that your commits are either individually buildable or squashed
  • ensure that your commit messages describe what they do (referring to tickets using #NNNN syntax when appropriate)
  • have added source comments describing your change. For larger changes you likely should add a [Note][notes] and cross-reference it from the relevant places.
  • add a [testcase to the testsuite][adding test].
  • updates the users guide if applicable
  • mentions new features in the release notes for the next release
Edited by Max

Merge request reports