dotnet / dotnet/fsharp

Consuming a CLIEvent uses hidden closures, disallowing `base.Event`

Open
#9,806 7 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-Accessibility Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Consuming an event creates a closure, requiring a `as self` reference. This doesn't seem necessary.

```fsharp
type A() =
[]
member val Event =
(new DelegateEvent()).Publish
type B() =
inherit A()
do base.Event.Add ignore // Error: 'base' values may only be used to make direct calls...
```

Even `let x = base.Event` is not allowed.

NOTE: the workaround is to use the implicit `add_Event` explicitly:

```fsharp
open System

type A() =
[]
member val Event =
(new DelegateEvent()).Publish
type B() =
inherit A()
do base.add_Event (fun _ _ -> ())
```

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.