[Issue 9598] New: Cannot use moveFront on MapResult!(lambda, ByLine!(char, char))
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 26 22:33:59 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598
Summary: Cannot use moveFront on MapResult!(lambda,
ByLine!(char, char))
Product: D
Version: D2
Platform: All
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: zshazz at gmail.com
--- Comment #0 from Chris Cain <zshazz at gmail.com> 2013-02-26 22:33:51 PST ---
Using DMD 2.062 with no command line arguments other than the source file in
question
I have the following (expected valid) code:
---
import std.stdio, std.file, std.algorithm, std.conv, std.range;
void main() {
dirEntries("data", "*.out", SpanMode.shallow)
.map!(e => File(e.name).byLine()
.map!(line => text(line))() // compile error
)()
.array()
.nWayUnion() // line 9
.copy(stdout.lockingTextWriter);
}
---
Which produces errors. Error 1 is a compile-time failure producing the
following message:
---
C:\D\dmd2\windows\bin\..\..\src\phobos\std\range.d(6695): Error: static assert
"Cannot move front of a range with a postblit and an rvalue front."
C:\D\dmd2\windows\bin\..\..\src\phobos\std\container.d(3797):
instantiated from here: moveFront!(MapResult!(__lambda4, ByLine!(char,
char))[])
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10526):
instantiated from here: BinaryHeap!(MapResult!(__lambda4, ByLine!(char,
char))[], compFront)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10562):
instantiated from here: NWayUnion!("a < b", MapResult!(__lambda4, ByLine!(char,
char))[])
D:\[snip]\src\reducedCase.d(9): instantiated from here: nWayUnion!("a <
b", MapResult!(__lambda4, ByLine!(char, char))[])
---
If I change the code to this:
---
import std.stdio, std.file, std.algorithm, std.conv, std.range;
void main() {
dirEntries("data", "*.out", SpanMode.shallow)
.map!(e => File(e.name).byLine()
.map!text() // Compiles, runtime error
)()
.array()
.nWayUnion() // line 9
.copy(stdout.lockingTextWriter);
}
---
Then the code compiles, but produces a runtime error (when files are in data
directory and named *.out):
object.Error: Access Violation
----------------
0x00429674
0x004294FF
0x7730B459 in LdrRemoveLoadAsDataTable
0x7730B42B in LdrRemoveLoadAsDataTable
0x772C0133 in KiUserExceptionDispatcher
0x0018F6E8
0x0018F738
----------------
Specifically, these errors apply to MapResult!(lambda, ByLine!(char, char)).
For instance, using a string[][] as an array and applying a .map!text() as
above, there is no problem for either case.
---
import std.stdio, std.file, std.algorithm, std.conv, std.range;
void main() {
[["abc", "cbd"], ["dce", "efg"]]
.map!(e =>
//e.map!text() // OK
e.map!(line => text(line))() // OK
)()
.array()
.nWayUnion()
.copy(stdout.lockingTextWriter);
}
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list