www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4968] New: inout is sticky to function return type

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4968

           Summary: inout is sticky to function return type
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tomash.brechko gmail.com



14:57:27 PDT ---
Call to writeln(f(i)) below won't compile because dmd 2.049 thinks f() returns
"inout(int)", so "void writeln(T...)(T args)" expands to "void
writeln(inout(int)...(inout(int) args)", and inout parameter requires inout
return type.  Rewriting "void" as "inout(void)" helps, but obviously is wrong.

import std.stdio;

inout(int)
f(inout int i)
{
  return i;
}

void
main()
{
  int i;

  writeln(typeof(f(i)).stringof); // Outputs "inout(int)", not "int".

  int j = f(i);
  writeln(i); // Works OK :).

  writeln(f(i)); // Won't compile :(.
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4968


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com



06:06:46 PDT ---
This is a good catch.  Although inout doesn't work currently, so don't expect
much yet.

IMO, this is how the compiler should behave:

void foo(T)(T t)
{
  writeln(typeof(t).stringof);
}

inout(int)
f(inout(int) i)
{
   return i;
}

void main()
{
   int i;
   const int j;
   immutable int k;
   foo(f(i));
   foo(f(j));
   foo(f(k));
}

should print:

int
const(int)
immutable(int)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4968




Created an attachment (id=964)
test patch


function, delegate, etc.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4968


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------

           obsolete|                            |



Created an attachment (id=965)
Improvement

Posted pull request:
https://github.com/D-Programming-Language/dmd/pull/58

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4968


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 3748 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2011