Description
Some array expressions fail to compile with the following error message: Error in pass3 for type Program, error: ldelem
. This is easily reproduced with the latest F# 9 (.NET 9) on Windows.
Repro steps
let arr1 = [| 0; 1; 2; 3 |]
let arr2 = [| 0UL; 1UL; 2UL; 3UL |]
let wrap x = [| x |]
let good = [| for a in arr1 do wrap a |]
let bad = [| for a in arr2 do wrap a |] // this is causing the prob
When copy-paste the above code to dotnet fsi
, the last line produces the error:
> let bad = [| for a in arr2 do wrap a |];;
error FS0192: internal error: Error in pass3 for type <StartupCode$FSI_0003>.$FSI_0003, error: ldelem
Expected behavior
It should compile.
Actual behavior
Internal error
Known workarounds
By using F# 8 (.NET 8) the same code compiles:
> let arr1 = [| 0; 1; 2; 3 |]
- let arr2 = [| 0UL; 1UL; 2UL; 3UL |]
- let wrap x = [| x |]
- let good = [| for a in arr1 do wrap a |]
- let bad = [| for a in arr2 do wrap a |];;
val arr1: int array = [|0; 1; 2; 3|]
val arr2: uint64 array = [|0UL; 1UL; 2UL; 3UL|]
val wrap: x: 'a -> 'a array
val good: int array array = [|[|0|]; [|1|]; [|2|]; [|3|]|]
val bad: uint64 array array = [|[|0UL|]; [|1UL|]; [|2UL|]; [|3UL|]|]
Related information
I'm using the latest .NET 9 (VS 17.12.3) on Windows.
.NET SDK:
Version: 9.0.101
Commit: eedb237549
Workload version: 9.0.100-manifests.4a280210
MSBuild version: 17.12.12+1cce77968
Metadata
Metadata
Assignees
Type
Projects
Status
Done