diff trunk/src/Declarations.d @ 301:caef255a2801

- Fix in some ctors: adding only non-null members to this.children.
author aziz
date Sat, 11 Aug 2007 17:30:02 +0000
parents 6cf3a5069109
children df237b3b5f09
line wrap: on
line diff
--- a/trunk/src/Declarations.d	Fri Aug 10 11:21:05 2007 +0000
+++ b/trunk/src/Declarations.d	Sat Aug 11 17:30:02 2007 +0000
@@ -148,7 +148,12 @@
   {
     super(hasBody);
     mixin(set_kind);
-    this.children = [tparams] ~ cast(Node[])bases ~ decls;
+    if (tparams)
+      this.children = [tparams];
+    if (bases.length)
+      this.children ~= bases;
+    if (decls.length)
+      this.children ~= decls;
     this.name = name;
     this.tparams = tparams;
     this.bases = bases;
@@ -165,7 +170,10 @@
   {
     super(hasBody);
     mixin(set_kind);
-    this.children = [tparams] ~ cast(Node[])decls;
+    if (tparams)
+      this.children = [tparams];
+    if (decls.length)
+      this.children ~= decls;
     this.name = name;
     this.tparams = tparams;
     this.decls = decls;
@@ -181,7 +189,10 @@
   {
     super(hasBody);
     mixin(set_kind);
-    this.children = [tparams] ~ cast(Node[])decls;
+    if (tparams)
+      this.children = [tparams];
+    if (decls.length)
+      this.children ~= decls;
     this.name = name;
     this.tparams = tparams;
     this.decls = decls;
@@ -247,6 +258,7 @@
   FunctionBody funcBody;
   this(Type returnType, Token* funcName, TemplateParameters tparams, Parameters params, FunctionBody funcBody)
   {
+    assert(returnType !is null);
     super(funcBody.funcBody !is null);
     mixin(set_kind);
     this.children = [returnType];
@@ -363,7 +375,9 @@
   {
     super(true);
     mixin(set_kind);
-    this.children = [condition, message];
+    this.children = [condition];
+    if (message)
+      this.children ~= message;
     this.condition = condition;
     this.message = message;
   }
@@ -457,7 +471,8 @@
   {
     super(TOK.Pragma, decls);
     mixin(set_kind);
-    this.children ~= args;
+    if (args.length)
+      this.children ~= args;
     this.ident = ident;
     this.args = args;
   }