Summary: Add const inference for templated method and delegate
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-02-16 07:50:25 PST ---
Not only pure/nothrow/@safe should be inferred, but const on parameters and
methods should be inferred too. This increases the expressiveness of alias
parameters and is required for making templates const correct. Inferring const
for delegate parameters reduces the annotation overhead and makes treatment of
template delegate literals uniform with normal delegate literals.

IOW, the following code should compile:

int glob;

class Foo(alias a){
    int x;
    void foo(){a(this);}
    static int bar(Foo x){return a(foo);}

void main(){
    alias Foo!((p){glob=p.x;}) T; // parameter p inferred const
    auto foo = new immutable(T);;  // OK, inferred const; // OK, parameter x of inferred const
    (T x){glob = x.x;}(foo); // OK, parameter x inferred const

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to