Skip to content
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
1 change: 1 addition & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [Python] Add `Math.DivRem` support for int, int64, and bigint (by @dbrattli)
* [Python] Fix modulo with negative numbers using Python floored semantics instead of .NET truncated semantics for bigint (fixes #4462) (by @dbrattli)
* [Beam] Fix `System.String.Concat` with 4+ arguments not being supported (by @dbrattli)
* [TS/Python] Fix thisArg type for overloads in structs (#4453) (by @ncave)
* [TS/Python] Fix invalid `this` argument type in structs (#4453) (by @ncave)
* [JS/TS] Fix `N` format specifier (`ToString("N0")`, `String.Format("{0:N0}", ...)`) producing a trailing dot when precision is 0 (fix #2582) (by @MangelMaxime)
* [JS/TS] Fix `C0` and `P0` format specifiers producing trailing dot (e.g., `"¤1,000."` → `"¤1,000"`) (by @MangelMaxime)
Expand Down
1 change: 1 addition & 0 deletions src/Fable.Compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [Python] Add `Math.DivRem` support for int, int64, and bigint (by @dbrattli)
* [Python] Fix modulo with negative numbers using Python floored semantics instead of .NET truncated semantics for bigint (fixes #4462) (by @dbrattli)
* [Beam] Fix `System.String.Concat` with 4+ arguments not being supported (by @dbrattli)
* [TS/Python] Fix thisArg type for overloads in structs (#4453) (by @ncave)
* [TS/Python] Fix invalid `this` argument type in structs (#4453) (by @ncave)
* [JS/TS] Fix `N` format specifier (`ToString("N0")`, `String.Format("{0:N0}", ...)`) producing a trailing dot when precision is 0 (fix #2582) (by @MangelMaxime)
* [JS/TS] Fix `C0` and `P0` format specifiers producing trailing dot (e.g., `"¤1,000."` → `"¤1,000"`) (by @MangelMaxime)
Expand Down
7 changes: 6 additions & 1 deletion src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,12 @@ module Util =
let body =
// TODO: If ident is not captured maybe we can just replace it with "this"
if isIdentUsed thisArg.Name body then
let thisArgType =
match thisArg.Type with
| Replacements.Util.IsByRefType com typ -> typ
| typ -> typ

let thisArg = { thisArg with Type = thisArgType }
let thisIdent = Fable.IdentExpr { thisArg with Name = "this" }

let thisIdent =
Expand Down Expand Up @@ -3331,7 +3337,6 @@ but thanks to the optimisation done below we get
List.zip args tc.Args
|> List.map (fun (id, tcArg) ->
let ta = makeArgTypeAnnotation com ctx id

Parameter.parameter (tcArg, ?typeAnnotation = ta)
)

Expand Down
6 changes: 6 additions & 0 deletions src/Fable.Transforms/Python/Fable2Python.Transforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ let getMemberArgsAndBody (com: IPythonCompiler) ctx kind hasSpread (args: Fable.

let body =
if isIdentUsed thisArg.Name body then
let thisArgType =
match thisArg.Type with
| Replacements.Util.IsByRefType com typ -> typ
| typ -> typ

let thisArg = { thisArg with Type = thisArgType }
let thisKeyword = Fable.IdentExpr { thisArg with Name = "self" }

Fable.Let(thisArg, thisKeyword, body)
Expand Down
1 change: 1 addition & 0 deletions tests/Beam/TypeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ValueTypeR =
val mutable X: float
new(x: float) = { X = x }
member this.IsEmpty() = this.X < 0.0
override this.ToString() = $"{this.X}"

[<Struct>]
type StructUnion = Value of string
Expand Down
1 change: 1 addition & 0 deletions tests/Dart/src/TypeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ open Util
// val mutable X: float
// new(x: float) = { X = x }
// member this.IsEmpty() = this.X < 0.0
// override this.ToString() = $"{this.X}"

// [<Struct>]
// type StructUnion = Value of string
Expand Down
1 change: 1 addition & 0 deletions tests/Js/Main/TypeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ type ValueTypeR =
val mutable X: float
new(x: float) = { X = x }
member this.IsEmpty() = this.X < 0.0
override this.ToString() = $"{this.X}"

[<Struct>]
type StructUnion = Value of string
Expand Down
1 change: 1 addition & 0 deletions tests/Python/TestType.fs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
val mutable X: float
new(x: float) = { X = x }
member this.IsEmpty() = this.X < 0.0
override this.ToString() = $"{this.X}"

[<Struct>]
type StructUnion = Value of string
Expand Down Expand Up @@ -592,7 +593,7 @@

type IndexedProps(v: int) =
let mutable v = v
member _.Item with get (v2: int) = v + v2 and set v2 (s: string) = v <- v2 + int s

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (ubuntu-latest, 3.14)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (ubuntu-latest, 3.12)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (ubuntu-latest, 3.13)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (windows-latest, 3.12)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (windows-latest, 3.13)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 596 in tests/Python/TestType.fs

View workflow job for this annotation

GitHub Actions / build-python (windows-latest, 3.14)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.
member _.Item with get (v2: float) = float v + v2 / 2.

[<Interface>]
Expand Down
1 change: 1 addition & 0 deletions tests/Rust/tests/src/TypeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
val mutable X: float
new(x: float) = { X = x }
member this.IsEmpty() = this.X < 0.0
override this.ToString() = $"{this.X}"

[<Struct>]
type StructUnion = Value of string
Expand Down Expand Up @@ -513,7 +514,7 @@

type IndexedProps(v: int) =
let mutable v = v
member _.Item with get (v2: int) = v + v2 and set v2 (s: string) = v <- v2 + int s

Check warning on line 517 in tests/Rust/tests/src/TypeTests.fs

View workflow job for this annotation

GitHub Actions / build-rust (no_std)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 517 in tests/Rust/tests/src/TypeTests.fs

View workflow job for this annotation

GitHub Actions / build-rust (default)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.

Check warning on line 517 in tests/Rust/tests/src/TypeTests.fs

View workflow job for this annotation

GitHub Actions / build-rust (threaded)

An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'int' but setter of type 'string'.
member _.Item with get (v2: float) = float v + v2 / 2.

[<Interface>]
Expand Down
Loading