Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,323
    • Issues 4,323
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 372
    • Merge Requests 372
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13713

Closed
Open
Opened May 17, 2017 by Niklas Hambüchen@nh2Reporter

fdefer-type-errors makes missing import errors disappear

I have this code

{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}


import           Data.Type.Equality ((:~:)(Refl))
import           GHC.TypeLits
import qualified Numeric.LinearAlgebra as LA
import           Numeric.LinearAlgebra.Static


toVec :: forall n . (KnownNat n) => LA.Vector Double -> R n
toVec vec = withVector vec $ \(v :: R n2) -> case sameNat (Proxy @n) (Proxy @n2) of
  Just Refl -> v
  Nothing -> error "wrong dimensions"

Notably I forgot to import Proxy.

Without -fdefer-type-errors I get this error:

➤ nix-shell -p "haskellPackages.ghcWithPackages (pkgs:[pkgs.hmatrix])" --pure --run 'ghci ghc-8.0.2-proxy-confusing-error.hs'
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( ghc-8.0.2-proxy-confusing-error.hs, interpreted )

ghc-8.0.2-proxy-confusing-error.hs:12:60: error:
    Data constructor not in scope: Proxy

ghc-8.0.2-proxy-confusing-error.hs:12:60: error:
    * Cannot apply expression of type `t1'
      to a visible type argument `n'
    * In the first argument of `sameNat', namely `(Proxy @n)'
      In the expression: sameNat (Proxy @n) (Proxy @n2)
      In the expression:
        case sameNat (Proxy @n) (Proxy @n2) of {
          Just Refl -> v
          Nothing -> error "wrong dimensions" }
Failed, modules loaded: none.

but with -fdefer-type-errors the Data constructor not in scope: Proxy is gone!

➤ nix-shell -p "haskellPackages.ghcWithPackages (pkgs:[pkgs.hmatrix])" --pure --run 'ghci ghc-8.0.2-proxy-confusing-error.hs -fdefer-type-errors'
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( ghc-8.0.2-proxy-confusing-error.hs, interpreted )

ghc-8.0.2-proxy-confusing-error.hs:12:60: error:
    * Cannot apply expression of type `t1'
      to a visible type argument `n'
    * In the first argument of `sameNat', namely `(Proxy @n)'
      In the expression: sameNat (Proxy @n) (Proxy @n2)
      In the expression:
        case sameNat (Proxy @n) (Proxy @n2) of {
          Just Refl -> v
          Nothing -> error "wrong dimensions" }
Failed, modules loaded: none.

This is probably related to #12529 (closed).

Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC nh2
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#13713