[GHC] #12509: ghci -XSafe fails in an inscrutable way

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Trying to run `ghci -XSafe` produces the following output: {{{ GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help <interactive>:1:6: error: Not in scope: ‘System.IO.hSetBuffering’ No module named ‘System.IO’ is imported. <interactive>:1:30: error: Not in scope: ‘System.IO.stdin’ No module named ‘System.IO’ is imported. <interactive>:1:46: error: Not in scope: data constructor ‘System.IO.NoBuffering’ No module named ‘System.IO’ is imported. <interactive>:1:70: error: Not in scope: ‘System.IO.hSetBuffering’ No module named ‘System.IO’ is imported. <interactive>:1:94: error: Not in scope: ‘System.IO.stdout’ No module named ‘System.IO’ is imported. <interactive>:1:111: error: Not in scope: data constructor ‘System.IO.NoBuffering’ No module named ‘System.IO’ is imported. <interactive>:1:135: error: Not in scope: ‘System.IO.hSetBuffering’ No module named ‘System.IO’ is imported. <interactive>:1:159: error: Not in scope: ‘System.IO.stderr’ No module named ‘System.IO’ is imported. <interactive>:1:176: error: Not in scope: data constructor ‘System.IO.NoBuffering’ No module named ‘System.IO’ is imported. }}} I'm not sure whether this should work, but in any case the error message is horrible. I tried adding `-trust base` to no avail. For comparison, ghc-7.10.3 starts with no trouble: {{{
ghci -XSafe GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help Prelude> }}}
(Motivation: I'm using ghci in Safe mode to track down import problems with SafeHaskell. As a workaround, I can use `:set -XSafe` after ghci's startup is done.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * cc: dterei (added) * keywords: => SafeHaskell -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: dterei Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dterei): * owner: => dterei Comment: Thanks for the report. This is definitely a bug, I'll take a look shortly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: dterei Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell 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 RolandSenn): @terei\\ Do you still plan to fix this? If yes, please go ahead; if no, I kindly ask you to unassign the ticket.\\ Many thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: dterei Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * cc: RolandSenn (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: dterei Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell 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 monoidal): Since the ticket had no activity for over 2 years, I think you can go ahead. I suspect that that this can be done using code similar to https://phabricator.haskell.org/D5452. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: dterei => RolandSenn -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell 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 RolandSenn): @monodial:
I suspect that that this can be done using code similar to https://phabricator.haskell.org/D5452
It's not quite simple as this. -XSafe is not a dynamic flag, and is not meant be be reset. Therefore a simple function similar to `gopt_set :: DynFlags -> GeneralFlag -> DynFlags` is not available to set `SafeHaskellMode` ! The return type of the function `setSafeHaskell :: SafeHaskellMode -> DynP ()` is more complicated to use, and I think, adding a new public function to the DynFlags module for this ticket is probably not the best idea. However, I have still some other ideas to solve this... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Gitlab Merge Wiki Page: | Request 21 -------------------------------------+------------------------------------- Changes (by RolandSenn): * testcase: => make test TEST=T12509 * status: new => patch * differential: => Gitlab Merge Request 21 * related: => #13385, #14342 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Gitlab Merge Wiki Page: | Request 23 -------------------------------------+------------------------------------- Changes (by int-e): * differential: Gitlab Merge Request 21 => Gitlab Merge Request 23 Comment: cf. https://gitlab.haskell.org/ghc/ghc/merge_requests/23 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Gitlab Merge Wiki Page: | Request 23 -------------------------------------+------------------------------------- Comment (by int-e): Following in RolandSenn's trail... `ghci` evaluates some code internally. One such piece of code comes from `ghc/GHCi/UI/Monad.hs`, `initInterpBuffering`, which evaluates `System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering` (and the same for `stdout` and `stderr`). This works fine without `-XSafe`, but with `-XSafe` there is a stricter check that requires `System.IO` to actually be imported: {{{ $ ghci GHCi, version 8.6.1: http://www.haskell.org/ghc/ :? for help Prelude> System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering Prelude> :set -XSafe Prelude> System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering <interactive>:3:1: error: Not in scope: ‘System.IO.hSetBuffering’ No module named ‘System.IO’ is imported. <interactive>:3:25: error: Not in scope: ‘System.IO.stdin’ No module named ‘System.IO’ is imported. <interactive>:3:41: error: Not in scope: data constructor ‘System.IO.NoBuffering’ No module named ‘System.IO’ is imported. Prelude> import System.IO Prelude System.IO> System.IO.hSetBuffering System.IO.stdin System.IO.NoBuffering Prelude System.IO> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/241 -------------------------------------+------------------------------------- Changes (by RolandSenn): * differential: Gitlab Merge Request 23 => https://gitlab.haskell.org/ghc/ghc/merge_requests/241 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/241 -------------------------------------+------------------------------------- Changes (by RolandSenn): * milestone: => 8.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12509: ghci -XSafe fails in an inscrutable way
-------------------------------------+-------------------------------------
Reporter: int-e | Owner: RolandSenn
Type: bug | Status: patch
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.0.1
Resolution: | Keywords: SafeHaskell
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: make test
| TEST=T12509
Blocked By: | Blocking:
Related Tickets: #13385, #14342 | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/241
-------------------------------------+-------------------------------------
Comment (by Marge Bot

#12509: ghci -XSafe fails in an inscrutable way -------------------------------------+------------------------------------- Reporter: int-e | Owner: RolandSenn Type: bug | Status: closed Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: SafeHaskell Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: make test | TEST=T12509 Blocked By: | Blocking: Related Tickets: #13385, #14342 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/241 -------------------------------------+------------------------------------- Changes (by RolandSenn): * status: patch => closed * resolution: => fixed Comment: [https://ghc.haskell.org/trac/ghc/ticket/12509#comment:13 Obviously] patch [https://gitlab.haskell.org/ghc/ghc/merge_requests/241 !241] got merged by Marge Bot! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12509#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC