Skip to content
Playground(another site)

bynk.types.embeds_ambiguous

Error A type is embedded by more than one variant of a sum, so ?'s conversion would be ambiguous.

embeds E as V lets ? wrap an E error in the variant V. It picks the variant by the error's type, so a type may be embedded once: with two variants wrapping PayError, ? could not tell which one an error belongs to. Embed the type in one variant, and build the other by hand where you want it.

Example

type OrderError =
| Payment(reason: PayError)
| Refund(reason: PayError)
embeds PayError as Payment, PayError as Refund // ✗ `PayError` twice
type OrderError =
| Payment(reason: PayError)
| Refund(reason: PayError)
embeds PayError as Payment // ✓ once

In the Book

See also

  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.embeds_ambiguous shows the same from the installed toolchain, without a network.