Skip to content

Implicitly import Prelude in a module called Prelude (#22228)

Lawton Nichols requested to merge lawtonnichols/ghc:T22228 into master

Previously, the following program (T22228a) would not compile:

module Prelude where

foo = True

This was because the base Prelude was not implicitly imported when the module is also named Prelude.

To make the above program compile (and not recursively import itself), the parser now inserts import "base" Prelude whenever the module's name is Prelude, unless the user:

  1. explicitly imports base Prelude themselves, or
  2. explicitly does not import the base Prelude with NoImplicitPrelude.

To avoid confusion, the user should ideally do either (1) or (2) above—I've added a warning if the user does neither.

Fixes Prelude is not imported in a module called Prelude (#22228 - closed).

Merge request reports