diff options
| author | gingerBill <bill@gingerbill.org> | 2019-07-09 10:49:45 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-07-09 10:49:45 +0100 |
| commit | 7c99f521877ee0795a04c6ed3e1a2bbc1df7edf6 (patch) | |
| tree | c1fab9d07355b53b55404c364d7f6fccc5dc4c32 /src/check_type.cpp | |
| parent | 4ab9edeb53559f6ab6ef39a5ad9b45564d22aa8e (diff) | |
Add minimum requirement of 2 variants for #no_nil
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 6cd982bcb..df3c554dd 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -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.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) { i64 custom_align = 1; |