[GHC] #13631: In GHCi a result is wrong when -fdefer-typed-holes is used with underscore alone

GHC ghc-devs at haskell.org
Sun Apr 30 14:57:08 UTC 2017


#13631: In GHCi a result is wrong when -fdefer-typed-holes is used with underscore
alone
-------------------------------------+-------------------------------------
           Reporter:  vanto          |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Incorrect result
  Unknown/Multiple                   |  at runtime
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I open this ticket instead of {{{#13579}}} to restate it and I closed the
 other.\\
 In fact a result of the compiler which I think is wrong misled me.\\
 Therefore I close tickets {{{#13602}}} and {{{#13557}}}.\\
 In Haskell2010 Language Report it is said that :\\
 1. underscore "_ " all by itself is a reserved identifier.\\
 2. underscore "_" is treated as a lowercase letter, and can occur wherever
 a lowercase letter can.\\
 So {{{_e}}} is an identifier like {{{__}}}\\

 GHCi gives a bad result when he computed the code below.\\


 {{{
 Prelude> :set -fdefer-typed-holes
 Prelude> let f = map (\x -> True) [_, _]

 <interactive>:2:27: warning: [-Wtyped-holes]
     * Found hole: _ :: a0
       Where: `a0' is an ambiguous type variable
     * In the expression: _
       In the second argument of `map', namely `[_, _]'
       In the expression: map (\ x -> True) [_, _]
     * Relevant bindings include
         f :: [Bool] (bound at <interactive>:2:5)

 <interactive>:2:30: warning: [-Wtyped-holes]
     * Found hole: _ :: a0
       Where: `a0' is an ambiguous type variable
     * In the expression: _
       In the second argument of `map', namely `[_, _]'
       In the expression: map (\ x -> True) [_, _]
     * Relevant bindings include
         f :: [Bool] (bound at <interactive>:2:5)
 Prelude> f
 [True,True]
 }}}
 The underscore "_" is alone , all by itself and yet is recognized as an
 identifier, and GHCi gives a result.\\
 This is the bug.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13631>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list