www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7476] New: Write(ln) functions no longer accept retro range

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

           Summary: Write(ln) functions no longer accept retro range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-02-09
12:06:31 PST ---
import std.stdio, std.range;

void main()
{
    write(retro("abcd"));
}

Dmd outputs:

std\range.d(295): Error: static assert  "Cannot put a Result into a
LockingTextWriter"
std\format.d(1509):        instantiated from here:
put!(LockingTextWriter,Result)
std\format.d(1984):        instantiated from here:
formatRange!(LockingTextWriter,Result,char)
std\format.d(2228):        instantiated from here:
formatValue!(LockingTextWriter,Result,char)
std\format.d(319):        instantiated from here:
formatGeneric!(LockingTextWriter,Result,char)
std\stdio.d(684):        instantiated from here:
formattedWrite!(LockingTextWriter,char,Result)
std\stdio.d(1503):        instantiated from here: write!(Result)
retro.d(5):        instantiated from here: write!(Result)

This worked on 2.057.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 09 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


Kevin <kevin brogan.ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kevin brogan.ca


--- Comment #1 from Kevin <kevin brogan.ca> 2012-02-10 00:34:41 PST ---
Works for me.

Windows 7 64bit - Service Pack 1


C:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>where dmd
C:\D\dmd\windows\bin\dmd.exe
C:\D\dmd2\windows\bin\dmd.exe

C:\Users\Kevin\Documents\D
Projects\ConsoleApp1\ConsoleApp1\bin>C:\D\dmd2\windows\bin\dmd.exe ..\main.d

C:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>main.exe
dcba
C:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>type ..\main.d
´╗┐import std.stdio, std.range;

void main()
{
    write(retro("abcd"));
}
C:\Users\Kevin\Documents\D
Projects\ConsoleApp1\ConsoleApp1\bin>C:\D\dmd2\windows\bin\dmd.exe
DMD32 D Compiler v2.057
Copyright (c) 1999-2011 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html
Usage: --- truncate ---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476



--- Comment #2 from Kevin <kevin brogan.ca> 2012-02-10 00:38:30 PST ---
Wait, I'm confused. You said it works on 2.057 (which I can confirm). What
version is it not working on? 2.057 is the latest.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #3 from Jonathan M Davis <jmdavisProg gmx.com> 2012-02-10 00:43:32
PST ---
 Wait, I'm confused. You said it works on 2.057 (which I can confirm). What
 version is it not working on? 2.057 is the latest.
The latest on github (and the current 2.058 beta). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476



--- Comment #4 from Kevin <kevin brogan.ca> 2012-02-10 02:00:32 PST ---
Just downloaded the git source and compiled with dmc

Works for me on latest version. 2.048 Beta

c:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>dmd ../main.d
DMD v2.058 DEBUG

c:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>main.exe
dcba
c:\Users\Kevin\Documents\D Projects\ConsoleApp1\ConsoleApp1\bin>

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476



--- Comment #5 from Kevin <kevin brogan.ca> 2012-02-10 02:04:28 PST ---
I've got to stop typing at 2 in the morning...

I mean 2.058 Debug, as shown in the console dump.

(In reply to comment #4)
 Just downloaded the git source and compiled with dmc
 
 Works for me on latest version. 2.048 Beta
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch


--- Comment #6 from timon.gehr gmx.ch 2012-02-10 04:22:52 PST ---
I think it is a regression in Phobos. Have you compiled against Phobos 2.057 or
Phobos 2.058head?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


--- Comment #7 from Kenji Hara <k.hara.pg gmail.com> 2012-02-10 04:55:04 PST ---
A shallow answer:
2.058 was merged a pull to improve std.format:
https://github.com/D-Programming-Language/phobos/pull/298
and after that this regression has been occurred.

A deep answer:
This is a problem rooted in the std.range.put implementation.
reduced code:
----
import std.range;

struct LockingTextWriter
{
    void put(dchar c){}
}
struct RetroResult
{
    bool end = false;
     property bool empty() const { return end; }
     property dchar front(){ return 'a'; }
    void popFront(){ end = true; }
}
void main()
{
    LockingTextWriter w;
    RetroResult r;
    put(w, r);  // test.d(20)
}

Output:
----
C:\dmd2\src\phobos\std\range.d(295): Error: static assert  "Cannot put a
RetroResult into a LockingTextWriter"
test.d(20):        instantiated from here: put!(LockingTextWriter,RetroResult)

Current std.format.formatValue treats retro("abcd") as a kind of string range.
And try to put it into Writer by using std.range.put().

  void put(R, E)(ref R r, E e)     // std.range.put signature

When E is an array (of cause it is random access range), put() runs the
range-to-range copy. But put() cannot instantiate with E that isn't array
range.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #8 from Kenji Hara <k.hara.pg gmail.com> 2012-02-10 05:08:10 PST ---
https://github.com/D-Programming-Language/phobos/pull/426

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simendsjo gmail.com


--- Comment #9 from Kenji Hara <k.hara.pg gmail.com> 2012-02-17 07:13:24 PST ---
*** Issue 7531 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476



--- Comment #10 from github-bugzilla puremagic.com 2012-02-18 10:47:07 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/3a03376c7d6b8b5b998aa5c3e0dfd9837e3198dc
Merge pull request #426 from 9rnsr/fix7476

Issue 7476 - Write(ln) functions no longer accept retro range

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


Yao Gomez <yao.gomez gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yao.gomez gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7476


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #11 from Kenji Hara <k.hara.pg gmail.com> 2012-02-18 22:43:55 PST
---
*** Issue 7433 has been marked as a duplicate of this issue. ***

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