-
Notifications
You must be signed in to change notification settings - Fork 13
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
Evaluating commands fails after #168 #171
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45ec922
to
2a439ac
Compare
c5bdf99
to
83107eb
Compare
9999years
commented
Dec 4, 2023
// We use `:add *{module}` to force interpreting the module. We do this here instead of in | ||
// `add_module` to save time if eval commands aren't used (or aren't needed for a | ||
// particular module). | ||
self.interpret_module(&path, log).await?; |
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.
Here's the actual bugfix, making sure the modules are interpreted and using the module path (instead of the module name) to import them.
parsonsmatt
approved these changes
Dec 5, 2023
This was referenced Apr 10, 2024
9999years
added a commit
that referenced
this pull request
Apr 15, 2024
Our favorite bug is back! We have a situation where `ghciwatch` loads all the modules at the start of the session, so they're all loaded: ``` ghci> :show targets Foo Bar Baz ``` Then, an eval command in (for example) module `Foo` is executed. To start with, the module is added and explicitly interpreted: ``` ghci> :add *src/Foo.hs ``` Unfortunately, this always uses the module path (see [#171](#171)), so if `ghciwatch` wasn't the one to load the module (e.g. it was loaded at the start of the session), the module path and module name will conflict and lead tot he dreaded "module is defined in multiple files". See: [https://gitlab.haskell.org/ghc/ghc/-/issues/13254#note_525037](https://gitlab.haskell.org/ghc/ghc/-/issues/13254#note_525037) # Solution I think we can fix this by keeping track of how each module is added to the session — as a path or as a module name — and then only using that form going forward.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#168 introduced another bug with eval commands. The actual bugfix here is relatively small, but I needed some architectural changes in the test harness (to support restarting the
ghciwatch
session) and in theghciwatch
codebase to make these changes.Mode
s introduced in Run tests on save #11 and gutted in Make--errors
output compatible withghcid
#78. This groupedghci
output into buffers based on the "mode"ghciwatch
was in when the output was produced (modules being compiled, tests being run, internal data being gathered, etc.). Over time this was used less and less. Now we parse diagnostics out of all compiler output and it's fine.Ghci::process_ghc_messages
method introduced in Fix "module defined in multiple files" by parsing GHC diagnostics #77. The idea was that methods likeStdout::prompt
would return a list of parsed GHC messages/diagnostics, and those would be processed byGhci
. In practice, it was difficult to remember to pass the lists of messages toprocess_ghc_messages
consistently. Now, each method that produces diagnostics takes a&mut CompilationLog
. There's many places where messages are produced, but only a few where messages need to be written out (after reloads, after startup), so this is a lot more convenient.Bug reproduction details
There's two bugs here:
module '...' is not interpreted
andmodule '...' defined in multiple files
. My attempted fix for the first bug in #168 caused the second bug. This PR fixes both.First, you load a
ghci
session:This interprets each module. When the GHC option
-fwrite-if-simplified-core
(introduced in GHC 9.4) is used, loading theghci
session additionally writes interface files for each module:Then, you can load a new
ghci
session, which will load the interface modules and use them to generateghci
byte-code directly. Critically, this means that the modules are not considered to be "interpreted", leading to this error message:How
ghciwatch
triggers the bugWhen
ghciwatch
's--enable-eval
flag is used, an eval commandrunMyCommand
for a moduleMyModule
is executed roughly like this::module + *MyModule
brings the top-level definitions ofMyModule
into scope, so that eval commands can refer to definitions in the module they're defined in.@parsonsmatt noticed that if
ghci
loaded a module from one of these interface files, evaluating commands in that file would fail:I initially attempted to fix this in #168, which added an explicit
:add *Foo
before running the eval command, which forces the module to be interpreted.Unfortunately, using the module name instead of the module path could lead to the module being added twice, causing the dreaded
module defined in multiple files
bug (see #37, #77, #125).