Emil Kantis
Emil Kantis

Reputation: 1114

Conflicting constructors in imported C# lib

I can't really describe what's going on here any better than this screenshot:

the problem

The tooltip says the return type of the constructor is unit, while the "new" part says it should be Repository. Obviously a constructor should return an instance of the class itself, so why does it return unit?

Full source available at https://github.com/Kantis/GitSemVer

Upvotes: 1

Views: 68

Answers (1)

latkin
latkin

Reputation: 16792

Tagging constructors with unit is just a convention for tooltips, it doesn't affect the actual compilation. I guess it's true that it's a bit weird/inconsistent, compared to the details shown below.

Your code is fine as-is, the squiggles on let are just because CalculateVersion does not yet contain a complete expression. If you add a return value it works fine:

let CalculateVersion(path:string) =
    let repo = new LibGit2Sharp.Repository(path)
    42  // return something

Upvotes: 4

Related Questions