[GHC] #14000: Out of scope errors with type families do not mention scope

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) 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: -------------------------------------+------------------------------------- {{{ {-# LANGUAGE TypeFamilies #-} class C a where type T a c :: a -> T a main = c noSuchThing }}} yields: {{{ test_bad_error.hs:6:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a }}} This makes simple out-of-scope error seem very perplexing and is a huge regression in error quality. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: RyanGlScott (added) * failure: None/Unknown => Poor/confusing error message * keywords: => TypeFamilies Comment: Indeed, the error message in GHC 7.10.3 and earlier was simply: {{{ $ /opt/ghc/7.10.3/bin/ghci Bug.hs GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:5:10: Not in scope: ‘noSuchThing’ Failed, modules loaded: none. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Interestingly, I tried a random commit from before GHC 8.0.1 (707b2be97539b83efb91cd9f17f94c91397ad2b4), and I received more information in the error messages: {{{ $ inplace/bin/ghc-stage2 --interactive ../Bug.hs GHCi, version 8.0.0.20160109: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( ../Bug.hs, interpreted ) ../Bug.hs:5:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a ../Bug.hs:5:10: error: Variable not in scope: noSuchThing }}} So at separate commits, GHC (1) started complaining about this `Couldn't match expected type` business (which is questionable), and (2) stopped complaining about `noSuchThing` not being in scope (which is definitely wrong). I've yet to figure out which commits are responsible. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * version: 8.0.1 => 8.0.2 Comment: Actually, the `Couldn't match expected type` error was dropped somewhere between 8.0.1 and 8.0.2, since in 8.0.1, you get: {{{ $ /opt/ghc/8.0.1/bin/ghci ../Bug.hs GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( ../Bug.hs, interpreted ) ../Bug.hs:5:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a ../Bug.hs:5:10: error: Variable not in scope: noSuchThing }}} But in GHC 8.0.2: {{{ $ /opt/ghc/8.0.2/bin/ghci ../Bug.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( ../Bug.hs, interpreted ) ../Bug.hs:5:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: simonpj (added) Comment: The `Variable not in scope` error was dropped in 5662ceaeb4da4fdee0f9fc01f72855168471377f (`Improve error handling in TcRnMonad`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): The `Couldn't match expected type` error snuck in after fb7b6922573af76a954d939c85e6af7c39a19896 (`Treat out-of-scope variables as holes`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope
-------------------------------------+-------------------------------------
Reporter: EyalLotem | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Resolution: | Keywords: TypeFamilies
Operating System: Unknown/Multiple | Architecture:
Type of failure: Poor/confusing | Unknown/Multiple
error message | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: fixed | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Poor/confusing | Test Case: error message | typecheck/should_fail/T14000 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => typecheck/should_fail/T14000 * resolution: => fixed Comment: Excellent report; fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.2 Component: Compiler | Version: 8.0.2 Resolution: fixed | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Poor/confusing | Test Case: error message | typecheck/should_fail/T14000 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: closed => merge * milestone: => 8.2.2 Comment: Might be worth merging. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14000: Out of scope errors with type families do not mention scope -------------------------------------+------------------------------------- Reporter: EyalLotem | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.2 Component: Compiler | Version: 8.0.2 Resolution: fixed | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Poor/confusing | Test Case: error message | typecheck/should_fail/T14000 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Old description:
{{{ {-# LANGUAGE TypeFamilies #-} class C a where type T a c :: a -> T a main = c noSuchThing }}}
yields: {{{ test_bad_error.hs:6:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a }}}
This makes simple out-of-scope error seem very perplexing and is a huge regression in error quality.
New description: {{{#!hs {-# LANGUAGE TypeFamilies #-} class C a where type T a c :: a -> T a main = c noSuchThing }}} yields: {{{ test_bad_error.hs:6:1: error: • Couldn't match expected type ‘T a’ with actual type ‘T a0’ NB: ‘T’ is a type function, and may not be injective The type variable ‘a0’ is ambiguous • In the ambiguity check for the inferred type for ‘main’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type main :: forall a. T a }}} This makes simple out-of-scope error seem very perplexing and is a huge regression in error quality. -- Comment: Merged to `ghc-8.2` with a0558a5af9bdba208b629d04d729849166f565fd. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14000#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC