Skip to content

Commit

Permalink
Use similar leaf-node logic on other mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Aug 30, 2024
1 parent 83ed1ad commit 108ed55
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions unison-cli/src/Unison/LSP/FileAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,9 @@ analyseNotes codebase fileUri ppe src notes = do
Result.TypeError errNote@(Context.ErrorNote {cause}) -> do
let typeErr = TypeError.typeErrorFromNote errNote
ranges = case typeErr of
TypeError.Mismatch {mismatchSite} -> do
let locs = ABT.annotation <$> expressionLeafNodes mismatchSite
(r, rs) <- withNeighbours (locs >>= aToR)
pure (r, ("mismatch",) <$> rs)
TypeError.BooleanMismatch {mismatchSite} -> singleRange $ ABT.annotation mismatchSite
TypeError.ExistentialMismatch {mismatchSite} -> singleRange $ ABT.annotation mismatchSite
TypeError.Mismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite
TypeError.BooleanMismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite
TypeError.ExistentialMismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite
TypeError.FunctionApplication {f} -> singleRange $ ABT.annotation f
TypeError.NotFunctionApplication {f} -> singleRange $ ABT.annotation f
TypeError.AbilityCheckFailure {abilityCheckFailureSite} -> singleRange abilityCheckFailureSite
Expand Down Expand Up @@ -323,6 +320,10 @@ analyseNotes codebase fileUri ppe src notes = do
Context.OtherBug _s -> todoAnnotation
pure (noteDiagnostic note ranges, [])
where
leafNodeRanges label mismatchSite = do
let locs = ABT.annotation <$> expressionLeafNodes mismatchSite
(r, rs) <- withNeighbours (locs >>= aToR)
pure (r, (label,) <$> rs)
-- Diagnostics with this return value haven't been properly configured yet.
todoAnnotation = []
singleRange :: Ann -> [(Range, [a])]
Expand Down

0 comments on commit 108ed55

Please sign in to comment.