Improve Error Reporting for Premature modDetail Access in HPT
Since HPT is now mutable (merge request #13675 (closed)), fixIO at initModDetails is no longer particularly useful. Moreover, premature access to modDetail (MDI) can result in an uninformative hang, as seen in issue #25858 (closed).
A better approach would be:
- Insert a placeholder into HPT that triggers a panic with a more informative error message.
- Construct MDI as usual.
- Replace the placeholder in HPT with the actual MDI.
With this approach, premature access will produce a clear error message instead of an uninformative hang, making it easier to trace and debug issues like #25858 (closed).
Proposed Change
Replace:
initModDetails hsc_env iface =
fixIO $ \details' -> do
add_iface_to_hpt iface details' hsc_env
genModDetails hsc_env iface
With:
initModDetails hsc_env iface = do
add_iface_to_hpt iface
(panic $ "initModDetails: premature access to ModDetail: "
++ moduleNameString (moduleName $ mi_module iface))
hsc_env
details <- genModDetails hsc_env iface
add_iface_to_hpt iface details hsc_env
return details