When typeof(x)(...) is used as a struct literal, the compiler adds parentheses around typeof(x) in the generated .di file. When the .di file is later used, the compiler interprets (typeof(x)) as a C-style cast. I tend to use return typeof(return)(...); a lot in generic code, and this issue makes header files completely unusable to me. Test case: $ cat test.d struct S { int i; } S foo() { return typeof(return)(123); } $ dmd -c -o- -H test.d $ cat test.di // D import file generated from 'test.d' struct S { int i; } S foo() { return (typeof(return))(123); } $ dmd -c -o- test.di test.di(8): C style cast illegal, use cast(typeof(return))123
Fixed http://www.dsource.org/projects/dmd/changeset/629 as part of bug 4713.