This is lovely, almost exactly the proposal I sketched in some thread a few months ago! In general, I’m guessing you can write
_::0 in most situations? My proposal didn’t include the pathspec on purpose, since I thought it was much too noisy. I can see from your examples how it might be necessary, though.
What does the following desugar to?
let x: fn(A) -> (A|B) = (A|B)::0;
I fear that this might result in a lot of work for the linker, since each crate will generate its own copies of these functions and the linker will need to dedup them.
Also, I think I’ve suggested the syntax
enum(A, B) before? I think the extra keyword is fine, since anonymous sums are likely to be rarer than anonymous enums, and is more symmetric with extant syntax. Plus, again on the assumption that they’re rarer, a reader spotting
enum(A, B) might have a better guess (and a more searchable name) for the syntax.
As an obvious corrollary to the above paragraph, it might be worth it to introduce “sum enums” in lieu of tuple structs:
enum Foo(A, B);, and by that token, “never-like enums”, e.g.