Skip to content

Add mainModuleNameIs and demote mainModIs

Thank you for your contribution to GHC!

Please take a few moments to verify that your commits fulfill the following:

  • are either individually buildable or squashed
  • have commit messages which describe what they do (referring to [Notes][notes] and 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.
  • replace this message with a description motivating your change

Motivation

When the module declaration for the main module is omitted, we default the unit-id to "main" and name is "Main". Even in the case we changed the unit-id via -this-unit-id. I don't see a reason why the main module should have a different unit-id than the other modules within a unit.

It also messes with !3950 (closed), since the unit-id "main" is not in the unit-env (e.g. not one of the declared home units) and then we can't find the Main module and everything crashes. So, I'd like to tackle this issue here, to make !3950 (closed) easier to merge.

The field mainModIs points to a wrong unit, in my opinion, in most cases. This changes how the unit-id of the main module is defined, by turning it into a property that emerges from "DynFlags".

Edited by Hannes Siebenhandl

Merge request reports