[GHC] #9177: Suggest Int when user uses int
#9177: Suggest Int when user uses int ------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #1388 | ------------------------------------+------------------------------------- This ticket is a fork of #1388. We already give suggestions when the user mispells names, based on edit distance. But this does not cross the boundaries between different kind of names. It would be helpful if {{{Not in scope: type variable `int'}}} would also say {{{Did you mean the type constructor `Int'}}}? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by simonpj): Good idea. Want to implement it? Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * owner: => nomeata Comment: Almost done, this is my ZuriHac warm up ticket :-) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by nomeata): I have two variants: One that suggests `Integer` when `integer` is typed, and one that suggests even `Integer` if `integerr` is typed (using the same edit distance metric stuff). I’ll push the first, followed by the second, so that one can easily revert. Of course there is no limit on how smart the error message can be. In `type Foo = eq`, one cannot mean `Eq` (as it is a class), but that is not available on the level of `OccNames`. But I guess the suggestion is still an improvement. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * status: new => patch Comment: Another example of this logic leading the user into a direction that will cause a different error: {{{ Prelude> let foo = () Prelude> let g = Foo -- good suggestion <interactive>:5:9: Not in scope: data constructor ‘Foo’ Perhaps you meant variable ‘foo’ (line 2) Prelude> let f (Foo x) = x -- bad suggestion <interactive>:3:8: Not in scope: data constructor ‘Foo’ Perhaps you meant variable ‘foo’ (line 2) }}} Anyways, I pushed it to `wip/T9177` for review (but will likely push to master in the next days; people can still complain afterwards). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by simonpj): Sounds good to me. Do get someone at Zurihac to look it over and then push to master. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by Joachim Breitner <mail@…>): In [changeset:"009e86f5dd2bc2657be093c76ba679b7866b651a/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="009e86f5dd2bc2657be093c76ba679b7866b651a" Suggest Int when user writes int and the other way around. This fixes #9177. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by Joachim Breitner <mail@…>): In [changeset:"ae41a50f0378c00351df5414b35026fc4bce2b44/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="ae41a50f0378c00351df5414b35026fc4bce2b44" Report all possible results from related name spaces instead of just one matching directly. This is an alternative way to fix ticket #9177. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by Joachim Breitner <mail@…>): In [changeset:"d3cae19055d6f148b6085fb5d6885a1826215aad/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="d3cae19055d6f148b6085fb5d6885a1826215aad" Add testcase for #9177 and adjust test output }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by goldfire): Replying to [comment:3 nomeata]:
I have two variants: One that suggests `Integer` when `integer` is typed, and one that suggests even `Integer` if `integerr` is typed (using the same edit distance metric stuff). I’ll push the first, followed by the second, so that one can easily revert.
Of course there is no limit on how smart the error message can be. In `type Foo = eq`, one cannot mean `Eq` (as it is a class), but that is not available on the level of `OccNames`. But I guess the suggestion is still an improvement.
In case anyone is inspired to make this smarter, I'll note that `type Foo = Eq` is perfectly reasonable, in the presence of !ConstraintKinds. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by hvr): * milestone: => 7.10.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9177#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC