Add a new attribute [<Prototype(?bool)>] (name discussable). - Default behavior:
A record type has a prototype iff one of the following is true: - It has instance members. - It implements an interface. - With [<Prototype>] (or equivalently [<Prototype(true)>]):
A record type always has a prototype. - With [<Prototype(false)>]:
A record type never has a prototype.
- Instance members are compiled into static members with 1 extra first arg. - If it tries to implement an interface, compile error. - Note: if a record type doesn't have a prototype (for any of the above reasons), then trying to type-test against it throws a compile error.

  • JankoA

    A tricky part was to uncover and fix an issue with the JSON serializer: De/serializing records was optimized to use identity function when all fields are the same name, there are no optional fields and no prototype for the record. But on inlined records in union cases when simplified this way, the tag field remained incorrectly on the result (not breaking match/union case get, but breaking JS structural equality). Extra care is needed to remove the tag field in this (and only this) case when deserializing the union.

  • github

    This topic has been closed.

  • JankoA

    Implemented and released in Zafir.4.0.160.40-beta6