[Issue 2581] DDoc doesn't work for functions with auto return type.

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


Walter Bright  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


--- Comment #1 from Walter Bright  2011-01-20 
22:50:53 PST ---
http://www.dsource.org/projects/dmd/changeset/886

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


[Issue 5470] D documentation in CHM format

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


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 5470] New: D documentation in CHM format

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

   Summary: D documentation in CHM format
   Product: D
   Version: D1 & D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P3
 Component: websites
AssignedTo: nob...@puremagic.com
ReportedBy: thecybersha...@gmail.com


--- Comment #0 from Vladimir  2011-01-20 21:53:58 PST 
---
I've written a tool to automatically convert the D documentation (both D1 and
D2) to the CHM format. The tool, and pre-generated CHMs, are available here:
http://thecybershadow.net/d/docs/

I've asked on IRC if anyone considered linking to the page from D's webpage,
and Andrei seems to think it's a good idea.

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


[Issue 1001] print stack trace (in debug mode) when program die

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



--- Comment #35 from Sean Kelly  2011-01-20 15:40:41 
PST ---
(In reply to comment #33)
> For a win32 stacktrace (XP+) you might check my project on this:
> 
> http://3d.benjamin-thaut.de/?p=15

Thanks!  I've noticed that the code doesn't have a Boost-compatible copyright. 
Would you be averse to changing this so some derivative could be used in
druntime?  I also found this in the MSDN docs:

"All DbgHelp functions, such as this one, are single threaded. Therefore, calls
from more than one thread to this function will likely result in unexpected
behavior or memory corruption. To avoid this, you must synchronize all
concurrent calls from more than one thread to this function."

http://msdn.microsoft.com/en-us/library/ms681327(v=vs.85).aspx

I guess that means that the stack trace generation on Windows will have to be
wrapped in a synchronized block.

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


[Issue 2581] DDoc doesn't work for functions with auto return type.

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


Andrei Alexandrescu  changed:

   What|Removed |Added

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


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


[Issue 5469] New: Limitation when instantiating templates in the context of a function

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

   Summary: Limitation when instantiating templates in the context
of a function
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: jens.k.muel...@gmx.de


--- Comment #0 from jens.k.muel...@gmx.de 2011-01-20 12:27:09 PST ---
The following code does not compile (tried with dmd v2.050 on Linux).

import std.functional;
import std.algorithm;

void main() {
auto numbers = [0, 1, 2, 3, 4, 5];

bool var = true;
bool returnVar(uint a) { return var; }
alias not!(returnVar) notReturnVar;
//bool notReturnVar(uint a) { return not!returnVar(a); } // workaround

filter!(returnVar)(numbers);
filter!(notReturnVar)(numbers); // does not compile
}

It fails with:
/path/to/src/phobos/std/algorithm.d(854): Error: constructor
std.algorithm.Filter!(not,int[]).Filter.this cannot get frame pointer to not
/path/to/src/phobos/std/algorithm.d(866): Error: function
std.algorithm.Filter!(not,int[]).Filter.popFront cannot get frame pointer to
not

It has problems getting the frame pointer to the template function
not!(returnVar). As far as I understand it.
A workaround is to define a non-template function.

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


[Issue 5468] New: Linker fails to link libraries using phobos2 with C code

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

   Summary: Linker fails to link libraries using phobos2 with C
code
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: Optlink
AssignedTo: nob...@puremagic.com
ReportedBy: past...@gmail.com


--- Comment #0 from GreatEmerald  2011-01-20 11:52:33 PST ---
When you try to create a static D library that imports and/or uses anything
from the phobos2 library, the generated library can no longer be linked with C
programs.

For testing purposes, I have two files, the D library:

module dpart;
import std.stdio;

extern(C):
shared int ResultD;

int Process(int Value)
{
printf("You have sent the value %d to the D library.\n", Value);
ResultD = (Value % 5);
return ResultD;
}

And the C file that is using the library:

#include 

extern int ResultD;

int Process(int Value);

int main()
{
int Result;

printf("This text is written in C. Input a number.\n");
scanf("%d", &Result);
Process(Result);
printf("%d modulus 5 is %d.\n", Result, ResultD);
getchar();
getchar();
return 0;
}

I compile this code using two steps:
dmd -c -lib dpart.d
dmc dpart.lib cpart.c

And I get this linker error:

link cpart,,,dpart+user32+kernel32/noi;
OPTLINK (R) for Win32  Release 8.00.5
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
dpart.lib
 Warning 140: Library probably needs FIXLIB
dpart.lib(dpart)
 Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ

--- errorlevel 1

I get additional errors if I try to use writeln() instead of printf(), but it
compiles and runs fine if I import std.c.stdio instead of std.stdio. Linking
also fails if I try to import any of other parts of phobos2 included in D, such
as std.path.

I'm using DMD 2.051 and DMC 8.42n on Windows 7 x64.

-- 
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 5467] library-based typedef

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



