#14715 closed bug (fixed)

GHC 8.4.1-alpha regression with PartialTypeSignatures

Reported by: RyanGlScott Owned by:
Priority: highest Milestone: 8.4.1
Component: Compiler (Type checker) Version: 8.4.1-alpha1
Keywords: PartialTypeSignatures Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This bug prevents lol-apps' tests and benchmarks from building with GHC 8.4.1-alpha2. This is as much as I'm able to minimize the issue:

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Bug (bench_mulPublic) where

data Cyc r
data CT zp r'q
class Reduce a b
type family LiftOf b

bench_mulPublic :: forall z zp zq . (z ~ LiftOf zq, _) => Cyc zp -> Cyc z -> IO (zp,zq)
bench_mulPublic pt sk = do
  ct :: CT zp (Cyc zq) <- encrypt sk pt
  undefined ct

encrypt :: forall z zp zq. Reduce z zq => Cyc z -> Cyc zp -> IO (CT zp (Cyc zq))
encrypt = undefined

On GHC 8.2.2, this compiles without issue. But on GHC 8.4.1-alpha2, this errors with:

$ /opt/ghc/8.4.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:15:1: error:
    • Could not deduce (Reduce fsk0 zq)
      from the context: (z ~ LiftOf zq, Reduce fsk zq)
        bound by the inferred type for ‘bench_mulPublic’:
                   forall z zp zq fsk.
                   (z ~ LiftOf zq, Reduce fsk zq) =>
                   Cyc zp -> Cyc z -> IO (zp, zq)
        at Bug.hs:(15,1)-(17,14)
      The type variable ‘fsk0’ is ambiguous
    • In the ambiguity check for the inferred type for ‘bench_mulPublic’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        bench_mulPublic :: forall z zp zq fsk.
                           (z ~ LiftOf zq, Reduce fsk zq) =>
                           Cyc zp -> Cyc z -> IO (zp, zq)
15 | bench_mulPublic pt sk = do
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^...

Change History (5)

comment:1 Changed 20 months ago by RyanGlScott

Cc: simonpj added

This regression was introduced in 8dc6d645fc3384b3b8ded0578939f5c855dd2ed5 (Re-engineer Given flatten-skolems).

comment:2 Changed 20 months ago by simonpj

I'm on this; turned out to be easy

comment:3 Changed 20 months ago by Simon Peyton Jones <simonpj@…>

In e7c3878d/ghc:

Move zonkWC to the right place in simplfyInfer

runTcSWithEvBinds does some unification, so the zonkWC
must be after, not before!  Yikes.  An outright bug.

This fixes Trac #14715.

comment:4 Changed 20 months ago by simonpj

Status: newmerge

Merge if possible.

Thanks for reporting this.

comment:5 Changed 20 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.