
#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 Resolution: | Keywords: | RebindableSyntax Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by isovector: Old description:
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.
New description: 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 | }}} Notice that this error mentions `return` not being in scope, despite trying to call `pure`. This suggests to the user that there is some desugaring going on to transform pure into return (but there isn't!). 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#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler