in reply to Type coercion and union

I think I know why this fails.

When the types are in a union and the first value fails, the result is undef and I think* that is what is passed to the 2nd type. If I create a named coercion that covers both types, things work as intended.

declare_coercion "CoerceXeroType", from Str, via { return +{ Invoice => 'ACCREC', SupplierInvoice => 'ACCPAY', Credit => 'ACCRECCREDIT', SupplierCredit => 'ACCPAYCREDIT', }->{$_}; } ;