You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only import inner scope for module we are stopped at.
At the start of a session we import the **exported** symbols of:
- Prelude
- loaded Debug View modules
- debugeee home units module
(we were importing their inner scope before).
During an eval, if stopped at a breakpoint, we also import
the inner scope of the breakpoint module.
Imports made by the user at the REPL are as before:
preserved across stops, only for exported symbols.
A package-qualified module import will be looked up directly in the exposed
583
582
packages, IGNORING the home units modules.
583
+
-- FIXME: PackageImport expects a PackageName, it only works with unit-ids with external packages by a quirk of the implementation, for home units though you can set your own package names and get around the problem.
584
584
585
585
This can lead to two scenarios:
586
586
@@ -623,10 +623,6 @@ cleanupInterp = do
623
623
sendMessage i Shutdown
624
624
pureInterpPending
625
625
626
-
--| WARNING: callback is not to be used from other threads.
627
-
withUnliftGhc:: ((Ghcb->IOb) ->IOa) ->Ghca
628
-
withUnliftGhc k = reifyGhc $\ s -> k (flip reflectGhc s)
Source level package qualified imports `import "foo" A` interpret "foo" as a package name.
389
+
390
+
When one manually builds a `RawPkgQual` for an `ImportDecl` one can get away with using a unit-id, but only for external (i.e. not home) units.
391
+
That it works does not seem entirely intended (see quoted snippet below), the code is in `renamePkgQual`: If a package qualifier is not found among packages it's looked up as an external unit. This is already in the code path for `OtherPkg` though, which is why Home Units are excluded.
392
+
```
393
+
| otherwise
394
+
-> OtherPkg (UnitId pkg_fs)
395
+
-- not really correct as pkg_fs is unlikely to be a valid unit-id but
396
+
-- we will report the failure later...
397
+
```
398
+
399
+
Home units will only be found if the qualifier matches their dflags' `thisPackageName`. However that's bugged because the lookup doesn't bother considering there can be multiple units in the same package (library, sublibraries and exe units), and just picks the first found, leading to an import error if e.g. the library unit is picked but the module was in the exe one.
400
+
Related GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/24227
401
+
402
+
Turns out that the package name of a home unit is pretty meaningless though, so we can update the dflags to replace it with anything that's actually unique so we can dodge the bug.
403
+
404
+
Another stumbling block is that the `IIDecl` mode of an `InteractiveImport` does not allow importing hidden modules, but again for home units we can alter the DynFlags so all modules are exposed.
405
+
406
+
See issue #288 for what can we do for users at the repl.
0 commit comments