[GHC] #10576: REPL returns list of all imported names when operator completion requested

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Keywords: | Operating System: Unknown/Multiple completions complete command | Type of failure: Incorrect result operator | at runtime Architecture: | Blocked By: Unknown/Multiple | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- When querying completions for operators GHCi returns a list containing all imported names rather than suitable completions. For example, if you simply start GHCi and run `:complete repl ">>"` command it will give you all names from base and Prelude. Then if you import something else, for example `:m +Data.Text`, the result of query will contain names from Data.Text also. In case of projects (`cabal repl`) things are worst, because returned list contains all names imported project-wise and it could be really huge. GHCi behaves similarly with following queries: :complete repl "(>>" :complete repl "Prelude.>>" :complete repl "Prelude.(>>" I only tested this on OS X 10.9, GHC 7.8.4 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Geraldus): Same here on Windows with GHC 7.8.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: #9996 | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * owner: => thomie * related: => #9996 Comment: Also reported as #9996. The problem comes from using the default `word_break_chars` when completing identifiers in `ghc/ghc/InteractiveUI.hs`: {{{ -- We initialize readline (in the interactiveUI function) to use -- word_break_chars as the default set of completion word break characters. -- This can be overridden for a particular command (for example, filename -- expansion shouldn't consider '/' to be a word break) by setting the third -- entry in the Command tuple above. -- -- NOTE: in order for us to override the default correctly, any custom entry -- must be a SUBSET of word_break_chars. word_break_chars :: String word_break_chars = let symbols = "!#$%&*+/<=>?@\\^|-~" specials = "(),;[]`{}" spaces = " \t\n" in spaces ++ specials ++ symbols wrapIdentCompleter = wrapCompleter word_break_chars }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: #9996 | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Geraldus): My little investigation lead me to `completeQuotedWord` function, but I can't follow any further now because I can't find where it comes from: `completeCmd` [1] -> -> [2] -> `ghciCompleteWord` [3] -> [4] -> `completeExpression` [5] {{{ completeExpression = completeQuotedWord (Just '\\') "\"" listFiles completeIdentifier }}} [1]:https://github.com/ghc/ghc/blob/d20031d4c88b256cdae264cb05d9d850e973d956/ghc... [2]:https://github.com/ghc/ghc/blob/d20031d4c88b256cdae264cb05d9d850e973d956/ghc... [3]:https://github.com/ghc/ghc/blob/d20031d4c88b256cdae264cb05d9d850e973d956/ghc... [4]:https://github.com/ghc/ghc/blob/d20031d4c88b256cdae264cb05d9d850e973d956/ghc... [5]:https://github.com/ghc/ghc/blob/d20031d4c88b256cdae264cb05d9d850e973d956/ghc... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: #9996 | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Geraldus):
The problem comes from using the default `word_break_chars`
Oh, so I suppose potential solution is to check if prefix to be completed starts with operator symbol, and if the case do not use `wrapIdentCompleter` in `completeIdentifier`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: thomie Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: #9996 | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by Geraldus: Old description:
When querying completions for operators GHCi returns a list containing all imported names rather than suitable completions.
For example, if you simply start GHCi and run `:complete repl ">>"` command it will give you all names from base and Prelude. Then if you import something else, for example `:m +Data.Text`, the result of query will contain names from Data.Text also.
In case of projects (`cabal repl`) things are worst, because returned list contains all names imported project-wise and it could be really huge.
GHCi behaves similarly with following queries: :complete repl "(>>" :complete repl "Prelude.>>" :complete repl "Prelude.(>>"
I only tested this on OS X 10.9, GHC 7.8.4
New description: When querying completions for operators GHCi returns a list containing all imported names rather than suitable completions. For example, if you simply start GHCi and run `:complete repl ">>"` command it will give you all names from base and Prelude. Then if you import something else, for example `:m +Data.Text`, the result of query will contain names from Data.Text also. In case of projects (`cabal repl`) things are worst, because returned list contains all names imported project-wise and it could be really huge. GHCi behaves similarly with following queries: {{{ :complete repl "(>>" :complete repl "Prelude.>>" :complete repl "Prelude.(>>" }}} I only tested this on OS X 10.9, GHC 7.8.4 -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: Geraldus Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | completions complete command Type of failure: Incorrect result | operator at runtime | Architecture: Blocked By: | Unknown/Multiple Related Tickets: #9996 | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by Geraldus): * owner: thomie => Geraldus -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: Geraldus Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: completions | complete command operator Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9996 | Differential Rev(s): Phab:D1058 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Geraldus): * differential: => Phab:D1058 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10576: REPL returns list of all imported names when operator completion requested
-------------------------------------+-------------------------------------
Reporter: Geraldus | Owner: Geraldus
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 7.8.4
Resolution: | Keywords: completions
| complete command operator
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: #9996 | Differential Rev(s): Phab:D1058
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10576: REPL returns list of all imported names when operator completion requested -------------------------------------+------------------------------------- Reporter: Geraldus | Owner: Geraldus Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.4 Resolution: | Keywords: completions | complete command operator Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect result | Test Case: ghci/prog017 at runtime | ghci/scripts/T10576a T10576b Blocked By: | Blocking: Related Tickets: #9996 | Differential Rev(s): Phab:D1058 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * testcase: => ghci/prog017 ghci/scripts/T10576a T10576b Comment: Update. This works: {{{ Prelude> (☀☀) _ _ = () Prelude> x1 ☀<TAB> }}} This doesn't work: {{{ Prelude> (☀☀) _ _ = () Prelude> x1☀<TAB> }}} A space is needed between the variable and the operator for completion to work. To solve this nicely requires adding a function to haskeline, similar to `completeWord`, but which takes a predicate function instead of a list of escape characters. The tests `T10576a` and `T10576b` are marked `expect_broken` for this issue. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10576#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC