Skip to content

Commit

Permalink
Suggestions for mispelled values - fixes dotnet#1909
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 2, 2016
1 parent 88a4cff commit dd1b41d
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2115,10 +2115,11 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) fullyQualified m ad n
Some (FreshenUnqualifiedItem ncenv m res, [])
| None ->
None

match envSearch with
| Some res -> res
| None ->
let search =
let innerSearch =
// Check if it's a type name, e.g. a constructor call or a type instantiation
let ctorSearch =
let tcrefs = LookupTypeNameInEnvMaybeHaveArity fullyQualified id.idText typeNameResInfo nenv
Expand All @@ -2131,12 +2132,24 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) fullyQualified m ad n
let implicitOpSearch =
if IsMangledOpName id.idText then
success [(resInfo,Item.ImplicitOp(id, ref None),[])]
else NoResultsOrUsefulErrors
else
NoResultsOrUsefulErrors


ctorSearch +++ implicitOpSearch

let resInfo,item,rest =
match AtMostOneResult m innerSearch with
| Result _ as res -> ForceRaise res
| _ ->
let predictedNames =
nenv.eUnqualifiedItems
|> Seq.map (fun e -> e.Value.DisplayName)
|> Set.ofSeq

let failingCase = raze (UndefinedName(0,FSComp.SR.undefinedNameValueOfConstructor,id,NoPredictions))
ctorSearch +++ implicitOpSearch +++ failingCase
let failingCase = raze (UndefinedName(0,FSComp.SR.undefinedNameValueOfConstructor,id,predictedNames))
ForceRaise failingCase

let resInfo,item,rest = ForceRaise (AtMostOneResult m search)
ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item))
item,rest

Expand Down

0 comments on commit dd1b41d

Please sign in to comment.