Fix derived Ix instances for one-constructor GADTs
authorRyan Scott <ryan.gl.scott@gmail.com>
Sun, 11 Sep 2016 14:27:36 +0000 (10:27 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Sun, 11 Sep 2016 14:38:41 +0000 (10:38 -0400)
commit7b7ea8f40e7400b8c183595a85bb2c65c9f9bb29
treed24a8194605bceef5c747bf6411e154ae641bf97
parent04184a2a582d175dad4a696f5047cd66bfe26f8e
Fix derived Ix instances for one-constructor GADTs

Summary:
Standalone-derived `Ix` instances would panic on GADTs with exactly
one constructor, since the list of fields was being passed to a function that
uses `foldl1` in order to generate an implementation for `inRange`. This adds a
simple check that makes `inRange` be `True` whenever a product type has no
fields.

Fixes #12583.

Test Plan: make test TEST=12583

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2521

GHC Trac Issues: #12583
compiler/hsSyn/HsExpr.hs
compiler/typecheck/TcGenDeriv.hs
docs/users_guide/8.0.2-notes.rst
testsuite/tests/deriving/should_compile/T12583.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T