-
Notifications
You must be signed in to change notification settings - Fork 99
Conversation
@@ -144,7 +144,7 @@ library | |||
Development.IDE.Plugin.CodeAction.RuleTypes | |||
Development.IDE.Plugin.Completions.Logic | |||
Development.IDE.Plugin.Completions.Types | |||
if impl(ghc > 8.7) || flag(ghc-lib) | |||
if (impl(ghc > 8.7) && impl(ghc < 8.10)) || flag(ghc-lib) |
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.
If this is correct, then why do we need the file in tree for 8.8 as well?
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 file contains the implementation of the mkHieFile
function. This function is present in GHC 8.10. And the implementation for GHC-8.8 is based on HIE files from GHC, where the implementation of this function for GHC 8.6 is based on ghcide
own reimplementation of HIE files. So there are 3 cases for this function.
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.
The version of mkHieFile
in GHC 8.8 was unsuitable for ghcide, so we inlined the implementation locally to fix it. After that, @mpickering yourself propagated the fix upstream, which is the reason it happily does not need to be inlined when building against GHC 8.10
EDIT: oh no, it looks like the fix didn't make it into 8.10, and we still need to use the local version. I guess that complicates things a bit ...
src/Development/IDE/GHC/HieAst.hs
Outdated
let tc_binds = tcg_binds ts | ||
(asts', arr) <- getCompressedAsts tc_binds rs | ||
let Just src_file = ml_hs_file $ ms_location ms | ||
src <- liftIO $ BS.readFile src_file |
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.
It is how the mkHieFile
function is implemented in GHC 8.10. This function is called only once in the whole codebase and empty string ""
is passed as an argument to it instead of src
. Maybe this was done for some performance/memory reasons, but I made the implementation consistent with GHC 8.10 to have fewer surprises.
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 implementation is unsuitable for ghcide where files opened in the editor live in a virtual file system, and was the reason that we had to inline this module and change the implementation of mkHieFile
. Please revert :)
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.
The point of copying this file is to remove this part of the implementation if I remember correctly.
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.
@pepeiborra Thanks for the detailed explanation. This change is reverted. The HieAst
module for ghc-8.8 has no changes now.
Thanks, @pepeiborra for the patch! I guess now the build is failing due to HLint warnings in the new file. |
CI for GHC 8.10 fails due to the test failure. The following test fails, don't know how to fix it:
|
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.
CI for GHC 8.10 fails due to the test failure. The following test fails, don't know how to fix it:
plugins: FAIL (1.49s) test/src/Development/IDE/Test.hs:39: Could not find (DsError,(8,14),"Variable not in scope: c") in List [Diagnostic {_range = Range {_start = Position {_line = 0, _character = 0}, _end = Position {_line = 0, _character = 0}}, _severity = Just DsError, _code = Nothing, _source = Just "typecheck", _message = "/tmp/extra-dir-78866602889079/Testing.hs:1:1: error:\n Bad interface file: /home/vsts/.stack/snapshots/x86_64-linux/0d09385e35771f64a4c4bf9b92b8b30fbc8ce487126f21b5edfae99a26a1d108/8.10.1/lib/x86_64-linux-ghc-8.10.1/ghc-typelits-knownnat-0.7.2-DCI9V85uoFeJnRWeFtLtpR/GHC/TypeLits/KnownNat.hi\n Something is amiss; requested module ghc-typelits-knownnat-0.7.2:GHC.TypeLits.KnownNat differs from name found in the interface file array-0.5.4.0:GHC.TypeLits.KnownNat (if these names look the same, try again with -dppr-debug)", _tags = Nothing, _relatedInformation = Nothing}]
I can repro this error locally with a ghc 8.10.1 build via Nix, which removes stack from the equation.
And reproducing what the test does in ghci doesn't show the error, so it's almost certainly not an issue in the related plugin and libraries.
src/Development/IDE/GHC/HieAst.hs
Outdated
let tc_binds = tcg_binds ts | ||
(asts', arr) <- getCompressedAsts tc_binds rs | ||
let Just src_file = ml_hs_file $ ms_location ms | ||
src <- liftIO $ BS.readFile src_file |
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 implementation is unsuitable for ghcide where files opened in the editor live in a virtual file system, and was the reason that we had to inline this module and change the implementation of mkHieFile
. Please revert :)
Following GHC's suggestion to use
|
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.
Thank you very much! The inlined hie implementation makes me a bit sad but I don’t see a better solution.
It looks like this conflicted with some other PRs merged recently so it needs rebasing. If you run into issues let me know and I’m happy to help!
Resolves #518
The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed
@cocreature Thanks for the heads up! I've rebased on the latest |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -1,8 +1,10 @@ | |||
-- Copyright (c) 2019 The DAML Authors. All rights reserved. | |||
-- SPDX-License-Identifier: Apache-2.0 | |||
|
|||
{-# LANGUAGE CPP #-} |
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.
Hlint is failing because we explicitly whitelist modules that are allowed to use CPP. You can just add this module to the list: https://github.com/digital-asset/ghcide/blob/9adb11125ed8c671e802405a272c5c34ec1df0d3/.hlint.yaml#L77
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.
Thanks! Should be fixed now.
Hm, the test failure still persists. I have to admit that I have no idea what is going wrong here 🤔 |
Only the Linux build of 8.10 fails. The windows build succeeds. Platform specific GHC bug? |
We don’t actually run tests on Windows at all atm. We just check that they compile. In the interest in moving this forward, how about we open an issue for the failing test and just disable it for 8.10 for now? This still seems like a clear improvement over the status quo so it would be a shame to block it on this. |
Resolves #518
The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed
Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
@pepeiborra Thanks for the fix! The build seems passing now 👍 |
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.
Looks great, thanks!
* [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * Plugin tests known broken in 8.10.1 (haskell/ghcide#556) * Bump up ghc-check version Co-authored-by: Pepe Iborra <pepeiborra@gmail.com> Co-authored-by: pepe iborra <pepeiborra@gmail.com>
* [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * Plugin tests known broken in 8.10.1 (haskell/ghcide#556) * Bump up ghc-check version Co-authored-by: Pepe Iborra <pepeiborra@gmail.com> Co-authored-by: pepe iborra <pepeiborra@gmail.com>
* [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * [haskell/ghcide#518] Build ghcide with GHC 8.10.1 Resolves haskell/ghcide#518 * Move CPP logic to the Compat module * Revert changes to mkHieFile * Add local fork of HieAst for 8.10.1 The fix for mkHieFile didn't make it into 8.10.1, so the override is still needed * Ignore hlint in src-ghc810/HieAst.hs * Whitelist CPP for Development.IDE.GHC.Orphans * Plugin tests known broken in 8.10.1 (haskell/ghcide#556) * Bump up ghc-check version Co-authored-by: Pepe Iborra <pepeiborra@gmail.com> Co-authored-by: pepe iborra <pepeiborra@gmail.com>
Resolves #518
I was able to implement a small patch that allows
ghcide
to build with GHC 8.10. A couple of tests are failing, though. Any feedback is appreciated!