[Issue 4110] Function template with two constraints

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4110


Gide Nwawudu g...@nwawudu.com changed:

   What|Removed |Added

   Keywords||accepts-invalid
 Status|NEW |RESOLVED
 CC||g...@nwawudu.com
 Resolution||DUPLICATE


--- Comment #1 from Gide Nwawudu g...@nwawudu.com 2010-04-24 02:41:46 PDT ---
You missed out a brace, patch in BUG 4084 should prevent this from compiling.

*** This issue has been marked as a duplicate of issue 4084 ***

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


[Issue 4084] Ignored missing main() closing bracket

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4084



--- Comment #2 from Gide Nwawudu g...@nwawudu.com 2010-04-24 02:41:46 PDT ---
*** Issue 4110 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: ---


[Issue 2484] Templated classes have no moduleinfo

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2484


Robert Clipsham rob...@octarineparrot.com changed:

   What|Removed |Added

 CC||rob...@octarineparrot.com


--- Comment #5 from Robert Clipsham rob...@octarineparrot.com 2010-04-24 
12:50:38 BST ---
It seems the system for doing this has been replaced in D2, it uses a property
rather than a variable:
http://dsource.org/projects/druntime/browser/trunk/src/object_.d#L1495, it
should still function the same way though.

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


[Issue 2484] Templated classes have no moduleinfo

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2484



--- Comment #6 from nfx...@gmail.com 2010-04-24 06:41:02 PDT ---
But it's not user accessible:
http://dsource.org/projects/druntime/browser/trunk/import/object.di#L226
Well, maybe this is just a temporary regression.

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


[Issue 4116] New: object.di does not match object_.d

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4116

   Summary: object.di does not match object_.d
   Product: D
   Version: 2.041
  Platform: Other
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: druntime
AssignedTo: s...@invisibleduck.org
ReportedBy: rob...@octarineparrot.com


--- Comment #0 from Robert Clipsham rob...@octarineparrot.com 2010-04-24 
15:29:03 BST ---
The ModuleInfo struct in the user visible object.di does not match the
implementation in object_.d, which disables some functionality eg the ability
to find the classes in a module from user code. The two files need
synchronizing to make sure everything that needs to be accessible is.

http://dsource.org/projects/druntime/browser/trunk/src/object_.d#L1267
http://dsource.org/projects/druntime/browser/trunk/import/object.di#L226

Note the absence of the localClasses property in object.di, among other missing
properties.

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


[Issue 2484] Templated classes have no moduleinfo

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2484


nfx...@gmail.com changed:

   What|Removed |Added

   Keywords||patch


--- Comment #8 from nfx...@gmail.com 2010-04-24 08:24:31 PDT ---
Here's a partial patch against dmd 1.057:

diff --git a/dsymbol.c b/dsymbol.c
index 7614e13..5fca88e 100644
--- a/dsymbol.c
+++ b/dsymbol.c
@@ -715,6 +715,20 @@ ScopeDsymbol::ScopeDsymbol(Identifier *id)
 prots = NULL;
 }

+void ScopeDsymbol::addLocalClass(ClassDeclarations * aclasses) {
+//
+if (!members)
+return;
+
+//printf(members-dim = %d\n, members-dim);
+for (int i = 0; i  members-dim; i++)
+{   Dsymbol *member = (Dsymbol *)members-data[i];
+
+//printf(\tmember '%s'\n, member-toChars());
+member-addLocalClass(aclasses);
+}
+}
+
 Dsymbol *ScopeDsymbol::syntaxCopy(Dsymbol *s)
 {
 //printf(ScopeDsymbol::syntaxCopy('%s')\n, toChars());
diff --git a/dsymbol.h b/dsymbol.h
index e566515..49f8750 100644
--- a/dsymbol.h
+++ b/dsymbol.h
@@ -270,6 +270,8 @@ struct ScopeDsymbol : Dsymbol
 static Dsymbol *getNth(Array *members, size_t nth, size_t *pn = NULL);

 ScopeDsymbol *isScopeDsymbol() { return this; }
+
+void addLocalClass(ClassDeclarations *);
 };

 // With statement scope
diff --git a/template.h b/template.h
index 90b5161..ecbd04e 100644
--- a/template.h
+++ b/template.h
@@ -87,6 +87,9 @@ struct TemplateDeclaration : ScopeDsymbol
 int isOverloadable();

 void makeParamNamesVisibleInConstraint(Scope *paramscope);
+
+// don't add uninstantiated template classes
+void addLocalClass(ClassDeclarations *) {}
 };

 struct TemplateParameter
diff --git a/toobj.c b/toobj.c
index e2d2403..1431e0e 100644
--- a/toobj.c
+++ b/toobj.c
@@ -92,13 +92,7 @@ void Module::genmoduleinfo()

 ClassDeclarations aclasses;

