$ more d_compiler_bug_around_debug.d #!/usr/bin/rdmd -debug import std.stdio; void main(){ bool dummy_flag = false; if( dummy_flag ) debug{ writeln("debug print 1"); } writeln( "Some real action ..." ); debug{ writeln("debug print 2"); } else{ writeln( "Some other action "); } } $ ./d_compiler_bug_around_debug.d Some real action ... debug print 2 $ dmd -v DMD32 D Compiler v2.057 Copyright (c) 1999-2011 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html ...
If debug statements are removed - compiler behave as expected: $ more d_compiler_bug_around_debug.d #!/usr/bin/rdmd -debug import std.stdio; void main(){ bool dummy_flag = false; if( dummy_flag ) writeln("debug print 1"); writeln( "Some real action ..." ); writeln("debug print 2"); else{ writeln( "Some other action "); } } $ ./d_compiler_bug_around_debug.d ./d_compiler_bug_around_debug.d(10): found 'else' instead of statement ./d_compiler_bug_around_debug.d(13): unrecognized declaration Failed: dmd -debug -v -o- './d_compiler_bug_around_debug.d' -I'.' >./d_compiler_bug_around_debug.d.deps
I'm not sure what you're expecting, but the compiler behaves correctly in your first example.
I am expecting to see somewhat like ./d_compiler_bug_around_debug.d(10): found 'else' instead of statement ./d_compiler_bug_around_debug.d(13): unrecognized declaration when compiled with debug key and nothing when compiled without. I believe my expectations are correct ...
(In reply to comment #3) > I am expecting to see somewhat like > > ./d_compiler_bug_around_debug.d(10): found 'else' instead of statement > ./d_compiler_bug_around_debug.d(13): unrecognized declaration > > when compiled with debug key and nothing when compiled without. > I believe my expectations are correct ... The following is valid syntax: debug { } else { } Although I don't think I've ever wanted to use an else block on a debug statement.