Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · XO0917

Docs

XO0917: a catch-all variant built from a run time value

warning · reported by the vet

A valued enum’s catch-all keeps the values no variant names. Built directly from a run time value, it holds whatever the value is, even one a named variant has, and then compares unequal to that variant. E.from(v) returns the named variant for a known value and the catch-all otherwise. Keep the direct form with // xo:allow XO0917 REASON when the value is known to be new. See core 2.3 and decision 0493.

Example

fn class_of(s: Str) -> StorageClass { StorageClass.Unknown(s) }

Fix

fn class_of(s: Str) -> StorageClass { StorageClass.from(s) }

Run xo explain XO0917 for this text in a terminal, or see section 10.6 of the specification.