www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9633] New: compiles trait wrongly returns true even when object method call actually does not compile

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9633

           Summary: compiles trait wrongly returns true even when object
                    method call actually does not compile
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: puneet coverify.org



---
The following code prints "baz compiles in global scope" with version 2.063. No
message is printed with version 2.062.

baz is an object method and does not compile in module scope since no (this
pointer) object has been provided as argument. So compiles trait on line 11
should return false, as is done by DMD version 2.062.

class Foo {                                              // 1 
  void baz() {}                                          // 2
  void bar() {                                           // 3
    static if(compilesWithoutThis!baz) {                 // 4
      import std.stdio;                                  // 5
      writeln("baz compiles in global scope");           // 6
    }                                                    // 7
  }                                                      // 8
}                                                        // 9
template compilesWithoutThis (alias F) {                 // 10
  static if(__traits(compiles, F()))                     // 11
    enum bool compilesWithoutThis = true;                // 12
  else                                                   // 13
    enum bool compilesWithoutThis = false;               // 14
}                                                        // 15
void main() {                                            // 16
  Foo foo = new Foo;                                     // 17
  foo.bar();                                             // 18
}                                                        // 19

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9633


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1722

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9633




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/85c896a7514c72e8ff9bd7b546e3aa1257cb70ff
[REG2.063a] fix Issue 9633 - compiles trait wrongly returns true even when
object method call actually does not compile

Improve isNeedThisScope

https://github.com/D-Programming-Language/dmd/commit/0679c4c31ba78853873933324c69cd90e7714d15


[REG2.063a] Issue 9633 - compiles trait wrongly returns true even when object
method call actually does not compile

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 06 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9633


Walter Bright <bugzilla digitalmars.com> changed:

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


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