Hannes Siebenhandl pushed to branch wip/fendor/has-field-hie at Glasgow Haskell Compiler / GHC Commits: 8926227e by fendor at 2026-09-16T11:43:40+02:00 Type of the whole record dot syntax is still recorded - - - - - 3 changed files: - compiler/GHC/Iface/Ext/Utils.hs - testsuite/tests/hiefile/should_run/RecordDotTypes.hs - testsuite/tests/hiefile/should_run/RecordDotTypes.stdout Changes: ===================================== compiler/GHC/Iface/Ext/Utils.hs ===================================== @@ -82,15 +82,19 @@ resolveVisibility kind ty_args foldType :: (HieType a -> a) -> HieTypeFix -> a foldType f (Roll t) = f $ fmap (foldType f) t -selectPoint :: HieFile -> (Int,Int) -> Maybe (HieAST Int) -selectPoint hf (sl,sc) = getFirst $ +selectPoint :: HieFile -> (Int,Int) -> Maybe (HieAST TypeIndex) +selectPoint hf p = selectRange hf p p + +selectRange :: HieFile -> (Int,Int) -> (Int,Int) -> Maybe (HieAST TypeIndex) +selectRange hf (sl,sc) (el, ec) = getFirst $ flip foldMap (M.toList (getAsts $ hie_asts hf)) $ \(HiePath fs,ast) -> First $ case selectSmallestContaining (sp fs) ast of Nothing -> Nothing Just ast' -> Just ast' where sloc fs = mkRealSrcLoc fs sl sc - sp fs = mkRealSrcSpan (sloc fs) (sloc fs) + eloc fs = mkRealSrcLoc fs el ec + sp fs = mkRealSrcSpan (sloc fs) (eloc fs) findEvidenceUse :: NodeIdentifiers a -> [Name] findEvidenceUse ni = [n | (Right n, dets) <- xs, any isEvidenceUse (identInfo dets)] ===================================== testsuite/tests/hiefile/should_run/RecordDotTypes.hs ===================================== @@ -22,6 +22,11 @@ x = MyRecord { a = "Hello", b = 12, c = MyChild { z = "there" } } y = x.a ++ show x.b ++ x.c.z -- ^ ^ ^ ^^ -- 1 2 3 45 +-- ^-^ ^-^ ^-^ +-- 6 7 8 +-- ^---^ +-- 9 + p1,p2,p3,p4 :: (Int,Int) p1 = (22,6) @@ -30,10 +35,19 @@ p3 = (22,25) p4 = (22,28) p5 = (22,29) +r6 = (p1, (22, 8)) +r7 = ((22,17), p2) +r8 = (p3, (22, 27)) +r9 = (p3, p5) + selectPoint' :: HieFile -> (Int,Int) -> HieAST Int selectPoint' hf loc = maybe (error "point not found") id $ selectPoint hf loc +selectRange' :: HieFile -> ((Int,Int), (Int, Int)) -> HieAST Int +selectRange' hf (s, e) = + maybe (error "range not found") id $ selectRange hf s e + main = do (df, hf) <- readTestHie "RecordDotTypes.hie" forM_ [p1,p2,p3,p4,p5] $ \point -> do @@ -41,3 +55,11 @@ main = do let types = concatMap nodeType $ getSourcedNodeInfo $ sourcedNodeInfo $ selectPoint' hf point forM_ types $ \typ -> do putStrLn (renderHieType df $ recoverFullType typ (hie_types hf)) + + forM_ [r6, r7, r8, r9] $ \range -> do + putStr $ "At " ++ showRange range ++ ", got type: " + let types = concatMap nodeType $ getSourcedNodeInfo $ sourcedNodeInfo $ selectRange' hf range + forM_ types $ \typ -> do + putStrLn (renderHieType df $ recoverFullType typ (hie_types hf)) + where + showRange (p1, p2) = show p1 ++ " - " ++ show p2 ===================================== testsuite/tests/hiefile/should_run/RecordDotTypes.stdout ===================================== @@ -3,3 +3,7 @@ At (22,20), got type: MyRecord -> Integer At (22,25), got type: MyRecord At (22,28), got type: MyChild -> [Char] At (22,29), got type: MyChild -> [Char] +At (22,6) - (22,8), got type: [Char] +At (22,17) - (22,20), got type: Integer +At (22,25) - (22,27), got type: MyChild +At (22,25) - (22,29), got type: [Char] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8926227e75bdaeaf3f2a649f2d1edf6a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8926227e75bdaeaf3f2a649f2d1edf6a... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Hannes Siebenhandl (@fendor)