Bug 9215 – [2.061 beta] isDymanicArray/DynamicArrayTypeOf broken for classes/interfaces with AliasThis

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-26T18:17:00Z
Last change time
2012-12-27T23:48:02Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-12-26T18:17:53Z
Using DMD 2.061 beta 1, this code --- import std.traits : DynamicArrayTypeOf; interface Foo { final int aliasThis() @property { return 0; } alias aliasThis this; } pragma(msg, DynamicArrayTypeOf!(Foo[])); --- leads to a rather interesting error message (note the missing location information): --- Error: function test.Foo.aliasThis () is not callable using argument types () inout test.d(8): Error: template instance std.traits.DynamicArrayTypeOf!(Foo[]) error instantiating test.d(8): while evaluating pragma(msg, DynamicArrayTypeOf!(Foo[])) --- The culprit lies in the implementation of DynamicArrayTypeOf, but I didn't have a closer look at it yet to figure out whether it is a DMD or a Phobos bug. This issue causes isDynamicArray to silently return false for Foo[] as defined above.
Comment #1 by k.hara.pg — 2012-12-26T20:13:44Z
This is a dup of bug 9177 (it's a dmd bug), and is not a regression. It reproduces from 2.057. *** This issue has been marked as a duplicate of issue 9177 ***
Comment #2 by code — 2012-12-27T03:30:03Z
Reopened, as the issue wih isDynamicArray _is_ a regression, and for example breaks std.array.popFront for arrays of classes with alias this. If DynamicArrayTypeOf is broken, then please try to find a way to implement isDynamicArray without relying on it.
Comment #3 by k.hara.pg — 2012-12-27T05:17:23Z
(In reply to comment #2) > Reopened, as the issue wih isDynamicArray _is_ a regression, and for example > breaks std.array.popFront for arrays of classes with alias this. If > DynamicArrayTypeOf is broken, then please try to find a way to implement > isDynamicArray without relying on it. OK. The regression of isDynamicArray has been introduced by this Phobos change. https://github.com/D-Programming-Language/phobos/commit/43fdbc83a1e710f30f8fc6cf464636f69487267b After that, isDynamicArray depends on DynamicArrayTypeOf, and now the bug 9177 affects to both templates. We would be able to revert the Phobos change to fix the regression, but I'd like to recommend fixing bug 9177 to remove root issue. https://github.com/D-Programming-Language/dmd/pull/1385
Comment #4 by k.hara.pg — 2012-12-27T23:48:02Z
OK, by fixing bug 9177: https://github.com/D-Programming-Language/dmd/commit/9f2d9eafacd75c22ea7a705151ee2a8e20a1638c These results were also fixed as expected. pragma(msg, DynamicArrayTypeOf!(Foo[])); // prints "Foo[]" pragma(msg, isDynamicArray!(Foo[])); // prints "true"