zmaten
zmaten

Reputation: 477

F# not recognizing members of a record type

I am doing a simple mapping and the compiler doesn't recognize the record's members. The image shows the type OpeningHours itself is clearly ok, with all 3 properties showing:

Recognized record type with all members

But hovering over the marked property shows:

error FS0039: The field, constructor or member 'Day' is not defined.

Namespaces are all referenced and I even assign to the very same properties few lines below without any issue.

Upvotes: 4

Views: 381

Answers (2)

TheQuickBrownFox
TheQuickBrownFox

Reputation: 10624

OpeningHours is a class, not a record. This is one way to create an instance of the class:

OpeningHours(day = oh.Day, opens = oh.Opens, closes = oh.Closes)

Upvotes: 5

Honza Brestan
Honza Brestan

Reputation: 10947

Based on the constructor and properties, it looks like OpeningHours is defined as a class, not a record. The record syntax can't be used with classes, so the solution is either to change OpeningHours to a record, or to instantiate it using its existing constructor.

Upvotes: 4

Related Questions