--- Comment #1 from Trass3r  2011-01-20 08:51:08 PST ---
And that's the latest code draft I could find:

enum Type
{
Independent,
Super,
Sub,
Parallel,
}

struct Typedef( T, Type type = Type.Sub, T init = T.init, string _f = __FILE__,
int _l = __LINE__ )
{
T payload = init;


static if ( type != Type.Independent )
{
this( T value )
{
payload = value;
}
}
static if ( type == Type.Sub)
{
// typedef int foo; foo f;
// f.opCast!(t)() == cast(t) f
T opCast(T)()
{
return payload;
}
}
static if ( type == Type.Sub || type == Type.Parallel )
{
alias payload this;
}
static if ( type == Type.Super )
{
typeof( this ) opAssign( T value )
{
payload = value;
return this;
}
}
else static if ( type == Type.Sub )
{
@disable void opAssign( T value );
}
}

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


[Issue 5467] New: library-based typedef

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

   Summary: library-based typedef
   Product: D
   Version: D1 & D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: mrmoc...@gmx.de


--- Comment #0 from Trass3r  2011-01-20 08:48:32 PST ---
Typedef is scheduled for deprecation but there is no proper library-based
solution to it yet. Andrei pointed out the following use cases:

1. Something that's just like another type yet "parallel" with it. This is good
for abstractions that encode different units of measurement that aren't
supposed to be mixed.

ParallelTypedef!double Miles;

Such a type should accept explicit initialization from a regular double:

auto dist = Miles(3.2);

However it shouldn't accept initialization from another parallel typedef:

ParallelTypedef!double Kms;
auto dist1 = Kms(4);
auto dist2 = Miles(dist1); // no

Arithmetic operations should only work within Miles but not mixing Miles with
other types. Here's where things already get complicated - you do want to allow
some operations between Miles and double (e.g. "*"), in some others you don't
(e.g. "+"). Here's where a library facility would help:

ParallelTypdef!(double, "allow_arithmetic", "allow_mixed:*,/,%")
Miles;

2. Opaque "handle" types that can be used with overloading. The base type of
the typedef is just the storage strategy:

OpaqueTypedef!int FileHandle;

Such a typedef supports no arithmetic and no implicit conversions. You can
explicitly initialize it from an int and you can cast it back to it using an
explicit cast.

3. Proper subtype. Create a true subtype of a type that allows explicit
initialization from the type and implicit conversion to the type.

SubtypeTypedef!Exception MyException;

4. Proper supertype. The base type implicitly converts to the introduced type,
but not vice versa.

SupertypeTypedef!uint Bits;

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


[Issue 5461] Invalid declaration for auto functions in .di files generated by DMD -H

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



--- Comment #1 from Nicolas Sicard  2011-01-20 08:25:32 PST ---
Created an attachment (id=872)
patch of func.c in DMD 2.051

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


[Issue 5465] AA.keys with char keys

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


Don  changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au


