Re: Where (else) do I need to register instances from loaded modules?

INTERNAL
Hi,
Thanks Matt! Unfortunately, I couldn't get it working even with these suggestions.
1. I changed registerModule so that it only changes the HPT when toUnitId (moduleUnit mod) == homeUnitId (hsc_dflags env). But I'm pretty sure this will be vacuously true, since the unit of the module comes from prepareModule setting the home unit before the call to `downsweep`.
TBH I don't understand the whole idea behind the home package, and maybe all my pain comes from misusing packages in the first place. As you can see in the original code I've sent, I'm loading modules from different units; in my real use case, I'd even like to do things like load module1 from unit1, then module2 from unit2, then module3 from unit1 again -- basically just using the units as a cheap way to classify modules so that later downstream, I can make decisions based on the unit of the module of the source of a given definition. Should I give up on this idea, is this going to lead to problems later on?
2. I also changed mkModIface to fill in the `deps` and while I'm at it, the `usages` field, by copy-pasting more code from mkIfaceTc. I'm really starting to think that I'd be better off just changing mkIfaceTc to return a PartialModIface... Anyway, the new definitions of `deps` and `usages` are:
let pluginModules = map lpModule (cachedPlugins (hsc_dflags hsc_env))
unit_id = homeUnitId (hsc_dflags hsc_env)
deps <- mkDependencies
unit_id (map mi_module pluginModules) tcg
dep_files <- readIORef dependent_files
let used_names = mkUsedNames tcg
usages <- mkUsageInfo hsc_env this_mod (imp_mods imports) used_names
dep_files merged pluginModules
With these changes applied, I am still seeing the same error. Printing shows that `dep_orphs deps` is empty for Instance.src; further tracing, in turn, shows that `imp_orphs . tcg_imports $ tcg` is also empty!
I have also found the wording in the documentation regarding dep_orphs confusing: it sounds like, in my case, this would mean that Use has a dependency on Instance, because it is using an orphan instance from there. But my problems are way before I am making a ModIface for Use, since it fails already during typechecking. But you saying the problem is the incomplete deps in ModIface must mean that dep_orphs needs to be filled in the ModIface for Instance (or, oh god I hope not, Class), right?
If I sound somewhat confused, rest assured that in reality I am even MORE confused!
Any further advice welcome,
Gergo
-----Original Message-----
From: Matthew Pickering

INTERNAL
Oops, forgot to attach the updated program
-----Original Message-----
From: Erdi, Gergo
Sent: Wednesday, August 25, 2021 10:37 AM
To: Matthew Pickering
participants (1)
-
Erdi, Gergo