summaryrefslogtreecommitdiff
path: root/testsuite/tests/rename/should_fail/T18240b.stderr
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-06-09 18:13:35 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-30 07:10:42 -0400
commit71006532abb88a53df7c7e0b3a5e2c8af99a48d1 (patch)
treed8874dbdd68ce911a83374dd6e241a80153553fc /testsuite/tests/rename/should_fail/T18240b.stderr
parentbfa5698b1ab0190820a2df19487d3d72d3a7924d (diff)
downloadhaskell-71006532abb88a53df7c7e0b3a5e2c8af99a48d1.tar.gz
Reject nested foralls/contexts in instance types more consistently
GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271.
Diffstat (limited to 'testsuite/tests/rename/should_fail/T18240b.stderr')
-rw-r--r--testsuite/tests/rename/should_fail/T18240b.stderr24
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/rename/should_fail/T18240b.stderr b/testsuite/tests/rename/should_fail/T18240b.stderr
new file mode 100644
index 0000000000..330e5cc72f
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/T18240b.stderr
@@ -0,0 +1,24 @@
+
+T18240b.hs:17:15: error:
+ ‘via’ type cannot contain nested ‘forall’s or contexts
+ In a deriving declaration
+
+T18240b.hs:18:24: error:
+ ‘via’ type cannot contain nested ‘forall’s or contexts
+ In a deriving declaration
+
+T18240b.hs:19:25: error:
+ ‘via’ type cannot contain nested ‘forall’s or contexts
+ In a deriving declaration
+
+T18240b.hs:26:24: error:
+ Derived class type cannot contain nested ‘forall’s or contexts
+ In the data type declaration for ‘Bar’
+
+T18240b.hs:27:33: error:
+ Derived class type cannot contain nested ‘forall’s or contexts
+ In the data type declaration for ‘Bar’
+
+T18240b.hs:28:34: error:
+ Derived class type cannot contain nested ‘forall’s or contexts
+ In the data type declaration for ‘Bar’