Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve extension method when it shadows a property on a type #12751

Closed
baronfel opened this issue Feb 20, 2022 · 3 comments
Closed

Can't resolve extension method when it shadows a property on a type #12751

baronfel opened this issue Feb 20, 2022 · 3 comments
Labels

Comments

@baronfel
Copy link
Member

baronfel commented Feb 20, 2022

Repro steps

Given the following F# Script that uses Spectre.Console, similar code from the C# examples cannot be compiled without a lot of gymnastics:

#r "nuget: Spectre.Console"

open Spectre.Console

// explicit usage of the extension method works
let t = HasTableBorderExtensions.Border(Table(), TableBorder.Square)
// expected usage of the extension method fails to compile - the compiler picks the Property on the type instead, which isn't a method
// Table.Border: TableBorder with get, set
let t' = Table().Border(TableBorder.Square)

Expected behavior

The compiler chooses the extension method that is in scope from the library.

Actual behavior

The compiler gives FS0003 (This value is not a function and cannot be applied) because it's expecting a property rather than a method.

Known workarounds

See the usage directly above, but the extension method that is in scope can be used directly. This is far less than ideal because a) the entire library is built around this sort of wrapping-builder pattern, and b) Spectre.Console is a very high-profile library in .NET in the space of command-line tooling.

Related information

This is on F# 6 on the 6.0.200 SDK.

@baronfel baronfel added the Bug label Feb 20, 2022
@baronfel
Copy link
Member Author

I'm not actually sure this is a bug but it may require the RFC process, as it changes the method overload resolution logic.

@vzarytovskii
Copy link
Member

Looks like a duplicate of fsharp/fslang-suggestions#1039

@baronfel
Copy link
Member Author

Good find, I'll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants