From 88f6d8d7ac2594d84be0cbfd955d66cf21ab1027 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Mon, 19 May 2014 14:44:02 -0700 Subject: [PATCH] Fix AST equality checks --- astprinter.d | 4 +++- std/d/ast.d | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/astprinter.d b/astprinter.d index f78a97b..9bc8874 100644 --- a/astprinter.d +++ b/astprinter.d @@ -578,7 +578,9 @@ class XMLPrinter : ASTVisitor override void visit(const FunctionLiteralExpression functionLiteralExpression) { output.writeln(""); + functionLiteralExpression.functionOrDelegate != tok!"" + ? str(functionLiteralExpression.functionOrDelegate) + : "auto", "\">"); functionLiteralExpression.accept(this); output.writeln(""); } diff --git a/std/d/ast.d b/std/d/ast.d index 04a5c71..565ff00 100644 --- a/std/d/ast.d +++ b/std/d/ast.d @@ -311,10 +311,12 @@ template visitIfNotNull(fields ...) } } -mixin template OpEquals() +mixin template OpEquals(bool print = false) { override bool opEquals(Object other) const { + static if (print) + pragma(msg, generateOpEquals!(typeof(this))); mixin (generateOpEquals!(typeof(this))); } } @@ -334,7 +336,7 @@ template generateOpEquals(T) { enum opEqualsPart = "\nif (obj." ~ p[0] ~ ".length != this." ~ p[0] ~ ".length) return false;\n" ~ "foreach (i; 0 .. this." ~ p[0] ~ ".length)\n" - ~ "\tif (this." ~ p[0] ~ "[i] != obj." ~ p[0] ~ "[i]) return false;"; + ~ "\tif (this." ~ p[0] ~ "[i] != obj." ~ p[0] ~ "[i]) return false;" ~ opEqualsPart!(p[1 .. $]); } else enum opEqualsPart = "\nif (obj." ~ p[0] ~ " != this." ~ p[0] ~ ") return false;" ~ opEqualsPart!(p[1 .. $]);