Bug 7476 – Write(ln) functions no longer accept retro range

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-09T12:06:00Z
Last change time
2012-02-18T22:43:55Z
Keywords
pull
Assigned to
andrei
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2012-02-09T12:06:31Z
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.
Comment #1 by kevin — 2012-02-10T00:34:41Z
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 ---
Comment #2 by kevin — 2012-02-10T00:38:30Z
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.
Comment #3 by issues.dlang — 2012-02-10T00:43:32Z
> 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).
Comment #4 by kevin — 2012-02-10T02:00:32Z
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>
Comment #5 by kevin — 2012-02-10T02:04:28Z
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
Comment #6 by timon.gehr — 2012-02-10T04:22:52Z
I think it is a regression in Phobos. Have you compiled against Phobos 2.057 or Phobos 2.058head?
Comment #7 by k.hara.pg — 2012-02-10T04:55:04Z
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.
Comment #8 by k.hara.pg — 2012-02-10T05:08:10Z
Comment #9 by k.hara.pg — 2012-02-17T07:13:24Z
*** Issue 7531 has been marked as a duplicate of this issue. ***
Comment #10 by github-bugzilla — 2012-02-18T10:47:07Z
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
Comment #11 by k.hara.pg — 2012-02-18T22:43:55Z
*** Issue 7433 has been marked as a duplicate of this issue. ***