Issue #609: Single-variant enum shorthand for enums from other modules and packages (ADR-347)

Open and answer this issue on GitHub.

ready · opened 2026-10-13 · updated 2026-10-13 · 0 comments

ADR-347 (#608, fa6bd8a) lets Typ(x) stand for Typ::Variant(x) when Typ is an enum with exactly one variant. The build rewrites the short form right after parsing (crates/nikaia/src/one_variant.rs), and it only knows the enums of the same file and of std. An enum declared in another module of the program or in a package is not recognised yet, so the short form is refused there although the rule (Part I 3.4) applies to every enum.

To build

  1. Recognise single-variant enums from other modules of the program (resolved through use), e.g. by moving the rewrite to where module types are known, or by giving the rewrite the module’s enum table.
  2. The same for enums from packages (packages/<name>/, dependencies).
  3. Tests: a two-module program constructing and matching m::Wrap(x); a package enum used with the short form; NK1252 still fires for a two-variant enum from another module.

Back to Open Issues