From 6fe77da02d5b1ec322ba3e51beecf092219b6748 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 5 Apr 2018 10:47:14 +0200 Subject: [PATCH] fix #575 - Dscanner should allow opCmp with no toHash --- src/dscanner/analysis/opequals_without_tohash.d | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dscanner/analysis/opequals_without_tohash.d b/src/dscanner/analysis/opequals_without_tohash.d index 13df894..5575e32 100644 --- a/src/dscanner/analysis/opequals_without_tohash.d +++ b/src/dscanner/analysis/opequals_without_tohash.d @@ -76,12 +76,6 @@ class OpEqualsWithoutToHashCheck : BaseAnalyzer string message = "'" ~ name.text ~ "' has method 'toHash', but not 'opEquals'."; addErrorMessage(name.line, name.column, KEY, message); } - - if (hasOpCmp && !hasOpEquals) - { - addErrorMessage(name.line, name.column, KEY, - "'" ~ name.text ~ "' has method 'opCmp', but not 'opEquals'."); - } } enum string KEY = "dscanner.suspicious.incomplete_operator_overloading"; @@ -108,6 +102,15 @@ unittest } } + // AA would use default equal and default toHash + struct Bee + { + int opCmp(Bee) const + { + return true; + } + } + // Fail on class opEquals class Rabbit // [warn]: 'Rabbit' has method 'opEquals', but not 'toHash'. {