Nested reference type record values and nullable constraints
See original GitHub issueGiven the following examples I can’t quite figure out what the compiler is doing here.
type InnerRecord = { Id: int }
[<Struct>]
type StructRecord = { Value: obj }
// Ok
let nullable = Nullable({Value = 1 })
[<Struct>]
type StructRecord2 = { Value: InnerRecord }
// A generic construct requires that the type 'StructRecord2' have a public default constructor
let nullable = Nullable({Value = { Id = 1 }})
[<Struct>]
type StructType(value: obj) =
member _.Value = value
// Ok
let nullable = Nullable(StructType(1))
[<Struct>]
type StructType2(value: InnerRecord) =
member _.Value = value
// A generic construct requires that the type 'StructType2' have a public default constructor
let nullable = Nullable(StructType2({ Id = 1 }))
[<Struct>]
type StructType3(value: StructType) =
member _.Value = value
// Ok
let nullable = Nullable(StructType3(StructType()))
[<Struct>]
type InnerStructRecord = { Id: int }
[<Struct>]
type StructType4(value: InnerStructRecord) =
member _.Value = value
// Ok
let nullable = Nullable(StructType4({ Id = 1 }))
Why specifically is it not allowed to store a struct that has a reference type record as one of its fields? (And then secondly, if it is expected behavior the error is supremely unhelpful in figuring this out)
This issue seems related to a previous issue https://github.com/dotnet/fsharp/issues/7946#issuecomment-687266672 but the linked explanation reads like it should only apply to generic structs.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Nullable reference types - specification - C# 9.0 draft ...
This feature specification provides a more complete specification for nullable reference types.
Read more >BigQuery - Nested and Repeated not allowing to insert Null ...
I have a field with mutiplt Nested and Repeated fields inside it. It is not allowing me to Insert null values or null...
Read more >Specify nested and repeated columns in table schemas
Nested and repeated schemas are subject to the following limitations: A schema cannot contain more than 15 levels of nested RECORD types. Columns...
Read more >Constraints on Databricks
Columns nested within array or map types do not accept NOT NULL constraints. See CREATE TABLE [USING] and ALTER TABLE ALTER COLUMN.
Read more >Considerations for Semi-structured Data Stored in VARIANT
This rule ensures that information is not lost, i.e, the difference between VARIANT “null” values and SQL NULL values is not obfuscated. Elements...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Workaround for now shows how busted the compiler behavior is here.
@NinoFloris Thanks, I’ll take a look