[commit: ghc] master: Refactor wild card renaming (058af6c)

git at git.haskell.org git at git.haskell.org
Tue Jun 9 05:10:22 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/058af6c90a0e8d122f2d1339b6b4fd0b5ec83d05/ghc

>---------------------------------------------------------------

commit 058af6c90a0e8d122f2d1339b6b4fd0b5ec83d05
Author: Thomas Winant <thomas.winant at cs.kuleuven.be>
Date:   Mon Jun 8 23:45:48 2015 -0500

    Refactor wild card renaming
    
    Summary:
    Refactor wild card error reporting
    
    * Merge `HsWildcardTy` and `HsNamedWildcardTy` into one constructor
      `HsWildCardTy` with as field the new type `HsWildCardInfo`, which has two
      constructors: `AnonWildCard` and `NamedWildCard`.
    
    * All partial type checks are removed from `RdrHsSyn.hs` and are now done
      during renaming in order to report better error messages. When wild cards
      are allowed in a type, the new function `rnLHsTypeWithWildCards` (or
      `rnHsSigTypeWithWildCards`) should be used. This will bring the named wild
      cards into scope before renaming them. When this is not done, renaming will
      trigger "Unexpected wild card..." errors.
    
      Unfortunately, this has to be done separately for anonymous wild cards
      because they are given a fresh name during renaming, so they will not cause
      an out-of-scope error. They are handled in `tc_hs_type`, as a special case
      of a lookup that fails.
    
      The previous opt-out approach is replaced with an opt-in approach. No more
      panics because of forgotten checks!
    
    * `[t| _ |]` isn't caught by the above two checks, so it is currently handled
      by a special case. The error message (generated in the `DsM` monad) doesn't
      provide as much context information as the other cases.
    
    * Instead of three (!) functions that walk `HsType`, there is now only one
      pure function called `collectWildCards`.
    
    * Alternative approach: catch all unwanted wild cards in `rnHsTyKi` by looking
      at the `HsDocContext`. This will reduce the number of places to catch
      unwanted wild cards form three to one, and make the error messages more
      uniform, albeit less informative, as the error context for renaming is not
      as informative as the one for type checking. A new constructor of
      `HsDocContext` will be required for pattern synonyms signatures.
    
      Small problem: currently type-class type signatures can't be distinguished
      from type signatures using the `HsDocContext`.
    
    This requires an update to the Haddock submodule.
    
    Test Plan: validate
    
    Reviewers: goldfire, simonpj, austin
    
    Reviewed By: simonpj
    
    Subscribers: bgamari, thomie, goldfire
    
    Differential Revision: https://phabricator.haskell.org/D613
    
    GHC Trac Issues: #10098


>---------------------------------------------------------------

058af6c90a0e8d122f2d1339b6b4fd0b5ec83d05
 compiler/deSugar/DsMeta.hs                         |   5 +
 compiler/hsSyn/HsTypes.hs                          |  77 ++++--
 compiler/hsSyn/PlaceHolder.hs                      |   1 +
 compiler/parser/Parser.y                           |  35 +--
 compiler/parser/RdrHsSyn.hs                        | 274 +--------------------
 compiler/rename/RnBinds.hs                         |  16 +-
 compiler/rename/RnExpr.hs                          |  10 +-
 compiler/rename/RnTypes.hs                         | 255 +++++++++++++------
 compiler/typecheck/TcEnv.hs                        |   7 +
 compiler/typecheck/TcHsType.hs                     |   9 +-
 compiler/typecheck/TcRnDriver.hs                   |   5 +-
 compiler/typecheck/TcRnMonad.hs                    |   3 +
 .../ExtraConstraintsWildcardNotLast.stderr         |   6 +-
 .../should_fail/ExtraConstraintsWildcardTwice.hs   |   5 +
 .../ExtraConstraintsWildcardTwice.stderr           |   5 +
 .../NamedExtraConstraintsWildcard.stderr           |   6 +-
 .../should_fail/NamedWildcardsNotInMonotype.stderr |   8 +-
 .../NestedExtraConstraintsWildcard.stderr          |   8 +-
 .../NestedNamedExtraConstraintsWildcard.stderr     |   6 +-
 .../should_fail/PartialClassMethodSignature.hs     |   2 +-
 .../should_fail/PartialClassMethodSignature.stderr |   6 +-
 .../should_fail/PartialClassMethodSignature2.hs    |   5 +
 .../PartialClassMethodSignature2.stderr            |   5 +
 .../should_fail/UnnamedConstraintWildcard1.stderr  |   6 +-
 .../should_fail/UnnamedConstraintWildcard2.stderr  |   6 +-
 .../partial-sigs/should_fail/WildcardInADT1.stderr |   6 +-
 .../partial-sigs/should_fail/WildcardInADT2.stderr |   6 +-
 .../partial-sigs/should_fail/WildcardInADT3.stderr |   6 +-
 .../should_fail/WildcardInADTContext1.stderr       |   4 +-
 .../should_fail/WildcardInADTContext2.stderr       |   4 +-
 .../should_fail/WildcardInDefault.stderr           |   5 +-
 .../should_fail/WildcardInDefaultSignature.hs      |   5 +-
 .../should_fail/WildcardInDefaultSignature.stderr  |   7 +-
 .../should_fail/WildcardInDeriving.stderr          |   4 +-
 .../should_fail/WildcardInForeignExport.stderr     |   7 +-
 .../should_fail/WildcardInForeignImport.stderr     |   7 +-
 .../should_fail/WildcardInGADT1.stderr             |   6 +-
 .../should_fail/WildcardInGADT2.stderr             |   5 +-
 .../should_fail/WildcardInInstanceHead.stderr      |   4 +-
 .../should_fail/WildcardInInstanceSig.stderr       |   5 +-
 .../should_fail/WildcardInNewtype.stderr           |   6 +-
 .../should_fail/WildcardInPatSynSig.stderr         |   5 +-
 .../WildcardInStandaloneDeriving.stderr            |   4 +-
 .../should_fail/WildcardInTypeBrackets.stderr      |   4 +-
 .../WildcardInTypeFamilyInstanceLHS.stderr         |   6 +-
 .../WildcardInTypeFamilyInstanceRHS.stderr         |   6 +-
 .../should_fail/WildcardInTypeSynonymRHS.stderr    |   5 +-
 testsuite/tests/partial-sigs/should_fail/all.T     |   2 +
 utils/haddock                                      |   2 +-
 49 files changed, 396 insertions(+), 496 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 058af6c90a0e8d122f2d1339b6b4fd0b5ec83d05


More information about the ghc-commits mailing list