diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-07-17 12:43:45 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-30 07:12:16 -0400 |
commit | d47324ce49b0c4f419823cbd7fd47e134a1b255a (patch) | |
tree | 015da0d155c1241cde370bf339ac7547a4d92fc0 /testsuite | |
parent | 01c948eba4bea2d2c8ad340e12c1e7b732b334f7 (diff) | |
download | haskell-d47324ce49b0c4f419823cbd7fd47e134a1b255a.tar.gz |
Don't mark closed type family equations as occurrences
Previously, `rnFamInstEqn` would mark the name of the type/data
family used in an equation as an occurrence, regardless of what sort
of family it is. Most of the time, this is the correct thing to do.
The exception is closed type families, whose equations constitute its
definition and therefore should not be marked as occurrences.
Overzealously counting the equations of a closed type family as
occurrences can cause certain warnings to not be emitted, as observed
in #18470. See `Note [Type family equations and occurrences]` in
`GHC.Rename.Module` for the full story.
This fixes #18470 with a little bit of extra-casing in
`rnFamInstEqn`. To accomplish this, I added an extra
`ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of
`AssocTyFamInfo` and refactored the relevant call sites accordingly
so that this information is propagated to `rnFamInstEqn`.
While I was in town, I moved `wrongTyFamName`, which checks that the
name of a closed type family matches the name in an equation for that
family, from the renamer to the typechecker to avoid the need for an
`ASSERT`. As an added bonus, this lets us simplify the details of
`ClosedTyFamInfo` a bit.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/indexed-types/should_fail/Overlap5.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/rename/should_fail/T16002.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/th/T15362.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/th/T15362.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T18470.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T18470.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T11623.stderr | 8 |
8 files changed, 26 insertions, 19 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/Overlap5.stderr b/testsuite/tests/indexed-types/should_fail/Overlap5.stderr index 512859753c..f67549104b 100644 --- a/testsuite/tests/indexed-types/should_fail/Overlap5.stderr +++ b/testsuite/tests/indexed-types/should_fail/Overlap5.stderr @@ -1,6 +1,6 @@ Overlap5.hs:8:3: error: - Mismatched type name in type family instance. - Expected: F - Actual: G - In the declaration for type family ‘F’ + • Mismatched type name in type family instance. + Expected: F + Actual: G + • In the type family declaration for ‘F’ diff --git a/testsuite/tests/rename/should_fail/T16002.stderr b/testsuite/tests/rename/should_fail/T16002.stderr index 98db6f99b6..91279ffeeb 100644 --- a/testsuite/tests/rename/should_fail/T16002.stderr +++ b/testsuite/tests/rename/should_fail/T16002.stderr @@ -1,6 +1,6 @@ T16002.hs:6:3: error: - Mismatched type name in type family instance. - Expected: B - Actual: A - In the declaration for type family ‘B’ + • Mismatched type name in type family instance. + Expected: B + Actual: A + • In the type family declaration for ‘B’ diff --git a/testsuite/tests/th/T15362.hs b/testsuite/tests/th/T15362.hs index 183f887252..1bab4d776c 100644 --- a/testsuite/tests/th/T15362.hs +++ b/testsuite/tests/th/T15362.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds #-} +{-# LANGUAGE TemplateHaskell, TypeOperators, DataKinds, TypeFamilies #-} module T15362 where diff --git a/testsuite/tests/th/T15362.stderr b/testsuite/tests/th/T15362.stderr index 0ec2dd8e48..b63cb3553e 100644 --- a/testsuite/tests/th/T15362.stderr +++ b/testsuite/tests/th/T15362.stderr @@ -1,10 +1,6 @@ -T15362.hs:8:10: error: +T15362.hs:7:2: error: • Mismatched type name in type family instance. Expected: + Actual: Maybe - In the declaration for type family ‘+’ - • In the Template Haskell quotation - [d| type family a + b where - Maybe Zero b = b - Succ a + b = Succ (a + b) |] + • In the type family declaration for ‘+’ diff --git a/testsuite/tests/typecheck/should_compile/T18470.hs b/testsuite/tests/typecheck/should_compile/T18470.hs new file mode 100644 index 0000000000..618c1433ff --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T18470.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wunused-top-binds #-} + +module T18470 () where + +type family Closed x where + Closed Int = Bool diff --git a/testsuite/tests/typecheck/should_compile/T18470.stderr b/testsuite/tests/typecheck/should_compile/T18470.stderr new file mode 100644 index 0000000000..ffefb020d3 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T18470.stderr @@ -0,0 +1,3 @@ + +T18470.hs:6:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: type constructor or class ‘Closed’ diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 5917318476..51977768c7 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -718,3 +718,4 @@ test('T17775-viewpats-b', normal, compile_fail, ['']) test('T17775-viewpats-c', normal, compile_fail, ['']) test('T17775-viewpats-d', normal, compile_fail, ['']) test('T18412', normal, compile, ['']) +test('T18470', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_fail/T11623.stderr b/testsuite/tests/typecheck/should_fail/T11623.stderr index 78be1651e2..0f6253f103 100644 --- a/testsuite/tests/typecheck/should_fail/T11623.stderr +++ b/testsuite/tests/typecheck/should_fail/T11623.stderr @@ -1,6 +1,6 @@ T11623.hs:5:23: error: - Mismatched type name in type family instance. - Expected: T - Actual: Maybe - In the declaration for type family ‘T’ + • Mismatched type name in type family instance. + Expected: T + Actual: Maybe + • In the type family declaration for ‘T’ |