Commit 01490b4c authored by Edward Z. Yang's avatar Edward Z. Yang

Mark previously failing backpack tests as passing, with correct output.

Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 9df4ce4f
......@@ -26,8 +26,7 @@ test('bkp31', normal, backpack_compile, [''])
test('bkp32', normal, backpack_compile, [''])
test('bkp33', normal, backpack_compile, [''])
test('bkp34', normal, backpack_compile, [''])
# instance merging when heads overlap prefers an arbitrary instance
test('bkp35', expect_broken(0), backpack_compile, [''])
test('bkp35', normal, backpack_compile, [''])
test('bkp36', normal, backpack_compile, [''])
test('bkp37', normal, backpack_compile, [''])
test('bkp38', normal, backpack_compile, [''])
......
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE IncoherentInstances #-}
unit p where
signature A where
data K a
instance Read a => Show (K a)
instance Show (K (a -> b))
unit q where
signature A where
data K a
......@@ -10,19 +11,9 @@ unit q where
unit r where
dependency p[A=<A>]
dependency q[A=<A>]
-- At the moment, the merge arbitrarily picks one of the
-- instances to make available, so only one of these statements
-- will typecheck. Somehow need an OR constraint (but type
-- class solver doesn't backtrack, so that ain't gonna work).
--
-- It's actually a bit interesting to decide what this should
-- be: "instance Show a" would satisfy both of these, but
-- nothing else seems to work (incoherent instance is not
-- enough because GHC could pick the wrong instance and then
-- fail to solve the constraint.)
module R where
import A
f :: Show a => K a -> String
f = show
g :: Read a => K a -> String
g :: K (a -> b) -> String
g = show
[1 of 3] Processing p
[1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
[2 of 3] Processing q
[1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
[3 of 3] Processing r
[1 of 2] Compiling A[sig] ( r/A.hsig, nothing )
[2 of 2] Compiling R ( r/R.hs, nothing )
......@@ -3,24 +3,24 @@ test('bkpfail03', normal, backpack_typecheck_fail, [''])
test('bkpfail04', normal, backpack_typecheck_fail, [''])
test('bkpfail05', normal, backpack_compile_fail, [''])
test('bkpfail06', normal, backpack_compile_fail, [''])
test('bkpfail07', expect_broken(0), backpack_typecheck_fail, ['']) # could fix this but not priority
test('bkpfail07', normal, backpack_compile_fail, [''])
test('bkpfail09', normal, backpack_compile_fail, [''])
test('bkpfail10', normal, backpack_compile_fail, [''])
test('bkpfail11', normal, backpack_compile_fail, [''])
test('bkpfail12', normal, backpack_compile_fail, [''])
test('bkpfail13', normal, backpack_compile_fail, [''])
test('bkpfail14', normal, backpack_compile_fail, [''])
test('bkpfail15', expect_broken(0), backpack_compile_fail, ['']) # we don't error here...
test('bkpfail15', normal, backpack_compile_fail, [''])
test('bkpfail16', normal, backpack_compile_fail, [''])
test('bkpfail17', normal, backpack_compile_fail, [''])
test('bkpfail18', normal, backpack_compile_fail, [''])
test('bkpfail19', normal, backpack_compile_fail, [''])
test('bkpfail20', normal, backpack_compile_fail, [''])
test('bkpfail21', normal, backpack_compile_fail, [''])
# it does fail, but not quite in the right way yet...
test('bkpfail22', expect_broken(0), backpack_compile_fail, [''])
test('bkpfail22', normal, backpack_compile_fail, [''])
test('bkpfail23', normal, backpack_compile_fail, [''])
test('bkpfail24', normal, backpack_compile_fail, [''])
test('bkpfail25', normal, backpack_compile_fail, [''])
test('bkpfail26', normal, backpack_compile_fail, [''])
test('bkpfail27', normal, backpack_compile_fail, [''])
test('bkpfail28', normal, backpack_compile_fail, [''])
unit p where
signature H where
data T = T Int
unit q where
signature A where -- indefinite version
unit h where
module T where
data T = T Bool
module H(T(..)) where
import T
dependency p[H=<H>]
signature A where -- indefinite version
unit q where
dependency p[H=h[A=<A>]:H]
[1 of 2] Processing p
[1 of 1] Compiling H[abstract sig] ( p/H.hsig, nothing )
[2 of 2] Processing q
[1 of 4] Compiling A[abstract sig] ( q/A.hsig, nothing )
[2 of 4] Compiling T ( q/T.hs, nothing )
[3 of 4] Compiling H ( q/H.hs, nothing )
[4 of 4] Including p
[1 of 3] Processing p
[1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
[2 of 3] Processing h
[1 of 3] Compiling T ( h/T.hs, nothing )
[2 of 3] Compiling H ( h/H.hs, nothing )
[3 of 3] Compiling A[sig] ( h/A.hsig, nothing )
[3 of 3] Processing q
[1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
bkpfail07.bkp:7:9: error:
Type constructor ‘T.T’ has conflicting definitions in the module
and its hsig file
Main module: data T.T = T.T Bool
Hsig file: data T.T = T.T Int
The constructors do not match: The types for ‘T.T’ differ
bkpfail07.bkp:6:9: error:
• Type constructor ‘h[A=<A>]:T.T’ has conflicting definitions in the module
and its hsig file
Main module: data h[A=<A>]:T.T = h[A=<A>]:T.T GHC.Types.Bool
Hsig file: data h[A=<A>]:T.T = h[A=<A>]:T.T GHC.Types.Int
The constructors do not match: The types for ‘h[A=<A>]:T.T’ differ
• while checking that h[A=<A>]:H implements signature H in p[H=h[A=<A>]:H]
[1 of 3] Processing p
[1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
[2 of 3] Compiling Q[sig] ( p/Q.hsig, nothing )
[3 of 3] Compiling P ( p/P.hs, nothing )
[2 of 3] Processing q
Instantiating q
[1 of 1] Compiling Q ( q/Q.hs, bkpfail15.out/q/Q.o )
[3 of 3] Processing r
[1 of 1] Compiling A[sig] ( r/A.hsig, nothing )
bkpfail15.bkp:8:9: error:
• Identifier ‘q:Q.f’ has conflicting definitions in the module
and its hsig file
Main module: q:Q.f :: GHC.Types.Bool
Hsig file: q:Q.f :: GHC.Types.Int
The two types are different
• while checking that q:Q implements signature Q in p[A=<A>, Q=q:Q]
......@@ -15,6 +15,7 @@ unit badimpl where
module H2 where
type S = ()
unit check where
dependency q[H2=badimpl:H2]
dependency p[H=q[H2=badimpl:H2]:N]
-- signature H3 where
module C where
......
Not working test
[1 of 4] Processing p
[1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
[2 of 2] Compiling M ( p/M.hs, nothing )
[2 of 4] Processing q
[1 of 2] Compiling H2[sig] ( q/H2.hsig, nothing )
[2 of 2] Compiling N ( q/N.hs, nothing )
[3 of 4] Processing badimpl
Instantiating badimpl
[1 of 1] Compiling H2 ( badimpl/H2.hs, bkpfail22.out/badimpl/H2.o )
[4 of 4] Processing check
Instantiating check
[1 of 2] Including q[H2=badimpl:H2]
Instantiating q[H2=badimpl:H2]
[1 of 2] Compiling H2[sig] ( q/H2.hsig, bkpfail22.out/q/q-FjwGsuDQ5qiKUCvnEATUA9/H2.o )
bkpfail22.bkp:16:9: error:
Type constructor ‘badimpl:H2.S’ has conflicting definitions in the module
and its hsig file
Main module: type badimpl:H2.S = ()
Hsig file: type badimpl:H2.S = GHC.Types.Bool
{-# LANGUAGE FlexibleInstances #-}
-- This doesn't work: GHC MUST pick the wrong one!
-- {-# LANGUAGE IncoherentInstances #-}
unit p where
signature A where
data K a
instance Show a => Show (K a)
unit q where
signature A where
data K a
instance Read a => Show (K a)
unit r where
dependency p[A=<A>]
dependency q[A=<A>]
module R where
import A
f :: Show a => K a -> String
f = show
g :: Read a => K a -> String
g = show
[1 of 3] Processing p
[1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
[2 of 3] Processing q
[1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
[3 of 3] Processing r
[1 of 2] Compiling A[sig] ( r/A.hsig, nothing )
[2 of 2] Compiling R ( r/R.hs, nothing )
bkpfail28.bkp:18:13: error:
• Overlapping instances for Show (K a) arising from a use of ‘show’
Matching instances:
instance [safe] Show a => Show (K a)
-- Defined at bkpfail28.bkp:11:18
instance [safe] Read a => Show (K a)
-- Defined at bkpfail28.bkp:11:18
• In the expression: show
In an equation for ‘f’: f = show
bkpfail28.bkp:20:13: error:
• Overlapping instances for Show (K a) arising from a use of ‘show’
Matching instances:
instance [safe] Show a => Show (K a)
-- Defined at bkpfail28.bkp:11:18
instance [safe] Read a => Show (K a)
-- Defined at bkpfail28.bkp:11:18
• In the expression: show
In an equation for ‘g’: g = show
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment