Skip to content
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

[DUX-2341] Parse "Module not found" messages #296

Open
9999years opened this issue Jun 13, 2024 · 0 comments
Open

[DUX-2341] Parse "Module not found" messages #296

9999years opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
linear Created by Linear-GitHub Sync

Comments

@9999years
Copy link
Member

9999years commented Jun 13, 2024

This will help us keep the module set in sync more reliably

See:

ghciwatch/src/ghci/mod.rs

Lines 700 to 747 in a97ecd3

// TODO: This could lead to the module set getting out of sync with the underlying GHCi
// session.
//
// If there's a TOATOU bug here (e.g. we're attempting to add a module but the file no
// longer exists), then we can get into a situation like this:
//
// ghci> :add src/DoesntExist.hs src/MyLib.hs
// File src/DoesntExist.hs not found
// [4 of 4] Compiling MyLib ( src/MyLib.hs, interpreted )
// Ok, four modules loaded.
//
// ghci> :show targets
// src/MyLib.hs
// ...
//
// We've requested to load two modules, only one has been loaded, but GHCi has reported
// that compilation was successful and hasn't added the failing module to the target set.
// Note that if the file is found but compilation fails, the file _is_ added to the target
// set:
//
// ghci> :add src/MyCoolLib.hs
// [4 of 4] Compiling MyCoolLib ( src/MyCoolLib.hs, interpreted )
//
// src/MyCoolLib.hs:4:12: error:
// • Couldn't match expected type ‘IO ()’ with actual type ‘()’
// • In the expression: ()
// In an equation for ‘someFunc’: someFunc = ()
// |
// 4 | someFunc = ()
// | ^^
// Failed, three modules loaded.
//
// ghci> :show targets
// src/MyCoolLib.hs
// ...
//
// I think this is OK, because the only reason we need to know which modules are loaded is
// to avoid the "module defined in multiple files" bug [1], so the potential outcomes of
// making this mistake are:
//
// 1. The next time the file is modified, we attempt to `:add` it instead of `:reload`ing
// it. This is harmless, though it changes the order that `:show modules` prints output
// in (maybe local binding order as well or something).
// 2. The next time the file is modified, we attempt to `:add` it by path instead of by
// module name, but this function is only used when the modules aren't already in the
// target set, so we know the module doesn't need to be referred to by its module name.
//
// [1]: https://gitlab.haskell.org/ghc/ghc/-/issues/13254#note_525037

From SyncLinear.com | DUX-2341

@github-actions github-actions bot added the linear Created by Linear-GitHub Sync label Jun 13, 2024
@9999years 9999years self-assigned this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

1 participant