Conversation
… map, type conversions, isinstance, bytes Adds 15 new [<Fact>] tests for builtins that were bound in Builtins.fs but had no test coverage: - abs (int and float) - chr / ord (and round-trip) - len (list and string) - map (single and two-iterable overloads) - str / int / float type conversions - isinstance / type - bytes (from byte array and from string with encoding) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`len` on an F# `int list` fails because FSharpList has no `__len__`; convert via `builtins.list` instead. Drop the two-iterable `map` case — the binding's `'T1 * 'T2 -> 'T3` signature compiles to a tuple-input function but Python's `map` calls `f(a, b)` positionally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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>
240b2bf to
2040e42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds tests for builtins that were bound but had no coverage, and fixes a binding bug uncovered by the new tests.
🐞 Bug fix
builtins.map2- and 3-iterable overloads — the function parameter was typed as'T1 * 'T2 -> 'T3(tuple-input), which Fable compiles to a Python function expecting a single tuple argument. But Python'smap(f, it1, it2)callsf(a, b)positionally, so the overloads failed at runtime withTypeError: takes 1 positional argument but 2 were given. Switched both overloads toSystem.Func<...>, matching the pattern already used byfunctools.reduceanditertools.accumulate. Call sites use the natural curried form:builtins.map ((fun a b -> a + b), xs, ys).🧪 Tests
Adds 17 new
[<Fact>]tests covering builtins that had zero coverage:abschr/ordlenmapstrintfloatisinstancepyInt/pyStrtype references withemitPyExprtypebytesisinstance/typetests useemitPyExprto construct genuine Python primitives (per the comment in the existingpyInstanceoftest), since F#int/float/boolcompile to Fable wrapper classes.Notes
mainto pick up the type references andpyInt/pyStrhelpers from feat(stdlib): expose Python type references and dict/list constructors in Builtins #291.CHANGELOG.mdentry — assumed to be auto-generated from commit messages.CI will validate that the Fable-compiled Python passes all assertions.