Bug 4785 – auto return of a function with in contract
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-09-01T10:38:00Z
Last change time
2012-05-02T20:40:57Z
Keywords
contracts, patch, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-09-01T10:38:41Z
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
Comment #1 by jens.k.mueller — 2011-03-30T10:29:23Z
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.
Comment #2 by kennytm — 2011-04-20T12:03:17Z
Maybe issue 5867 is the same as this.
Comment #3 by maximzms — 2011-06-10T06:53:11Z
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();
}
----------
*** Issue 7060 has been marked as a duplicate of this issue. ***
Comment #6 by lovelydear — 2012-04-21T15:34:01Z
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>
Comment #7 by bearophile_hugs — 2012-04-24T18:32:31Z
I hope the patch will be merged in some more months.
Comment #8 by github-bugzilla — 2012-05-02T18:25:29Z