Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/fsharp/vs/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,21 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =

| V v ->
match v.ValReprInfo with
| None -> failwith "not a module let binding or member"
| None ->
let _, tau = v.TypeScheme
if isFunTy cenv.g tau then
let typeArguments, _typ = stripFunTy cenv.g tau
[ for typ in typeArguments do
let allArguments =
if isTupleTy cenv.g typ
then tryDestTupleTy cenv.g typ
else [typ]
yield
allArguments
|> List.map (fun arg -> FSharpParameter(cenv, arg, { Name=None; Attribs= [] }, x.DeclarationLocationOpt, false, false, false))
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
else makeReadOnlyCollection []
| Some (ValReprInfo(_typars,curriedArgInfos,_retInfo)) ->
let tau = v.TauType
let argtysl,_ = GetTopTauTypeInFSharpForm cenv.g curriedArgInfos tau range0
Expand Down
60 changes: 60 additions & 0 deletions tests/service/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4325,3 +4325,63 @@ let ``Test project34 should report correct accessibility for System.Data.Listene
|> Option.get

listenerFuncEntity.Accessibility.IsPrivate |> shouldEqual true

module Project35 =
open System.IO

let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs")
let base2 = Path.GetTempFileName()
let dllName = Path.ChangeExtension(base2, ".dll")
let projFileName = Path.ChangeExtension(base2, ".fsproj")
let fileSource1 = """
type Test =
let curriedFunction (one:int) (two:float) (three:string) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ValReprInfo = None for these declarations today? From the look of what you have above, I was expecting the test case to be a function defined in an expression:

let Test() =
     let curriedFunction (one:int) (two:float) (three:string) = ...

not a function defined in a class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let bindings in a type have no ValReprInfo either, thats why Ive always moaned about CurrendParameterGroups

one + int two + int three
let tupleFunction (one:int, two:float, three:string) =
one + int two + int three
"""
File.WriteAllText(fileName1, fileSource1)
let cleanFileName a = if a = fileName1 then "file1" else "??"

let fileNames = [fileName1]
let args = mkProjectCommandLineArgs (dllName, fileNames)
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)


[<Test>]
let ``Test project35 CurriedParameterGroups should be available for nested functions`` () =
let wholeProjectResults = checker.ParseAndCheckProject(Project35.options) |> Async.RunSynchronously
let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously
let findByDisplayName name =
Array.find (fun (su:FSharpSymbolUse) -> su.Symbol.DisplayName = name)

let curriedFunction = allSymbolUses |> findByDisplayName "curriedFunction"
match curriedFunction.Symbol with
| :? FSharpMemberOrFunctionOrValue as mfv ->
let curriedParamGroups =
mfv.CurriedParameterGroups
|> Seq.map Seq.toList
|> Seq.toList
match curriedParamGroups with
| [[param1];[param2];[param3]] ->
param1.Type.TypeDefinition.DisplayName |> should equal "int"
param2.Type.TypeDefinition.DisplayName |> should equal "float"
param3.Type.TypeDefinition.DisplayName |> should equal "string"
| _ -> failwith "Unexpected parameters"
| _ -> failwith "Unexpected symbol type"

let tupledFunction = allSymbolUses |> findByDisplayName "tupleFunction"
match tupledFunction.Symbol with
| :? FSharpMemberOrFunctionOrValue as mfv ->
let curriedParamGroups =
mfv.CurriedParameterGroups
|> Seq.map Seq.toList
|> Seq.toList
match curriedParamGroups with
| [[param1;param2;param3]] ->
param1.Type.TypeDefinition.DisplayName |> should equal "int"
param2.Type.TypeDefinition.DisplayName |> should equal "float"
param3.Type.TypeDefinition.DisplayName |> should equal "string"
| _ -> failwith "Unexpected parameters"
| _ -> failwith "Unexpected symbol type"