Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,829
    • Issues 4,829
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 445
    • Merge requests 445
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17060

Closed
Open
Created Aug 14, 2019 by Robert Peszek@rpeszek

Compiler ignores Typeable constraint

Summary

Compiler allows passing types with no Typeable instance to functions declared with Typeable constraint.

Steps to reproduce

The following compiles (no pragmas needed)

import Data.Typeable 

brokenGhc :: Typeable a => a -> a 
brokenGhc = id  

tst = brokenGhc (Foo "bar") 

brokenGhc2 :: (Typeable a) => a -> String
brokenGhc2 = show . typeOf

tst2 = brokenGhc2 (Foo "Bar")
-- ghci> tst2
-- "Foo"

data Foo = Foo String

Possibly related to #10770?

Expected behavior

tst and tst2 should not compile. Note Foo has no instances!

Environment

  • GHC version used: Tested with ghc-8.6.5/lts-14.0, ghc-8.2.2/lts-12.22

Optional:

  • Operating System: Ubuntu 18.04 and Ubuntu 18.10

  • System Architecture:

Suggested Labels:

Typeable ~bug program incorrectly accepted

Edited Aug 14, 2019 by Robert Peszek
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking