Skip to content

Commit ce7eba9

Browse files
dbrattliclaude
andauthored
[Beam] Fix System.String.Concat with 4+ arguments (#4459)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8ae38af commit ce7eba9

4 files changed

Lines changed: 14 additions & 1 deletion

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+
* [Beam] Fix `System.String.Concat` with 4+ arguments not being supported (by @dbrattli)
1213
* [TS/Python] Fix invalid `this` argument type in structs (#4453) (by @ncave)
1314
* [JS/TS] Fix `N` format specifier (`ToString("N0")`, `String.Format("{0:N0}", ...)`) producing a trailing dot when precision is 0 (fix #2582) (by @MangelMaxime)
1415
* [JS/TS] Fix `C0` and `P0` format specifiers producing trailing dot (e.g., `"¤1,000."``"¤1,000"`) (by @MangelMaxime)

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+
* [Beam] Fix `System.String.Concat` with 4+ arguments not being supported (by @dbrattli)
1213
* [TS/Python] Fix invalid `this` argument type in structs (#4453) (by @ncave)
1314
* [JS/TS] Fix `N` format specifier (`ToString("N0")`, `String.Format("{0:N0}", ...)`) producing a trailing dot when precision is 0 (fix #2582) (by @MangelMaxime)
1415
* [JS/TS] Fix `C0` and `P0` format specifiers producing trailing dot (e.g., `"¤1,000."``"¤1,000"`) (by @MangelMaxime)

src/Fable.Transforms/Beam/Replacements.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,14 @@ let private strings
940940
| [ items ] -> emitExpr r t [ items ] "fable_string:concat($0)" |> Some
941941
| [ a; b ] -> emitExpr r t [ a; b ] "iolist_to_binary([$0, $1])" |> Some
942942
| [ a; b; c ] -> emitExpr r t [ a; b; c ] "iolist_to_binary([$0, $1, $2])" |> Some
943-
| _ -> None
943+
| _ ->
944+
let argsList =
945+
List.foldBack
946+
(fun arg acc -> Value(NewList(Some(arg, acc), String), None))
947+
args
948+
(Value(NewList(None, String), None))
949+
950+
emitExpr r t [ argsList ] "fable_string:concat($0)" |> Some
944951
// String.Compare
945952
| "Compare", None, [ a; b ] -> Helper.LibCall(com, "fable_string", "compare", t, [ a; b ]) |> Some
946953
| "Compare", None, [ a; b; compType ] ->

tests/Beam/StringTests.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ let ``test String.Compare with StringComparison works`` () =
410410
let ``test System.String.Concat works`` () =
411411
String.Concat("a", "b", "c") |> equal "abc"
412412

413+
[<Fact>]
414+
let ``test System.String.Concat with 4 args works`` () =
415+
String.Concat("a", "b", "c", "d") |> equal "abcd"
416+
413417
// --- String constructors ---
414418

415419
[<Fact>]

0 commit comments

Comments
 (0)