-//printf(members-dim = %d\n, members-dim);
-for (int i = 0; i  members-dim; i++)
-{  Dsymbol *member = (Dsymbol *)members-data[i];
-
-   //printf(\tmember '%s'\n, member-toChars());
-   member-addLocalClass(aclasses);
-}
+addLocalClass(aclasses);

 // importedModules[]
 int aimports_dim = aimports.dim;


Here's a test case:

import tango.io.Stdout;

class This {}

struct X {
class Foo {
}
}

class C(T) { }

void main() {
class Goo { } //not detected
auto z = new Goo();
C!(int) x = new C!(int);
ClassInfo cobj = Object.classinfo;
foreach (ModuleInfo m; ModuleInfo) {
foreach (ClassInfo ci; m.localClasses) {
if (ci is This.classinfo) {
foreach (c; m.localClasses)
Stdout.formatln({}, c.name);
}
}
}

It prints:
d.This
d.X.Foo
d.C!(int).C

As can be seen, class Goo is still missing. It seems the patch doesn't search
through functions. Maybe there are other cases where it still fails.

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


[Issue 4117] New: rev 439 compilation error

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4117

   Summary: rev 439 compilation error
   Product: D
   Version: unspecified
  Platform: Other
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: ellery-newco...@utulsa.edu


--- Comment #0 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-24 
10:47:09 PDT ---
when trying to compile rev 439 I get

expression.c:5293: error: jump to label ‘Lerr’
expression.c:5045: error:   from here
expression.c:5048: error:   crosses initialization of ‘Type* t’

easy fix, though.

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


[Issue 4117] rev 439 compilation error

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4117



--- Comment #1 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-24 
10:48:08 PDT ---
Created an attachment (id=612)
the easy fix

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


[Issue 4117] rev 439 compilation error

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4117


Ellery Newcomer ellery-newco...@utulsa.edu changed:

   What|Removed |Added

 Attachment #612 is|0   |1
   obsolete||


--- Comment #2 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-24 
10:50:47 PDT ---
Created an attachment (id=613)
the easy fix that isn't broken

dang it.

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


[Issue 3854] Error on static initialization of arrays with trailing comma.

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3854


Ellery Newcomer ellery-newco...@utulsa.edu changed:

   What|Removed |Added

 Attachment #597 is|0   |1
   obsolete||


--- Comment #9 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-04-24 
11:07:19 PDT ---
Created an attachment (id=614)
the patch which I mistakenly put in 3716

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


[Issue 4118] New: std.conv.to!SomeStruct(hello) crashes compiler

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4118

   Summary: std.conv.to!SomeStruct(hello) crashes compiler
   Product: D
   Version: 2.041
  Platform: x86_64
OS/Version: Mac OS X
Status: NEW
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: michel.for...@michelf.com


--- Comment #0 from Michel Fortin michel.for...@michelf.com 2010-04-24 
14:15:55 EDT ---
The program below crashes with Bus error when trying to compile from the
command line on Mac OS X 10.6.3. I know this was not crashing the compiler a
few versions ago (some time early january 2010).

---
import std.conv;

struct SomeStruct { }

void main() {
auto s = to!SomeStruct(hello);
}
---

It is a real problem for me that it crashes the compiler since I'm using a
__traits(compile, ...) with something similar for conditional compilation, and
this does not work anymore.

---
import std.conv;

struct SomeStruct { }

void main() {
static if (__traits(compiles, to!SomeStruct(hello))) {
auto s = to!SomeStruct(hello);
}
}
---

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


[Issue 4059] Incorrect C++ name mangling

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4059


Robert Clipsham rob...@octarineparrot.com changed:

   What|Removed |Added

   Keywords|patch   |


--- Comment #5 from Robert Clipsham rob...@octarineparrot.com 2010-04-24 
19:24:44 BST ---
It seems there are other cases that this patch breaks, so there's obviously a
different way of fixing this.

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


[Issue 4119] New: bigint string assign

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4119

   Summary: bigint string assign
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 15:46:15 PDT ---
I'd like this code to work:

import std.bigint: BigInt;
void main() {
BigInt i;
i = 100_000_000_000_000_000_000_000_000_000;
}


With dmd 2.043 it prints:

test.d(4): Error: template bigint.BigInt.opAssign(T : long) does not match any
function template declaration
test.d(4): Error: template bigint.BigInt.opAssign(T : long) cannot deduce
template function from argument types !()(string)

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


[Issue 4120] New: bigint implicit cast too bool

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4120

   Summary: bigint implicit cast too bool
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 15:49:39 PDT ---
I'd like this code to work:


import std.bigint: BigInt;
void main() {
BigInt b = 1;
if (b)
int r = 10;
}

With an opCast(bool).

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


[Issue 4121] New: Associative array value bigint assign

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4121

   Summary: Associative array value bigint assign
   Product: D
   Version: future
  Platform: x86
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 15:54:32 PDT ---
I don't understand this error (this is not related to BigInt missing a toHash):

import std.bigint: BigInt;
void main() {
BigInt[int] aa;
BigInt b = BigInt(1);
aa[10] = b; // line 5
}


dmd 2.043 shows:
core.exception.rangeer...@temp(5): Range violation

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


[Issue 4122] New: More handy BigInt.toString()

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4122

   Summary: More handy BigInt.toString()
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 16:09:02 PDT ---
The toString() of BigInt is not handy to print bigintegers during debugging. I
have had to create a function like:

const(char)[] bigIntRepr(BigInt i) {
const(char)[] result;
i.toString((const(char)[] s){ result = s; }, d);
return result;
}


Note that this doesn't work (Access violation, I don't know why):

