Skip to content

Commit 0eef9ef

Browse files
authored
[Rust] Fixed negative counting in CallInfo.GenericArgs (#4441)
1 parent 4c6c93a commit 0eef9ef

6 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/Fable.Cli/CHANGELOG.md

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

1010
### Fixed
1111

12+
* [Rust] Fixed negative counting in CallInfo.GenericArgs (by @ncave)
1213
* [JS/TS] Improve `Regex.Escape` and `Regex.Unescape` handling (by @MangelMaxime)
1314
* [All] Fix allow plugins to target .NET6 target framework (by @MangelMaxime)
1415
* [Python] Fix function references passed as arguments inside tail-call optimised functions gaining unnecessary default parameters for outer TCO variables they don't reference (fix #3877)

src/Fable.Compiler/CHANGELOG.md

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

1010
### Fixed
1111

12+
* [Rust] Fixed negative counting in CallInfo.GenericArgs (by @ncave)
1213
* [JS/TS] Improve `Regex.Escape` and `Regex.Unescape` handling (by @MangelMaxime)
1314
* [All] Fix allow plugins to target .NET6 target framework (by @MangelMaxime)
1415
* [Python] Fix function references passed as arguments inside tail-call optimised functions gaining unnecessary default parameters for outer TCO variables they don't reference (fix #3877)

src/Fable.Transforms/Rust/Fable2Rust.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,7 @@ module Util =
24082408
match membOpt with
24092409
| Some memb ->
24102410
let genArgsCount =
2411-
(List.length callInfo.GenericArgs) - (List.length memb.GenericParameters)
2411+
max 0 ((List.length callInfo.GenericArgs) - (List.length memb.GenericParameters))
24122412

24132413
let ownerGenArgs = callInfo.GenericArgs |> List.take genArgsCount
24142414
let membGenArgs = callInfo.GenericArgs |> List.skip genArgsCount

src/fable-standalone/test/bench-compiler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bench-compiler"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[[bin]]
77
name = "bench-compiler"

src/quicktest-rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "fable_quicktest_rust"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
fable_library_rust = { path = "../../temp/fable-library-rust" }

tests/Rust/tests/src/ApplicativeTests.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -631,16 +631,16 @@ let ``Trait calls work with record fields`` () =
631631
replaceById {Id=Id"ja"; Name="Voll"} ar |> Seq.head |> fun x -> equal "Sarah" x.Name
632632
replaceById {Id=Id"foo"; Name="Anna"} ar |> Seq.head |> fun x -> equal "Anna" x.Name
633633

634-
// [<Fact>]
635-
// let ``Nested trait calls work`` () = // See #2468
636-
// let i: int = parse "123"
637-
// let b: bool = parse "true"
638-
// let p: Parseable = parse ""
639-
// let h : DateTimeOffset = parse "2011-03-04T15:42:19+03:00"
640-
// equal 123 i
641-
// equal true b
642-
// equal Parseable p
643-
// equal (DateTimeOffset(2011, 3, 4, 15, 42, 19, TimeSpan.FromHours(3.))) h
634+
[<Fact>]
635+
let ``Nested trait calls work`` () = // See #2468
636+
let i: int = parse "123"
637+
let b: bool = parse "true"
638+
let p: Parseable = parse ""
639+
let h : DateTimeOffset = parse "2011-03-04T15:42:19+03:00"
640+
equal 123 i
641+
equal true b
642+
equal Parseable p
643+
equal (DateTimeOffset(2011, 3, 4, 15, 42, 19, TimeSpan.FromHours(3.))) h
644644

645645
[<Fact>]
646646
let ``Inline local function can call another inline function with trait call`` () =
@@ -1783,7 +1783,7 @@ module AccessorFunctionShorthand =
17831783
let inline namePropertyGetter<'a when 'a:(member Name: string)> (x: 'a) = x |> _.Name
17841784

17851785
[<Fact>]
1786-
let ``test Accessor function shorthand works for records`` () =
1786+
let ``Accessor function shorthand works for records`` () =
17871787
let people : AccessorFunctionShorthand.User list =
17881788
[
17891789
{ Name = "John" }
@@ -1794,7 +1794,7 @@ let ``test Accessor function shorthand works for records`` () =
17941794
equal names ["John"; "Jane"]
17951795

17961796
[<Fact>]
1797-
let ``test Accessor function shorthand works for anonymous records`` () =
1797+
let ``Accessor function shorthand works for anonymous records`` () =
17981798
let people =
17991799
[
18001800
{| Name = "John" |}

0 commit comments

Comments
 (0)