Thread overview
[Issue 7922] New: alias this causes weird formatting issues for strings
Apr 16, 2012
Andrej Mitrovic
Apr 17, 2012
Kenji Hara
Apr 20, 2012
SomeDude
Apr 20, 2012
SomeDude
May 21, 2012
Walter Bright
April 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922

           Summary: alias this causes weird formatting issues for strings
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-04-16 06:26:12 PDT ---
import std.string;
import std.stdio;

struct Wrap
{
    string _payload;
    alias _payload this;
}

void main()
{
    Wrap foo;
    string x = format("%s %s", "1", "2");
    foo ~= x;
    writeln(foo);  // writes: 1 2

    Wrap bar;
    bar ~= format("%s %s", "1", "2");
    writeln(bar);  // writes:
(immutable(char)[],immutable(char)[],immutable(char)[])1 2
}

What's going on here?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
           Severity|normal                      |regression


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-04-16 23:49:12 PDT ---
This is a regression of fixing bug 7583.

Reduced test case:
----
struct S
{
    int[] arr;
    alias arr this;
}
S func(...)
{
    S ret;
    ret.arr.length = _arguments.length;
    return ret;
}
void main()
{
    int[] arr;
    assert(arr.length == 0);
    arr ~= func(1, 2);  //NG
    //arr = func(1, 2); //OK
    assert(arr.length == 2);
}

Pull request: https://github.com/D-Programming-Language/dmd/pull/885

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-04-20 02:18:55 PDT ---
See also 7598

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922



--- Comment #3 from SomeDude <lovelydear@mailmetrash.com> 2012-04-20 02:19:55 PDT ---
(In reply to comment #2)
> See also 7598

See also issue 7598

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922



--- Comment #4 from github-bugzilla@puremagic.com 2012-05-21 14:59:47 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a235ba424a9095b5ca2cc08f6c3444354c1a0013 fix Issue 7922 - alias this causes weird formatting issues for strings

This was a regression of fixing 7583, and redundant copy of syntax tree have
been made this problem.
So I revert efd4711 + cd7dfca, and add necessary and sufficient copy.

https://github.com/D-Programming-Language/dmd/commit/3ecc1f3fbfd1d821bd647bde2e9d4adbcf9f2b9d Merge pull request #885 from 9rnsr/fix7922

Issue 7922 - alias this causes weird formatting issues for strings

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7922


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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