const(char)[] bigIntRepr(BigInt i) {
const(char)[] result;
i.toString((const(char)[] s){ result = s; }, null);
return result;
}


My suggestion is to change the signature of BigInt.toString() from this:

void toString(void delegate(const (char)[]) sink, string formatString) const {


To something like this:

string toString(void delegate(string) sink=null, string formatString=d) const
{   

And make it return a string filled with the decimal representation when sink is
null; and to return an empty string when sink!=null.



Eventually the signature can even become:

string toString(void delegate(string) sink=null, string formatString=d,
string thousands=) const {

So if thousands=_ the number gets represented as:

100_000_000_000

But this is less important.

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


[Issue 4123] New: BitArray this() with length

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4123

   Summary: BitArray this() with length
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 16:14:29 PDT ---
Using Phobos with dmd 2.043 this is wrong code, because it initialized the
length field but doesn't actually extend the array.
I think this is a natural syntax that people will want to use, so I suggest to
add this syntax, otherwise I think this will be a cause of bugs in programs.

So this is an enhancement request, but it's borderline with a bug report.


import std.bitmanip: BitArray;
void main() {
auto b = BitArray(10);
}

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


[Issue 4124] New: toString() for BitArray and more

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4124

   Summary: toString() for BitArray and more
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 16:26:12 PDT ---
A toString() method for std.bitmanip.BitArray is useful. It can use a simple
representation like the Python bitarray:

010100101011

Or as java.util.BitSet (but I prefer the Python version):

{1, 3, 6, 8, 10, 15} 


Other methods useful for BitArray:
- reset all bits
- set all bits
- are all bit set?
- are all bit reset?
- count set bits (there are _very_ efficient algorithms to do this).
- set n-th bit (this can be a little more efficient than bs[n]=1;)
- reset n-th bit (this can be a little more efficient than bs[n]=1;)
- flip n-th bit


I think the sort() method of BitArray is not commonly useful.

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


[Issue 4125] New: std.numeric.gcd can use a binary GCD

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4125

   Summary: std.numeric.gcd can use a binary GCD
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 16:57:35 PDT ---
std.numeric.gcd can use a faster Binary GCD algorithm, especially when the
input type is unsigned. This page has both C code (and asm, but the C code is
probably enough in many situations):

http://en.wikipedia.org/wiki/Binary_GCD_algorithm

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


[Issue 4126] New: std.range.ElementType doesn't work with opApply

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4126

   Summary: std.range.ElementType doesn't work with opApply
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-24 17:34:36 PDT ---
ElementType doesn't work with a class/struct that defines an opApply, this
prints 'void' (dmd 2.043):


import std.stdio: writeln;
import std.range: ElementType;

struct Foo {
char stop;
int opApply(int delegate(ref long) dg) {
int result;
for (long i = 0; i  stop; i++) {
result = dg(i);
if (result)
break;
}
return result;
}
}

void main() {
writeln(typeid(ElementType!Foo)); // Output: void
}



A naive way to find the type given by the opApply:

template IterType(alias iterable) {
alias ReturnType!({ foreach(x; iterable)
return x;
assert(0);
  }) IterType;
}


A more refined way (this template is named BaseType1, because it goes down just
one level):

...
static if ( is(typeof(T.opApply)) )
alias OpApplyType!(T) BaseType1;
...


Where:

template OpApplyType(T) {
static if (ParameterTypeTuple!(ParameterTypeTuple!(T.opApply)[0]).length ==
1)
alias ParameterTypeTuple!(ParameterTypeTuple!(T.opApply)[0])[0]
OpApplyType;
else
alias ParameterTypeTuple!(ParameterTypeTuple!(T.opApply)[0])
OpApplyType;
}

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


[Issue 4127] New: std.stdio.File doesn't close popen() files correctly

2010-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4127

   Summary: std.stdio.File doesn't close popen() files correctly
   Product: D
   Version: 2.041
  Platform: Other
OS/Version: Linux
Status: NEW
  Severity: minor
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: destructiona...@gmail.com


--- Comment #0 from Adam D. Ruppe destructiona...@gmail.com 2010-04-24 
17:56:02 PDT ---
{
File f;
f.popen(command, w);
f.write(hello world);
}

This throws in its destructor cannot close file (success). It looks like File
always calls fclose() on its handle, but if it is opened with popen(), it
should call pclose() to close it instead.

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