Skip to content

Commit

Permalink
fix Issue 8307 - inconsistent treatment of auto functions
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 19, 2014
1 parent 2e409a5 commit 15259b7
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions function.dd
Expand Up @@ -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))

Expand Down

0 comments on commit 15259b7

Please sign in to comment.