Thread overview
[Issue 10577] New: 2.063 Mixin Regression (works with 2.062)
Jul 09, 2013
Puneet Goel
Jul 09, 2013
Kenji Hara
Jul 09, 2013
Puneet Goel
Jul 12, 2013
Puneet Goel
Jul 13, 2013
Kenji Hara
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577

           Summary: 2.063 Mixin Regression (works with 2.062)
           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-07-08 18:32:49 PDT ---
Here is the minimal code to reproduce.
Works with version 2.062. With version 2.063 and latest github snapshot, I get
an error:

test.d(37): Error: function test.derived.foo multiple overrides of same
function


// Code starts here
enum sync;

public template get_sync(size_t I, A...) {
  static if(I == A.length)           enum bool get_sync = false;
  else static if(is(A[I] == sync))   enum bool get_sync = true;
    else                             enum bool get_sync = get_sync!(I+1, A);
}

template add_sync(T, size_t ITER=0) {
  static if(ITER == (__traits(derivedMembers, T).length)) {
    enum string add_sync = "";
  } else {
    enum string mem = __traits(derivedMembers, T)[ITER];
    enum string add_sync =
      "static if(! __traits(isVirtualMethod, " ~ mem ~ ")) {" ~
      "mixin(add_sync!(get_sync!(0, __traits(getAttributes, "
      ~ mem ~ ")), \"" ~ mem ~ "\"));} " ~ add_sync!(T, ITER+1);
  }
}

template add_sync(bool A, string M) {
  static if(A) {
    enum string add_sync = " auto " ~ M[1..$] ~
      "() {synchronized(this) return " ~ M ~ ";}";
  } else {
    enum string add_sync = "";
  }
}

class base {
  public void foo() {}
}

class derived : base {
  mixin(add_sync!(derived));
  @sync private bool _bar;
  public override void foo() {}
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-08 20:48:28 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2322

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577



--- Comment #2 from Puneet Goel <puneet@coverify.org> 2013-07-08 22:21:29 PDT ---
Thanks Kenji. Tried your pull request in my code. Works for me too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577



--- Comment #3 from github-bugzilla@puremagic.com 2013-07-09 05:58:39 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/51991f94be53375fe66339d46eea343cd8a107a6 fix Issue 10577 - 2.063 Mixin Regression (works with 2.062)

https://github.com/D-Programming-Language/dmd/commit/af61ebff5404dd408b1b40ef94e17fb585c1a7b6 Merge pull request #2322 from 9rnsr/fix10577

[REG2.063] Issue 10577 - 2.063 Mixin Regression (works with 2.062)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |hsteoh@quickfur.ath.cx
         Resolution|                            |WORKSFORME


--- Comment #4 from hsteoh@quickfur.ath.cx 2013-07-09 11:44:36 PDT ---
Seems to have been fixed by the pull. I can compile the code without errors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 12, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577


Puneet Goel <puneet@coverify.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |


--- Comment #5 from Puneet Goel <puneet@coverify.org> 2013-07-12 10:30:43 PDT ---
Slightly different test case. But since this too is related, I am re-opening the same bug. Let me know if I should instead be opening a separate bug for this.

With this code, I am getting a *spurious* deprecation warning (compiles without warning with version 2.062).

test.d(37): Deprecation: class test.derived use of test.base.foo() hidden by
derived is deprecated. Use 'alias base.foo foo;' to introduce base class
overload set.

// test.d Code starts here
enum sync;

public template get_sync(size_t I, A...) {
  static if(I == A.length)           enum bool get_sync = false;
  else static if(is(A[I] == sync))   enum bool get_sync = true;
    else                             enum bool get_sync = get_sync!(I+1, A);
}

template add_sync(T, size_t ITER=0) {
  static if(ITER == (__traits(derivedMembers, T).length)) {
    enum string add_sync = "";
  } else {
    enum string mem = __traits(derivedMembers, T)[ITER];
    enum string add_sync =
      "static if(! __traits(isVirtualMethod, " ~ mem ~ ")) {" ~
      "mixin(add_sync!(get_sync!(0, __traits(getAttributes, "
      ~ mem ~ ")), \"" ~ mem ~ "\"));} " ~ add_sync!(T, ITER+1);
  }
}

template add_sync(bool A, string M) {
  static if(A) {
    enum string add_sync = " auto " ~ M[1..$] ~
      "() {synchronized(this) return " ~ M ~ ";}";
  } else {
    enum string add_sync = "";
  }
}

abstract class base {
  mixin(add_sync!(base));
  @sync private bool _bar;
  public void foo();
}

class derived: base {
  public override void foo() {}
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 13, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10577


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-13 05:33:04 PDT ---
(In reply to comment #5)
> Slightly different test case. But since this too is related, I am re-opening the same bug. Let me know if I should instead be opening a separate bug for this.
> 
> With this code, I am getting a *spurious* deprecation warning (compiles without warning with version 2.062).

I filed the issue in separate bug 10628.

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