Bug 1279 – const/invariant functions don't accept const/invariant return types

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-06-19T07:49:00Z
Last change time
2014-02-14T20:35:49Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
kamm-removethis

Comments

Comment #0 by kamm-removethis — 2007-06-19T07:49:06Z
This fails to compile class Foo { int x; invariant invariant(int)* geti() // line 6 { return &x; } const const(int)* getc() // line 12 { return &x; } // line 15 } with the errors invartest.d(6): Declaration expected, not '(' invartest.d(12): Declaration expected, not '(' invartest.d(15): unrecognized declaration. Putting the return types into aliases fixes the problem: alias invariant(int)* RT_I; invariant RT_I geti() {...} alias const(int)* RT_C; const RT_C getc() {...} compiles.
Comment #1 by jarrett.billingsley — 2007-06-19T14:09:48Z
*** Bug 1281 has been marked as a duplicate of this bug. ***
Comment #2 by bruno.do.medeiros+deebugz — 2007-06-22T17:17:28Z
Nor even variables declared at module scope: ---- ---- module mod; invariant(char)[] p; ---- mod.d(2): Declaration expected, not '('
Comment #3 by kamm-removethis — 2007-06-27T14:47:38Z
Fixed in DMD 2.001