[dmd-beta] dmd 1.065 and 2.050 beta

Andrei Alexandrescu andrei at erdani.com
Thu Oct 28 12:08:22 PDT 2010


The problem is caused by line 362 in typecons.d, introduced by Shin 
(rsinfu):

alias field this;

Commenting that line out makes Stephan's code sample work.

Shin's change is beneficial because it allows using tup[2] to access the 
third field of a tuple "tup". This was one of the main intents of the 
"alias this" feature. Using the workarounds such as tup.field[2] or 
tup._2 has never gained traction, so I'm glad to see top[2] (almost) work.

The change does not introduce a bug, instead it exposes a bug in the 
compiler. The bug is that the compiler is too eager to automatically 
trigger the "alias this" mechanism. I therefore suggest making Stephan's 
code into a unittest and fixing the compiler to make the unittest work.


Andrei

On 10/27/10 17:51 CDT, Walter Bright wrote:
> Trying the old version of std.typecons and it works, so it's not a
> compiler bug.
>
> Stephan Dilly wrote:
>> I am sorry but i found another regression trying to build my codebase
>> with the new beta:
>>
>>
>> import std.typecons;
>>
>> alias Tuple!(int,"aa",int,"bb") Foo;
>> void main()
>> {
>> Foo[] m_array;
>>
>> Foo f;
>> m_array ~= f;
>> }
>>
>>
>> This portion of code used to work with dmd2049. The beta now says:
>> Error: cannot append type (int,int) to type Tuple!(int,"aa",int,"bb")[]
>>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta


More information about the dmd-beta mailing list