Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10315 closed bug (duplicate)

ApiAnnotations : Empty context loses annotations

Reported by: alanz Owned by: alanz
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.10.1
Keywords: ApiAnnotations Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #10354 Differential Rev(s): Phab:D836 Phab:D868
Wiki Page:


A type signature of the form

bar :: (   ) => a-> Bool

generates annotations for the ( ) => but the SrcSpan they are attached to is discarded so the annotations are not attached to the AST.

The discarding process happens in

mkHsForAllTy exp tvs (L _ []) ty = mk_forall_ty exp tvs ty

where the empty located context is discarded.

Change History (8)

comment:1 Changed 5 years ago by alanz

Differential Rev(s): Phab:855

comment:2 Changed 5 years ago by alanz

Status: newpatch

comment:3 Changed 5 years ago by alanz

comment:4 Changed 5 years ago by alanz

Differential Rev(s): Phab:855Phab:855,Phab:868
Owner: alanz deleted
Status: patchnew

comment:5 Changed 5 years ago by alanz

Owner: set to alanz

comment:6 Changed 5 years ago by alanz

Differential Rev(s): Phab:855,Phab:868Phab:D836 Phab:D868
Resolution: duplicate
Status: newclosed

comment:7 Changed 5 years ago by Alan Zimmerman <alan.zimm@…>

In c553e980e4a5d149af13bb705ec02819a15937ee/ghc:

ApiAnnotations : AST version of nested forall loses forall annotation

When parsing

    {-# LANGUAGE ScopedTypeVariables #-}

    extremumNewton :: forall tag. forall tag1.
                       tag -> tag1 -> Int
    extremumNewton = undefined

the parser creates nested HsForAllTy's for the two forall statements.

These get flattened into a single one in `HsTypes.mk_forall_ty`

This patch removes the flattening, so that API Annotations are not lost in the

Test Plan: ./validate

Reviewers: goldfire, austin, simonpj

Reviewed By: simonpj

Subscribers: bgamari, mpickering, thomie, goldfire

Differential Revision:

GHC Trac Issues: #10278, #10315, #10354, #10363

comment:8 Changed 5 years ago by Alan Zimmerman <alan.zimm@…>

In 0df14b5db06751f817d3ba794cc74ac54519b5b8/ghc:

ApiAnnotations : parens around a context with wildcard loses annotations

In the following code, the extra set of parens around the context end up
with detached annotations.

    {-# LANGUAGE PartialTypeSignatures #-}
    module ParensAroundContext where

    f :: ((Eq a, _)) => a -> a -> Bool
    f x y = x == y

Trac ticket #10354

It turns out it was the TupleTy that was the culprit.

This may also solve #10315

Test Plan: ./validate

Reviewers: hvr, austin, goldfire

Reviewed By: austin

Subscribers: goldfire, bgamari, thomie, mpickering

Differential Revision:

GHC Trac Issues: #10354, #10315
Note: See TracTickets for help on using tickets.