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

#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

#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

#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: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#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: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1-beta1 Resolution: fixed | Keywords: | RebindableSyntax Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | rename/should_fail/T15607 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => rename/should_fail/T15607 * resolution: => fixed Comment: A plane journey gave me an opportunity to fix this. Thanks for reporting it! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15607#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC