From af252569f75d7c9e6b09c4d56fda600c9ec6b64b Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 20 Jun 2018 12:32:38 +0200 Subject: [PATCH] fix #665 - The check for auto function without return doesn't handle "implicit auto functions" --- src/dscanner/analysis/auto_function.d | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dscanner/analysis/auto_function.d b/src/dscanner/analysis/auto_function.d index 25bb1bb..53aeac0 100644 --- a/src/dscanner/analysis/auto_function.d +++ b/src/dscanner/analysis/auto_function.d @@ -49,7 +49,7 @@ public: _returns[$-1] = false; const bool autoFun = decl.storageClasses - .any!(a => a.token.type == tok!"auto"); + .any!(a => a.token.type == tok!"auto" || a.atAttribute !is null); decl.accept(this); @@ -216,6 +216,16 @@ unittest AutoFunctionChecker.MESSAGE, ), sac); + assertAnalyzerWarnings(q{ + @property doStuff(){} // [warn]: %s + @safe doStuff(){} // [warn]: %s + @disable doStuff(); + @safe void doStuff(); + }c.format( + AutoFunctionChecker.MESSAGE, + AutoFunctionChecker.MESSAGE, + ), sac); + assertAnalyzerWarnings(q{ enum _genSave = "return true;"; auto doStuff(){ mixin(_genSave);}