[Issue 5710] cannot use delegates as parameters to non-global template

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


Rainer Schuetze r.sagita...@gmx.de changed:

   What|Removed |Added

 CC||r.sagita...@gmx.de


--- Comment #7 from Rainer Schuetze r.sagita...@gmx.de 2011-03-07 00:35:26 
PST ---
This could be implemented with a single context pointer, if the this pointer of
the Foo instance can be found through the stack frame pointer. In the example
the pointer to foo is already there, but in the more general case, a hidden
stack/closure variable needs to be used.

I'm not sure how much it would complicate code generation, though. It could end
up as a can of worms, e.g. having to deal with multiple aliases to different
kind of context pointers.

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


[Issue 5710] cannot use delegates as parameters to non-global template

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


Brad Roberts bra...@puremagic.com changed:

   What|Removed |Added

 CC||bra...@puremagic.com


--- Comment #8 from Brad Roberts bra...@puremagic.com 2011-03-07 01:19:35 PST 
---
(In reply to comment #6)
 Consider if we add another type - a function pointer with two context 
 pointers.
 Now we have quite a menagerie:
 
 1. function pointer
 2. function pointer with context pointer (delegate)
 3. function pointer with two context pointers
 
 Is that really where we want to go?

Yes.  They're just function parameters.  Define how they're passed and pass
'em.  It doesn't need to be fancy or tricky.  It's not particularly different
from passing dynamic arrays having a well defined parameter layout.  Just
considered it just a tuple of two pointers.  It's not rocket science.

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


[Issue 796] Asserting a null object reference throws AssertError Failure internal\invariant.d(14) or Access Violation

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


Bernard Helyer blood.of.l...@gmail.com changed:

   What|Removed |Added

 CC||blood.of.l...@gmail.com


--- Comment #7 from Bernard Helyer blood.of.l...@gmail.com 2011-03-07 
03:12:41 PST ---
Every time I write 

  assert(object);

A dagger pierces my heart and I remember I must write

  assert(object !is null); 

Could we get this fixed this decade some time?

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


[Issue 5713] New: Broken final switch on ints

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

   Summary: Broken final switch on ints
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: accepts-invalid
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-03-07 04:27:15 PST ---
The purpose of final switch is to increase code safety compared to normal
switches on enums. This D2 program compiles and runs with no errors (dmd
2.052):


void main() {
int x = 100;
final switch (x % 3) {
case 0: break;
case 1: break;
}
}


Two possible ways for the D compiler to manage this code:
- Disallow it, not allowing final switches on int values;
- Manage it correctly and require the case case 2: too.
- (A third possibility: ignore the limited range of the switching value and
requiring coverage of the whole integer range, but this is not a good
solution).

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


[Issue 5714] New: case ranges in final switches

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

   Summary: case ranges in final switches
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-03-07 04:31:23 PST ---
This is a low-priority enhancement suggestion.

If the type to final-switch on has a natural ordering (so it's not an enum!),
like a char/ubyte/byte, then in some situations I'd like to use the range
syntax:


void main() {
 ubyte u;
 final switch (u) {
 case   0: .. case 100: break;
 case 101: .. case 255: break;
 }
}


Currently DMD 2.052 gives the errors:
test.d(4): Error: case ranges not allowed in final switch
test.d(5): Error: case ranges not allowed in final switch


See also bug 5713

If case ranges are not allowed on full-range int values, then you can't use
them in a final switch.

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


[Issue 5704] Silent ddoc failure on plot2kill

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



--- Comment #3 from David Simcha dsim...@yahoo.com 2011-03-07 05:28:09 PST ---
Ok, I got kind of lucky and found an easy way to get rid of all the
dependencies.  This program produces absolutely no output either of html files
or to stdout when compiled with -D -c -v.  This is a very unstable bug, i.e.
when I try to take pretty much anything out of this test case, it's no longer
reproducible.

///
class GuiAgnosticBase {
protected:
double _width = 0;
double _height = 0;

string _title;
string _xLabel;
string _yLabel;
public:

abstract int defaultWindowWidth();
abstract int defaultWindowHeight();
abstract int minWindowWidth();
abstract int minWindowHeight();

final double width()  {
return _width;
}

final double height()  {
return _height;
}

final string title()() {
return _title;
}

final This title(this This)(string newTitle) {
_title = newTitle;
return cast(This) this;
}

final string xLabel()() {
return _xLabel;
}

final This xLabel(this This)(string newLabel) {
_xLabel = newLabel;
return cast(This) this;
}

final string yLabel()() {
return _yLabel;
}

///
final This yLabel(this This)(string newLabel) {
_yLabel = newLabel;
return cast(This) this;
}
}

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


[Issue 5713] Broken final switch on ints

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


Stewart Gordon s...@iname.com changed:

   What|Removed |Added

   Keywords||spec, wrong-code
 CC||s...@iname.com


--- Comment #1 from Stewart Gordon s...@iname.com 2011-03-07 05:39:56 PST ---
At first I thought maybe it was ignoring the error out of knowledge that x % 3
== 1 in this instance.  But no - it still accepts (and runs without even a
SwitchError) if I change x to 101.

But you'd need to cover -1 and -2 as well for this to make sense.

The spec doesn't actually disallow it:
http://www.digitalmars.com/d/2.0/statement.html#FinalSwitchStatement

A final switch statement is just like a switch statement, except that:

* No DefaultStatement is allowed.
* No CaseRangeStatements are allowed.
* If the switch Expression is of enum type, all the enum members must
appear in the CaseStatements.
* The case expressions cannot evaluate to a run time initialized value.

But this seems to be a mistake, and that no SwitchError is thrown strikes me as
a bug.

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


[Issue 873] Scope-dependent compilation error

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



--- Comment #2 from Stewart Gordon s...@iname.com 2011-03-07 06:44:48 PST ---
What does foo.init mean?  Looks to me like invalid code.

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


[Issue 5715] New: Contradiction in spec: meaning of variable.init

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

   Summary: Contradiction in spec: meaning of variable.init
   Product: D
   Version: D1  D2
  Platform: All
   URL: http://www.digitalmars.com/d/1.0/property.html#init
OS/Version: All
Status: NEW
  Keywords: spec
  Severity: normal
  Priority: P2
 Component: websites
AssignedTo: nob...@puremagic.com
ReportedBy: s...@iname.com
Blocks: 677


--- Comment #0 from Stewart Gordon s...@iname.com 2011-03-07 06:58:04 PST ---
If applied to a variable or field, it is the default initializer for that
variable or field. For example:

int a;
int b = 1;
typedef int t = 2;
t c;
t d = cast(t)3;

int.init// is 0
a.init// is 0
b.init// is 0
t.init// is 2
c.init// is 2
d.init// is 2

According to the prose, b.init == 1.  But this claims it is 0.  Similarly with
d.

I recall the semantics being changed at some point from the initial value of
the variable to that of its type.  This matches the examples, but not what the
statement actually says.  Possible rewrite of that paragraph:

.init produces a constant expression that is the default initializer. If
applied to a type, it is the default initializer for that type. If applied to a
variable, it is the default initializer for the variable's type.  If applied to
a field, it is the default initializer for that field.  For example:

Moreover, is the meaning for a field meant to apply only to type.field
constructions, or to object.field constructions as well?

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


[Issue 5716] New: Problem with sorting tuples

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

   Summary: Problem with sorting tuples
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-03-07 16:15:56 PST ---
Problem found by Andr� Stein, then reduced. This D2 code used to work:


import std.typecons, std.algorithm;
alias Tuple!(uint) T;
void main() {
auto array = [T(1), T(3), T(2)];
sort(array);
}


But with DMD 2.052 it gives:
object.Exception@src\rt\arraycat.d(40): overlapping array copy

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


[Issue 5713] Broken final switch on ints

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



--- Comment #2 from bearophile_h...@eml.cc 2011-03-07 16:17:51 PST ---
See also bug 5714

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


[Issue 5700] Allow dup in nothrow functions

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



--- Comment #3 from bearophile_h...@eml.cc 2011-03-07 16:21:27 PST ---
See also:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learnarticle_id=25400

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


[Issue 5719] New: [patch] std.conv.to should support structs with custom converters in addition to objects

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

   Summary: [patch] std.conv.to should support structs with custom
converters in addition to objects
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Keywords: patch
  Severity: normal
  Priority: P3
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: sandf...@jhu.edu


--- Comment #0 from Rob Jacques sandf...@jhu.edu 2011-03-07 21:50:57 PST ---
Currently std.conv.to allows classes to define custom conversion routines to
non-class types, but doesn't provide structs with the same functionality. This
functionality can be extended to structs by a minor change in one of the toImpl
template constraints from
is(S : Object)  !is(T : Object)
to 
((is(S : Object)  !is(T : Object)) || is(S == struct))

The particular toImpl is currently located at Line 687 in git (line 680 in DMD
2.051) and has been reproduced in full below with the patch, along with an
updated unit test. The patch passes the unit tests below and the unit tests in
my current fork of std.variant and std.json, but I haven't tested it against
the entire phobos test suite.

/**
Object-_to-non-object conversions look for a method to of the source
object.

Example:

class Date
{
T to(T)() if(is(T == long))
{
return timestamp;
}
...
}

unittest
{
debug(conv) scope(success) writeln(unittest @, __FILE__, :, __LINE__, 
succeeded.);
auto d = new Date;
auto ts = to!long(d); // same as d.to!long()
}

 */
T toImpl(T, S)(S value) if ( ((is(S : Object)  !is(T : Object)) || is(S ==
struct))  !isSomeString!T
 is(typeof(S.init.to!(T)()) : T))
{
return value.to!T();
}

unittest
{
debug(conv) scope(success) writeln(unittest @, __FILE__, :, __LINE__, 
succeeded.);
class B { T to(T)() { return 43; } }
auto b = new B;
assert(to!int(b) == 43);
struct C { T to(T)() { return 43; } }
C c;
assert(to!int(c) == 43);
}

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