Thread overview
[Issue 9124] New: Object variable of variadic template struct needs explicit "this" in certain situations
Dec 12, 2012
Puneet Goel
Dec 12, 2012
Kenji Hara
Dec 12, 2012
Puneet Goel
Dec 13, 2012
Kenji Hara
Dec 13, 2012
Puneet Goel
Dec 17, 2012
Walter Bright
December 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9124

           Summary: Object variable of variadic template struct needs
                    explicit "this" in certain situations
           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> 2012-12-07 19:36:22 PST ---
Kindly look at the code pasted below. with the current github dmd snapshot, it
gives me an error:
Error: this for _val needs to be type Foo not type Foo!(28)

It is a corner case. I could not reduce the code further than give below. For example if I replace SIZE with N[0] directly in the declarative for result, the issue disappears.

struct Foo (N...)
{
  enum SIZE = N[0];
  private int _val;

  public void opAssign (T) (T other)
    if (is(T unused == Foo!(_N), _N...))
      {
    _val = other._val;       // compile error
    // this._val = other._val; // explicit this make it work
      }

  public auto opUnary (string op) () if (op == "~") {
    Foo!(SIZE) result = this;
    return result;
  }
}

void main()
{
  Foo!(28) a;
  Foo!(28) b = ~a;
}

--- Comment #1 from github-bugzilla@puremagic.com 2012-12-11 16:22:31 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f6b421121ff945c08bca5bafd8df07913d64a727
fix Issue 9124 - Object variable of variadic template struct needs explicit
"this" in certain situations

https://github.com/D-Programming-Language/dmd/commit/8e22c48774d4200c80e5808f5c0658d28a0625fc Merge pull request #1366 from 9rnsr/fix9124

Issue 9124 - Object variable of variadic template struct needs explicit "this" in certain situations

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-11 17:05:58 PST ---
https://github.com/D-Programming-Language/dmd/pull/1366

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


Puneet Goel <puneet@coverify.org> changed:

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


--- Comment #3 from Puneet Goel <puneet@coverify.org> 2012-12-12 09:35:19 PST ---
I am reopening the bug with a different testcase that is still failing with the same error. Please see the comments below in the code to locate the offending line.

template Foo (T, U, string OP) {
  enum N = T.SIZE;
  alias Foo!(false, true, N) Foo;
}

struct Foo (bool S, bool L, N...) {
  enum SIZE = 5;
  long[1] _a = 0;
  void someFunction() const {
    auto data = _a;        // Does not compile
    // auto data = this._a; // <--- Compiles
  }
  auto opBinary (string op, T) (T ) {
    Foo!(typeof(this), T, op) test;
  }
}

void main() {
  auto p = Foo!(false, false, 5)();
  auto q = Foo!(false, false, 5)();
  p|q;
  p&q;
}

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



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-12 18:24:42 PST ---
Thanks for finding another case. My first fix was not sufficient.

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

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



--- Comment #5 from Puneet Goel <puneet@coverify.org> 2012-12-12 23:02:58 PST ---
(In reply to comment #4)
> 
> https://github.com/D-Programming-Language/dmd/pull/1368

This looks good. I have taken out all the 132 "this" disambiguators that I had put in my code. The code compiles and runs perfectly now.

Thanks Kenji. You Rock!

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



--- Comment #6 from github-bugzilla@puremagic.com 2012-12-17 02:01:52 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/69307c29749ee45ded4c59e58ff01d94b1fbc7bd
2nd fix for Issue 9124 - Object variable of variadic template struct needs
explicit "this" in certain situations

https://github.com/D-Programming-Language/dmd/commit/3662698e1d592693d7556741bc6bf95474908e9a Merge pull request #1368 from 9rnsr/fix9124

Issue 9124 & 9143 - manifest constant should be de-symbolize in template argument comparison

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


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