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,334
    • Issues 4,334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 369
    • Merge Requests 369
  • 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
  • #14149

Closed
Open
Opened Aug 23, 2017 by Simon Peyton Jones@simonpjDeveloper

Tyepchecker generates top-level unboxed coercion

Consider this code

{-# OPTIONS_GHC -fdefer-out-of-scope-variables #-}

module Foo where

import Data.Coerce

f :: Bool
f = coerce (k :: Int)

It generates a lint error:

*** Core Lint errors : in result of Desugar (after optimization) ***
<no location info>: warning:
    [RHS of cobox_a11N :: (Int :: *) ~R# (Bool :: *)]
    The type of this binder is unlifted: cobox_a11N
    Binder's type: (Int :: *) ~R# (Bool :: *)
*** Offending Program ***
$trModule :: Module
[LclIdX]
$trModule = Module (TrNameS "main"#) (TrNameS "Foo"#)

cobox_a11N :: (Int :: *) ~R# (Bool :: *)
[LclId[CoVarId]]
cobox_a11N
  = typeError
      @ ('TupleRep '[])
      @ ((Int :: *) ~R# (Bool :: *))
      "Foo.hs:8:5: error:\n\
      \    \\226\\128\\162 Couldn't match representation of type \\226\\128\\152Int\\226\\128\\153 with that of \\226\\128\\152Bool\\226\\128\\153\n\
      \        arising from a use of \\226\\128\\152coerce\\226\\128\\153\n\
      \    \\226\\128\\162 In the expression: coerce (k :: Int)\n\
      \      In an equation for \\226\\128\\152f\\226\\128\\153: f = coerce (k :: Int)\n\
      \(deferred type error)"#

f :: Bool
[LclIdX]
f = (typeError
       @ 'LiftedRep
       @ Int
       "Foo.hs:8:13: error: Variable not in scope: k :: Int\n\
       \(deferred type error)"#)
    `cast` (cobox_a11N :: (Int :: *) ~R# (Bool :: *))

*** End of Offense ***

Reason: this rather hacky test in TcUnify.buildImplication

       ; if null skol_tvs && null given && (not deferred_type_errors ||
                                            not (isTopTcLevel tc_lvl))

did take account of Opt_DeferOutOfScopeVariables.

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