dotnet / dotnet/fsharp

Some checks don't be performed on F#-style extension methods

Open
#19,227 0 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Bug
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

These checks don't be performed on F#-style extension methods.

https://github.com/dotnet/fsharp/blob/a9d3eade1d29e4c7ab1dfbf71b911d038cc6ebd9/src/Compiler/Checking/PostInferenceChecks.fs#L2407-L2477

**Repro steps**

Put this code into fsi:
```fsharp
open System.Runtime.CompilerServices;;

[]
type C =
// FS0440: Methods with curried arguments cannot declare 'out', 'ParamArray', 'optional', 'ReflectedDefinition', 'byref', 'CallerLineNumber', 'CallerMemberName', or 'CallerFilePath' arguments
[]
static member B(this: obj)(arg: string outref) = ()
// FS1246: 'CallerLineNumber' must be applied to an argument of type 'int', but has been applied to an argument of type 'string'
[]
static member C(this: obj, [] ?line: string) = ()
;;

type System.Object with
// No error
member this.B()(arg: string outref) = ()
// No error
member this.C([] ?line: string) = ()
;;
```

**Expected behavior**

Both C#-style and F#-style extension methods give the same error reports.

**Actual behavior**

Only C#-style extension methods gives the error reports.

**Known workarounds**

Not using F#-style extension methods.

**Related information**

* Microsoft (R) F# Interactive version F# 10.0 的 14.0.101.0
* .NET 10.0.101

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.