Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#10668 closed bug (fixed)

Missing brackets in import hint with TypeOperators

Reported by: bjmprice Owned by: thomasw
Priority: normal Milestone: 7.10.3
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: T10668
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1093
Wiki Page:

Description

import Data.Type.Equality(Refl)

errors with

error:
    In module ‘Data.Type.Equality’:
      ‘Refl’ is a data constructor of ‘:~:’
    To import it use
      ‘import’ Data.Type.Equality( :~:( Refl ) )
    or
      ‘import’ Data.Type.Equality( :~:(..) )

But the code there does not parse, one needs

import Data.Type.Equality((:~:)(Refl))

instead (note the extra brackets!).

Change History (7)

comment:1 Changed 2 years ago by thomasw

Owner: set to thomasw

comment:2 Changed 2 years ago by thomasw

I have found the cause, I'll upload a diff on Phabricator.

comment:3 Changed 2 years ago by thomasw

Differential Rev(s): Phab:D1093

comment:4 Changed 2 years ago by Ben Gamari <ben@…>

In b5c94262/ghc:

Parenthesise TypeOperator in import hints

When a constructor was mistakenly imported directly instead of as a
constructor of a data type, a hint will be shown on how to correctly
import
it. Just like the constructor, the data type should be surrounded in
parentheses if it is an operator (TypeOperator in this case).

Instead of:

    error:
        In module ‘Data.Type.Equality’:
          ‘Refl’ is a data constructor of ‘:~:’
        To import it use
          ‘import’ Data.Type.Equality( :~:( Refl ) )
        or
          ‘import’ Data.Type.Equality( :~:(..) )

Print:

    error:
        In module ‘Data.Type.Equality’:
          ‘Refl’ is a data constructor of ‘(:~:)’
        To import it use
          ‘import’ Data.Type.Equality( (:~:)( Refl ) )
        or
          ‘import’ Data.Type.Equality( (:~:)(..) )

Test Plan: pass new test

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #10668

comment:5 Changed 2 years ago by thomasw

Test Case: T10668

comment:6 Changed 2 years ago by bgamari

Milestone: 7.10.3
Status: newmerge

comment:7 Changed 2 years ago by bgamari

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

Last edited 2 years ago by bgamari (previous) (diff)
Note: See TracTickets for help on using tickets.