Thread overview
[Issue 9633] New: compiles trait wrongly returns true even when object method call actually does not compile
Mar 02, 2013
Puneet Goel
Mar 06, 2013
Kenji Hara
Mar 07, 2013
Walter Bright
March 02, 2013
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


--- Comment #0 from Puneet Goel <puneet@coverify.org> 2013-03-02 08:37:46 PST ---
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: -------
March 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9633


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-03-05 23:41:48 PST ---
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: -------
March 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9633



--- Comment #2 from github-bugzilla@puremagic.com 2013-03-06 23:55:17 PST ---
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 Merge pull request #1722 from 9rnsr/fix9633

[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: -------
March 07, 2013
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: -------