[Issue 4268] New: ambiguous name mangling for local functions
http://d.puremagic.com/issues/show_bug.cgi?id=4268 Summary: ambiguous name mangling for local functions Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: r.sagita...@gmx.de --- Comment #0 from Rainer Schuetze r.sagita...@gmx.de 2010-06-04 05:46:37 PDT --- This code: module test; struct struc { struct fnb {} } struc fna() { struct fnb { static void fnc() { static struct x {} pragma(msg,x.mangleof); } } return struc(); } struc.fnb fna() { static void fnc() { static struct x {} pragma(msg,x.mangleof); } return struc.fnb(); } outputs with dmd -c test.d S4test3fnaFZS4test5struc3fnb3fncFZv1x S4test3fnaFZS4test5struc3fnb3fncFZv1x so both functions fnc have the same mangled name. This seems like a very constructed situation, but it just illustrates that std.demangle cannot create correct output for local functions if the outer function returns a qualified type. This happens because there is no seperator between the return type and the identifier of the local symbol name. As a result, local functions might not show up correctly in call stacks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4269] New: invalid type accepted if evaluated while errors are gagged
http://d.puremagic.com/issues/show_bug.cgi?id=4269 Summary: invalid type accepted if evaluated while errors are gagged Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: r.sagita...@gmx.de --- Comment #0 from Rainer Schuetze r.sagita...@gmx.de 2010-06-04 05:58:53 PDT --- The D2 code (tried with DMD 2.042 and 2.046): static if(__traits(compiles,A.sizeof)) pragma(msg, A.sizeof compiles!); class A { void foo(B b); } compiles without error with dmd -c test.d or even links if foo is made final. This is caused by the error when evaluating B is muted while processing __traits(compiles), but A is never revisited later. A debug version of DMD outputs ty = 37, '_error_' assert glue.c(1059) 0 This can happen whenever globals.gag is non-zero, i.e. with speculative semantic analysis. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4235] !in not working (D1)
http://d.puremagic.com/issues/show_bug.cgi?id=4235 Don clugd...@yahoo.com.au changed: What|Removed |Added Keywords|ice-on-valid-code | --- Comment #5 from Don clugd...@yahoo.com.au 2010-06-04 06:06:42 PDT --- Removing the ICE keyword from this bug since it has no test case. I have tried many times to reproduce a crash, but there's no enough information. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3662] Wrong compile error within struct constructor and C-style initializer
http://d.puremagic.com/issues/show_bug.cgi?id=3662 Don clugd...@yahoo.com.au changed: What|Removed |Added Keywords||patch CC||clugd...@yahoo.com.au --- Comment #2 from Don clugd...@yahoo.com.au 2010-06-04 12:46:36 PDT --- Trivial. Missing 'loc' in error call. PATCH: init.c, StructInitializer::semantic(), line 158. if (ad-ctor) -error(%s %s has constructors, cannot use { initializers }, use + error(loc, %s %s has constructors, cannot use { initializers }, use %s( initializers ) instead, ad-kind(), ad-toChars(), ad-toChars()); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4270] New: Missing line number in 'can only catch class objects' error message
http://d.puremagic.com/issues/show_bug.cgi?id=4270 Summary: Missing line number in 'can only catch class objects' error message Product: D Version: 2.041 Platform: Other OS/Version: Windows Status: NEW Keywords: diagnostic, patch Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: clugd...@yahoo.com.au --- Comment #0 from Don clugd...@yahoo.com.au 2010-06-04 12:51:32 PDT --- void bug4270() { try{} catch(int banana) {} } -- Error: can only catch class objects, not 'int' -- PATCH: statement.c 4197 void Catch::semantic(Scope *sc) type = type-semantic(loc, sc); if (!type-toBasetype()-isClassHandle()) -error(can only catch class objects, not '%s', type-toChars()); +error(loc, can only catch class objects, not '%s', type-toChars()); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4270] Missing line number in 'can only catch class objects' error message
http://d.puremagic.com/issues/show_bug.cgi?id=4270 --- Comment #1 from Don clugd...@yahoo.com.au 2010-06-04 13:15:49 PDT --- Bug 3712 is a combination of this bug, with a D1-only error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4270] Missing line number in 'can only catch class objects' error message
http://d.puremagic.com/issues/show_bug.cgi?id=4270 bearophile_h...@eml.cc changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #2 from bearophile_h...@eml.cc 2010-06-04 13:20:59 PDT --- An idea: comment out the error() that doesn't accept a line number, then fix all calling points that use it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 1382] memory allocated for arrays in CTFE functions during compilation is not released
http://d.puremagic.com/issues/show_bug.cgi?id=1382 bearophile_h...@eml.cc changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #6 from bearophile_h...@eml.cc 2010-06-04 15:19:11 PDT --- A partially artificial test case. Faster and better versions are quite possible, but I expect dmd to be able to run this quickly. import std.stdio: writeln; ubyte[1 NPOW] setBits(int NPOW)() { nothrow pure uint setBits8(uint n) { uint result; foreach (i; 0 .. 8) if (n (1 i)) result++; return result; } nothrow pure uint setBits16(uint n) { enum uint FIRST_UBYTE = 0b___; enum uint SECOND_UBYTE = 0b___; return setBits8(n FIRST_UBYTE) + setBits8((n SECOND_UBYTE) 8); } typeof(return) result; foreach (i; 1 .. result.length) result[i] = cast(typeof(result[0]))setBits16(i); return result; } enum nbits = setBits!16(); // currently 12 is about the max void main() { writeln(nbits); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4271] New: drop/pop methods for std.algorithm.BinaryHeap
http://d.puremagic.com/issues/show_bug.cgi?id=4271 Summary: drop/pop methods for std.algorithm.BinaryHeap Product: D Version: future Platform: x86 OS/Version: Windows 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-06-04 15:28:50 PDT --- During the usage of a Heap one of the most commonly used operations is to pop an item from a heap and then to use it. But in std.algorithm.BinaryHeap the pop() doesn't return the item, probably for performance reasons (it requires the copy of the item). (So to pop an use one item you can use pop(1)[0] or take the top and then pop, but the second possibility is not an expression.) There are some ways to solve this problem, but the simpler is probably to just use two different names for two functions. So the pop() can return the popped item. And then the heap can define another method that just pops the top item and doesn't return it, this method can be called for example drop. The following untested code gives is an idea of how it can be implemented: /** Pops the largest element (according to the predicate $(D less)) and returns it. */ ElementType!Range pop() { enforce(_length); auto tmp = _store.front; enforce(_length); if (_length 1) swap(_store.front, _store[_length - 1]); --_length; percolateDown(_store[0 .. _length]); return tmp; } /** Drops the largest element (according to the predicate $(D less)). */ void drop() { enforce(_length); if (_length 1) swap(_store.front, _store[_length - 1]); --_length; percolateDown(_store[0 .. _length]); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4271] drop/pop methods for std.algorithm.BinaryHeap
http://d.puremagic.com/issues/show_bug.cgi?id=4271 --- Comment #2 from bearophile_h...@eml.cc 2010-06-04 15:40:21 PDT --- In most of my usages of a heap I don't have just to use the top item or just to pop the top item, I have to pop the top item and then use the popped out item. To perform this operation I can currently use something like: item = heap.top(); heap.pop(); But this is not handy because that is not a single expression, so I can't put it inside other expressions. So I have to use: somefunction(heap.top(1)[0]); But being this operation so common, I'd like to write simpler code: somefunction(heap.top()); I have suggested to add the drop() method too to not decrease the performance of the (uncommon) code that just needs to remove the top item with no need to use it (or uses it using top() in other points of the code). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4272] New: x.typeof syntax
http://d.puremagic.com/issues/show_bug.cgi?id=4272 Summary: x.typeof syntax Product: D Version: future 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 2010-06-04 15:42:55 PDT --- A syntax like x.typeof can be considered. There are situations where you will need to parenthesize anyway, like: import std.stdio; void main() { int x = 1; float y = 1.5; writeln(typeid(typeof(x + y))); } You will have to write: (x + y).typeof But in many situations with this change you will be able to avoid the (). This syntax is more similar/uniform to the x.sizeof syntax too (that is sizeof(x) in C). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4271] drop/pop methods for std.algorithm.BinaryHeap
http://d.puremagic.com/issues/show_bug.cgi?id=4271 --- Comment #3 from bearophile_h...@eml.cc 2010-06-04 16:00:04 PDT --- Sorry, that was a partially wrong comment, I meant: So I have to use: somefunction(heap.pop(1)[0]); But being this operation so common, I'd like to write simpler code: somefunction(heap.pop()); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4273] Error: functions cannot return a tuple
http://d.puremagic.com/issues/show_bug.cgi?id=4273 --- Comment #2 from Walter Bright bugzi...@digitalmars.com 2010-06-04 17:16:41 PDT --- Fixing this would require conflating a Tuple!(T) with T. I think this would be a mistake. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4273] Error: functions cannot return a tuple
http://d.puremagic.com/issues/show_bug.cgi?id=4273 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||WONTFIX -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4270] Missing line number in 'can only catch class objects' error message
http://d.puremagic.com/issues/show_bug.cgi?id=4270 --- Comment #3 from Don clugd...@yahoo.com.au 2010-06-04 17:36:00 PDT --- (In reply to comment #2) An idea: comment out the error() that doesn't accept a line number, then fix all calling points that use it. That's exactly how I found this one! There are four uses of the wrong function. It's discussed in dmd-internals. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4273] Error: functions cannot return a tuple
http://d.puremagic.com/issues/show_bug.cgi?id=4273 --- Comment #3 from Sean Kelly s...@invisibleduck.org 2010-06-04 18:21:00 PDT --- You're right, it was a mistake in my code. Sorry. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4274] New: Better array of inner structs error message
http://d.puremagic.com/issues/show_bug.cgi?id=4274 Summary: Better array of inner structs error message Product: D Version: future Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2010-06-04 18:20:50 PDT --- This wrong D2 program: void main() { struct Foo { void bar() {} } auto foos = new Foo[1]; // line 5 } At compile time dmd v2.046 prints: temp.d(5): Error: cannot have array of inner structs Foo But for D newbies coming from C or C++ can find that error message cryptic. Using a static struct solves this problem. So a possible error message can be: temp.d(5): Error: cannot have array of inner structs Foo, you can use a 'static struct' instead. This improved error message is not perfect, but it seems better. (I don't understand why D error messages don't have the ending full stop.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---