-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Bug
Copy link
Labels
Area-Compiler-OptimizationThe F# optimizer, release code gen etc.The F# optimizer, release code gen etc.BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
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 usewith
based on another record type that also useswith
based on another record type: ifbaz
is changed to= { foo with...
the code builds correctly.- The record type must contain a
static let
: ifstaticLet
is removed then the code builds correctly. - The code must be in a function: if
doThing
is 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.101
SDK.
Metadata
Metadata
Assignees
Labels
Area-Compiler-OptimizationThe F# optimizer, release code gen etc.The F# optimizer, release code gen etc.BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
New