safesparrow / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
1 stars 0 forks source link

Provide a unit testing tool that compares the resolved dependency graph with one inferred from a TypedTree. #22

Open safesparrow opened 1 year ago

safesparrow commented 1 year ago

MVP with an example merged in https://github.com/safesparrow/fsharp/pull/18 .

We should productionise/generalise it if it's not already clean/generic enough.

nojaf commented 1 year ago

An interesting case I just found is the following:

// A.fs
module A

type A = int

// B.fs
module B 

open A
let b () : A array = [| 0 |]

// C.fs
module C

// The typed tree knows what type A is!
let c = B.b () 

In our current detection we see the following:

A: []
B: [ A ]
C: [ B ]

The typed tree however knows that c is of type A. So it sees this instead:

A: []
B: [ A ]
C: [ A; B ]

This doesn't really affect the outcome of the heuristic. When type-checking A will be known before C is checked. But it does yield incomplete results in the assertion of #18.

I guess to compare both graphs we should include all dependencies as well.

safesparrow commented 1 year ago

Yes, we should either compare transitive closures of the graphs or trim the graph from the TypedTree and remove duplicates. The former is much easier (eg. Graph transitiveOpt) so probably what we should do.