Skip to content

Minimal fix for eval regression #488

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

Merged
merged 3 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghcide
14 changes: 9 additions & 5 deletions plugins/default/src/Ide/Plugin/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ import Data.Bifunctor (Bifunctor (first))
import Data.Char (isSpace)
import qualified Data.HashMap.Strict as Map
import Data.List (find)
import Data.Maybe (catMaybes)
import Data.Maybe (fromMaybe, catMaybes)
import Data.String (IsString (fromString))
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time (getCurrentTime)
import Development.IDE
import Development.IDE.GHC.Compat (DynFlags, ExecResult (..), GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified),
import Development.IDE.GHC.Compat (DynFlags(importPaths), ExecResult (..),
GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified),
Ghc, GhcLink (LinkInMemory),
GhcMode (CompManager),
HscTarget (HscInterpreted),
Expand All @@ -61,10 +62,9 @@ import Development.IDE.GHC.Compat (DynFlags, ExecResult (..), GeneralF
setTargets, simpleImportDecl,
typeKind, ways)
import DynamicLoading (initializePlugins)
import DynFlags (targetPlatform)
import GHC.Generics (Generic)
import GhcMonad (modifySession)
import GhcPlugins (defaultLogActionHPutStrDoc,
import GhcPlugins (targetPlatform, defaultLogActionHPutStrDoc,
gopt_set, gopt_unset, interpWays,
updateWays, wayGeneralFlags,
wayUnsetGeneralFlags)
Expand Down Expand Up @@ -195,7 +195,11 @@ runEvalCmd lsp state EvalParams {..} = withIndefiniteProgress lsp "Eval" Cancell
hscEnv' <- ExceptT $
evalGhcEnv (hscEnv session) $ do
env <- getSession
-- Install the module pragmas and options
df <- liftIO $ setupDynFlagsForGHCiLike env $ ms_hspp_opts ms
-- Restore the cradle import paths
df <- return df{importPaths = fromMaybe (importPaths df) $ envImportPaths session}
-- Set the modified flags in the session
_lp <- setSessionDynFlags df

-- copy the package state to the interactive DynFlags
Expand Down Expand Up @@ -295,7 +299,7 @@ evalGhciLikeCmd cmd arg = do
df <- getSessionDynFlags
case lookup cmd ghciLikeCommands
<|> snd <$> find (T.isPrefixOf cmd . fst) ghciLikeCommands of
Just hndler ->
Just hndler ->
fmap
(T.unlines . map ("-- " <>) . T.lines
)
Expand Down
2 changes: 2 additions & 0 deletions test/functional/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ tests = testGroup
$ goldenTest "T24.hs"
, testCase ":kind treats a multilined result properly"
$ goldenTest "T25.hs"
, testCase "local imports"
$ goldenTest "T26.hs"
]

goldenTest :: FilePath -> IO ()
Expand Down
4 changes: 4 additions & 0 deletions test/testdata/eval/T26.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module T26 where
import T25 ()

-- >>> "hello"
5 changes: 5 additions & 0 deletions test/testdata/eval/T26.hs.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module T26 where
import T25 ()

-- >>> "hello"
-- "hello"
30 changes: 29 additions & 1 deletion test/testdata/eval/hie.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
cradle: {direct: {arguments: ["T1", "T2", "T3", "T4"]}}
cradle:
direct:
arguments:
- "T1"
- "T2"
- "T3"
- "T4"
- "T5"
- "T6"
- "T7"
- "T8"
- "T9"
- "T10"
- "T11"
- "T12"
- "T13"
- "T14"
- "T15"
- "T16"
- "T17"
- "T18"
- "T19"
- "T20"
- "T21"
- "T22"
- "T23"
- "T24"
- "T25"
- "T26"