Hannes Siebenhandl pushed to branch wip/fendor/26610 at Glasgow Haskell Compiler / GHC

Commits:

9 changed files:

Changes:

  • changelog.d/26610
    1
    +section: compiler
    
    2
    +synopsis: Fix instance resolution for shadowed modules
    
    3
    +description:
    
    4
    +  Instances imported from modules with the same module name as the importing module
    
    5
    +  were dropped accidentally since we didn't account for the unit id of the imported module.
    
    6
    +mrs:
    
    7
    +issues: #26610

  • compiler/GHC/Driver/Env.hs
    ... ... @@ -269,7 +269,8 @@ hugInstancesBelow hsc_env uid mnwib = do
    269 269
            hugSomeThingsBelowUs (\mod_info ->
    
    270 270
                                       let details = hm_details mod_info
    
    271 271
                                       -- Don't include instances for the current module
    
    272
    -                                  in if moduleName (mi_module (hm_iface mod_info)) == mn
    
    272
    +                                  in if    moduleUnitId (mi_module (hm_iface mod_info)) == uid
    
    273
    +                                        && moduleName (mi_module (hm_iface mod_info)) == mn
    
    273 274
                                            then []
    
    274 275
                                            else [(md_insts details, md_fam_insts details)])
    
    275 276
                               True -- Include -hi-boot
    

  • testsuite/tests/ghci/prog-mhu008/Makefile
    1
    +TOP=../../..
    
    2
    +include $(TOP)/mk/boilerplate.mk
    
    3
    +include $(TOP)/mk/test.mk

  • testsuite/tests/ghci/prog-mhu008/a/M.hs
    1
    +module M (T (..)) where
    
    2
    +
    
    3
    +newtype T = MkT Int
    
    4
    +  deriving (Eq, Ord)

  • testsuite/tests/ghci/prog-mhu008/all.T
    1
    +test('prog-mhu008',
    
    2
    +     [extra_files(['a/', 'b/', 'unitA', 'unitB']),
    
    3
    +     cmd_prefix('ghciWayFlags=' + config.ghci_way_flags),
    
    4
    +     req_interp],
    
    5
    +     ghci_multiunit_script, [['unitA', 'unitB'], 'prog-mhu008.script'])

  • testsuite/tests/ghci/prog-mhu008/b/M.hs
    1
    +{-# LANGUAGE PackageImports #-}
    
    2
    +
    
    3
    +module M
    
    4
    +  ( module Export
    
    5
    +  , cmp
    
    6
    +  ) where
    
    7
    +
    
    8
    +import "a" M as Export
    
    9
    +
    
    10
    +cmp :: T -> T -> Bool
    
    11
    +cmp x y = x <= y

  • testsuite/tests/ghci/prog-mhu008/prog-mhu008.script
    1
    +:set -XPackageImports
    
    2
    +import "a" M qualified as MA
    
    3
    +import "b" M qualified as MB
    
    4
    +
    
    5
    +MB.cmp (MA.T 1) (MA.T 2)

  • testsuite/tests/ghci/prog-mhu008/unitA
    1
    +-this-unit-id a-0-inplace
    
    2
    +-this-package-name a
    
    3
    +-i
    
    4
    +-ia/src
    
    5
    +M

  • testsuite/tests/ghci/prog-mhu008/unitB
    1
    +-this-unit-id b-0-inplace
    
    2
    +-this-package-name b
    
    3
    +-package-id a-0-inplace
    
    4
    +-i
    
    5
    +-ib/src
    
    6
    +M