diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-12-26 19:47:04 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-01-25 05:21:40 -0500 |
commit | c3fde723633d1788e4ded8c6f59eb7cef1ae95fd (patch) | |
tree | 60f6c00540541449b7aada6765048de49af9f371 /compiler/GHC/Rename | |
parent | 86966d48954db4a8bd40046af259ed60aed535eb (diff) | |
download | haskell-c3fde723633d1788e4ded8c6f59eb7cef1ae95fd.tar.gz |
Handle local fixity declarations in DsMeta properly
`DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the
effect of causing local fixity declarations to be dropped when quoted
in Template Haskell. But there is no good reason for this state of
affairs, as the code in `DsMeta.repFixD` (which handles top-level
fixity declarations) handles local fixity declarations just fine.
This patch factors out the necessary parts of `repFixD` so that they
can be used in `rep_sig` as well.
There was one minor complication: the fixity signatures for class
methods in each `HsGroup` were stored both in `FixSig`s _and_ the
list of `LFixitySig`s for top-level fixity signatures, so I needed
to take action to prevent fixity signatures for class methods being
converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting
these fixity signatures in two places and added
`Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls`
to explain the new design.
Fixes #17608. Bumps the Haddock submodule.
Diffstat (limited to 'compiler/GHC/Rename')
-rw-r--r-- | compiler/GHC/Rename/Source.hs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/compiler/GHC/Rename/Source.hs b/compiler/GHC/Rename/Source.hs index 6796aa6b41..f36a556224 100644 --- a/compiler/GHC/Rename/Source.hs +++ b/compiler/GHC/Rename/Source.hs @@ -104,10 +104,10 @@ rnSrcDecls group@(HsGroup { hs_valds = val_decls, hs_ruleds = rule_decls, hs_docs = docs }) = do { - -- (A) Process the fixity declarations, creating a mapping from - -- FastStrings to FixItems. - -- Also checks for duplicates. - local_fix_env <- makeMiniFixityEnv fix_decls ; + -- (A) Process the top-level fixity declarations, creating a mapping from + -- FastStrings to FixItems. Also checks for duplicates. + -- See Note [Top-level fixity signatures in an HsGroup] in GHC.Hs.Decls + local_fix_env <- makeMiniFixityEnv $ hsGroupTopLevelFixitySigs group ; -- (B) Bring top level binders (and their fixities) into scope, -- *except* for the value bindings, which get done in step (D) @@ -2301,13 +2301,8 @@ add gp loc (SpliceD _ splice@(SpliceDecl _ _ flag)) ds -- relevant to the larger base of users. -- See #12146 for discussion. --- Class declarations: pull out the fixity signatures to the top -add gp@(HsGroup {hs_tyclds = ts, hs_fixds = fs}) l (TyClD _ d) ds - | isClassDecl d - = let fsigs = [ L l f - | L l (FixSig _ f) <- tcdSigs d ] in - addl (gp { hs_tyclds = add_tycld (L l d) ts, hs_fixds = fsigs ++ fs}) ds - | otherwise +-- Class declarations: added to the TyClGroup +add gp@(HsGroup {hs_tyclds = ts}) l (TyClD _ d) ds = addl (gp { hs_tyclds = add_tycld (L l d) ts }) ds -- Signatures: fixity sigs go a different place than all others |