summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-10-24 10:39:50 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-30 18:52:50 -0400
commit31fcb55f4ff8c06c5ab100a6817cae8b571295a9 (patch)
treed7c46a6e6b9f0f7bdf807f7e6e27d2d593e83251 /testsuite
parent9902d9ec95dfc3ddb3e8a703de6b000c3ac3871a (diff)
downloadhaskell-31fcb55f4ff8c06c5ab100a6817cae8b571295a9.tar.gz
Split HsConDecl{H98,GADT}Details
Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr12
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr4
-rw-r--r--testsuite/tests/parser/should_compile/DumpRenamedAst.stderr2
-rw-r--r--testsuite/tests/parser/should_compile/T15323.stderr2
-rw-r--r--testsuite/tests/printer/T18791.stderr6
5 files changed, 14 insertions, 12 deletions
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
index 9af02d8c66..2e5452129b 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
@@ -386,7 +386,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:25:13-18 }
(HsAppTy
@@ -522,7 +522,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:31:13-18 }
(HsAppTy
@@ -658,7 +658,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:37:13-18 }
(HsAppTy
@@ -794,7 +794,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:43:13-18 }
(HsAppTy
@@ -930,7 +930,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:49:13-18 }
(HsAppTy
@@ -1066,7 +1066,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544.hs:55:14-20 }
(HsAppTy
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
index ccba2caf27..d1ff09f56c 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
@@ -39,7 +39,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[])
({ T17544_kw.hs:16:18-20 }
(HsTyVar
@@ -83,7 +83,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[(HsScaled
(HsUnrestrictedArrow
(NormalSyntax))
diff --git a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
index 599d369ff5..e869299a76 100644
--- a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
+++ b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
@@ -374,7 +374,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[(HsScaled
(HsUnrestrictedArrow
(NormalSyntax))
diff --git a/testsuite/tests/parser/should_compile/T15323.stderr b/testsuite/tests/parser/should_compile/T15323.stderr
index 0e2734dd48..8539599660 100644
--- a/testsuite/tests/parser/should_compile/T15323.stderr
+++ b/testsuite/tests/parser/should_compile/T15323.stderr
@@ -72,7 +72,7 @@
({ T15323.hs:6:35 }
(Unqual
{OccName: v}))))))))]))
- (PrefixCon
+ (PrefixConGADT
[])
({ T15323.hs:6:41-54 }
(HsAppTy
diff --git a/testsuite/tests/printer/T18791.stderr b/testsuite/tests/printer/T18791.stderr
index 09aee04678..e245ef0fbe 100644
--- a/testsuite/tests/printer/T18791.stderr
+++ b/testsuite/tests/printer/T18791.stderr
@@ -39,7 +39,7 @@
(False))
[]
(Nothing)
- (PrefixCon
+ (PrefixConGADT
[(HsScaled
(HsUnrestrictedArrow
(NormalSyntax))
@@ -61,4 +61,6 @@
({ <no location info> }
[])))))]
(Nothing)
- (Nothing))) \ No newline at end of file
+ (Nothing)))
+
+