Thread overview
[Issue 7566] New: compiler works incorrectly when debug{} statements are present, ver 2.057
Feb 23, 2012
Timofei Bolshakov
Feb 23, 2012
Timofei Bolshakov
Feb 23, 2012
Walter Bright
Feb 23, 2012
Timofei Bolshakov
Feb 24, 2012
yebblies
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7566

           Summary: compiler works incorrectly when debug{} statements are
                    present, ver 2.057
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: tbolsh@gmail.com


--- Comment #0 from Timofei Bolshakov <tbolsh@gmail.com> 2012-02-23 07:43:33 PST ---
$ 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
...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7566



--- Comment #1 from Timofei Bolshakov <tbolsh@gmail.com> 2012-02-23 07:46:31 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7566


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |INVALID


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-02-23 12:30:38 PST ---
I'm not sure what you're expecting, but the compiler behaves correctly in your first example.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7566



--- Comment #3 from Timofei Bolshakov <tbolsh@gmail.com> 2012-02-23 13:07:19 PST ---
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 ...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7566


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #4 from yebblies <yebblies@gmail.com> 2012-02-24 13:15:51 EST ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------