Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#13435 closed bug (fixed)

Segfaults on levity-polymorphic type class

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.2.1
Component: Compiler (Type checker) Version: 8.0.1
Keywords: LevityPolymorphism Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime crash Test Case: typecheck/should_run/T13435
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

{-# Language FlexibleInstances, TypeFamilies, TypeInType, MagicHash #-}

import Data.Kind
import GHC.Exts

class Shw (a :: TYPE rep) where
  shw :: a -> String

instance Int# ~ a => Shw (a :: TYPE IntRep) where
  shw a = "I#" ++ show (I# a)

main = putStrLn (shw 3#)

induces a segfault

$ runghc --version
runghc 8.0.1
$ runghc test.hs
I#Segmentation fault

Change History (13)

comment:1 Changed 3 years ago by Iceland_jack

Keywords: LevityPolymorphism added

comment:2 Changed 3 years ago by dfeuer

I believe the type checker should reject that class declaration. I'm not an expert at levity polymorphism, but I think class methods are supposed to have uniform calling conventions.

comment:3 Changed 3 years ago by dfeuer

Type of failure: None/UnknownGHC accepts invalid program

comment:4 Changed 3 years ago by dfeuer

Component: CompilerCompiler (Type checker)
Milestone: 8.4.1

comment:5 Changed 3 years ago by Richard Eisenberg <rae@…>

In 66d174a/ghc:

Test #13435 in typecheck/should_run/T13435

comment:6 Changed 3 years ago by goldfire

Milestone: 8.4.18.2.1
Status: newmerge

Levity polymorphism will evolve, and so I think it's worth merging.

comment:7 Changed 3 years ago by goldfire

Test Case: typecheck/should_run/T13435

comment:8 Changed 3 years ago by dfeuer

Type of failure: GHC accepts invalid programRuntime crash

Guess I was wrong....

comment:9 Changed 3 years ago by simonpj

I don't get this. David says it crashes; Richard adds a test that succeeds, but does not change what the compiler does. Merging Richard's tests won't fix any bugs. Who is right?

Last edited 3 years ago by simonpj (previous) (diff)

comment:10 Changed 3 years ago by bgamari

Resolution: fixed
Status: mergeclosed

comment:11 Changed 3 years ago by dfeuer

I was just wrong, I believe. Sorry.

comment:12 Changed 2 years ago by goldfire

During my levity-polymorphism sweep, I saw that this was newly working. I'm not sure exactly what did it, but the seg-fault is gone, and the program looks good to me.

comment:13 Changed 2 years ago by Iceland_jack

Great! Cheers Richard

Note: See TracTickets for help on using tickets.