D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4401 - auto functions cannot be inner functions
Summary: auto functions cannot be inner functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
: 3654 5045 6903 (view as issue list)
Depends on:
Blocks:
 
Reported: 2010-06-28 07:07 UTC by Philippe Sigaud
Modified: 2011-11-07 21:43 UTC (History)
6 users (show)

See Also:


Attachments
allow parsing inner auto functions (598 bytes, patch)
2010-06-28 21:32 UTC, Ellery Newcomer
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Philippe Sigaud 2010-06-28 07:07:11 UTC
It seems auto function cannot be inner functions:

void foo()
{
    string bar(string s) { return s;} // works
    auto   baz(string s) { return s;} // error!
}

Errors:

main.d|13|found 's' when expecting ')'|
main.d|13|semicolon expected, not ')'|
main.d|13|found ')' instead of statement|

Reading the docs, nothing tells me auto functions cannot be used as inner function. So either it's a bug or you should update the docs.
Comment 1 Ellery Newcomer 2010-06-28 21:32:58 UTC
Created attachment 686 [details]
allow parsing inner auto functions
Comment 2 Leopold Walkling 2010-06-30 12:58:50 UTC
While skimming parser.c I noticed that the auto keyword is treated like a storage specifier, so this one is allowed:

auto void bar() { }

The spec says nothing about this case, but it seems nonsensical.
Comment 3 Ellery Newcomer 2010-07-01 09:10:51 UTC
seems this is a duplicate of issue 3654
Comment 4 bearophile_hugs 2010-07-01 09:34:46 UTC
*** Issue 3654 has been marked as a duplicate of this issue. ***
Comment 5 David Nadlinger 2011-07-30 15:35:55 UTC
*** Issue 5045 has been marked as a duplicate of this issue. ***
Comment 6 David Nadlinger 2011-07-30 15:37:38 UTC
For newer DMD versions, the error messages seems to have moved a level higher: »function declaration without return type. (Note that constructors are always named 'this')«
Comment 7 Kenji Hara 2011-11-07 09:54:21 UTC
*** Issue 6903 has been marked as a duplicate of this issue. ***
Comment 8 Kenji Hara 2011-11-07 10:35:05 UTC
D2 Patch:
https://github.com/D-Programming-Language/dmd/pull/500