[Issue 8510] No line number in error message for conflicting aliases

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8510



--- Comment #3 from github-bugzi...@puremagic.com 2012-08-27 00:45:10 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8e9ac9bc36ffeca069e2896210bda95821bed1a2
fix Issue 8510 - No line number in error message for conflicting aliases

https://github.com/D-Programming-Language/dmd/commit/c4dfdff1b11dc683ac630b7e4f2e2c845057b19b
Merge pull request #1072 from 9rnsr/fix8510

Issue 8510 - No line number in error message for conflicting aliases

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


[Issue 8422] [CTFE] TypeTuple of tuples can't be read at compile time

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8422


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

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


--- Comment #1 from Don clugd...@yahoo.com.au 2012-08-27 00:54:20 PDT ---
This is not a CTFE issue.
It's odd because although the name is 'TypeTuple', it is NOT a type tuple!
As well as types, TypeTuple also accepts literals, and that's what's
happening here. It's not a tuple of tuples, but rather a
foreach over a tuple of struct literals. The fact that the struct literals
were compile-time constants, is lost. Another side-effect is that you
can modify the struct literal is an lvalue. This seems wrong.

Reduced test case:

template TypeTuple(TList...)
{
alias TList TypeTuple;
}

struct T { int x; }

void main()
{
enum a = T(1);
enum b = 6;
foreach(t; TypeTuple!(b, a))
{
enum u = t;
}
}

Pull request:
https://github.com/D-Programming-Language/dmd/pull/1095

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


[Issue 8422] [CTFE] TypeTuple of tuples can't be read at compile time

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8422



--- Comment #2 from Jonathan M Davis jmdavisp...@gmx.com 2012-08-27 01:08:40 
PDT ---
I know fullwell that TypeTuple can hold more than just types. I need to be able
to iterate over a list of tuples at compile time, and a TypeTuple with foreach
should be the way to do that. I don't see why it wouldn't work beyond a
compiler bug.

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


[Issue 6484] compose can't take multi arg functions

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6484



--- Comment #1 from github-bugzi...@puremagic.com 2012-08-27 01:34:27 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/aa40b3b47d64dbf55bd559f113148925ced61ccf
Merge pull request #753 from mylodon/enh6484

fix issue 6484

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


[Issue 8574] [std.format] The flag ' ' works for floating numbers, not only for integers

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8574



--- Comment #2 from github-bugzi...@puremagic.com 2012-08-27 01:44:14 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b7df920554f1c53313740f33aa762342e38fa00c
fix Issue 8574 - [std.format] The flag ' ' works for floating numbers, not only
for integers

https://github.com/D-Programming-Language/phobos/commit/0a511e3975e7c0e4b05c5bff56728ba0263c77fe
Merge pull request #755 from 9rnsr/fix8574

Issue 8574 - [std.format] The flag ' ' works for floating numbers, not only for
integers

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


[Issue 8591] typecons.RefCounted.refCountedPayload should be nothrow

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8591



--- Comment #2 from monarchdo...@gmail.com 2012-08-27 06:36:37 PDT ---
I didn't know that nothrow could be inferred.

Also, I completely agree that duplicating the function is, at best,
un-desirable.

Yet the inference doesn't wor;: However, I am not calling refCountedPayload
directly, but the alias alias refCountedPayload this. Maybe that is the
reason? Or not, I just read #8504.

Anyways, it is preventing me from marking other functions as unconditionally
nothrow.

I think that in the long run, it is better to have a single workaround, which
can be centrally fixed later, rather than having a bunch of functions work
around it, potentially never fixing some of those workaround.

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


[Issue 8593] New: CT out of bounds checks sometimes skipped

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8593

   Summary: CT out of bounds checks sometimes skipped
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: accepts-invalid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: andrej.mitrov...@gmail.com


--- Comment #0 from Andrej Mitrovic andrej.mitrov...@gmail.com 2012-08-27 
08:11:09 PDT ---
This compiles but it should give a CT error since x[4] is out of bounds:
import std.typetuple;
void main()
{
alias TypeTuple!(int) x;
static if (is(x[4] == int))
{
}
}

This correctly gives the error message, 'int' and 'x[4]' just swapped places:
import std.typetuple;
void main()
{
alias TypeTuple!(int) x;
static if (is(int == x[4]))
{
}
}

test.d(17): Error: tuple index 4 exceeds 1

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


[Issue 8593] CT out of bounds checks sometimes skipped

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8593


Andrej Mitrovic andrej.mitrov...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


