Compiling the code: -------------------------- void checkops(T...)( T ops ) { static assert( 0 ); } void receive(T...)( T ops ) { checkops( ops ); get( ops ); } void get(T...)( T vals ) { void onStandardMsg() { foreach( t; T ) { } } } void test() { assert( !__traits( compiles, { receive( (long x) {}, (int x) {} ); } ) ); } ------------------------- Produces the error: Internal error: s2ir.c 339 What's likely happening is semantic() is not run on onStandardMsg(), which is likely caused by the __traits(compile failing, and yet marking semantic() as having been run.
This is probably related to bug 4910, and also to bug 4269 ("invalid type accepted if evaluated while errors are gagged") There's a problem with the gagging system. One difficulty is that if there has been a forward reference, CTFE needs to run semantic3 on the function. If errors are gagged from inside VarDeclaration::semantic, the gagging should only apply to CTFE; the semantic3 errors should not be gagged. The problem is, the gagging system doesn't have any mechanism for ungagging. If we instantiated a template from inside is(typeof()), semantic errors should be gagged; we don't yet know if the template will be instantiated. Let's call this an investigative template instantiation. This is recursive; any template instantiated from inside a investigative template is also investigative. BUT, any semantic run on anything other than a investigative template should NOT be gagged. The simple incrementing and decrementing of global.gag doesn't quite work. The other side of the problem is bug 4269: failed templates are not removed. If there is an attempt to instantiate them from a non-gagged state, the original (previously suppressed) error messages should be shown.
Reduced test case fails also on D1.070 (again with ICE(s2ir.c). On D2.054 and later, this test case hits bug 6675 ICE(glue.c) instead. ====== void receive(T)() { static assert( 0 ); get( 7 ); } void get(T)( T val ) { void onStandardMsg() { foreach( t; T ) { } } } static assert(!is(typeof( { receive!(int)(); }() )));
https://github.com/D-Programming-Language/dmd/commit/6dc84fd7f2f43d28039d08bf80658cffc97e00f0 https://github.com/D-Programming-Language/dmd/commit/cf7a78423f426fb0d2d62b0af821129f1a4077a1
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル