Summary: IFTI should imply const where inout is present on
                    args, but not on return type
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Steven Schveighoffer <> 2011-10-12 
16:32:01 PDT ---

void foo(T)(T v)

inout(int)* bar(inout(int)* x)
    return x;

bug.d(1): Error: inout on parameter means inout must be on return type as well
(if from D1 code, replace with 'ref')
bug.d(1): Error: variable!(inout(int)*).foo.v inout variables can only
be declared inside inout functions
bug.d(7): Error: template instance!(inout(int)*) error instantiating

It is safe for IFTI to assume all inout parameters are const instead of inout,
since inout implicitly casts to const.

However, inout should still be used where it participates in the return type. 
For example, this currently-valid code should continue to compile:

T foo(T)(T v)
    return v;

inout(int)* bar(inout(int)* x)
    return foo(x);

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

Reply via email to