--- Comment #1 from Andrej Mitrovic andrej.mitrov...@gmail.com 2012-08-27 
08:19:24 PDT ---
Timon Gehr:
Actually it is according to the specification:

3. is ( Type == TypeSpecialization )
The condition is satisfied if Type is semantically correct and is the same type
as TypeSpecialization.

= TypeSpecialization is compiled without suppressing errors.

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


[Issue 8594] New: Enum string validator in Phobos?

2012-08-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8594

   Summary: Enum string validator in Phobos?
   Product: D
   Version: D2
  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 2012-08-27 12:00:47 PDT ---
In the Ada language there is a handy feature, you can define an enumeration of
chars, and then give enum arrays literal as strings, and the compiler enforces
the usage of just the allowed chars:


procedure Test is
   type Hexa is ('A', 'B', 'C', 'D', 'E', 'F');
   type Hex_Array is array (0 .. 5) of Hexa;
   data : Hex_Array;
begin
  data := BACEDC;
end;


Similar literals are very useful, there are many kinds of problems that use
data defined on a subset of the chars, and the chars are a compact
representation. Such strings are able to represent sequence of commands, start
configurations of problems, boards of games, and many kinds of discrete
problems.

(Note: in Ada stack-allocated arrays like Hex_Array are used quite often, more
than heap-allocated arrays.)


If you try to define a literal that contains a wrong char:

procedure Test is
   type Hexa is ('A', 'B', 'C', 'D', 'E', 'F');
   type Hex_Array is array (0 .. 5) of Hexa;
   data : Hex_Array;
begin
  data := BACgDC;
end;


The Ada compiler gives you a compile-time error:

prog.adb:6:15: character not defined for type Hexa defined at line 2


Such compile-time validation is very useful to avoid bugs in the program, and
in D using enum literals is useful because it allows you to use a safer static
switch to process the data, instead of a regular switch on string chars.


This is one possible D translation, but even using with() the array literal
requires commas (and strings are often more handy literals):

enum Hexa : char { A='A', B='B', C='C', D='D', E='E', F='F' }
alias Hexa[6] HexArray; // this is not a true type as in Ada
void main() {
HexArray data;
with (Hexa)
data = [B,A,C,E,D,C];
}



So I have created a small compile-time function + template that validates a
string at compile time:

// - - - - - - - - - - - - - - - -
import std.traits: isSomeChar, EnumMembers;

private E[] _validateEnumString(E)(in string txt)
pure nothrow if (is(E TC == enum)  isSomeChar!TC) {
auto result = new typeof(return)(txt.length);

OUTER:
foreach (i, c; txt) {
/*static*/ foreach (e; EnumMembers!E)
if (c == e) {
result[i] = e;
continue OUTER;
}
assert(false, Not valid enum char:  ~ c);
}

return result;
}

enum Hexa : char { A='A', B='B', C='C', D='D', E='E', F='F' }

template Hexas(string path) {
enum Hexas = _validateEnumString!Hexa(path);
}

alias Hexa[6] HexArray;
void main() {
HexArray data = Hexas!BACEDC;
}
// - - - - - - - - - - - - - - - -




This alternative design uses a cast to avoid the input duplication and maybe
reduces the compilation time, but produces only arrays of immutable enums:

// - - - - - - - - - - - - - - - -
import std.traits: isSomeChar, EnumMembers;

private immutable(E)[] _validateEnumString(E)(in string txt)
pure nothrow if (is(E TC == enum)  isSomeChar!TC) {

OUTER:
foreach (i, c; txt) {
/*static*/ foreach (e; EnumMembers!E)
if (c == e)
continue OUTER;
assert(false, Not valid enum char:  ~ c);
}

return cast(typeof(return))txt;
}

enum Hexa : char { A='A', B='B', C='C', D='D', E='E', F='F' }

template Hexas(string path) {
enum Hexas = _validateEnumString!Hexa(path);
}

alias Hexa[6] HexArray;
void main() {
HexArray data = Hexas!BACEDC;
auto data2 = Hexas!BACEDC;
static assert(is(typeof(data2) == immutable(Hexa)[]));
}
// - - - - - - - - - - - - - - - -


Defining enum array literals this way is one of the built-in features of Ada,
because it's commonly useful, this is quoted from Wikipedia:
http://en.wikipedia.org/wiki/Enumerated_type#Ada

Like Modula-3 Ada treats Boolean and Character as special pre-defined (in
package Standard) enumerated types. Unlike Modula-3 one can also define own
character types:

type Cards is (7, 8, 9, J, Q, K, A);


So maybe a template similar to the ones I have shown here is useful enough to
be added to Phobos.

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