mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Add minimum requirement of 2 variants for #no_nil
This commit is contained in:
@@ -716,6 +716,11 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array<Op
|
|||||||
|
|
||||||
union_type->Union.variants = variants;
|
union_type->Union.variants = variants;
|
||||||
union_type->Union.no_nil = ut->no_nil;
|
union_type->Union.no_nil = ut->no_nil;
|
||||||
|
if (union_type->Union.no_nil) {
|
||||||
|
if (variants.count < 2) {
|
||||||
|
error(ut->align, "A union with #no_nil must have at least 2 variants");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ut->align != nullptr) {
|
if (ut->align != nullptr) {
|
||||||
i64 custom_align = 1;
|
i64 custom_align = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user