Opened 9 months ago

Closed 8 months ago

#12094 closed bug (fixed)

Unlifted types and pattern synonym signatures

Reported by: akio Owned by:
Priority: normal Milestone: 8.0.2
Component: Compiler (Type checker) Version: 8.0.1
Keywords: PatternSynonyms Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D2255
Wiki Page:


The following program is rejected by ghc-8.0.1:

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
module Foo where

import GHC.Exts (Int#)

pattern Zero :: Int# -- commenting out this line works
pattern Zero <- 0#
% ghc-stage2 unlifted-pattern-synonym.hs
[1 of 1] Compiling Foo              ( unlifted-pattern-synonym.hs, unlifted-pattern-synonym.o )

unlifted-pattern-synonym.hs:7:17: error:
    • Expecting a lifted type, but ‘Int#’ is unlifted
    • In the type ‘Int#’

Commenting out the type signature removes the error.

GHC 7.10.3 accepts this program, with and without the type signature.

Change History (6)

comment:1 Changed 9 months ago by thomie

Cc: mpickering added
Keywords: PatternSynonyms added; pattern synonyms removed

Also fails in HEAD.

comment:2 Changed 9 months ago by mpickering

Differential Rev(s): Phab:D2255
Status: newpatch

Easy fix. Thanks for reporting the bug.

comment:3 Changed 9 months ago by Matthew Pickering <matthewtpickering@…>

In 8c9b8a31/ghc:

Allow unlifted types in pattern synonym result type

Fixes #12094

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12094

comment:4 Changed 9 months ago by mpickering

Status: patchmerge

comment:5 Changed 9 months ago by Iceland_jack

Bidirectional form also works

-- ghci> let a@(I# Zero) = I# Zero in a
-- 0
pattern Zero = 0#

Edit: should rather be

pattern Zero# = 0#
Last edited 9 months ago by Iceland_jack (previous) (diff)

comment:6 Changed 8 months ago by bgamari

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