[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-07-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073


Rob Jacques  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||WORKSFORME


--- Comment #9 from Rob Jacques  2011-07-05 17:14:51 PDT ---
I added a new bug report for the fixed-sized array issue: Issue 6256. But
otherwise, this appears to be fixed as of DMD 2.053.

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-07-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #8 from bearophile_h...@eml.cc 2011-07-03 18:28:49 PDT ---
(In reply to comment #7)
> I've had trouble with map in DMD 2.053 and fixed it with this patch. I've even
> updated the patch to the new internal struct style being used in 
> std.algorithm.
> (not-yet posted). But this has been due to map not handling fixed sized 
> arrays:
> 
> ubyte[12] datum;
> map!"a"(datum);
> 
> Which as of this evening's SVN, is still true. I don't know about the original
> code which spawned this bug report, but once fixed-sized arrays work, I can
> re-test it.

I'd like map to work on fixed-size arrays too, but I think Andrei doesn't want
this to be fixed.

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-07-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073



--- Comment #7 from Rob Jacques  2011-07-03 17:58:29 PDT ---
I've had trouble with map in DMD 2.053 and fixed it with this patch. I've even
updated the patch to the new internal struct style being used in std.algorithm.
(not-yet posted). But this has been due to map not handling fixed sized arrays:

ubyte[12] datum;
map!"a"(datum);

Which as of this evening's SVN, is still true. I don't know about the original
code which spawned this bug report, but once fixed-sized arrays work, I can
re-test it.

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-07-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073


yebblies  changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #6 from yebblies  2011-07-04 02:57:48 EST ---
None of these examples fail for me with dmd 2.054 head on win32.  Can anybody
reproduce this with a current dmd?

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-05-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073



--- Comment #5 from Rob Jacques  2011-05-19 17:36:31 PDT ---
*oops* forgot the else statements

template map(fun...) {
auto map(Range)(Range r) {
static if (fun.length > 1) {
return Map!(unaryFun!(adjoin!(staticMap!(unaryFun,fun))),Range)(r);
} else {
static if( is(typeof(fun[0]) == delegate) ) {
return Map!(fun, Range)(fun[0],r);
} else static if( is(typeof(unaryFun!fun) == delegate) ) {
return Map!(unaryFun!fun, Range)(unaryFun!fun,r);
} else static if( is(Range E:E[]) ) {
return Map!(unaryFun!fun, E[])(r[]);
} else {
return Map!(unaryFun!fun, Range)(r);
}
}
}
}

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-05-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073



--- Comment #4 from Rob Jacques  2011-05-19 17:22:16 PDT ---
Minor update to handle fixed sized arrays properly.

template map(fun...) {
auto map(Range)(Range r) {
static if (fun.length > 1) {
return Map!(unaryFun!(adjoin!(staticMap!(unaryFun,fun))),Range)(r);
} else {
static if( is(typeof(fun[0]) == delegate) ) {
return Map!(fun, Range)(fun[0],r);
} static if( is(Range E:E[]) ) {
return Map!(unaryFun!fun, E[])(r[]);
} else {
return Map!(unaryFun!fun, Range)(r);
}
}
}
}

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-01-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073



--- Comment #3 from Rob Jacques  2011-01-20 09:33:15 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > In DMD 2.051, this error message has ceased to be generated for certain 
> > inputs
> > and instead a runtime access violation is generated. Here is a reduced test
> > case:
> > 
> > struct Bar(T) {
> > T x;
> > Bar dot(Bar b) { return Bar(x+b.x); }
> > }
> > 
> > void main(string[] args) {
> > Bar!real   b;
> > Bar!real[] data = new Bar!real[5];
> > auto foobar  = map!((a){return a.dot(b); })(data);
> > return;
> > }
> 
> I just tried the example above with 2.051. It compiles and runs. Could you
> please provide a different example? Thanks!

While it does compile on my system, when it runs it causes an "object.Error:
Access Violation". I'm on an Intel Core-i7 920 (Quad core) running Windows 7
64-bit. Just to double check, here is a more extensive version of the same test
which verifies the map is run correctly. 

void main(string[] args) {
Bar!real   b = Bar!real(5);
Bar!real[] data = new Bar!real[5];
foreach(i,ref d;data)
d.x = i;
Bar!real[] expected = new Bar!real[5];
foreach(i,ref e;expected)
e = data[i].dot(b);
auto foobar  = map!((a){return a.dot(b); })(data);
foreach(z;zip(foobar,expected))
assert(z[0].x == z[1].x);
return;
}

Also, does the example from my first post compile & run for you?

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-01-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073



--- Comment #2 from Andrei Alexandrescu  2011-01-16 
14:18:23 PST ---
(In reply to comment #1)
> In DMD 2.051, this error message has ceased to be generated for certain inputs
> and instead a runtime access violation is generated. Here is a reduced test
> case:
> 
> struct Bar(T) {
> T x;
> Bar dot(Bar b) { return Bar(x+b.x); }
> }
> 
> void main(string[] args) {
> Bar!real   b;
> Bar!real[] data = new Bar!real[5];
> auto foobar  = map!((a){return a.dot(b); })(data);
> return;
> }

I just tried the example above with 2.051. It compiles and runs. Could you
please provide a different example? Thanks!

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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-01-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073


Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||and...@metalanguage.com
 AssignedTo|nob...@puremagic.com|and...@metalanguage.com


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


[Issue 5073] wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

2011-01-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5073


Rob Jacques  changed:

   What|Removed |Added

   Keywords||patch, wrong-code
   Severity|normal  |regression


--- Comment #1 from Rob Jacques  2011-01-05 13:14:37 PST ---
In DMD 2.051, this error message has ceased to be generated for certain inputs
and instead a runtime access violation is generated. Here is a reduced test
case:

struct Bar(T) {
T x;
Bar dot(Bar b) { return Bar(x+b.x); }
}

void main(string[] args) {
Bar!real   b;
Bar!real[] data = new Bar!real[5];
auto foobar  = map!((a){return a.dot(b); })(data);
return;
}

Here is a modified to std.algorithm.map that works arounds this specific bug:

template map(fun...) {
auto map(Range)(Range r) {
static if (fun.length > 1) {
return Map!( unaryFun!( adjoin!(staticMap!(unaryFun, fun)) ), Range
)(r);
} else {
static if( is(typeof(fun[0]) == delegate) ) {
return Map!(fun, Range)(fun[0],r);
} else {
return Map!(unaryFun!fun, Range)(r);
}
}
}
}

struct Map(alias fun, Range) if (isInputRange!(Range))
{
Unqual!Range _input;
static if( is(typeof(fun) == delegate) ) {
typeof(fun) _fun;
this(typeof(fun) dg, Range input) { _fun = dg;  _input = input; }
} else {
alias fun _fun;
this(Range input) { _input = input; }
}


alias typeof({ return _fun(.ElementType!(Range).init); }()) ElementType;

static if (isBidirectionalRange!(Range)) {
@property ElementType back(){ return  _fun(_input.back); }
  voidpopBack() { _input.popBack;}
}

// Propagate infinite-ness.
static if (isInfinite!Range)  {
enum bool empty = false;
} else {
@property bool empty() { return _input.empty; }
}

void popFront() { _input.popFront; }

@property ElementType front() { return _fun(_input.front); }

static if (isRandomAccessRange!Range)
{
ElementType opIndex(size_t index)
{
return _fun(_input[index]);
}
}

// hasLength is busted, Bug 2873
static if (is(typeof(_input.length) : size_t)
|| is(typeof(_input.length()) : size_t))
{
@property size_t length()
{
return _input.length;
}
}

static if (hasSlicing!(Range)) {
typeof(this) opSlice(size_t lowerBound, size_t upperBound) {
auto result = this;
result._input = result._input[lowerBound..upperBound];
return result;
}
}

static if (isForwardRange!Range)
@property Map save()
{
auto result = this;
result._input = result._input.save;
return result;
}
}

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