[GHC] #14370: non-deferred typed hole despite -fdefer-typed-holes

#14370: non-deferred typed hole despite -fdefer-typed-holes -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider the following ghci session. {{{ GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Prelude> :set -fdefer-typed-holes -Wno-typed-holes Prelude> :set -fdefer-out-of-scope-variables -Wno-deferred-out-of-scope- variables Prelude> let x = [_]; y = [r] Prelude> (length x, length y) (1,1) Prelude> length [_] <interactive>:4:9: error: • Found hole: _ :: a0 Where: ‘a0’ is an ambiguous type variable • In the expression: _ In the first argument of ‘length’, namely ‘[_]’ In the expression: length [_] • Relevant bindings include it :: Int (bound at <interactive>:4:1) Prelude> length [r] 1 }}} Why does the `length [_]` expression produce a type error immediately instead of being deferred? (I've asked the same question in #14367 but this looks like a real bug.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: non-deferred typed hole despite -fdefer-typed-holes -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): Does [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #deferred-type-errors-in-ghci this] answer your question? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: non-deferred typed hole despite -fdefer-typed-holes -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-e): Replying to [comment:1 monoidal]:
Does [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #deferred-type-errors-in-ghci this] answer your question?
Yes and no. I still believe that the behavior is surprising, but this means it's a feature, not a bug (I don't care enough to argue otherwise). Btw, from this section I would conclude that `length [r]` should also produce an error, since both typed holes and out of scope variables fall under the headline [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #deferring-type-errors-to-runtime Deferring type errors to runtime]. In any case it appears that the documentation can be improved a bit. * clarify in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #deferred-type-errors-in-ghci Deferred type errors in GHCi] that this applies to type checking errors (including typed holes) but not to name resolution (out of scope variables) * I didn't find the GHCi exception when reading [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #typed-holes Typed Holes] so a forward reference may be helpful * The description of [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using- warnings.html#ghc-flag--fdefer-type-errors -fdefer-type-errors] should mention that it implies -fdefer-out-of-scope-variables -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: non-deferred typed hole despite -fdefer-typed-holes -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-e): #10249 and #11130 provide some rationale for the current behavior from ghc's side. See also https://phabricator.haskell.org/D1527 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: improve documentation of -fdefer-typed-holes for naked expressions in ghci -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Documentation | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-e): * type: bug => task * component: Compiler => Documentation Old description:
Consider the following ghci session.
{{{ GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Prelude> :set -fdefer-typed-holes -Wno-typed-holes Prelude> :set -fdefer-out-of-scope-variables -Wno-deferred-out-of-scope- variables Prelude> let x = [_]; y = [r] Prelude> (length x, length y) (1,1) Prelude> length [_]
<interactive>:4:9: error: • Found hole: _ :: a0 Where: ‘a0’ is an ambiguous type variable • In the expression: _ In the first argument of ‘length’, namely ‘[_]’ In the expression: length [_] • Relevant bindings include it :: Int (bound at <interactive>:4:1) Prelude> length [r] 1 }}}
Why does the `length [_]` expression produce a type error immediately instead of being deferred?
(I've asked the same question in #14367 but this looks like a real bug.)
New description: Consider the following ghci session. {{{ GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Prelude> :set -fdefer-typed-holes -Wno-typed-holes Prelude> :set -fdefer-out-of-scope-variables -Wno-deferred-out-of-scope- variables Prelude> let x = [_]; y = [r] Prelude> (length x, length y) (1,1) Prelude> length [_] <interactive>:4:9: error: • Found hole: _ :: a0 Where: ‘a0’ is an ambiguous type variable • In the expression: _ In the first argument of ‘length’, namely ‘[_]’ In the expression: length [_] • Relevant bindings include it :: Int (bound at <interactive>:4:1) Prelude> length [r] 1 }}} Why does the `length [_]` expression produce a type error immediately instead of being deferred? ~~(I've asked the same question in #14367 but this looks like a real bug.)~~ The documentation can be improved here, see [#comment:2 comment 2] -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: improve documentation of -fdefer-typed-holes for naked expressions in ghci -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Documentation | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sighingnow): I think that the `Opt_DeferOutOfScopeVariables` isn't cancelled for naked expression in ghci should be a bug. Allowing `length [r]` is also unhelpful and may lead to some confusion for newcomers. I think this should be fixed as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14370: improve documentation of -fdefer-typed-holes for naked expressions in ghci -------------------------------------+------------------------------------- Reporter: int-e | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Documentation | Version: 8.2.1 Resolution: | Keywords: | DeferredErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => DeferredErrors -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14370#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC