[Git][ghc/ghc][wip/T18389] Refactor RecCon case of tcConArgs
Ryan Scott
gitlab at gitlab.haskell.org
Mon Oct 26 10:26:00 UTC 2020
Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC
Commits:
d54ad263 by Ryan Scott at 2020-10-26T06:25:42-04:00
Refactor RecCon case of tcConArgs
- - - - -
1 changed file:
- compiler/GHC/Tc/TyCl.hs
Changes:
=====================================
compiler/GHC/Tc/TyCl.hs
=====================================
@@ -3416,13 +3416,15 @@ tcConArgs (InfixCon bty1 bty2)
tcConArgs (RecCon fields)
= mapM tcConArg btys
where
- -- We need a one-to-one mapping from field_names to btys
- combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f)))
- (unLoc fields)
- explode (ns,ty) = zip ns (repeat ty)
- exploded = concatMap explode combined
- (_,btys) = unzip exploded
-
+ -- We need to ensure that each distinct field name gets its own type.
+ -- For example, if we have:
+ --
+ -- data T = MkT { a,b,c :: Int }
+ --
+ -- Then we should return /three/ Int types, not just one!
+ btys = [ hsLinear (cd_fld_type f)
+ | L _ f <- unLoc fields
+ , _fld_name <- cd_fld_names f ]
tcConArg :: HsScaled GhcRn (LHsType GhcRn) -> TcM (Scaled TcType, HsSrcBang)
tcConArg (HsScaled w bty)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d54ad2638c07c65f013fa02be8eaf4083ce06f1e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d54ad2638c07c65f013fa02be8eaf4083ce06f1e
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201026/1d927447/attachment.html>
More information about the ghc-commits
mailing list