Opened 3 years ago

Closed 3 years ago

#10354 closed bug (fixed)

ApiAnnotations : parens around a context with wildcard 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: #10315,#10354 Differential Rev(s): Phab:D868
Wiki Page:

Description

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

Change History (9)

comment:1 Changed 3 years ago by alanz

It seems RdrHsSyn.checkContext is the culprit

...
  check (HsParTy ty)    -- to be sure HsParTy doesn't get into the way
    = check (unLoc ty)
...

comment:2 Changed 3 years ago by alanz

Milestone: 7.10.2

comment:3 Changed 3 years ago by alanz

Differential Rev(s): Phab:D868

comment:4 Changed 3 years ago by alanz

Differential Rev(s): Phab:D868Phab:D868,Phab:D836

Fixing the HsForAllTy properly sorts out a number of issues.

comment:5 Changed 3 years ago by alanz

Differential Rev(s): Phab:D868,Phab:D836Phab:D868

Phab:D868 is required to be able to handle nested parens in a tuple context.

comment:6 Changed 3 years ago by alanz

Status: newpatch

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

In c553e980e4a5d149af13bb705ec02819a15937ee/ghc:

ApiAnnotations : AST version of nested forall loses forall annotation

Summary:
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
process.

Test Plan: ./validate

Reviewers: goldfire, austin, simonpj

Reviewed By: simonpj

Subscribers: bgamari, mpickering, thomie, goldfire

Differential Revision: https://phabricator.haskell.org/D836

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

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

In 0df14b5db06751f817d3ba794cc74ac54519b5b8/ghc:

ApiAnnotations : parens around a context with wildcard loses annotations

Summary:
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: https://phabricator.haskell.org/D868

GHC Trac Issues: #10354, #10315

comment:9 Changed 3 years ago by thoughtpolice

Resolution: fixed
Status: patchclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.