haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
362 stars 242 forks source link

Fix `ignore-exports` again on ghc-9.2 #1532

Closed nicuveo closed 1 year ago

nicuveo commented 1 year ago

Description

As part of the ghc-9.0 branch, a fix was introduced to keep the ignore-exports option working, but this fix was mistakenly dropped in later branches. Furthermore, the test introduced in #1082 to prevent regressions was also broken at a later point. This PR reintroduces the fix, fixes the old HTML test, and introduces a new hoogle test.

I'll open a similar PR targeting the ghc-9.4 branch. I don't know, however, how to ensure that this fixes also lands on main (or ghc-head?), and how to prevent the tests from just being ignored or "fixed" in the future.

Implementation

The fullModuleContents function iterates on all declarations of the module, but only keeps declarations for which it finds an AvailInfo, obtained from GHC's type-checker's output (see tcg_exports). However, that list only contains the AvailInfo information for declarations that are exported out of the module. To prevent non-exported declarations from being ignored when we actually request them, this PR takes the same approach as b93c6351afdfaf452ad9830a5f8536a353320a84 and crafts a simple AvailInfo for each declaration to be used in lieu of the raw tcg_exports list.

Steps to verify

See #1531 for a repro case.

Caveats

cabal test hypsrc-test fails on this branch, but also fails on the upstream, and is therefore not caused by this PR.