Commit 824637e
committed
Fix: preserve type applications in record patterns (fixes #1679)
When suggesting record patterns, check if the constructor has meaningful
type applications (e.g. @int, @type). Type applications can be removed only if:
1. There are no type arguments, OR
2. All type arguments are wildcards (@_)
This prevents HLint from suggesting invalid transformations that would
remove necessary type information.
Examples:
Ast.AstScatterS @_ @Shn1 @shp1 _ _ _ _ _
✓ Suggests: Ast.AstScatterS {} (wildcards can be omitted)
Ast.AstScatterS @A @Shn1 @shp1 _ _ _ _ _
✗ No suggestion (meaningful type apps must be preserved)
Test cases:
- foo (Bar _ _ _ _) = x → suggests Bar{}
- foo (Bar @_ _ _ _) = x → suggests Bar{} (@_ is redundant)
- foo (Bar @int _ _ _) = x → no suggestion (type app preserved)1 parent ddbcc5a commit 824637e
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| |||
200 | 198 | | |
201 | 199 | | |
202 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
203 | 210 | | |
204 | 211 | | |
205 | | - | |
| 212 | + | |
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
| |||
0 commit comments