#12529 closed bug (fixed)

Error message: visible type application of constructor/variable that is not in scope

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.0.2
Component: Compiler Version: 8.0.1
Keywords: TypeApplications Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: typecheck/should_fail/T12529
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

If I use an identifier not in scope:

$ ghci -ignore-dot-ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> p

<interactive>:1:1: error: Variable not in scope: p
Prelude> P

<interactive>:2:1: error: Data constructor not in scope: P

Using visible type application:

$ ghci -ignore-dot-ghci -XTypeApplications
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> p @Int

<interactive>:1:1: error:
    • Cannot apply expression of type ‘t0’
      to a visible type argument ‘Int’
    • In the expression: p @Int
      In an equation for ‘it’: it = p @Int
Prelude> P @Int

<interactive>:2:1: error:
    • Cannot apply expression of type ‘t0’
      to a visible type argument ‘Int’
    • In the expression: P @Int
      In an equation for ‘it’: it = P @Int

I would prefer these error messages to be the same as the first two: thoughts?

Change History (8)

comment:1 Changed 15 months ago by Iceland_jack

This gave me pause when I thought Proxy was in scope and tried applying to to a type variable Proxy @s

comment:2 Changed 15 months ago by goldfire

The fact that GHC treats out-of-scope errors as type errors causes degradation of certain error messages, like what you see here. I'm sure there's another ticket tracking this problem, but I'm unable to find it at the moment. Perhaps you can? If I recall, the original error message was about a lack of class instances.

comment:3 Changed 15 months ago by simonpj

It's #12170 I think. Ben, I think that patch (for #12170) is ready to go.

comment:4 Changed 15 months ago by goldfire

I'm afraid I wasn't referring to #12170, which is concerned with the interaction between -fdefer-type-errors and the new treatment of out-of-scope variables. The bug reported here triggers without -fdefer-type-errors.

comment:5 Changed 13 months ago by lexi.lambda

I recently ran into this, too. It’s definitely extremely confusing, since usually identifiers that aren’t in scope are very clearly indicated in error messages, but nothing in these errors would suggest that’s the problem. It took me a while to realize what exactly the problem was.

comment:6 Changed 13 months ago by Simon Peyton Jones <simonpj@…>

In 2fdf21b/ghc:

Further improve error handling in TcRn monad

This patch builds on the one for Trac #12124, by dealing properly
with out-of-scope "hole" errors.

This fixes Trac #12529. The hard error coming from visible type application
is still there, but the out-of-scope error is no longer suppressed.

(Arguably the VTA message should be suppressed somehow, but that's a
battle for another day.)

comment:7 Changed 13 months ago by simonpj

Status: newmerge
Test Case: typecheck/should_fail/T12529

Possibly worth merging? Since the patch for #12124 is.

comment:8 Changed 13 months ago by bgamari

Milestone: 8.0.2
Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.