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

Fixed #3915 #3917

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [GH-3900](https://github.com/fable-compiler/Fable/pull/3900) [Python] Fix nuget packages with hypens in their names (by @MangelMaxime)
* [Rust] Uncurry field types for object expressions (by @ncave)
* [Rust] Fixed pattern matching on `this` argument (by @ncave)
* [All] Fixed Missing DU member with interface (#3915) (by @ncave)
* [TS] Fixed missing Async type signature (#3864) (by @MangelMaxime)

## 4.21.0 - 2024-09-19
Expand Down
9 changes: 7 additions & 2 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,13 @@ module Patterns =
let (|UnionCaseTesterFor|_|) (memb: FSharpMemberOrFunctionOrValue) =
match memb.DeclaringEntity with
| Some ent when ent.IsFSharpUnion ->
// if memb.IsUnionCaseTester then // TODO: this currently fails, use when fixed
if memb.IsPropertyGetterMethod && memb.LogicalName.StartsWith("get_Is") then
// if memb.IsUnionCaseTester then // insufficient, could be an interface member
if
memb.IsPropertyGetterMethod
&& not memb.IsDispatchSlot
&& not memb.IsOverrideOrExplicitInterfaceImplementation
&& memb.LogicalName.StartsWith("get_Is")
then
let unionCaseName = memb.LogicalName |> Naming.replacePrefix "get_Is" ""
ent.UnionCases |> Seq.tryFind (fun uc -> uc.Name = unionCaseName)
else
Expand Down
11 changes: 9 additions & 2 deletions src/Fable.Transforms/Rust/Fable2Rust.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,11 @@ module Util =
else
mkGenericPathExpr (splitNameParts ident.Name) None

let isThisArgumentIdentExpr (expr: Fable.Expr) =
match expr with
| Fable.IdentExpr ident -> ident.IsThisArgument
| _ -> false

// let transformExprMaybeIdentExpr (com: IRustCompiler) ctx (expr: Fable.Expr) =
// match expr with
// | Fable.IdentExpr ident when ident.IsThisArgument ->
Expand Down Expand Up @@ -1602,7 +1607,9 @@ module Util =
let prepareRefForPatternMatch (com: IRustCompiler) ctx typ (name: string option) fableExpr =
let expr = com.TransformExpr(ctx, fableExpr)

if (name.IsSome && isRefScoped ctx name.Value) || (isInRefType com typ) then
if isThisArgumentIdentExpr fableExpr then
expr
elif (name.IsSome && isRefScoped ctx name.Value) || (isInRefType com typ) then
expr
elif shouldBeRefCountWrapped com ctx typ |> Option.isSome then
expr |> makeAsRef
Expand Down Expand Up @@ -4576,7 +4583,7 @@ module Util =
let isIgnoredMember (memb: Fable.MemberFunctionOrValue) = ent.IsFSharpExceptionDeclaration // to filter out compiler-generated exception equality

let isInterfaceMember (memb: Fable.MemberFunctionOrValue) =
memb.IsDispatchSlot
(memb.IsDispatchSlot || memb.IsOverrideOrExplicitInterfaceImplementation)
&& (memb.DeclaringEntity
|> Option.bind com.TryGetEntity
|> Option.map (fun ent -> ent.IsInterface)
Expand Down
Loading