Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
a7798e95
Commit
a7798e95
authored
Jun 25, 2013
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments for Trac #7989
parent
d67b9934
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
compiler/typecheck/TcExpr.lhs
compiler/typecheck/TcExpr.lhs
+27
-1
No files found.
compiler/typecheck/TcExpr.lhs
View file @
a7798e95
...
@@ -1519,9 +1519,10 @@ badFieldsUpd
...
@@ -1519,9 +1519,10 @@ badFieldsUpd
badFieldsUpd rbinds data_cons
badFieldsUpd rbinds data_cons
= hang (ptext (sLit "No constructor has all these fields:"))
= hang (ptext (sLit "No constructor has all these fields:"))
2 (pprQuotedList conflictingFields)
2 (pprQuotedList conflictingFields)
-- See Note [Finding the conflicting fields]
where
where
-- A (preferably small) set of fields such that no constructor contains
-- A (preferably small) set of fields such that no constructor contains
-- all of them.
-- all of them.
See Note [Finding the conflicting fields]
conflictingFields = case nonMembers of
conflictingFields = case nonMembers of
-- nonMember belongs to a different type.
-- nonMember belongs to a different type.
(nonMember, _) : _ -> [aMember, nonMember]
(nonMember, _) : _ -> [aMember, nonMember]
...
@@ -1560,7 +1561,32 @@ badFieldsUpd rbinds data_cons
...
@@ -1560,7 +1561,32 @@ badFieldsUpd rbinds data_cons
map (\ item@(_, membershipRow) -> (countTrue membershipRow, item))
map (\ item@(_, membershipRow) -> (countTrue membershipRow, item))
countTrue = length . filter id
countTrue = length . filter id
\end{code}
Note [Finding the conflicting fields]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have
data A = A {a0, a1 :: Int}
| B {b0, b1 :: Int}
and we see a record update
x { a0 = 3, a1 = 2, b0 = 4, b1 = 5 }
Then we'd like to find the smallest subset of fields that no
constructor has all of. Here, say, {a0,b0}, or {a0,b1}, etc.
We don't really want to report that no constructor has all of
{a0,a1,b0,b1}, because when there are hundreds of fields it's
hard to see what was really wrong.
We may need more than two fields, though; eg
data T = A { x,y :: Int, v::Int }
| B { y,z :: Int, v::Int }
| C { z,x :: Int, v::Int }
with update
r { x=e1, y=e2, z=e3 }, we
Finding the smallest subset is hard, so the code here makes
a decent stab, no more. See Trac #7989.
\begin{code}
naughtyRecordSel :: TcId -> SDoc
naughtyRecordSel :: TcId -> SDoc
naughtyRecordSel sel_id
naughtyRecordSel sel_id
= ptext (sLit "Cannot use record selector") <+> quotes (ppr sel_id) <+>
= ptext (sLit "Cannot use record selector") <+> quotes (ppr sel_id) <+>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment