changeset 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 d04a79e795a2
files trunk/src/Declarations.d trunk/src/Parser.d trunk/src/Types.d
diffstat 3 files changed, 25 insertions(+), 6 deletions(-) [+]
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;
   }
--- a/trunk/src/Parser.d	Fri Aug 10 11:21:05 2007 +0000
+++ b/trunk/src/Parser.d	Sat Aug 11 17:30:02 2007 +0000
@@ -1440,6 +1440,7 @@
     nT(); // Skip mixin keyword.
 
   static if (is(Class == MixinDeclaration))
+  {
     if (token.type == T.LParen)
     {
       // TODO: What about mixin(...).ident;?
@@ -1449,6 +1450,7 @@
       require(T.Semicolon);
       return new MixinDeclaration(e);
     }
+  }
 
     Expression[] templateIdent;
     Token* mixinIdent;
--- a/trunk/src/Types.d	Fri Aug 10 11:21:05 2007 +0000
+++ b/trunk/src/Types.d	Sat Aug 11 17:30:02 2007 +0000
@@ -359,7 +359,9 @@
   }
   this(Type t, Expression e, Expression e2)
   {
-    this.children = [e, e2];
+    this.children = [e];
+    if (e2)
+      this.children ~= e2;
     this.e = e;
     this.e2 = e2;
     this(t);