[GHC] #10663: ghci ignores stuff after an import command and a semicolon
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Keywords: newcomer | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC accepts Unknown/Multiple | invalid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- I can put a semicolon and then an expression or declaration after an import command in ghci, and the expression or declaration is simply ignored. {{{ rwbarton@morphism:~/ghc$ ghci-7.10.1 GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help Prelude> import Data.List; x Prelude Data.List> }}} The stuff after the semicolon does have to parse, but then is discarded. Pretty confusing. It's especially confusing when using `ghc -e` {{{ rwbarton@morphism:~/ghc$ ghc-7.10.1 -e "import Data.List; sort [2,1]" rwbarton@morphism:~/ghc$ echo $? 0 }}} The command is wrong (in general you cannot give multiple commands separated by semicolons, you must use multiple `-e` options), but GHC fails to complain in any way and silently ignores the "second command". -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by osa1): * cc: osa1 (added) Comment: I'm trying to understand expected syntax here. It seems like I can only put expressions after the first semicolon, other GHCi commands don't work: {{{ λ:6> import Data.List; x; x + y λ:7> import Data.List; import Data.Char <no location info>: parse error in import declaration λ:8> let x = 10 λ:9> x; x; x <interactive>:9:2: parse error on input ‘;’ λ:10> let y = 10; y <interactive>:10:14: parse error (possibly incorrect indentation or mismatched brackets) λ:11> import Data.Char; x λ:12> }}} Also, I can't see anything related with semicolons in user manual "Using GHCi" section(https://downloads.haskell.org/~ghc/latest/docs/html/users_guide /interactive-evaluation.html) so it seems to me like this semicolon behavior is not intended and just a side effect of the used parser. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Right, I think the expected behavior here (at least given the current behavior of ghci with respect to semicolons generally) is for `import Data.List; x` to be a syntax error of some kind. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): Fwiw, you can use the semicolon to set fixities: {{{
let add = (+); infixl 6 `add` }}}
-- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): That is a single `let`-command, `let { add = (+); infixl 6 `add` }`. You can write `do x; y` too, same logic. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): `type` (and presumably `data` and `class` and so on, everything which isn't real do-block syntax) has the same behavior as `import`, see #10704 for a real-life example. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1726 Wiki Page: | -------------------------------------+------------------------------------- Changes (by rdragon): * differential: => Phab:D1726 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1726 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"a84c21ebaa5c56a222d69f245ef4daa77054fdcb/ghc" a84c21eb/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a84c21ebaa5c56a222d69f245ef4daa77054fdcb" Reject import declaration with semicolon in GHCi Now GHCi rejects input containing an import declaration and semicolon, and prints an appropriate error message. Before, the stuff after an import declaration and semicolon got ignored (most of the time), without telling the user about it. As the default behaviour of GHCi is to reject multiple commands in a single input, we extend this behaviour to import commands. This patch fixes #10663. (See https://phabricator.haskell.org/D1518 for the introduction of `is_import` and `is_decl`.) Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1726 GHC Trac Issues: #10663 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: GHCi | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1726 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10663: ghci ignores stuff after an import command and a semicolon -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.10.1 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1726 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.0.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10663#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC