Skip to content

Commit 2040e42

Browse files
dbrattliclaude
andcommitted
fix(stdlib): builtins.map multi-iterable overloads use System.Func
The 2- and 3-iterable overloads typed the function as `'T1 * 'T2 -> 'T3` (tuple-input), which Fable compiles to a Python function expecting a single tuple arg. But Python's `map(f, it1, it2)` calls `f(a, b)` positionally, so calls failed with "takes 1 positional argument but 2 were given". Switching to `System.Func<...>` produces a Python function with the correct positional arity. Restores the two-iterable test and adds a three-iterable test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 214a046 commit 2040e42

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/stdlib/Builtins.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,12 @@ type IExports =
186186

187187
/// Make an iterator that computes the function using arguments from each
188188
/// of the iterables. Stops when the shortest iterable is exhausted.
189-
abstract map: ('T1 * 'T2 -> 'T3) * IEnumerable<'T1> * IEnumerable<'T2> -> IEnumerable<'T3>
189+
abstract map: System.Func<'T1, 'T2, 'T3> * IEnumerable<'T1> * IEnumerable<'T2> -> IEnumerable<'T3>
190190

191191
/// Make an iterator that computes the function using arguments from each
192192
/// of the iterables. Stops when the shortest iterable is exhausted.
193-
abstract map: ('T1 * 'T2 * 'T3 -> 'T4) * IEnumerable<'T1> * IEnumerable<'T2> * IEnumerable<'T3> -> IEnumerable<'T4>
193+
abstract map:
194+
System.Func<'T1, 'T2, 'T3, 'T4> * IEnumerable<'T1> * IEnumerable<'T2> * IEnumerable<'T3> -> IEnumerable<'T4>
194195

195196
/// Return the Unicode code point for a one-character string.
196197
abstract ord: char -> int

test/TestBuiltins.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ let ``test map with single iterable works`` () =
162162
|> Seq.toList
163163
|> equal [ 2; 4; 6 ]
164164

165+
[<Fact>]
166+
let ``test map with two iterables works`` () =
167+
builtins.map ((fun a b -> a + b), [ 1; 2; 3 ], [ 10; 20; 30 ])
168+
|> Seq.toList
169+
|> equal [ 11; 22; 33 ]
170+
171+
[<Fact>]
172+
let ``test map with three iterables works`` () =
173+
builtins.map ((fun a b c -> a + b + c), [ 1; 2; 3 ], [ 10; 20; 30 ], [ 100; 200; 300 ])
174+
|> Seq.toList
175+
|> equal [ 111; 222; 333 ]
176+
165177
[<Fact>]
166178
let ``test str conversion works`` () =
167179
builtins.str 42 |> equal "42"

0 commit comments

Comments
 (0)