]> Nishi Git Mirror - gwion.git/commitdiff
:art: disallow variadic unions
authorfennecdjay <fennecdjay@gmail.com>
Sun, 10 Mar 2024 16:44:47 +0000 (17:44 +0100)
committerfennecdjay <fennecdjay@gmail.com>
Sun, 10 Mar 2024 16:44:47 +0000 (17:44 +0100)
src/sema/sema.c

index 1967ea05b3e485ad8e2c166fc72f1e66e6c286fc..811e8844c21df83421236c75ab7417e59a683d60 100644 (file)
@@ -735,8 +735,15 @@ ANN static bool sema_union_def(Sema *a, Union_Def b) {
     if(!type_decl_array_empty(a, c->td, "in union member"))
       ok = false;
   }
-  if(b->tmpl && !sema_tmpl(a, b->tmpl))
-    ok = false;
+  if(b->tmpl) {
+    if(!sema_tmpl(a, b->tmpl))
+      ok = false;
+    if(is_spread_tmpl(b->tmpl)) {
+      gwerr_basic(_("unions can't be variadic"), NULL, NULL,
+                  a->filename, b->tag.loc, 0);
+      ok = false;
+    }
+  }
   return ok;
 }