unsafe coerce without extensions
The following program implements an unsafe coerce and works on versions of GHC at least as far back as 7.0.3 but is fixed in HEAD. I'm reporting this because I don't know if it was fixed on purpose and might merit at least a fix to the 7.6.X branch if not the 7.4.X branch (due to its use in the platform)
newtype Id a = Id { runId :: a }
-- Providing this type triggers a type-error
-- cast :: a -> b
cast v = runId z
where
z :: Id v
z = aux
where
aux = Id v
Example usage:
*Main> map cast [97..107 :: Int] :: String
"abcdefghijk"
*Main> cast (Just True) :: String
"\-1152921504589708267Segmentation fault: 11
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |