diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2023-06-14 12:05:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-14 12:05:34 +0100 |
| commit | 2149afabe1bf099b916b7f263e5b2ea45d987639 (patch) | |
| tree | 3dc80b5c6e38ecdcce53e6246d7628a4878276e0 /src/check_type.cpp | |
| parent | fc4a5e61c27467b30a421bceb7d21ac29ef8468e (diff) | |
| parent | ec32967daab5136fc2518f4068e7007e265c4e92 (diff) | |
Merge pull request #2590 from inbelic/inbelic/fix-no_nil-variants-err
[check-type] fix faulty #no_nil variants error
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index bbfc25a12..a69dcdadc 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -729,6 +729,12 @@ gb_internal void check_union_type(CheckerContext *ctx, Type *union_type, Ast *no union_type->Union.kind = ut->kind; switch (ut->kind) { case UnionType_no_nil: + if (union_type->Union.is_polymorphic && poly_operands == nullptr) { + GB_ASSERT(variants.count == 0); + if (ut->variants.count != 1) { + break; + } + } if (variants.count < 2) { error(ut->align, "A union with #no_nil must have at least 2 variants"); } |