From 15259b7319c1a7c7782888bec28c8d5acdeb317f Mon Sep 17 00:00:00 2001 From: k-hara Date: Sat, 13 Sep 2014 13:30:52 +0900 Subject: [PATCH] fix Issue 8307 - inconsistent treatment of auto functions --- function.dd | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/function.dd b/function.dd index 9e6b27343a..dc18e36016 100644 --- a/function.dd +++ b/function.dd @@ -125,27 +125,25 @@ foo() = 3; // reference returns can be lvalues $(H4 $(LNAME2 auto-functions, Auto Functions)) - $(P Auto functions have their return type inferred from any - $(GLINK2 statement, ReturnStatement)s - in the function body. - ) + $(P Auto functions have their return type inferred from any + $(GLINK2 statement, ReturnStatement)s in the function body. + ) - $(P An auto function is declared without a return type. + $(P An auto function is declared without a return type. If it does not already have a storage class, use the $(D_KEYWORD auto) storage class. - ) + ) - $(P If there are multiple $(I ReturnStatement)s, the types - of them must match exactly. If there are no $(I ReturnStatement)s, - the return type is inferred to be $(D_KEYWORD void). - ) + $(P If there are multiple $(I ReturnStatement)s, the types + of them must be implicitly convertible to a common type. + If there are no $(I ReturnStatement)s, the return type is inferred + to be $(D_KEYWORD void). ---- -auto foo(int i) -{ - return i + 3; // return type is inferred to be int -} ---- + --- + auto foo(int x) { return x + 3; } // inferred to be int + auto foo(int x) { return x; return 2.5; } // inferred to be double + --- + ) $(H4 $(LNAME2 auto-ref-functions, Auto Ref Functions))