Conversation
… expressions When an F# interface has a [<CLIEvent>] member, FCS exposes it as three members: the event property itself (e.g. 'SomethingChanged'), plus the add_/remove_ accessor methods. Python's transformInterface included all three in the generated Protocol class as abstract members. However, transformObjectExpr only generates add_/remove_ methods for CLIEvent members — it never generates the event property override. This left the Protocol with an unimplementable abstract member, causing mypy/pyright type errors when using object expressions that implement interfaces with [<CLIEvent>] members. Fix: identify CLIEvent property members by checking whether a companion add_<name> member exists in the same interface, and exclude them from the Protocol. The add_/remove_ methods are retained as they correctly model the subscription mechanism. Fixes #3039 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The CLIEvent property getter has CompiledName "get_Event" (with prefix) but DisplayName "Event", so the original CompiledName check never matched. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
Satisfies Ionide analyzer warning about implicit string comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
93 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3039
Root Cause
When an F# interface has a
[<CLIEvent>]member, FCS exposes it as three members inMembersFunctionsAndValues:EventwithCompiledName = "get_Event",IsGetter = true)add_Event— the subscribe accessorremove_Event— the unsubscribe accessorPython's
transformInterfaceincluded the event property getter in the generatedProtocolclass as an abstract member. However,transformObjectExpronly generatesadd_*/remove_*method overrides for[<CLIEvent>]members — it never generates an override for the event property getter. This left the Protocol with an unimplementable abstract member, causing type errors at every object expression implementing such an interface.Fix
In
transformInterface(Fable2Python.Transforms.fs), after collecting members, identify CLIEvent property members by checking whether a companionadd_<name>member exists. If so, exclude the event property from the Protocol usingDisplayNamematching (notCompiledName, since the getter hasCompiledName = "get_Event"while the extracted name fromadd_Eventis"Event"). Theadd_*/remove_*accessors are retained.Test
The previously commented-out test
"test Generic interface expression can have CLI events"intests/Python/TestEvent.fshas been reinstated (by the original bot PR). All 2267 Python tests pass.Notes
🤖 Generated with Claude Code