-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for a GHC bug with -XTemplateHaskell and ghci (fixes #303) #312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already merged, but I anyway have 2 questions (see below).
@@ -55,13 +56,17 @@ withInterpreter flags action = do | |||
let | |||
args = flags ++ [ | |||
"--interactive" | |||
, xTemplateHaskell | |||
#if __GLASGOW_HASKELL__ >= 802 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the meaning of such an #if
? The #if
is evaluated when doctest
is compiled, and we use such #if
s all over the place to ensure compilation with different GHCs. But this #if
does not make to seem a difference on the compilation of doctest
, but when I run doctest
.
Could it be a problem when I run doctest
with a different GHC version than it was compiled with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doctest
uses both ghc
(the library) and ghc --interactive
(the executable). The former is used to extract Haddock comments, the later is used to check examples. If we would only depend on the executable, we could just use whatever ghc
is on the PATH
. But with ghc
the library we can only depend on one version (specifically, the version we compile doctest
with). For that reason we fix both, ghc
the library and ghc
the executable to the ghc
version we compile against at compile time. The library version is fixed simply by depending on it. To fix the executable version we use ghc-paths
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this makes sense if doctest
sits within a per-GHC buildtree.
(For some reason, I have doctest
in my PATH, but that does not make sense in such a scenario.)
Related GHC bug: https://gitlab.haskell.org/ghc/ghc/-/issues/20670