Skip to content

Commit 3397038

Browse files
[Python] Fix #3998: PhysicalEquality
1 parent ffc6ee9 commit 3397038

5 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/Fable.Cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
12+
* [Python] - Fix #3998: PhysicalEquality (by @alfonsogarciacaro)
13+
1014
### Added
1115

1216
* [Python] - Print root module and module function comments (by @alfonsogarciacaro)

src/Fable.Compiler/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
12+
* [Python] - Fix #3998: PhysicalEquality (by @alfonsogarciacaro)
13+
1014
### Added
1115

1216
* [Python] - Print root module and module function comments (by @alfonsogarciacaro)

src/Fable.Transforms/Python/Replacements.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,8 @@ let languagePrimitives (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisAr
22692269
[ comp; left; right ] ->
22702270
Helper.InstanceCall(comp, "Equals", t, [ left; right ], i.SignatureArgTypes, ?loc = r)
22712271
|> Some
2272-
| ("PhysicalEquality" | "PhysicalEqualityIntrinsic"), [ left; right ] -> makeEqOp r left right BinaryEqual |> Some
2272+
| ("PhysicalEquality" | "PhysicalEqualityIntrinsic"), [ left; right ] ->
2273+
makeEqOpStrict r left right BinaryEqual |> Some
22732274
| ("PhysicalHash" | "PhysicalHashIntrinsic"), [ arg ] ->
22742275
Helper.LibCall(com, "util", "physicalHash", Int32.Number, [ arg ], ?loc = r)
22752276
|> Some

src/Fable.Transforms/Replacements.Util.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ let withTag tag =
179179
function
180180
| Call(e, i, t, r) -> Call(e, { i with Tags = tag :: i.Tags }, t, r)
181181
| Get(e, FieldGet i, t, r) -> Get(e, FieldGet { i with Tags = tag :: i.Tags }, t, r)
182+
| Operation(op, tags, t, r) -> Operation(op, tag :: tags, t, r)
182183
| e -> e
183184

184185
let getTags =

tests/Python/TestComparison.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ type Status =
6969
type MyClass(v) =
7070
member val Value: int = v with get, set
7171

72+
[<Fact>]
73+
let ``test PhysicalEquality works`` () = // See #3998
74+
let r1 = ResizeArray([1; 2])
75+
let r2 = ResizeArray([1; 2])
76+
let r3 = r1
77+
78+
LanguagePrimitives.PhysicalEquality r1 r2 |> equal false
79+
LanguagePrimitives.PhysicalEquality r2 r2 |> equal true
80+
LanguagePrimitives.PhysicalEquality r3 r1 |> equal true
81+
7282
[<Fact>]
7383
let ``test Typed array equality works`` () =
7484
let xs1 = [| 1; 2; 3 |]

0 commit comments

Comments
 (0)