Opened 3 years ago

Closed 3 years ago

#9889 closed bug (fixed)

Pattern synonym does not work in top-level pattern bind

Reported by: goldfire Owned by: cactus
Priority: normal Milestone: 7.10.1
Component: Compiler (Type checker) Version: 7.9
Keywords: PatternSynonyms Cc:
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:

Description (last modified by cactus)

When I say

{-# LANGUAGE PatternSynonyms #-}
pattern Id x = x

Id x = True

I get

    Not in scope: data constructor ‘Id’

This happens with both 7.8.3 and HEAD.

Change History (6)

comment:1 Changed 3 years ago by simonpj

Owner: set to cactus

Gergo: for you!

comment:2 Changed 3 years ago by cactus

Component: CompilerCompiler (Type checker)
Description: modified (diff)
Summary: Pattern synonym does not work at top levelPattern synonym does not work in top-level pattern bind
Type of failure: None/UnknownGHC rejects valid program

Note that pattern binds, in general, don't have this problem, only at the top level; e.g. the following works as expected:

{-# LANGUAGE PatternSynonyms #-}
pattern Id x = x

foo = x
  where
    Id x = True

comment:3 Changed 3 years ago by cactus

Status: newpatch

I've pushed a proposed fix for this to the wip/T9889 branch, but it might be a bit of a sensitive change, since it requires introducing pattern synonym names in the renamer in a separate pass between renaming TyClDecls and HsValBinds. Simon, please review.

commit e5f429cbc02df745df1517d53c8ca170de41757b
Author: Dr. ERDI Gergo <gergo@erdi.hu>
Date:   Wed Dec 17 22:09:06 2014 +0800

    Pattern synonym names need to be in scope before renaming bindings (#9889)

comment:4 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In 5830fc449af6b2c0ef5be409fd3457114ae938ca/ghc:

Pattern synonym names need to be in scope before renaming bindings (#9889)

I did a bit of refactoring at the same time, needless to say

comment:5 Changed 3 years ago by cactus

Milestone: 7.10.1
Status: patchmerge

comment:6 Changed 3 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.