--- Comment #1 from Don  2011-01-20 08:19:41 PST ---
It started doing that in 2.046, and still failed in 2.051. But it's working in
my local copy of DMD, so should be fixed in the next release.

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


[Issue 5451] Three ideas for RedBlackTree

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


Steven Schveighoffer  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||schvei...@yahoo.com
 AssignedTo|nob...@puremagic.com|schvei...@yahoo.com


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


[Issue 5197] Ddoc: access-attributed auto template function crashes dmd

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


Don  changed:

   What|Removed |Added

   Keywords||ddoc, ice-on-valid-code
 CC||clugd...@yahoo.com.au


--- Comment #3 from Don  2011-01-20 04:58:58 PST ---
(In reply to comment #2)
> Unfortunately, that still doesn't make auto function documentable; they simply
> vanish from the html.

Yes, but that's bug 2581, which is different from this crashing bug.

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


[Issue 5466] New: AA ranges

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

   Summary: AA ranges
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: druntime
AssignedTo: s...@invisibleduck.org
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-01-20 04:06:22 PST ---
I use D associative arrays often so I'd like AAs to be modified so byKey() and
byValue() return ranges (that have a length attribute too) usable with higher
order functions of std.algorithm like map and filter.

AAs too may become iterable with no method calls:
map!q{a * 10}([1:2, 3:4])

I also suggest to add a third associative array member function that returns a
range of (key,value) typecons tuples, as in a similar Python3 dict method.

--

To test the situation, this task is to create a dynamic array of pairs (tuples)
like:
[(10,"aa"), (20,"bb"), (30,"cc")]

from the associative array:
[1:'a', 2:'b', 3:'c']

If possible reading things lazily from the associative array.



Idiomatic Python2 solution (iteritems is lazy):

>>> d = {1:'a', 2:'b', 3:'c'}
>>> [(k*10, v*2) for k,v in d.iteritems()]
[(10, 'aa'), (20, 'bb'), (30, 'cc')]



D2 lazy solution without map():

import std.stdio, std.typecons;
void main() {
auto aa = [1:'a', 2:'b', 3:'c'];
Tuple!(int, string)[] r;
foreach (k, v; aa)
r ~= tuple(k*10, ""~v~v);
writeln(r);
}



The byPair() range allows to solve the task functionally ad lazily like this:

import std.stdio, std.typecons, std.algorithm;
void main() {
auto aa = [1:'a', 2:'b', 3:'c'];
auto r = map!q{ tuple(a[0]*10, a[1]~a[1]) }(aa.byPair());
writeln(r);
}

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


[Issue 5465] New: AA.keys with char keys

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

   Summary: AA.keys with char keys
   Product: D
   Version: D2
  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 2011-01-20 03:18:09 PST ---
Similar code used to work in D1 (printing "aehilmpstx "), but with DMD 2.051 it
prints a wrong output:



import std.stdio;
void main() {
string text = "this is a text example";
int[char] aa;
foreach (c; text)
aa[c]++;
writeln(aa.keys);
}


Generated printout:
t1@

Expected printout, something like:
['t', 'h', ' ', 'x', 'p', 'l', 'i', 'a', 'e', 'm', 's]

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


[Issue 4459] bad format - phobos/std/all.d - 2.051

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


Glenn Haecker  changed:

   What|Removed |Added

Summary|bad format -|bad format -
   |phobos/std/all.d - 2.048|phobos/std/all.d - 2.051


--- Comment #3 from Glenn Haecker  2011-01-20 02:59:22 
PST ---
Still broken in 2.051

Surely I'm not the only one building phobos on linux.

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


[Issue 5464] New: Attribute to not ignore function result

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

   Summary: Attribute to not ignore function result
   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-01-20 02:59:14 PST ---
Ignoring the result of some functions like string replace(), or the C
realloc(), or in general the result of strongly pure functions in D, is a
programmer mistake that often enough is a sign of a bug presence.

To face this problem GNU C has the warn_unused_result attribute:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
(This is more useful in C than D because in C there are no true built-in
exceptions, so error return values are common, and sometimes ignoring them is a
mistake.)

Some C lints require a void cast where you don't want to use a function result:
cast(void)foo(x);

In a language the default is different and where you don't want to use a
function result you have to add a specific annotation:
unused foo(x);

In D an attribute like @nodiscard (name invented by Andrej Mitrovic) may turn
ignoring return values into errors. To silence this error the programmer uses
something like cast(void).

So the error message may be:
"Error: unused result of @nodiscard function. Use cast(void) to override it."

Strongly pure functions may produce this error even if you don't use
@nodiscard.

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


[Issue 5463] New: errno undeclared in gzio.c

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

   Summary: errno undeclared in gzio.c
   Product: D
   Version: D2
  Platform: x86
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: ghaec...@idworld.net


--- Comment #0 from Glenn Haecker  2011-01-20 02:48:53 
PST ---
dmd 2.051

Building phobos fails at

cc -c  -m32 -O3 etc/c/zlib/gzio.c -ogenerated/posix/release/etc/c/zlib/gzio.o

with multiple "‘errno’ undeclared" errors.

gzio.c is missing errno header

#include 

Also, in etc/c/zlib/linux.mak lines 43 - 47 should be commented out or removed.

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


[Issue 5197] Ddoc: access-attributed auto template function crashes dmd

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


Andrei Alexandrescu  changed:

   What|Removed |Added

 CC||and...@metalanguage.com


--- Comment #2 from Andrei Alexandrescu  2011-01-20 
00:15:50 PST ---
Unfortunately, that still doesn't make auto function documentable; they simply
vanish from the html.

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


[Issue 4389] ICE(constfold.c, expression.c), or wrong code: string~=dchar in CTFE

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



--- Comment #6 from Don  2011-01-19 23:59:47 PST ---
Fails on D1 because dchar, wchar implicitly convert to char, even if they don't
fit.

PATCH: expression.c, CatAssignExp::semantic(), line 8574. The two 'else'
clauses need to be swapped,
so that we check for an array~char before we check for implicit conversion.


{   // Append array
e2 = e2->castTo(sc, e1->type);
type = e1->type;
e = this;
}
--- SWAP THIS SECTION WITH THE NEXT ONE
else if ((tb1->ty == Tarray) &&
e2->implicitConvTo(tb1next)
   )
{   // Append element
e2 = e2->castTo(sc, tb1next);
type = e1->type;
e = this;
}
---
else if (tb1->ty == Tarray &&
(tb1next->ty == Tchar || tb1next->ty == Twchar) &&
e2->implicitConvTo(Type::tdchar)
   )
{   // Append dchar to char[] or wchar[]
e2 = e2->castTo(sc, Type::tdchar);
type = e1->type;
e = this;

/* Do not allow appending wchar to char[] because if wchar happens
 * to be a surrogate pair, nothing good can result.
 */
}
---
else
{
if (tb1 != Type::terror && tb2 != Type::terror)
error("cannot append type %s to type %s", tb2->toChars(),
tb1->toChars());
e = new ErrorExp();
}

ALTERNATE PATCH:
Incidentally, if dchar->char is disallowed, all DMD tests still pass. But this
would probably cause existing valid code to break, so probably the first
solution is better.

mtype.c,  line 1570, MATCH TypeBasic::implicitConvTo(Type *to)
+   if ((ty == Tdchar || ty == Twchar) && to->ty == Tchar)
+return MATCHnomatch;
+   if (ty == Tdchar && to->ty == Twchar)
+   return MATCHnomatch;
}
else if (flags & TFLAGSfloating)
{
// Disallow implicit conversion of floating point to integer
if (tob->flags & TFLAGSintegral)
return MATCHnomatch;

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


[Issue 5197] Ddoc: access-attributed auto template function crashes dmd

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


Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #1 from Walter Bright  2011-01-19 
23:55:44 PST ---
http://www.dsource.org/projects/dmd/changeset/884

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