D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7566 - compiler works incorrectly when debug{} statements are present, ver 2.057
Summary: compiler works incorrectly when debug{} statements are present, ver 2.057
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-23 07:43 UTC by Timofei Bolshakov
Modified: 2012-02-23 18:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timofei Bolshakov 2012-02-23 07:43:33 UTC
$ 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
...
Comment 1 Timofei Bolshakov 2012-02-23 07:46:31 UTC
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
Comment 2 Walter Bright 2012-02-23 12:30:38 UTC
I'm not sure what you're expecting, but the compiler behaves correctly in your first example.
Comment 3 Timofei Bolshakov 2012-02-23 13:07:19 UTC
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 ...
Comment 4 yebblies 2012-02-23 18:15:51 UTC
(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.