anchor.diff:                  None
               else
                   Some (enc (getSome x).[0])
  +    elif isNullableUnion i mt then
  +        let enc = dE mt
  +        let getTag = FSV.PreComputeUnionTagReader(mt, flags)
  +        fun x ->
  +            if getTag x = 0 then
  +                None
  +            else
  +                Some (enc x)
       else
           let enc = dE mt
           fun x -> Some (enc x)
   
   let decodeOptionalField dD (i: FormatSettings) (mi: System.Reflection.MemberInfo) (mt: System.Type) : option<Value> -> obj =
  -    if isOptionalField mi mt then
  +    if isOptionalField i mi mt then
           let vt = mt.GetGenericArguments().[0]
           let dec = dD vt
           let ucis = FST.GetUnionCases(mt, flags)
  
positive.code:         | _ ->
              raise DecoderException
  
  let isOptionalField (mi: System.Reflection.MemberInfo) (mt: System.Type) =
      mt.IsGenericType &&
      mt.GetGenericTypeDefinition() = typedefof<option<_>> &&
      (mi.GetCustomAttributes(false)
      |> Array.exists (fun t -> t.GetType() = typeof<A.OptionalFieldAttribute>))
  
  let encodeOptionalField dE (i: FormatSettings) (mi: System.Reflection.MemberInfo) (mt: System.Type) : obj -> option<Encoded> =
      if isOptionalField mi mt then
          let vt = mt.GetGenericArguments().[0]
          let enc = dE vt
          let ucis = FST.GetUnionCases(mt, flags)
  
negative.code:         EncodeUnionTag : System.Type -> int -> option<string * Encoded>
          /// Get the JSON-encoded name of the given F# union case field.
          GetEncodedUnionFieldName : System.Reflection.PropertyInfo -> int -> string
          /// If true, represent fields whose type is a union marked
          /// UseNullAsTrueValue as absent field.
          /// Also always represent options as if they were marked [<OptionalField>].
          RepresentNullUnionsAsAbsentField : bool
          /// Pack an encoded value to JSON.
          Pack : Encoded -> Value
      }
  