google / ghc-source-gen

Library for generating Haskell source files and code fragments.
BSD 3-Clause "New" or "Revised" License
91 stars 29 forks source link

Build error with GHC 8.10.7 in ghc-source-gen-0.4.4.0 #109

Open cumber opened 9 months ago

cumber commented 9 months ago

When building with GHC 8.10.7, I get this error:

[10 of 25] Compiling GHC.SourceGen.Module ( src/GHC/SourceGen/Module.hs, dist/build/GHC/SourceGen/Module.o, dist/build/GHC/SourceGen/Module.dyn_o )

src/GHC/SourceGen/Module.hs:191:41: error:
    Variable not in scope: unqual :: OccNameStr -> RdrNameStr
    |
191 |                     (map (wrappedName . unqual) cs)
    |                                         ^^^^^^

This appears to have broken due to #103, which split

import GHC.SourceGen.Name
    ( RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr, unqual )

into

#if MIN_VERSION_ghc(9,0,0)
import GHC.SourceGen.Name (unqual)
#endif
#if MIN_VERSION_ghc(9,4,0)
import GHC.SourceGen.Name (RdrNameStr, ModuleNameStr(unModuleNameStr), OccNameStr)

However the usage of unqual at src/GHC/SourceGen/Module.hs:191 appears to be outside any #if, so I think GHC.SourceGen.Name needs to be imported unconditionally (at least unqual).

Or, if the intent was that GHC 9.0.0 is now the minimum supported version, the cabal file needs to be updated (and a revision pushed to Hackage) so that 0.4.4.0 isn't selected when building on older compilers.

blackgnezdo commented 9 months ago

@cumber if you push a fix (in the direction of your choice), I'm game to do a hackage release for 0.4.4.1.

blackgnezdo commented 9 months ago

FWIW, I don't feel like it makes too much sense to support 8.10 considering the last release in the series was over two years ago.

cumber commented 9 months ago

Yeah, I'd love to be using a more recent GHC. I'm using 8.10 for a few projects because the that's what the last version of GHCJS is. Since the effort behind GHCJS has moved to the JS target of GHC itself, it doesn't seem likely GHCJS will ever move from that. So that's what the Haskell-to-JS ecosystem is stuck with until the GHC JS compiler is polished enough for the major packages to migrate (and do the work of migration).

I would completely understand if you don't think it's worth maintaining 8.10 support; I'm perfectly happy sticking with the last version that supports it (so long as later releases are revised on Hackage to have correct lower bounds).

But there's a ton of stuff littered around the codebase that implies that 8.10 is supported; all the #if MIN_VERSION_ghc(9,0,0) makes no sense if no versions lower than that are intended to work, the main stack.yaml file names a Stackage resolver based on GHC 8.10.7, you've got a compat-8.10 folder, etc. I tried out my suggested change and it was enough to get 8.10.7 support working, so I just made a pull request for that since it would have been far more work to intentionally remove 8.10 support.

cumber commented 9 months ago

Thanks @blackgnezdo; I can confirm that building with the released 0.4.4.1 works in my GHC 8.10 projects. :+1: