Implicit 'this' references in struct/class templates are wrongly typed under certain circumstance and the following code doesn't compile. -------------------- void main() { auto va = S!("", int)(); auto vb = makeS!("", int)(); } struct S(alias p, T) { T s; T fun() { return s; } // (10) } S!(p, T) makeS(alias p, T)() { return typeof(return)(); } -------------------- % dmd -o- -c test.d test.d(10): Error: this for s needs to be type S not type S!("",int) -------------------- The error does not happen if - Either va or vb is commented out, - Template parameter "alias p" is replaced with "string p", or - "return s" at line (10) is replaced with "return this.s". The Sequence struct in std.range hits this problem. It currently works around the problem by supplying explicit 'this' to all fields.
https://github.com/D-Programming-Language/dmd/pull/94
https://github.com/D-Programming-Language/dmd/commit/d3c324c8b1290c84e4808f9ac040e70a3e27b7f6 https://github.com/D-Programming-Language/dmd/commit/ca51706314e24b1b65a0417fb6529074ef988727 https://github.com/D-Programming-Language/dmd/commit/6052888a19f0dc048c2aae07d03d5b239b0901ff
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル