auto foo() in {} body { return 0; } void main() { foo(); } DMD 2.048 prints: test.d(2): no identifier for declarator foo test.d(2): semicolon expected, not 'in' test.d(2): Declaration expected, not 'in' test.d(3): unrecognized declaration
I also hit this bug but on Linux and I suppose it fails on all platforms. My test code is auto foo() body { // does not compile if body is specified return 0; } void main() {} It fails with latest dmd (v2.052) test.d(2): function declaration without return type. (Note that constructors are always named 'this') test.d(2): no identifier for declarator foo() This bug makes using contracts and auto return type impossible. Maybe it's importance should therefore be increased.
Maybe issue 5867 is the same as this.
DMD v2.053 on Linux do not accept the following code: ---------- auto F1() {return 0;} // OK int F2() body {return 0;} // OK auto F3() body {return 0;} // ERROR: function declaration without return type... void main() { F1(); F2(); F3(); } ----------
https://github.com/D-Programming-Language/dmd/pull/147
*** Issue 7060 has been marked as a duplicate of this issue. ***
DMD 2.059: PS E:\DigitalMars\dmd2\samples> rdmd bug.d bug.d(1): function declaration without return type. (Note that constructors are always named 'this') bug.d(2): no identifier for declarator foo() PS E:\DigitalMars\dmd2\samples>
I hope the patch will be merged in some more months.
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bd0e45f56f869da03baf89d8b530a9a2afc5f561 Issue 4785 - auto return of a function with in contract https://github.com/D-Programming-Language/dmd/commit/007b936e0970666c7698ad7c3b2c2b3da2d8cbc0 Merge pull request #147 from 9rnsr/fix4785 Issue 4785 & 5039 Allow auto return function with contracts