Fix #15828, from `More explicit foralls`
ClosedPublic

Authored by mayac on Oct 29 2018, 9:38 PM.

Details

Summary

Fix a bug in commit 12eeb9 which permits the following:

class C a where
  type T a b
instance C (Maybe a) where
  type forall a b. T (Maybe a) b = b

where instead, the user should write:

instance C (Maybe a) where
  type forall b. T (Maybe a) b = b

Update the users guide to discuss scoping of type variables in
explicit foralls in type family instances.

Test Plan

validate

mayac created this revision.Oct 29 2018, 9:38 PM
mayac edited the test plan for this revision. (Show Details)Oct 29 2018, 9:39 PM
mayac added a reviewer: goldfire.
mayac updated the Trac tickets for this revision.Oct 29 2018, 9:39 PM
goldfire added inline comments.Nov 2 2018, 9:44 PM
compiler/rename/RnSource.hs
731–736

I may have promised @mayac the text of the comment that should be here, so here goes:

-- If we pass mb_cls instead of Nothing here, bindLHsTyVarBndrs will use class variables for any names the user meant to bring in scope here. This is an explicit forall, so we want fresh names, not class variables. Thus: always pass Nothing

mayac updated this revision to Diff 18598.Nov 5 2018, 3:39 PM

Added goldfire's comment

goldfire accepted this revision.Nov 7 2018, 10:41 AM

LGTM.

This revision is now accepted and ready to land.Nov 7 2018, 10:41 AM
monoidal requested changes to this revision.Nov 11 2018, 6:11 AM
monoidal added a subscriber: monoidal.
monoidal added inline comments.
testsuite/tests/rename/should_fail/all.T
143

typo: test

This revision now requires changes to proceed.Nov 11 2018, 6:11 AM
This revision was not accepted when it landed; it landed in state Needs Revision.Nov 29 2018, 6:45 PM
This revision was automatically updated to reflect the committed changes.
RyanGlScott added inline comments.
testsuite/tests/rename/should_fail/all.T
143

I went ahead and applied this change upon landing the patch.