-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1102 from forki/error1
Elm-like compiler errors for name resolution
- Loading branch information
Showing
26 changed files
with
673 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
/// Functions to format error message details | ||
module internal Microsoft.FSharp.Compiler.ErrorResolutionHints | ||
|
||
/// Filters predictions based on edit distance to an unknown identifier. | ||
let FilterPredictions unknownIdent allPredictions = | ||
let rec take n predictions = | ||
predictions | ||
|> Seq.mapi (fun i x -> i,x) | ||
|> Seq.takeWhile (fun (i,_) -> i < n) | ||
|> Seq.map snd | ||
|> Seq.toList | ||
|
||
allPredictions | ||
|> Seq.toList | ||
|> List.distinct | ||
|> List.sortBy (fun s -> Internal.Utilities.EditDistance.CalcEditDistance(unknownIdent,s)) | ||
|> take 5 | ||
|
||
let FormatPredictions predictions = | ||
match predictions with | ||
| [] -> System.String.Empty | ||
| _ -> | ||
let predictionText = | ||
predictions | ||
|> Seq.map (sprintf "%s %s" System.Environment.NewLine) | ||
|> String.concat "" | ||
System.Environment.NewLine + FSComp.SR.undefinedNameRecordLabelDetails() + predictionText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.