[GHC] #15607: RebindableSyntax warns `return` is not in scope when trying to call `pure`, but does not desugar between the two

GHC ghc-devs at haskell.org
Wed Sep 5 17:04:18 UTC 2018


#15607: RebindableSyntax warns `return` is not in scope when trying to call `pure`,
but does not desugar between the two
-------------------------------------+-------------------------------------
           Reporter:  isovector      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.6.1-beta1
           Keywords:                 |  Operating System:  Unknown/Multiple
  RebindableSyntax                   |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The following (incorrect) program fails to compile:

 {{{#!hs
 {-# LANGUAGE RebindableSyntax #-}

 import Prelude hiding (pure, return)

 t = do
   pure 5
 }}}

 {{{
     Not in scope: ‘return’
     Perhaps you want to remove ‘return’ from the explicit hiding list
     in the import of ‘Prelude’ (/home/sandy/Bug.hs:3:1-40).
   |
 6 |   pure 5
   |
 }}}

 Changing the import of Prelude to no longer hide `return` now gives the
 correct error:

 {{{#!hs
 import Prelude hiding (pure)
 }}}

 {{{
     • Variable not in scope: pure :: Integer -> t
     • Perhaps you want to remove ‘pure’ from the explicit hiding list
       in the import of ‘Prelude’ (/home/sandy/Bug.hs:3:1-28).
   |
 6 |   pure 5
   |   ^^^^
 }}}


 This is particularly confusing when `pure` is in scope and would typecheck
 but `return` is not. The error suggests that there is desugaring going on
 behind the scenes to turn `pure` into `return` via rebindable syntax.

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


More information about the ghc-tickets mailing list