When using 'with' to construct a record based on another record, in a specific set of circumstances the compiler fails with the following errors:
error FS0073: internal error: TryOptimizeRecordFieldGet: term argument out of range
error FS0193: internal error: Index was outside the bounds of the array.
The following toy application reproduces the error:
type FooBar =
{ xyz : string }
static let staticLet = 1
let doThing (foo : FooBar) =
let bar = { foo with xyz = foo.xyz }
let baz = { bar with xyz = bar.xyz }
printfn "%O" baz
doThing { xyz = "" }
Note that the following are required:
baz must use with based on another record type that also uses with based on another record type: if baz is changed to = { foo with... the code builds correctly.
- The record type must contain a
static let: if staticLet is removed then the code builds correctly.
- The code must be in a function: if
doThing is removed and replaced with let foo = { Field = "" } then the code builds correctly.
This error only happens when building with optimisations switched on.
Tested using the 9.0.101 SDK.
When using 'with' to construct a record based on another record, in a specific set of circumstances the compiler fails with the following errors:
The following toy application reproduces the error:
Note that the following are required:
bazmust usewithbased on another record type that also useswithbased on another record type: ifbazis changed to= { foo with...the code builds correctly.static let: ifstaticLetis removed then the code builds correctly.doThingis removed and replaced withlet foo = { Field = "" }then the code builds correctly.This error only happens when building with optimisations switched on.
Tested using the
9.0.101SDK.