Skip to content

Enum in class is not working: lead.proto.fs(251, 13): [FS0001] No overloads match for method 'OfJson'.  #160

@rstradling

Description

@rstradling

Snippet like the below

enum SourceEnum {
  FACEBOOK = 0;
  OTHER = 1;
}
message Source {
/* Only used if the source_type = OTHER */
  string other = 1;
  SourceEnum source = 2;
}

generates code

[<CLIMutable>]
type Source =
    { mutable other : string option
      mutable source : SourceEnum option }

    static member JsonObjCodec =
        (fun other source ->
        { other = other
          source = source }) <!> Operators.jopt<Source, String> ("other") (fun x -> x.other)
        <*> Operators.jopt<Source, SourceEnum> ("source") (fun x -> x.source)

which generates error

lead.proto.fs(251, 13): [FS0001] No overloads match for method 'OfJson'. The available overloads are shown below.

Which seems to be referring to this line

<*> Operators.jopt<Source, SourceEnum> ("source") (fun x -> x.source)

as the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions