Skip to content

Add oneof<...> type declarations - #71

Merged
kubouch merged 2 commits into
nushell:mainfrom
InnocentZero:oneof-typedecl
Aug 9, 2026
Merged

Add oneof<...> type declarations#71
kubouch merged 2 commits into
nushell:mainfrom
InnocentZero:oneof-typedecl

Conversation

@InnocentZero

Copy link
Copy Markdown
Contributor

Currently, the parser cannot support explicit type declarations for variables of the form oneof<x, y, z>. This commit adds support for that to the typechecker and the resolver.

More importantly, we need to discuss semantics of oneof properly. Atm, the explicit declarations resolve oneof<a> to a to save unnecessary overhead. We can make this an error as well (why would anyone realistically write let x: oneof<int> style declarations?). Apart from this, oneof always expects type arguments and errors otherwise (a cursed implementation would be to have let x: oneof<> typecheck to let x: any instead, but again, do we want it?).

Currently, the parser cannot support explicit type declarations for
variables of the form oneof<x, y, z>. This commit adds support for that
to the typechecker and the resolver.

Signed-off-by: innocentzero <1nn0c3n7z3r0@proton.me>
Signed-off-by: innocentzero <1nn0c3n7z3r0@proton.me>
@kubouch

kubouch commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Seems good, oneof<xyz> could be an error, but resolving to xyz is OK as well.

@kubouch
kubouch merged commit 0f362b5 into nushell:main Aug 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants