Opened 3 years ago

Closed 3 years ago

#13349 closed bug (fixed)

Make GHC handle orphan COMPLETE sets of conlikes better

Reported by: RyanGlScott Owned by: rwbarton
Priority: highest Milestone: 8.2.1
Component: Compiler Version: 8.1
Keywords: PatternSynonyms Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3243
Wiki Page:


Like orphan rewrite rules, it's possible to define orphan COMPLETE sets. For instance:

module Foo where

{-# COMPLETE False #-}

I suppose that we could define an orphan COMPLETE set as one that lives in a module where none of the conlikes are defined (or should we say "where one or more of the conlikes are not defined"? I'm not sure.)

Like orphan RULES, orphan COMPLETE sets are important to track properly when transitively reading from interface files, as failing to bring an orphan COMPLETE set into scope could affect pattern-match exhaustivness warnings that users see.

After discussing this with rwbarton and mpickering IRC, we decided that one of the two should happen:

  1. Treat orphan COMPLETE sets like orphan RULES. That is, mark a module as an orphan if it defines an orphan COMPLETE set, and thread a "COMPLETE pragma visibility" state through various places.
  2. Disallow orphan COMPLETE sets entirely.

Change History (7)

comment:1 Changed 3 years ago by rwbarton

Milestone: 8.2.1
Priority: normalhighest

Let's do 2 before COMPLETE pragmas are released into the wild, so that nobody starts to depend on orphan COMPLETE pragmas. I assume it is not difficult. Then we could consider whether to do 1 later; but that is certainly a fair amount of work and probably not worthwhile.

comment:2 Changed 3 years ago by rwbarton

Owner: set to rwbarton

comment:3 Changed 3 years ago by mpickering

I think there is just one place to change in the renamer.

comment:4 Changed 3 years ago by rwbarton

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

comment:5 Changed 3 years ago by simonpj

I agree with comment:1. Let's adopt (2) for now.

comment:6 Changed 3 years ago by Ben Gamari <ben@…>

In fce3d37/ghc:

Don't allow orphan COMPLETE pragmas (#13349)

We might support them properly in the future, but for now it's simpler
to disallow them.

Test Plan: validate

Reviewers: mpickering, austin, bgamari, simonpj

Reviewed By: mpickering, simonpj

Subscribers: simonpj, thomie

Differential Revision:

comment:7 Changed 3 years ago by bgamari

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