Skip to content

Commit 7f4bc58

Browse files
dbrattliclaude
andcommitted
fix(sys): type maxsize as nativeint instead of int
Python's sys.maxsize is 2^63−1 on 64-bit systems, which overflows Fable's Int32 (the target type for F# int). nativeint maps to Python's native int, preserving the full value. Re-adds the maxsize positivity test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aef8090 commit 7f4bc58

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/stdlib/Sys.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type IExports =
3535
/// Version information encoded as a single integer
3636
abstract hexversion: int
3737
/// Maximum value a variable of type int can take
38-
abstract maxsize: int
38+
abstract maxsize: nativeint
3939
/// Maximum Unicode code point value
4040
abstract maxunicode: int
4141
/// Module search path - list of directory names where Python looks for modules

‎test/TestSys.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ let ``test sys.platform is non-empty string`` () =
1111
let ``test sys.version is non-empty string`` () =
1212
sys.version.Length > 0 |> equal true
1313

14+
[<Fact>]
15+
let ``test sys.maxsize is positive`` () =
16+
sys.maxsize > 0n |> equal true
17+
1418
[<Fact>]
1519
let ``test sys.maxunicode is 1114111`` () =
1620
sys.maxunicode |> equal 1114111

0 commit comments

Comments
 (0)