[GHC] #13584: ghci parse error on operator info

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Keywords: parse, info, | Operating System: Linux operator | Architecture: x86_64 | Type of failure: Incorrect result (amd64) | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If requested info about some operator, ie `(+)` `:info (+)` is working as expected: {{{#!haskell
:i (+) class Num a where (+) :: a -> a -> a ... -- Defined in ‘GHC.Num’ infixl 6 + }}}
When additional space character is there `:info (+ )` it won't parse: {{{#!haskell
:i (+ )
<interactive>:1:3: error: parse error (possibly incorrect indentation or mismatched brackets) }}} Note that the same thing is working with `:type` so its strange it doesn't use the same parser here and there:ž {{{#!haskell
:t (+ ) (+ ) :: Num a => a -> a -> a }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Resolution: | Keywords: parse, info, | operator Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by akegalj: @@ -21,1 +21,1 @@ - use the same parser here and there:ž + use the same parser in both places: New description: If requested info about some operator, ie `(+)` `:info (+)` is working as expected: {{{#!haskell
:i (+) class Num a where (+) :: a -> a -> a ... -- Defined in ‘GHC.Num’ infixl 6 + }}}
When additional space character is there `:info (+ )` it won't parse: {{{#!haskell
:i (+ )
<interactive>:1:3: error: parse error (possibly incorrect indentation or mismatched brackets) }}} Note that the same thing is working with `:type` so its strange it doesn't use the same parser in both places: {{{#!haskell
:t (+ ) (+ ) :: Num a => a -> a -> a }}}
-- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Resolution: | Keywords: parse, info, | operator Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): It is indeed strange that these parse differently. I would argue that we should reject `(+ )`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Resolution: | Keywords: parse, info, | operator Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by anarchist666): The {{{words}}} operator is used in the {{{:info}}} command. {{{ info :: Bool -> String -> InputT GHCi () info _ "" = throwGhcException (CmdLineError "syntax: ':i <thing-you-want- info-about>'") info allInfo s = handleSourceError GHC.printException $ do unqual <- GHC.getPrintUnqual dflags <- getDynFlags sdocs <- mapM (infoThing allInfo) (words s) mapM_ (liftIO . putStrLn . showSDocForUser dflags unqual) sdocs }}} But you can type {{{:info + -}}} and get this {{{ class Num a where (+) :: a -> a -> a ... -- Defined in ‘GHC.Num’ infixl 6 + class Num a where (-) :: a -> a -> a ... -- Defined in ‘GHC.Num’ infixl 6 - }}} We can filter all brackets in the input line, but I want to know what the others think about it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Resolution: | Keywords: parse, info, | operator Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Alright, looking at the report again I suppose accepting `(+ )` is reasonable; afterall whitespace is not allowed in identifiers; it's merely a lexeme delimiter. I rescind comment:2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13584: ghci parse error on operator info -------------------------------------+------------------------------------- Reporter: akegalj | Owner: (none) Type: bug | Status: new Priority: lowest | Milestone: Component: GHCi | Version: 8.0.2 Resolution: | Keywords: parse, info, | operator Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): anarchist666, I'm not sure I understand your proposal. Are you suggesting that `:info` simply drop all parentheses from its arguments? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13584#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC